Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71b7655d91 | |||
| 8ba1c8c14b | |||
| 65093014f5 | |||
| f679c423db | |||
| bc2e46f648 | |||
| 944bc26fb9 | |||
| 5db13a7d69 | |||
| d577edf348 | |||
| 7195dea7cd |
@@ -4,12 +4,11 @@
|
|||||||
# Developer : Qin Yue @ 2026
|
# Developer : Qin Yue @ 2026
|
||||||
# Organization : OptiHK Limited
|
# Organization : OptiHK Limited
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
import os
|
import tempfile
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Dict, List
|
from typing import List
|
||||||
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
|
from layout_files import load_layout_cell_files, write_layout_cells_to_directory
|
||||||
from router_dependency import require_router_stack
|
from router_dependency import require_router_stack
|
||||||
|
|
||||||
|
|
||||||
@@ -31,16 +30,25 @@ def build_project_gds(
|
|||||||
prefer_full_gds: bool = False,
|
prefer_full_gds: bool = False,
|
||||||
) -> BuildResult:
|
) -> BuildResult:
|
||||||
"""Build a hierarchical project GDS from saved cell YAML files with mxpic_router."""
|
"""Build a hierarchical project GDS from saved cell YAML files with mxpic_router."""
|
||||||
cells = _load_project_cells(project_dir)
|
cells, warnings = _load_project_cells(project_dir)
|
||||||
if not cells:
|
if not cells:
|
||||||
raise ValueError("No saved cell YAML files found for this project")
|
raise ValueError("No saved cell YAML files found for this project")
|
||||||
|
|
||||||
return _build_with_mxpic_router(
|
with tempfile.TemporaryDirectory(prefix="mxpic_gds_project_") as staged_project_dir:
|
||||||
project_dir,
|
write_layout_cells_to_directory(cells, staged_project_dir)
|
||||||
output_path,
|
result = _build_with_mxpic_router(
|
||||||
pdk_public_root,
|
staged_project_dir,
|
||||||
technology_manifest_path,
|
output_path,
|
||||||
prefer_full_gds,
|
pdk_public_root,
|
||||||
|
technology_manifest_path,
|
||||||
|
prefer_full_gds,
|
||||||
|
)
|
||||||
|
|
||||||
|
return BuildResult(
|
||||||
|
output_path=result.output_path,
|
||||||
|
engine=result.engine,
|
||||||
|
cells_built=result.cells_built,
|
||||||
|
warnings=warnings + result.warnings,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -70,15 +78,6 @@ def _build_with_mxpic_router(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _load_project_cells(project_dir: str) -> Dict[str, dict]:
|
def _load_project_cells(project_dir: str):
|
||||||
"""Load saved cell YAML documents from a project directory."""
|
"""Load saved cell YAML documents from a project directory."""
|
||||||
cells = {}
|
return load_layout_cell_files(project_dir)
|
||||||
for filename in sorted(os.listdir(project_dir)):
|
|
||||||
if not filename.lower().endswith((".yml", ".yaml")):
|
|
||||||
continue
|
|
||||||
path = os.path.join(project_dir, filename)
|
|
||||||
with open(path, "r", encoding="utf-8") as file:
|
|
||||||
data = yaml.safe_load(file) or {}
|
|
||||||
cell_name = str(data.get("name") or os.path.splitext(filename)[0])
|
|
||||||
cells[cell_name] = data
|
|
||||||
return cells
|
|
||||||
|
|||||||
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
@@ -0,0 +1,126 @@
|
|||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Description: Layout YAML file filtering, parsing, and staging helpers.
|
||||||
|
# Inside functions: is_layout_cell_filename, parse_layout_cell_content, read_layout_cell_file, load_layout_cell_files, layout_cell_filename, write_layout_cells_to_directory
|
||||||
|
# Developer : Qin Yue @ 2026
|
||||||
|
# Organization : OptiHK Limited
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
|
LAYOUT_YAML_EXTENSIONS = (".yml", ".yaml")
|
||||||
|
ROUTE_SIDECAR_SUFFIXES = (".routes.yml", ".routes.yaml")
|
||||||
|
|
||||||
|
|
||||||
|
class LayoutFileError(ValueError):
|
||||||
|
"""Raised when a saved layout YAML file cannot be used as a cell."""
|
||||||
|
|
||||||
|
|
||||||
|
def is_layout_cell_filename(filename):
|
||||||
|
"""Return True for user layout cell YAML files, excluding sidecars/manifests."""
|
||||||
|
lower = (filename or "").lower()
|
||||||
|
if lower == "technology.yml":
|
||||||
|
return False
|
||||||
|
if lower.endswith(ROUTE_SIDECAR_SUFFIXES):
|
||||||
|
return False
|
||||||
|
return lower.endswith(LAYOUT_YAML_EXTENSIONS)
|
||||||
|
|
||||||
|
|
||||||
|
def is_layout_cell_document(data):
|
||||||
|
"""Return True when parsed YAML looks like an mxPIC saved cell/project."""
|
||||||
|
if not isinstance(data, dict):
|
||||||
|
return False
|
||||||
|
|
||||||
|
kind = data.get("kind")
|
||||||
|
if kind and str(kind).strip().lower() != "cell":
|
||||||
|
return False
|
||||||
|
|
||||||
|
layout_keys = {
|
||||||
|
"schema_version",
|
||||||
|
"canvas_size",
|
||||||
|
"canvasSize",
|
||||||
|
"instances",
|
||||||
|
"elements",
|
||||||
|
"pins",
|
||||||
|
"ports",
|
||||||
|
"bundles",
|
||||||
|
}
|
||||||
|
return any(key in data for key in layout_keys)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_layout_cell_content(content, source="layout YAML"):
|
||||||
|
"""Parse and validate saved layout YAML content."""
|
||||||
|
try:
|
||||||
|
data = yaml.safe_load(content or "") or {}
|
||||||
|
except yaml.YAMLError as exc:
|
||||||
|
raise LayoutFileError(f"{source} is not valid YAML: {exc}") from exc
|
||||||
|
|
||||||
|
if not is_layout_cell_document(data):
|
||||||
|
raise LayoutFileError(f"{source} is not a saved mxPIC layout cell")
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def read_layout_cell_file(path):
|
||||||
|
"""Read a saved layout cell file and return parsed data plus raw content."""
|
||||||
|
try:
|
||||||
|
with open(path, "r", encoding="utf-8") as file:
|
||||||
|
content = file.read()
|
||||||
|
except OSError as exc:
|
||||||
|
raise LayoutFileError(f"{os.path.basename(path)} could not be read: {exc}") from exc
|
||||||
|
return parse_layout_cell_content(content, os.path.basename(path)), content
|
||||||
|
|
||||||
|
|
||||||
|
def load_layout_cell_files(project_dir):
|
||||||
|
"""Load valid layout cell files from a project directory and collect warnings."""
|
||||||
|
cells = []
|
||||||
|
warnings = []
|
||||||
|
if not os.path.isdir(project_dir):
|
||||||
|
return cells, warnings
|
||||||
|
|
||||||
|
for filename in sorted(os.listdir(project_dir)):
|
||||||
|
if not is_layout_cell_filename(filename):
|
||||||
|
continue
|
||||||
|
path = os.path.join(project_dir, filename)
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
data, content = read_layout_cell_file(path)
|
||||||
|
except LayoutFileError as exc:
|
||||||
|
warnings.append(f"Skipped {filename}: {exc}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
cells.append({
|
||||||
|
"filename": filename,
|
||||||
|
"name": str(data.get("name") or os.path.splitext(filename)[0]),
|
||||||
|
"data": data,
|
||||||
|
"content": content,
|
||||||
|
})
|
||||||
|
return cells, warnings
|
||||||
|
|
||||||
|
|
||||||
|
def layout_cell_filename(cell_name, fallback="canvas_1.yml"):
|
||||||
|
"""Build a safe filename for staging a parsed layout cell."""
|
||||||
|
name = re.sub(r"[^A-Za-z0-9_.-]+", "_", str(cell_name or "")).strip("._")
|
||||||
|
if not name:
|
||||||
|
return fallback
|
||||||
|
return f"{name}.yml"
|
||||||
|
|
||||||
|
|
||||||
|
def write_layout_cells_to_directory(cells, output_dir):
|
||||||
|
"""Write valid layout cell contents into a clean staging directory."""
|
||||||
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
used_names = set()
|
||||||
|
for index, cell in enumerate(cells, start=1):
|
||||||
|
filename = layout_cell_filename(cell.get("name"), cell.get("filename") or f"cell_{index}.yml")
|
||||||
|
base, ext = os.path.splitext(filename)
|
||||||
|
unique_filename = filename
|
||||||
|
counter = 1
|
||||||
|
while unique_filename.lower() in used_names:
|
||||||
|
counter += 1
|
||||||
|
unique_filename = f"{base}_{counter}{ext}"
|
||||||
|
used_names.add(unique_filename.lower())
|
||||||
|
|
||||||
|
with open(os.path.join(output_dir, unique_filename), "w", encoding="utf-8") as file:
|
||||||
|
file.write(cell["content"])
|
||||||
@@ -9,6 +9,7 @@ import tempfile
|
|||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
from layout_files import load_layout_cell_files, write_layout_cells_to_directory
|
||||||
from router_dependency import require_router_stack
|
from router_dependency import require_router_stack
|
||||||
|
|
||||||
|
|
||||||
@@ -32,9 +33,20 @@ def create_routed_layout_svg(
|
|||||||
# Build into a temporary GDS first, then convert the generated top cell into
|
# Build into a temporary GDS first, then convert the generated top cell into
|
||||||
# the SVG preview consumed by the canvas.
|
# the SVG preview consumed by the canvas.
|
||||||
with tempfile.TemporaryDirectory(prefix="mxpic_routed_preview_") as temp_dir:
|
with tempfile.TemporaryDirectory(prefix="mxpic_routed_preview_") as temp_dir:
|
||||||
|
staged_project_dir = os.path.join(temp_dir, "project")
|
||||||
|
saved_cells, _warnings = load_layout_cell_files(project_dir)
|
||||||
|
staged_cells = [cell for cell in saved_cells if cell["name"] != cell_name]
|
||||||
|
staged_cells.append({
|
||||||
|
"filename": f"{cell_name}.yml",
|
||||||
|
"name": cell_name,
|
||||||
|
"data": layout,
|
||||||
|
"content": yaml_content,
|
||||||
|
})
|
||||||
|
write_layout_cells_to_directory(staged_cells, staged_project_dir)
|
||||||
|
|
||||||
temp_gds = os.path.join(temp_dir, f"{cell_name}.gds")
|
temp_gds = os.path.join(temp_dir, f"{cell_name}.gds")
|
||||||
build_project_gds(
|
build_project_gds(
|
||||||
project_dir=project_dir,
|
project_dir=staged_project_dir,
|
||||||
output_path=temp_gds,
|
output_path=temp_gds,
|
||||||
pdk_root=pdk_root,
|
pdk_root=pdk_root,
|
||||||
technology_manifest_path=technology_manifest_path,
|
technology_manifest_path=technology_manifest_path,
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ from werkzeug.security import check_password_hash
|
|||||||
import database
|
import database
|
||||||
from flask import Response
|
from flask import Response
|
||||||
from gds_builder import build_project_gds
|
from gds_builder import build_project_gds
|
||||||
|
from layout_files import (
|
||||||
|
LayoutFileError,
|
||||||
|
is_layout_cell_filename,
|
||||||
|
load_layout_cell_files,
|
||||||
|
parse_layout_cell_content,
|
||||||
|
read_layout_cell_file,
|
||||||
|
)
|
||||||
from pdk_access import (
|
from pdk_access import (
|
||||||
cleanup_expired_exports,
|
cleanup_expired_exports,
|
||||||
create_export_path,
|
create_export_path,
|
||||||
@@ -37,7 +44,9 @@ FRONTEND_DIR = os.path.join(BASE_DIR, '..', 'frontend')
|
|||||||
|
|
||||||
REPO_ROOT = os.path.abspath(os.path.join(BASE_DIR, '..', '..'))
|
REPO_ROOT = os.path.abspath(os.path.join(BASE_DIR, '..', '..'))
|
||||||
# Component/category icons are served from backend/icons for the library panel.
|
# Component/category icons are served from backend/icons for the library panel.
|
||||||
ICONS_DIR = os.path.join(BASE_DIR, 'icons')
|
ICONS_DIR = os.path.join(BASE_DIR, 'icons')
|
||||||
|
# Login page time-of-day background images.
|
||||||
|
PIC_DIR = os.path.join(FRONTEND_DIR, 'pic')
|
||||||
|
|
||||||
|
|
||||||
# Flask serves the HTML/CSS/JS frontend and exposes JSON APIs for persistence,
|
# Flask serves the HTML/CSS/JS frontend and exposes JSON APIs for persistence,
|
||||||
@@ -145,13 +154,17 @@ def cell_routes_path(project_name, cell_name):
|
|||||||
|
|
||||||
def write_route_points_sidecar(yaml_content, output_path):
|
def write_route_points_sidecar(yaml_content, output_path):
|
||||||
"""Extract route points from layout YAML and save them beside the cell."""
|
"""Extract route points from layout YAML and save them beside the cell."""
|
||||||
layout = yaml.safe_load(yaml_content) or {}
|
layout = yaml_content if isinstance(yaml_content, dict) else parse_layout_cell_content(yaml_content)
|
||||||
routes = {}
|
routes = {}
|
||||||
# The sidecar preserves manually edited route control points separately from
|
# The sidecar preserves manually edited route control points separately from
|
||||||
# the main YAML file for tooling that wants route-only metadata.
|
# the main YAML file for tooling that wants route-only metadata.
|
||||||
for bundle_name, bundle in (layout.get("bundles") or {}).items():
|
for bundle_name, bundle in (layout.get("bundles") or {}).items():
|
||||||
|
if not isinstance(bundle, dict):
|
||||||
|
continue
|
||||||
saved_links = []
|
saved_links = []
|
||||||
for link in bundle.get("links") or []:
|
for link in bundle.get("links") or []:
|
||||||
|
if not isinstance(link, dict):
|
||||||
|
continue
|
||||||
points = link.get("points") or []
|
points = link.get("points") or []
|
||||||
if not points:
|
if not points:
|
||||||
continue
|
continue
|
||||||
@@ -437,6 +450,14 @@ def canvas_helpers():
|
|||||||
"""Serve the shared canvas helper script used by canvas.html."""
|
"""Serve the shared canvas helper script used by canvas.html."""
|
||||||
return no_cache_response(send_from_directory(FRONTEND_DIR, 'canvas-helpers.js'))
|
return no_cache_response(send_from_directory(FRONTEND_DIR, 'canvas-helpers.js'))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/pic/<filename>')
|
||||||
|
def pic(filename):
|
||||||
|
"""Serve time-of-day background images for the login page."""
|
||||||
|
safe_name = os.path.basename(filename)
|
||||||
|
return send_from_directory(PIC_DIR, safe_name)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
def logout():
|
def logout():
|
||||||
"""Clear session and return to login."""
|
"""Clear session and return to login."""
|
||||||
@@ -457,18 +478,23 @@ def list_technologies():
|
|||||||
"""List technology choices from the active role-scoped PDK root."""
|
"""List technology choices from the active role-scoped PDK root."""
|
||||||
technologies = []
|
technologies = []
|
||||||
pdks_root = current_pdk_root()
|
pdks_root = current_pdk_root()
|
||||||
|
print(f"[TECH] pdks_root={pdks_root} exists={os.path.isdir(pdks_root)}")
|
||||||
# Technology choices are built from foundry/technology directories under the
|
# Technology choices are built from foundry/technology directories under the
|
||||||
# role PDK root, and only folders with technology.yml are exposed.
|
# role PDK root, and only folders with technology.yml are exposed.
|
||||||
if os.path.isdir(pdks_root):
|
if os.path.isdir(pdks_root):
|
||||||
for foundry in sorted(os.listdir(pdks_root)):
|
for foundry in sorted(os.listdir(pdks_root)):
|
||||||
foundry_path = os.path.join(pdks_root, foundry)
|
foundry_path = os.path.join(pdks_root, foundry)
|
||||||
if not os.path.isdir(foundry_path):
|
if not os.path.isdir(foundry_path):
|
||||||
|
print(f"[TECH] skip non-dir foundry={foundry}")
|
||||||
continue
|
continue
|
||||||
for technology in sorted(os.listdir(foundry_path)):
|
for technology in sorted(os.listdir(foundry_path)):
|
||||||
technology_path = os.path.join(foundry_path, technology)
|
technology_path = os.path.join(foundry_path, technology)
|
||||||
if not os.path.isdir(technology_path):
|
if not os.path.isdir(technology_path):
|
||||||
|
print(f"[TECH] skip non-dir tech={technology}")
|
||||||
continue
|
continue
|
||||||
if not os.path.exists(os.path.join(technology_path, "technology.yml")):
|
has_manifest = os.path.exists(os.path.join(technology_path, "technology.yml"))
|
||||||
|
print(f"[TECH] foundry={foundry} tech={technology} has_manifest={has_manifest}")
|
||||||
|
if not has_manifest:
|
||||||
continue
|
continue
|
||||||
technologies.append({
|
technologies.append({
|
||||||
"foundry": foundry,
|
"foundry": foundry,
|
||||||
@@ -476,6 +502,7 @@ def list_technologies():
|
|||||||
"id": f"{foundry}/{technology}",
|
"id": f"{foundry}/{technology}",
|
||||||
"label": f"{foundry} / {technology}"
|
"label": f"{foundry} / {technology}"
|
||||||
})
|
})
|
||||||
|
print(f"[TECH] returning {len(technologies)} technologies: {[t['id'] for t in technologies]}")
|
||||||
return jsonify({"technologies": technologies})
|
return jsonify({"technologies": technologies})
|
||||||
|
|
||||||
|
|
||||||
@@ -587,22 +614,24 @@ def list_projects():
|
|||||||
os.makedirs(root, exist_ok=True)
|
os.makedirs(root, exist_ok=True)
|
||||||
|
|
||||||
projects = []
|
projects = []
|
||||||
# Each project is a folder and each YAML file inside that folder is treated
|
# Each project is a folder and each valid layout YAML file inside that
|
||||||
# as one saved cell/canvas.
|
# folder is treated as one saved cell/canvas. Route sidecars and malformed
|
||||||
|
# files are ignored so reopen stays resilient to stale runtime artifacts.
|
||||||
for name in sorted(os.listdir(root)):
|
for name in sorted(os.listdir(root)):
|
||||||
path = os.path.join(root, name)
|
path = os.path.join(root, name)
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
continue
|
continue
|
||||||
cells = []
|
cells = []
|
||||||
for filename in sorted(os.listdir(path)):
|
for filename in sorted(os.listdir(path)):
|
||||||
if not filename.lower().endswith(('.yml', '.yaml')):
|
if not is_layout_cell_filename(filename):
|
||||||
continue
|
continue
|
||||||
cell_name = os.path.splitext(filename)[0]
|
cell_name = os.path.splitext(filename)[0]
|
||||||
yml_path = os.path.join(path, filename)
|
yml_path = os.path.join(path, filename)
|
||||||
cells.append({
|
try:
|
||||||
"name": cell_name,
|
read_layout_cell_file(yml_path)
|
||||||
"has_layout": os.path.exists(yml_path)
|
except LayoutFileError:
|
||||||
})
|
continue
|
||||||
|
cells.append({"name": cell_name, "has_layout": True})
|
||||||
meta = read_project_meta(name)
|
meta = read_project_meta(name)
|
||||||
projects.append({
|
projects.append({
|
||||||
"name": name,
|
"name": name,
|
||||||
@@ -648,24 +677,20 @@ def get_project(project_name):
|
|||||||
if not os.path.isdir(root):
|
if not os.path.isdir(root):
|
||||||
return jsonify({"error": "Project not found"}), 404
|
return jsonify({"error": "Project not found"}), 404
|
||||||
|
|
||||||
cells = []
|
loaded_cells, warnings = load_layout_cell_files(root)
|
||||||
for filename in sorted(os.listdir(root)):
|
cells = [
|
||||||
if not filename.lower().endswith(('.yml', '.yaml')):
|
{
|
||||||
continue
|
"name": os.path.splitext(cell["filename"])[0],
|
||||||
cell_name = os.path.splitext(filename)[0]
|
"content": cell["content"]
|
||||||
yml_path = os.path.join(root, filename)
|
}
|
||||||
if not os.path.exists(yml_path):
|
for cell in loaded_cells
|
||||||
continue
|
]
|
||||||
with open(yml_path, 'r', encoding='utf-8') as f:
|
|
||||||
cells.append({
|
|
||||||
"name": cell_name,
|
|
||||||
"content": f.read()
|
|
||||||
})
|
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"name": safe_name(project_name, 'project_1'),
|
"name": safe_name(project_name, 'project_1'),
|
||||||
"cells": cells,
|
"cells": cells,
|
||||||
"technology": read_project_meta(project_name).get("technology")
|
"technology": read_project_meta(project_name).get("technology"),
|
||||||
|
"warnings": warnings
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -687,6 +712,36 @@ def delete_project(project_name):
|
|||||||
return jsonify({"message": "deleted", "project": safe_name(project_name, 'project_1')})
|
return jsonify({"message": "deleted", "project": safe_name(project_name, 'project_1')})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/projects/<project_name>/rename', methods=['PUT'])
|
||||||
|
@login_required_json
|
||||||
|
def rename_project(project_name):
|
||||||
|
"""Rename a project folder."""
|
||||||
|
data = request.get_json(silent=True) or {}
|
||||||
|
new_name = (data.get('name') or '').strip()
|
||||||
|
if not new_name:
|
||||||
|
return jsonify({"error": "New project name is required"}), 400
|
||||||
|
|
||||||
|
root = project_root(project_name)
|
||||||
|
layout_root = os.path.abspath(user_layout_root())
|
||||||
|
target = os.path.abspath(root)
|
||||||
|
|
||||||
|
if not target.startswith(layout_root + os.sep):
|
||||||
|
return jsonify({"error": "Invalid project path"}), 400
|
||||||
|
if not os.path.isdir(target):
|
||||||
|
return jsonify({"error": "Project not found"}), 404
|
||||||
|
|
||||||
|
safe_new = safe_name(new_name, 'project_1')
|
||||||
|
new_root = os.path.join(user_layout_root(), safe_new)
|
||||||
|
if os.path.exists(new_root):
|
||||||
|
return jsonify({"error": "A project with that name already exists"}), 409
|
||||||
|
|
||||||
|
old_meta = read_project_meta(project_name)
|
||||||
|
os.rename(target, new_root)
|
||||||
|
write_project_meta(safe_new, {"name": safe_new, "technology": old_meta.get("technology")})
|
||||||
|
record_action('project.rename', project=safe_new, detail={"old_name": project_name})
|
||||||
|
return jsonify({"name": safe_new})
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/projects/<project_name>/cells/<cell_name>', methods=['PATCH', 'DELETE'])
|
@app.route('/api/projects/<project_name>/cells/<cell_name>', methods=['PATCH', 'DELETE'])
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def rename_cell(project_name, cell_name):
|
def rename_cell(project_name, cell_name):
|
||||||
@@ -728,18 +783,19 @@ def rename_cell(project_name, cell_name):
|
|||||||
def save_layout():
|
def save_layout():
|
||||||
"""Persist a canvas layout YAML document and refresh its preview assets."""
|
"""Persist a canvas layout YAML document and refresh its preview assets."""
|
||||||
try:
|
try:
|
||||||
data = request.get_json()
|
data = request.get_json(silent=True) or {}
|
||||||
project = safe_name(data.get('project'), 'project_1')
|
project = safe_name(data.get('project'), 'project_1')
|
||||||
cell = safe_name(data.get('cell'), 'canvas_1')
|
cell = safe_name(data.get('cell'), 'canvas_1')
|
||||||
content = data.get('content', '')
|
content = data.get('content', '')
|
||||||
create_preview = bool(data.get('preview', True))
|
create_preview = bool(data.get('preview', True))
|
||||||
|
layout_doc = parse_layout_cell_content(content, f"{project}/{cell}.yml")
|
||||||
|
|
||||||
save_path = cell_file_path(project, cell)
|
save_path = cell_file_path(project, cell)
|
||||||
os.makedirs(os.path.dirname(save_path), exist_ok=True)
|
os.makedirs(os.path.dirname(save_path), exist_ok=True)
|
||||||
|
|
||||||
with open(save_path, 'w', encoding='utf-8') as f:
|
with open(save_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
write_route_points_sidecar(content, cell_routes_path(project, cell))
|
write_route_points_sidecar(layout_doc, cell_routes_path(project, cell))
|
||||||
|
|
||||||
svg_path = None
|
svg_path = None
|
||||||
svg_version = None
|
svg_version = None
|
||||||
@@ -782,6 +838,8 @@ def save_layout():
|
|||||||
"preview_error": preview_error
|
"preview_error": preview_error
|
||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
|
except LayoutFileError as e:
|
||||||
|
return jsonify({"error": str(e)}), 400
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
@@ -901,10 +959,18 @@ def getLib():
|
|||||||
@app.route('/api/component/<component_name>')
|
@app.route('/api/component/<component_name>')
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def getComp(component_name):
|
def getComp(component_name):
|
||||||
"""Return component YAML data."""
|
"""Return component YAML data with injected category."""
|
||||||
data = readCompYaml(component_name, pdk_root_for_request_project())
|
comps_root = pdk_root_for_request_project()
|
||||||
|
data = readCompYaml(component_name, comps_root)
|
||||||
if data is None:
|
if data is None:
|
||||||
return jsonify({"error": "Component not found"}), 404
|
return jsonify({"error": "Component not found"}), 404
|
||||||
|
# Derive the category (parent folder name) for icon resolution on the canvas.
|
||||||
|
if isinstance(data, dict) and '__category__' not in data:
|
||||||
|
search_root = comps_root or current_pdk_root()
|
||||||
|
for root, dirs, files in os.walk(search_root):
|
||||||
|
if os.path.basename(root) == component_name:
|
||||||
|
data['__category__'] = os.path.basename(os.path.dirname(root))
|
||||||
|
break
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
@app.route('/api/component/<component_name>/image')
|
@app.route('/api/component/<component_name>/image')
|
||||||
|
|||||||
@@ -12,6 +12,13 @@
|
|||||||
}
|
}
|
||||||
root.MxpicCanvasHelpers = helpers;
|
root.MxpicCanvasHelpers = helpers;
|
||||||
})(typeof window !== 'undefined' ? window : globalThis, function () {
|
})(typeof window !== 'undefined' ? window : globalThis, function () {
|
||||||
|
// Global origin for YAML coordinate export/import so YAML values always match
|
||||||
|
// the RightPanel display coordinate system.
|
||||||
|
let __exportOriginX = null;
|
||||||
|
let __exportOriginY = null;
|
||||||
|
var setExportOrigin = (x, y) => { __exportOriginX = x; __exportOriginY = y; };
|
||||||
|
var getExportOrigin = () => ({ x: __exportOriginX, y: __exportOriginY });
|
||||||
|
|
||||||
// Label used by the canvas to represent generated mxpic_forge components.
|
// Label used by the canvas to represent generated mxpic_forge components.
|
||||||
const FORGE_COMPONENT_LABEL = 'generate with mxpic_forge';
|
const FORGE_COMPONENT_LABEL = 'generate with mxpic_forge';
|
||||||
// Serialized component type used when saving mxpic_forge-generated components.
|
// Serialized component type used when saving mxpic_forge-generated components.
|
||||||
@@ -20,14 +27,16 @@
|
|||||||
const DEFAULT_COMPONENT_BOX_SIZE = { width: 132, height: 82 };
|
const DEFAULT_COMPONENT_BOX_SIZE = { width: 132, height: 82 };
|
||||||
// Default editable canvas dimensions in micrometers.
|
// Default editable canvas dimensions in micrometers.
|
||||||
const DEFAULT_CANVAS_SIZE = { width: 5000, height: 5000 };
|
const DEFAULT_CANVAS_SIZE = { width: 5000, height: 5000 };
|
||||||
|
// Default canvas bounds as a four-wall rectangle (xmin, xmax, ymin, ymax).
|
||||||
|
const DEFAULT_CANVAS_BOUNDS = { xmin: 0, xmax: 5000, ymin: 0, ymax: 5000 };
|
||||||
// Base visual diameter and hit area used for port and anchor handles.
|
// Base visual diameter and hit area used for port and anchor handles.
|
||||||
const PORT_NODE_SIZE = 30;
|
const PORT_NODE_SIZE = 11;
|
||||||
const FREE_WIRES_BUNDLE_GROUP = 'free_wires';
|
const FREE_WIRES_BUNDLE_GROUP = 'free_wires';
|
||||||
const PORT_LABEL_MIN_CHARS = 5;
|
const PORT_LABEL_MIN_CHARS = 5;
|
||||||
const PORT_LABEL_CHAR_WIDTH = 7;
|
const PORT_LABEL_CHAR_WIDTH = 7;
|
||||||
const PORT_LABEL_HORIZONTAL_PADDING = 12;
|
const PORT_LABEL_HORIZONTAL_PADDING = 12;
|
||||||
// Anchor body width used in the canvas visual representation.
|
// Anchor body width used in the canvas visual representation.
|
||||||
const ANCHOR_NODE_WIDTH = 16;
|
const ANCHOR_NODE_WIDTH = 18;
|
||||||
// Default spacing between repeated anchor or port pins.
|
// Default spacing between repeated anchor or port pins.
|
||||||
const DEFAULT_ELEMENT_PITCH = 10;
|
const DEFAULT_ELEMENT_PITCH = 10;
|
||||||
// Defines built-in port and anchor element metadata before per-node expansion.
|
// Defines built-in port and anchor element metadata before per-node expansion.
|
||||||
@@ -307,15 +316,35 @@
|
|||||||
height: positiveNumber(size && size.height) || DEFAULT_CANVAS_SIZE.height
|
height: positiveNumber(size && size.height) || DEFAULT_CANVAS_SIZE.height
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Resolve valid canvas bounds (four-wall rectangle) from saved project metadata.
|
||||||
|
// Accepts either legacy {width, height} or new {xmin, xmax, ymin, ymax}.
|
||||||
|
const normalizeCanvasBounds = (bounds) => {
|
||||||
|
if (!bounds) return { ...DEFAULT_CANVAS_BOUNDS };
|
||||||
|
// New-style four-wall rectangle.
|
||||||
|
if (bounds.xmin != null || bounds.xmax != null || bounds.ymin != null || bounds.ymax != null) {
|
||||||
|
return {
|
||||||
|
xmin: Number.isFinite(Number(bounds.xmin)) ? Number(bounds.xmin) : DEFAULT_CANVAS_BOUNDS.xmin,
|
||||||
|
xmax: Number.isFinite(Number(bounds.xmax)) ? Number(bounds.xmax) : DEFAULT_CANVAS_BOUNDS.xmax,
|
||||||
|
ymin: Number.isFinite(Number(bounds.ymin)) ? Number(bounds.ymin) : DEFAULT_CANVAS_BOUNDS.ymin,
|
||||||
|
ymax: Number.isFinite(Number(bounds.ymax)) ? Number(bounds.ymax) : DEFAULT_CANVAS_BOUNDS.ymax
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Legacy width/height format: treat as rectangle from (0,0).
|
||||||
|
const w = positiveNumber(bounds.width) || DEFAULT_CANVAS_SIZE.width;
|
||||||
|
const h = positiveNumber(bounds.height) || DEFAULT_CANVAS_SIZE.height;
|
||||||
|
return { xmin: 0, xmax: w, ymin: 0, ymax: h };
|
||||||
|
};
|
||||||
|
|
||||||
// Keep dragged or pasted nodes inside the active canvas bounds.
|
// Keep dragged or pasted nodes inside the active canvas bounds.
|
||||||
|
// Accepts either legacy {width,height} or new {xmin,xmax,ymin,ymax} canvasSize.
|
||||||
const clampPositionToCanvas = (position, canvasSize, boxSize) => {
|
const clampPositionToCanvas = (position, canvasSize, boxSize) => {
|
||||||
const size = normalizeCanvasSize(canvasSize);
|
const bounds = normalizeCanvasBounds(canvasSize);
|
||||||
const box = normalizeBoxSize({ box_size: [boxSize && boxSize.width, boxSize && boxSize.height] });
|
const box = normalizeBoxSize({ box_size: [boxSize && boxSize.width, boxSize && boxSize.height] });
|
||||||
const maxX = Math.max(0, size.width - box.width);
|
const maxX = Math.max(bounds.xmin, bounds.xmax - box.width);
|
||||||
const maxY = Math.max(0, size.height - box.height);
|
const maxY = Math.max(bounds.ymin, bounds.ymax - box.height);
|
||||||
return {
|
return {
|
||||||
x: Math.min(maxX, Math.max(0, Number(position && position.x) || 0)),
|
x: Math.min(maxX, Math.max(bounds.xmin, Number(position && position.x) || 0)),
|
||||||
y: Math.min(maxY, Math.max(0, Number(position && position.y) || 0))
|
y: Math.min(maxY, Math.max(bounds.ymin, Number(position && position.y) || 0))
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -368,8 +397,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (points.length === 0) {
|
if (points.length === 0) {
|
||||||
const size = normalizeCanvasSize(page.canvasSize || DEFAULT_CANVAS_SIZE);
|
const bounds = normalizeCanvasBounds(page.canvasSize || page.canvasBounds);
|
||||||
points.push({ x: 0, y: 0 }, { x: size.width, y: size.height });
|
points.push({ x: bounds.xmin, y: bounds.ymin }, { x: bounds.xmax, y: bounds.ymax });
|
||||||
}
|
}
|
||||||
|
|
||||||
const minX = roundBoundsValue(Math.min(...points.map(point => point.x)));
|
const minX = roundBoundsValue(Math.min(...points.map(point => point.x)));
|
||||||
@@ -651,10 +680,20 @@
|
|||||||
return JSON.stringify(String(value));
|
return JSON.stringify(String(value));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert canvas Y coordinates into layout Y coordinates.
|
// Convert canvas coordinates into layout/display coordinates.
|
||||||
const canvasToLayoutY = (value) => -Number(value || 0);
|
// When origin is set, uses the RightPanel formula: displayY = originY - rfY
|
||||||
// Convert layout Y coordinates back into canvas Y coordinates.
|
// Falls back to simple negation for backward compatibility.
|
||||||
const layoutToCanvasY = (value) => -Number(value || 0);
|
const canvasToLayoutY = (value) => { const v = Number(value || 0); return __exportOriginY != null ? __exportOriginY - v : -v; };
|
||||||
|
const canvasToLayoutX = (value) => { const v = Number(value || 0); return __exportOriginX != null ? v - __exportOriginX : v; };
|
||||||
|
// Convert layout/display coordinates back into canvas coordinates.
|
||||||
|
// Uses self-inverse formula for Y: rfY = originY - displayY (same as above).
|
||||||
|
// Import: layout/display coords → canvas coords. Optional originY/originX allow
|
||||||
|
// per-file overrides (e.g. from a YAML canvas_origin field). When omitted the
|
||||||
|
// module-level origin is used; null origin falls back to simple negation / pass-through.
|
||||||
|
const layoutToCanvasY = (value, originY) => { const v = Number(value || 0); const oy = originY !== undefined ? originY : __exportOriginY; return oy != null ? oy - v : -v; };
|
||||||
|
const layoutToCanvasX = (value, originX) => { const v = Number(value || 0); const ox = originX !== undefined ? originX : __exportOriginX; return ox != null ? v + ox : v; };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Serialize nested component settings into YAML blocks.
|
// Serialize nested component settings into YAML blocks.
|
||||||
const buildSettingsYaml = (settings, indent) => {
|
const buildSettingsYaml = (settings, indent) => {
|
||||||
@@ -677,8 +716,8 @@
|
|||||||
: '\n settings:\n length:';
|
: '\n settings:\n length:';
|
||||||
|
|
||||||
return ` ${instanceName}:
|
return ` ${instanceName}:
|
||||||
component: ${componentValue}
|
component: "${componentValue}"
|
||||||
x: ${Number(position.x || 0).toFixed(1)}
|
x: ${canvasToLayoutX(position.x).toFixed(1)}
|
||||||
y: ${canvasToLayoutY(position.y).toFixed(1)}
|
y: ${canvasToLayoutY(position.y).toFixed(1)}
|
||||||
rotation: ${Number(rotation || 0).toFixed(1)}
|
rotation: ${Number(rotation || 0).toFixed(1)}
|
||||||
flip: ${flip ? 1 : 0}
|
flip: ${flip ? 1 : 0}
|
||||||
@@ -790,14 +829,11 @@
|
|||||||
const portNumber = normalizePortNumber(data && data.portNumber);
|
const portNumber = normalizePortNumber(data && data.portNumber);
|
||||||
const pitch = normalizePitch(data && data.pitch);
|
const pitch = normalizePitch(data && data.pitch);
|
||||||
const handleClearance = Math.max(pitch, 14);
|
const handleClearance = Math.max(pitch, 14);
|
||||||
const portDisplayName = String((data && (data.portName || data.componentDisplayName || data.label)) || 'port');
|
|
||||||
const portWidth = Math.max(
|
|
||||||
PORT_NODE_SIZE,
|
|
||||||
PORT_LABEL_HORIZONTAL_PADDING + Math.max(PORT_LABEL_MIN_CHARS, portDisplayName.length) * PORT_LABEL_CHAR_WIDTH
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
width: data && data.elementType === 'anchor' ? ANCHOR_NODE_WIDTH : portWidth,
|
width: data && data.elementType === 'anchor' ? ANCHOR_NODE_WIDTH : PORT_NODE_SIZE,
|
||||||
height: Math.max(PORT_NODE_SIZE, PORT_NODE_SIZE + Math.max(0, portNumber - 1) * handleClearance)
|
height: data && data.elementType === 'anchor'
|
||||||
|
? Math.max(PORT_NODE_SIZE * 1.125, PORT_NODE_SIZE * 1.125 + Math.max(0, portNumber - 1) * handleClearance)
|
||||||
|
: Math.max(PORT_NODE_SIZE, PORT_NODE_SIZE + Math.max(0, portNumber - 1) * handleClearance)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -911,7 +947,7 @@
|
|||||||
|
|
||||||
// Convert standalone port nodes into page-level layout pins.
|
// Convert standalone port nodes into page-level layout pins.
|
||||||
const buildPageComponentPins = (port, nodes) => {
|
const buildPageComponentPins = (port, nodes) => {
|
||||||
const portNodes = (nodes || []).filter(isPortElementNode);
|
const portNodes = (nodes || []).filter(n => n.id === 'page-port');
|
||||||
if (portNodes.length > 0) {
|
if (portNodes.length > 0) {
|
||||||
return portNodes.reduce((pins, node) => {
|
return portNodes.reduce((pins, node) => {
|
||||||
const data = node.data || {};
|
const data = node.data || {};
|
||||||
@@ -965,7 +1001,7 @@
|
|||||||
${data.layer ? `layer: ${data.layer}` : 'layer: WG_CORE'}
|
${data.layer ? `layer: ${data.layer}` : 'layer: WG_CORE'}
|
||||||
element: ${info.element}
|
element: ${info.element}
|
||||||
pin: ${info.pin}
|
pin: ${info.pin}
|
||||||
x: ${Number(info.x || 0).toFixed(1)}
|
x: ${canvasToLayoutX(info.x).toFixed(1)}
|
||||||
y: ${canvasToLayoutY(info.y).toFixed(1)}
|
y: ${canvasToLayoutY(info.y).toFixed(1)}
|
||||||
angle: ${Number(info.a || 0).toFixed(1)}
|
angle: ${Number(info.a || 0).toFixed(1)}
|
||||||
width: ${Number(info.width || 0.5)}${description}`;
|
width: ${Number(info.width || 0.5)}${description}`;
|
||||||
@@ -980,7 +1016,7 @@
|
|||||||
|
|
||||||
// Serialize built-in port and anchor nodes into layout element metadata.
|
// Serialize built-in port and anchor nodes into layout element metadata.
|
||||||
const buildElementsYaml = (nodes) => {
|
const buildElementsYaml = (nodes) => {
|
||||||
const elementNodes = (nodes || []).filter(isElementNode);
|
const elementNodes = (nodes || []).filter(n => isElementNode(n) && n.id !== 'page-port');
|
||||||
if (elementNodes.length === 0) return 'elements: {}';
|
if (elementNodes.length === 0) return 'elements: {}';
|
||||||
const lines = elementNodes.map(node => {
|
const lines = elementNodes.map(node => {
|
||||||
const data = node.data || {};
|
const data = node.data || {};
|
||||||
@@ -993,7 +1029,7 @@
|
|||||||
.join('\n');
|
.join('\n');
|
||||||
return ` ${name}:
|
return ` ${name}:
|
||||||
type: ${data.elementType}
|
type: ${data.elementType}
|
||||||
x: ${Number((node.position && node.position.x) || 0).toFixed(1)}
|
x: ${canvasToLayoutX((node.position && node.position.x) || 0).toFixed(1)}
|
||||||
y: ${canvasToLayoutY((node.position && node.position.y) || 0).toFixed(1)}
|
y: ${canvasToLayoutY((node.position && node.position.y) || 0).toFixed(1)}
|
||||||
angle: ${Number(angle || 0).toFixed(1)}
|
angle: ${Number(angle || 0).toFixed(1)}
|
||||||
pin_number: ${portNumber}
|
pin_number: ${portNumber}
|
||||||
@@ -1058,7 +1094,7 @@ ${pinLines}`;
|
|||||||
const storedPoints = Array.isArray(edge.data && edge.data.points) ? edge.data.points : [];
|
const storedPoints = Array.isArray(edge.data && edge.data.points) ? edge.data.points : [];
|
||||||
const points = storedPoints.length >= 2 ? getEdgeRoutePoints(edge, nodeMap) : [];
|
const points = storedPoints.length >= 2 ? getEdgeRoutePoints(edge, nodeMap) : [];
|
||||||
const pointsYaml = points.length > 0
|
const pointsYaml = points.length > 0
|
||||||
? `\n points:\n${points.map(point => ` - x: ${Number(point.x || 0).toFixed(1)}\n y: ${canvasToLayoutY(point.y).toFixed(1)}`).join('\n')}`
|
? `\n points:\n${points.map(point => ` - x: ${canvasToLayoutX(point.x).toFixed(1)}\n y: ${canvasToLayoutY(point.y).toFixed(1)}`).join('\n')}`
|
||||||
: '';
|
: '';
|
||||||
const isFreeRoute = Boolean(edge.data && edge.data.freeRoute) || (!sourceNode && !targetNode && points.length >= 2);
|
const isFreeRoute = Boolean(edge.data && edge.data.freeRoute) || (!sourceNode && !targetNode && points.length >= 2);
|
||||||
const linkYaml = isFreeRoute
|
const linkYaml = isFreeRoute
|
||||||
@@ -1307,6 +1343,7 @@ bundles:${groupsYaml ? `\n${groupsYaml}` : ' {}'}`;
|
|||||||
FORGE_COMPONENT_TYPE,
|
FORGE_COMPONENT_TYPE,
|
||||||
DEFAULT_COMPONENT_BOX_SIZE,
|
DEFAULT_COMPONENT_BOX_SIZE,
|
||||||
DEFAULT_CANVAS_SIZE,
|
DEFAULT_CANVAS_SIZE,
|
||||||
|
DEFAULT_CANVAS_BOUNDS,
|
||||||
PORT_NODE_SIZE,
|
PORT_NODE_SIZE,
|
||||||
DEFAULT_ELEMENT_PITCH,
|
DEFAULT_ELEMENT_PITCH,
|
||||||
ELEMENT_COMPONENTS,
|
ELEMENT_COMPONENTS,
|
||||||
@@ -1314,8 +1351,12 @@ bundles:${groupsYaml ? `\n${groupsYaml}` : ' {}'}`;
|
|||||||
DEFAULT_FORGE_ARGUMENTS,
|
DEFAULT_FORGE_ARGUMENTS,
|
||||||
FALLBACK_TECHNOLOGY_MANIFEST,
|
FALLBACK_TECHNOLOGY_MANIFEST,
|
||||||
FREE_WIRES_BUNDLE_GROUP,
|
FREE_WIRES_BUNDLE_GROUP,
|
||||||
|
setExportOrigin,
|
||||||
|
getExportOrigin,
|
||||||
canvasToLayoutY,
|
canvasToLayoutY,
|
||||||
|
canvasToLayoutX,
|
||||||
layoutToCanvasY,
|
layoutToCanvasY,
|
||||||
|
layoutToCanvasX,
|
||||||
createForgeArguments,
|
createForgeArguments,
|
||||||
createRouteSettings,
|
createRouteSettings,
|
||||||
updateRouteField,
|
updateRouteField,
|
||||||
@@ -1333,6 +1374,7 @@ bundles:${groupsYaml ? `\n${groupsYaml}` : ' {}'}`;
|
|||||||
normalizeBoxSize,
|
normalizeBoxSize,
|
||||||
chooseCategoryComponent,
|
chooseCategoryComponent,
|
||||||
normalizeCanvasSize,
|
normalizeCanvasSize,
|
||||||
|
normalizeCanvasBounds,
|
||||||
clampPositionToCanvas,
|
clampPositionToCanvas,
|
||||||
calculateLayoutBounds,
|
calculateLayoutBounds,
|
||||||
calculateCompositeBoxSize,
|
calculateCompositeBoxSize,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Organization : OptiHK Limited
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>mxPIC EDA Dashboard</title>
|
<title>mxPIC EDA Dashboard</title>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&family=Varela+Round&family=Inter:wght@400;500&display=swap" rel="stylesheet">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
@@ -42,12 +42,12 @@ Organization : OptiHK Limited
|
|||||||
--bg-panel: #eef4fa;
|
--bg-panel: #eef4fa;
|
||||||
--text-main: #142235;
|
--text-main: #142235;
|
||||||
--text-muted: #5f7085;
|
--text-muted: #5f7085;
|
||||||
--accent: #1d4ed8;
|
--accent: #3b82f6;
|
||||||
--accent-hover: #0f766e;
|
--accent-hover: #06b6d4;
|
||||||
--accent-green: #15803d;
|
--accent-green: #15803d;
|
||||||
--accent-warm: #b45309;
|
--accent-warm: #b45309;
|
||||||
--border: #d6e0eb;
|
--border: #b8c5d4;
|
||||||
--border-strong: #b6c4d4;
|
--border-strong: #8fa2b8;
|
||||||
--panel-soft: #f8fafc;
|
--panel-soft: #f8fafc;
|
||||||
--folder-icon: #38bdf8;
|
--folder-icon: #38bdf8;
|
||||||
--shadow: rgba(37, 99, 235, 0.1);
|
--shadow: rgba(37, 99, 235, 0.1);
|
||||||
@@ -173,7 +173,6 @@ Organization : OptiHK Limited
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-toggle,
|
|
||||||
.logout-btn,
|
.logout-btn,
|
||||||
.secondary-btn,
|
.secondary-btn,
|
||||||
.profile-action,
|
.profile-action,
|
||||||
@@ -196,7 +195,80 @@ Organization : OptiHK Limited
|
|||||||
}
|
}
|
||||||
|
|
||||||
.theme-toggle {
|
.theme-toggle {
|
||||||
min-width: 92px;
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 78px;
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 7px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--panel-soft);
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
transition: border-color 0.2s ease, background 0.2s ease;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.theme-toggle .toggle-icon {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
font-size: 21px;
|
||||||
|
z-index: 1;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: color 180ms ease, text-shadow 180ms ease;
|
||||||
|
color: var(--text-muted);
|
||||||
|
line-height: 1;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.theme-toggle-thumb {
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
width: calc(50% - 3px);
|
||||||
|
height: calc(100% - 4px);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--accent);
|
||||||
|
transition: left 280ms cubic-bezier(0.16, 1, 0.3, 1);
|
||||||
|
z-index: 0;
|
||||||
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.theme-toggle[data-theme="dark"] .theme-toggle-thumb {
|
||||||
|
left: calc(50% + 1px);
|
||||||
|
}
|
||||||
|
.theme-toggle[data-theme="bright"] .theme-toggle-thumb {
|
||||||
|
left: 2px;
|
||||||
|
}
|
||||||
|
.theme-toggle[data-theme="dark"] .toggle-moon {
|
||||||
|
color: #ffffff;
|
||||||
|
text-shadow: 0 0 8px rgba(96, 165, 250, 0.6);
|
||||||
|
}
|
||||||
|
.theme-toggle[data-theme="bright"] .toggle-sun {
|
||||||
|
color: #ffffff;
|
||||||
|
text-shadow: 0 0 8px rgba(250, 204, 21, 0.6);
|
||||||
|
}
|
||||||
|
.back-btn {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: var(--panel-soft);
|
||||||
|
color: var(--text-muted);
|
||||||
|
border-radius: 8px;
|
||||||
|
min-height: 36px;
|
||||||
|
padding: 0 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 700;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
transition: border-color 0.2s ease, color 0.2s ease;
|
||||||
|
}
|
||||||
|
.back-btn:hover {
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.logout-btn:hover,
|
.logout-btn:hover,
|
||||||
@@ -209,9 +281,9 @@ Organization : OptiHK Limited
|
|||||||
|
|
||||||
.container {
|
.container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 1320px;
|
max-width: 1550px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 34px 16px 30px;
|
padding: 34px 8px 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hero {
|
.hero {
|
||||||
@@ -291,7 +363,7 @@ Organization : OptiHK Limited
|
|||||||
|
|
||||||
.dashboard-grid {
|
.dashboard-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: minmax(0, 1fr) 300px;
|
grid-template-columns: minmax(0, 1fr) 420px;
|
||||||
gap: 18px;
|
gap: 18px;
|
||||||
align-items: start;
|
align-items: start;
|
||||||
}
|
}
|
||||||
@@ -318,11 +390,91 @@ Organization : OptiHK Limited
|
|||||||
.panel-title {
|
.panel-title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 0.86rem;
|
font-size: 0.86rem;
|
||||||
font-family: 'IBM Plex Mono', Consolas, monospace;
|
font-family: 'Varela Round', sans-serif;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
letter-spacing: 0.05em;
|
letter-spacing: 0.05em;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
body.light-mode .panel-title {
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expand-btn {
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--panel-soft);
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
|
font-size: 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expand-btn:hover {
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel.activity-expanded {
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
width: min(68vw, 860px);
|
||||||
|
max-height: 72vh;
|
||||||
|
z-index: 101;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background:
|
||||||
|
linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
|
||||||
|
var(--bg-elevated);
|
||||||
|
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-backdrop {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 100;
|
||||||
|
background: rgba(0, 0, 0, 0.55);
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-backdrop.active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.light-mode .activity-backdrop {
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel.activity-expanded .panel-body {
|
||||||
|
overflow: auto;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel.activity-expanded .activity-list {
|
||||||
|
max-height: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel.activity-expanded .expand-btn {
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--accent);
|
||||||
|
background: rgba(45, 212, 191, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.light-mode .panel.activity-expanded {
|
||||||
|
background:
|
||||||
|
linear-gradient(180deg, rgba(0, 0, 0, 0.02), transparent),
|
||||||
|
var(--bg-elevated);
|
||||||
|
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel-body {
|
.panel-body {
|
||||||
@@ -420,6 +572,55 @@ Organization : OptiHK Limited
|
|||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
}
|
}
|
||||||
|
body.light-mode .project-subtitle {
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-project-btn {
|
||||||
|
display: none;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 5px;
|
||||||
|
background: var(--panel-soft);
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 0.95rem;
|
||||||
|
cursor: pointer;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
transition: border-color 0.2s ease, color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-card:hover .edit-project-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-project-btn:hover {
|
||||||
|
border-color: var(--accent);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-name-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-name-input-inline {
|
||||||
|
display: block;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: inherit;
|
||||||
|
font-family: inherit;
|
||||||
|
color: var(--text-main);
|
||||||
|
background: var(--bg-card);
|
||||||
|
border: 1px solid var(--accent);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 2px 6px;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
.project-chips {
|
.project-chips {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -505,7 +706,7 @@ Organization : OptiHK Limited
|
|||||||
|
|
||||||
.profile-grid {
|
.profile-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: repeat(2, 1fr);
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,6 +768,7 @@ Organization : OptiHK Limited
|
|||||||
|
|
||||||
.activity-message {
|
.activity-message {
|
||||||
color: var(--text-main);
|
color: var(--text-main);
|
||||||
|
font-family: 'Inter', sans-serif;
|
||||||
font-size: 0.88rem;
|
font-size: 0.88rem;
|
||||||
line-height: 1.42;
|
line-height: 1.42;
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
@@ -727,7 +929,7 @@ Organization : OptiHK Limited
|
|||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
padding: 26px 16px 24px;
|
padding: 26px 8px 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hero {
|
.hero {
|
||||||
@@ -766,14 +968,18 @@ Organization : OptiHK Limited
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body class="light-mode">
|
||||||
<header>
|
<header>
|
||||||
<div class="brand">
|
<div class="brand">
|
||||||
<div class="brand-mark" aria-hidden="true"></div>
|
<div class="brand-mark" aria-hidden="true"></div>
|
||||||
MxPic - by <span class="company-wordmark">Opti<span class="company-hk">HK</span></span>
|
MxPic - by <span class="company-wordmark">Opti<span class="company-hk">HK</span></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<button class="theme-toggle" id="theme-toggle" type="button" aria-label="Switch color theme">Light mode</button>
|
<button class="theme-toggle" id="theme-toggle" type="button" data-theme="bright" aria-label="Toggle color mode" title="Toggle dark/light mode">
|
||||||
|
<span class="theme-toggle-thumb"></span>
|
||||||
|
<span class="toggle-icon toggle-sun">☼</span>
|
||||||
|
<span class="toggle-icon toggle-moon">☾</span>
|
||||||
|
</button>
|
||||||
<a href="/logout" class="logout-btn">Logout</a>
|
<a href="/logout" class="logout-btn">Logout</a>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -845,6 +1051,7 @@ Organization : OptiHK Limited
|
|||||||
<section class="panel">
|
<section class="panel">
|
||||||
<div class="panel-header">
|
<div class="panel-header">
|
||||||
<h2 class="panel-title">Recent Activity</h2>
|
<h2 class="panel-title">Recent Activity</h2>
|
||||||
|
<button class="expand-btn" id="expand-activity" type="button" title="Expand" aria-label="Expand activity panel">↖</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="activity-list" id="activity-list" aria-live="polite">
|
<div class="activity-list" id="activity-list" aria-live="polite">
|
||||||
@@ -856,6 +1063,7 @@ Organization : OptiHK Limited
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</aside>
|
</aside>
|
||||||
|
<div class="activity-backdrop" id="activity-backdrop" aria-hidden="true"></div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
@@ -949,7 +1157,7 @@ Organization : OptiHK Limited
|
|||||||
function applyTheme(mode) {
|
function applyTheme(mode) {
|
||||||
const isLight = mode === 'light';
|
const isLight = mode === 'light';
|
||||||
document.body.classList.toggle('light-mode', isLight);
|
document.body.classList.toggle('light-mode', isLight);
|
||||||
themeToggle.textContent = isLight ? 'Dark mode' : 'Light mode';
|
themeToggle.setAttribute('data-theme', isLight ? 'bright' : 'dark');
|
||||||
localStorage.setItem('mxpic-theme', mode);
|
localStorage.setItem('mxpic-theme', mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1046,6 +1254,63 @@ Organization : OptiHK Limited
|
|||||||
window.location.href = `/canvas?project=${encodeURIComponent(name)}`;
|
window.location.href = `/canvas?project=${encodeURIComponent(name)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function startRenameProject(oldName, nameRow, editBtn) {
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.type = 'text';
|
||||||
|
input.className = 'project-name-input-inline';
|
||||||
|
input.value = oldName;
|
||||||
|
input.spellcheck = false;
|
||||||
|
|
||||||
|
const currentSpan = nameRow.querySelector('.project-name');
|
||||||
|
if (currentSpan) currentSpan.replaceWith(input);
|
||||||
|
editBtn.style.display = 'none';
|
||||||
|
input.focus();
|
||||||
|
input.select();
|
||||||
|
|
||||||
|
const finishRename = async () => {
|
||||||
|
if (!input.parentNode) return;
|
||||||
|
const newName = input.value.trim();
|
||||||
|
if (!newName || newName === oldName) {
|
||||||
|
cancelRename();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/projects/${encodeURIComponent(oldName)}/rename`, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ name: newName })
|
||||||
|
});
|
||||||
|
const data = await response.json();
|
||||||
|
if (!response.ok) {
|
||||||
|
addActivity(data.error || 'Failed to rename project.', 'error');
|
||||||
|
cancelRename();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addActivity(`Renamed project "${oldName}" to "${data.name}"`, 'success');
|
||||||
|
loadProjects();
|
||||||
|
} catch {
|
||||||
|
addActivity('Failed to rename project.', 'error');
|
||||||
|
cancelRename();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancelRename = () => {
|
||||||
|
if (input.parentNode) {
|
||||||
|
const restored = document.createElement('span');
|
||||||
|
restored.className = 'project-name';
|
||||||
|
restored.textContent = oldName;
|
||||||
|
input.replaceWith(restored);
|
||||||
|
}
|
||||||
|
editBtn.style.display = 'inline-flex';
|
||||||
|
};
|
||||||
|
|
||||||
|
input.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === 'Enter') { e.preventDefault(); finishRename(); }
|
||||||
|
if (e.key === 'Escape') { e.preventDefault(); cancelRename(); }
|
||||||
|
});
|
||||||
|
input.addEventListener('blur', () => finishRename());
|
||||||
|
}
|
||||||
|
|
||||||
async function loadActivity() {
|
async function loadActivity() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/logs?limit=8');
|
const response = await fetch('/api/logs?limit=8');
|
||||||
@@ -1155,15 +1420,33 @@ Organization : OptiHK Limited
|
|||||||
icon.setAttribute('aria-hidden', 'true');
|
icon.setAttribute('aria-hidden', 'true');
|
||||||
|
|
||||||
const details = document.createElement('div');
|
const details = document.createElement('div');
|
||||||
|
details.style.minWidth = '0';
|
||||||
|
details.style.flex = '1';
|
||||||
|
|
||||||
|
const nameRow = document.createElement('div');
|
||||||
|
nameRow.className = 'project-name-row';
|
||||||
|
|
||||||
const name = document.createElement('span');
|
const name = document.createElement('span');
|
||||||
name.className = 'project-name';
|
name.className = 'project-name';
|
||||||
name.textContent = project.name;
|
name.textContent = project.name;
|
||||||
|
|
||||||
|
const editBtn = document.createElement('button');
|
||||||
|
editBtn.className = 'edit-project-btn';
|
||||||
|
editBtn.type = 'button';
|
||||||
|
editBtn.textContent = '🖊';
|
||||||
|
editBtn.title = 'Rename project';
|
||||||
|
editBtn.addEventListener('click', (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
startRenameProject(project.name, nameRow, editBtn);
|
||||||
|
});
|
||||||
|
|
||||||
|
nameRow.append(name, editBtn);
|
||||||
|
|
||||||
const subtitle = document.createElement('div');
|
const subtitle = document.createElement('div');
|
||||||
subtitle.className = 'project-subtitle';
|
subtitle.className = 'project-subtitle';
|
||||||
subtitle.textContent = 'Photonic layout project';
|
subtitle.textContent = 'Photonic layout project';
|
||||||
|
|
||||||
details.append(name, subtitle);
|
details.append(nameRow, subtitle);
|
||||||
top.append(icon, details);
|
top.append(icon, details);
|
||||||
|
|
||||||
const chips = document.createElement('div');
|
const chips = document.createElement('div');
|
||||||
@@ -1393,7 +1676,31 @@ Organization : OptiHK Limited
|
|||||||
applyTheme(document.body.classList.contains('light-mode') ? 'dark' : 'light');
|
applyTheme(document.body.classList.contains('light-mode') ? 'dark' : 'light');
|
||||||
});
|
});
|
||||||
|
|
||||||
applyTheme(localStorage.getItem('mxpic-theme') || 'dark');
|
const expandActivityBtn = document.getElementById('expand-activity');
|
||||||
|
const activityBackdrop = document.getElementById('activity-backdrop');
|
||||||
|
if (expandActivityBtn && activityBackdrop) {
|
||||||
|
expandActivityBtn.addEventListener('click', () => {
|
||||||
|
const panel = expandActivityBtn.closest('.panel');
|
||||||
|
if (panel) {
|
||||||
|
const expanded = !panel.classList.contains('activity-expanded');
|
||||||
|
panel.classList.toggle('activity-expanded', expanded);
|
||||||
|
activityBackdrop.classList.toggle('active', expanded);
|
||||||
|
expandActivityBtn.textContent = expanded ? '↘' : '↖';
|
||||||
|
activityBackdrop.setAttribute('aria-hidden', expanded ? 'false' : 'true');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
activityBackdrop.addEventListener('click', () => {
|
||||||
|
const panel = document.querySelector('.panel.activity-expanded');
|
||||||
|
if (panel) {
|
||||||
|
panel.classList.remove('activity-expanded');
|
||||||
|
activityBackdrop.classList.remove('active');
|
||||||
|
expandActivityBtn.textContent = '↖';
|
||||||
|
activityBackdrop.setAttribute('aria-hidden', 'true');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
applyTheme(localStorage.getItem('mxpic-theme') || 'light');
|
||||||
loadTechnologies();
|
loadTechnologies();
|
||||||
loadProfile();
|
loadProfile();
|
||||||
loadProjects();
|
loadProjects();
|
||||||
@@ -1402,3 +1709,4 @@ Organization : OptiHK Limited
|
|||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Description: Login page for authenticating users before entering the MXPIC EDA workspace.
|
Description: Login page for authenticating users before entering the MXPIC EDA workspace.
|
||||||
Inside functions: applyTheme, setSubmitState
|
Inside functions: setSubmitState
|
||||||
Developer : Qin Yue @ 2026
|
Developer : Qin Yue @ 2026
|
||||||
Organization : OptiHK Limited
|
Organization : OptiHK Limited
|
||||||
-->
|
-->
|
||||||
@@ -35,26 +35,6 @@ Organization : OptiHK Limited
|
|||||||
--focus-ring: rgba(93, 216, 243, 0.28);
|
--focus-ring: rgba(93, 216, 243, 0.28);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.light-mode {
|
|
||||||
--bg-main: #f4f7fb;
|
|
||||||
--bg-panel: #ffffff;
|
|
||||||
--bg-card: #ffffff;
|
|
||||||
--bg-soft: #eef4fa;
|
|
||||||
--text-main: #142235;
|
|
||||||
--text-muted: #5f7085;
|
|
||||||
--accent: #1d4ed8;
|
|
||||||
--accent-strong: #0f766e;
|
|
||||||
--accent-warm: #b45309;
|
|
||||||
--accent-green: #15803d;
|
|
||||||
--accent-red: #dc2626;
|
|
||||||
--border: #d6e0eb;
|
|
||||||
--border-strong: #b6c4d4;
|
|
||||||
--input-bg: #f8fafc;
|
|
||||||
--shadow: rgba(37, 99, 235, 0.12);
|
|
||||||
--error-text: #991b1b;
|
|
||||||
--error-bg: rgba(220, 38, 38, 0.08);
|
|
||||||
--focus-ring: rgba(29, 78, 216, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -65,23 +45,33 @@ Organization : OptiHK Limited
|
|||||||
min-height: 100dvh;
|
min-height: 100dvh;
|
||||||
font-family: 'IBM Plex Sans', "Segoe UI", sans-serif;
|
font-family: 'IBM Plex Sans', "Segoe UI", sans-serif;
|
||||||
color: var(--text-main);
|
color: var(--text-main);
|
||||||
background:
|
background-color: var(--bg-main);
|
||||||
linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
|
background-size: cover;
|
||||||
linear-gradient(0deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
|
background-position: center;
|
||||||
linear-gradient(135deg, var(--bg-main), #091526 62%, #0d1724);
|
background-repeat: no-repeat;
|
||||||
background-size: 48px 48px, 48px 48px, auto;
|
position: relative;
|
||||||
display: grid;
|
display: grid;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
padding: 28px;
|
padding: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.light-mode {
|
body::after {
|
||||||
|
content: '';
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: -1;
|
||||||
background:
|
background:
|
||||||
linear-gradient(90deg, rgba(29, 78, 216, 0.04) 1px, transparent 1px),
|
linear-gradient(90deg, rgba(255,255,255,0.026) 1px, transparent 1px),
|
||||||
linear-gradient(0deg, rgba(29, 78, 216, 0.04) 1px, transparent 1px),
|
linear-gradient(0deg, rgba(255,255,255,0.026) 1px, transparent 1px);
|
||||||
linear-gradient(135deg, #f8fbff, var(--bg-main));
|
background-size: 48px 48px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
body.bg-morning { background-image: url('/pic/morning.webp'); }
|
||||||
|
body.bg-noon { background-image: url('/pic/noon.webp'); }
|
||||||
|
body.bg-sunset { background-image: url('/pic/sunset.webp'); }
|
||||||
|
body.bg-night { background-image: url('/pic/night.webp'); }
|
||||||
|
|
||||||
button,
|
button,
|
||||||
input {
|
input {
|
||||||
font: inherit;
|
font: inherit;
|
||||||
@@ -93,47 +83,25 @@ Organization : OptiHK Limited
|
|||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-toggle {
|
|
||||||
position: fixed;
|
|
||||||
top: 20px;
|
|
||||||
right: 22px;
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
background: rgba(12, 23, 40, 0.86);
|
|
||||||
color: var(--text-main);
|
|
||||||
border-radius: 8px;
|
|
||||||
min-width: 92px;
|
|
||||||
height: 36px;
|
|
||||||
padding: 0 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 700;
|
|
||||||
box-shadow: 0 12px 28px var(--shadow);
|
|
||||||
backdrop-filter: blur(14px);
|
|
||||||
}
|
|
||||||
|
|
||||||
body.light-mode .theme-toggle {
|
|
||||||
background: rgba(255, 255, 255, 0.9);
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-shell {
|
.login-shell {
|
||||||
width: min(1040px, 100%);
|
width: min(1040px, 100%);
|
||||||
min-height: 590px;
|
min-height: 590px;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: minmax(0, 1fr) 410px;
|
grid-template-columns: minmax(0, 1fr) 410px;
|
||||||
border: 1px solid var(--border);
|
border: 1px solid rgba(42, 57, 79, 0.5);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: rgba(12, 23, 40, 0.88);
|
background: rgba(12, 23, 40, 0.34);
|
||||||
|
backdrop-filter: blur(24px);
|
||||||
|
-webkit-backdrop-filter: blur(24px);
|
||||||
box-shadow: 0 30px 80px var(--shadow);
|
box-shadow: 0 30px 80px var(--shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.light-mode .login-shell {
|
|
||||||
background: rgba(255, 255, 255, 0.94);
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-visual {
|
.login-visual {
|
||||||
padding: 38px;
|
padding: 38px;
|
||||||
background: var(--bg-panel);
|
background: rgba(12, 23, 40, 0.22);
|
||||||
border-right: 1px solid var(--border);
|
border-right: 1px solid rgba(42, 57, 79, 0.4);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 28px;
|
gap: 28px;
|
||||||
@@ -227,8 +195,8 @@ Organization : OptiHK Limited
|
|||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: var(--bg-card);
|
background: rgba(17, 28, 46, 0.30);
|
||||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
|
||||||
aspect-ratio: 16 / 9;
|
aspect-ratio: 16 / 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +209,7 @@ Organization : OptiHK Limited
|
|||||||
|
|
||||||
.preview-bar {
|
.preview-bar {
|
||||||
height: 36px;
|
height: 36px;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid rgba(42, 57, 79, 0.4);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -263,8 +231,8 @@ Organization : OptiHK Limited
|
|||||||
}
|
}
|
||||||
|
|
||||||
.preview-sidebar {
|
.preview-sidebar {
|
||||||
border-right: 1px solid var(--border);
|
border-right: 1px solid rgba(42, 57, 79, 0.4);
|
||||||
background: var(--input-bg);
|
background: rgba(9, 19, 32, 0.22);
|
||||||
padding: 14px;
|
padding: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +282,7 @@ Organization : OptiHK Limited
|
|||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
font-family: 'IBM Plex Mono', Consolas, monospace;
|
font-family: 'IBM Plex Mono', Consolas, monospace;
|
||||||
font-size: 0.68rem;
|
font-size: 0.68rem;
|
||||||
background: var(--bg-soft);
|
background: rgba(23, 36, 58, 0.27);
|
||||||
}
|
}
|
||||||
|
|
||||||
.preview-canvas {
|
.preview-canvas {
|
||||||
@@ -323,17 +291,10 @@ Organization : OptiHK Limited
|
|||||||
background:
|
background:
|
||||||
linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
|
linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
|
||||||
linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
|
linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
|
||||||
var(--bg-card);
|
rgba(17, 28, 46, 0.22);
|
||||||
background-size: 28px 28px;
|
background-size: 28px 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.light-mode .preview-canvas {
|
|
||||||
background:
|
|
||||||
linear-gradient(90deg, rgba(29, 78, 216, 0.05) 1px, transparent 1px),
|
|
||||||
linear-gradient(0deg, rgba(29, 78, 216, 0.05) 1px, transparent 1px),
|
|
||||||
var(--bg-card);
|
|
||||||
background-size: 28px 28px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node {
|
.node {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -341,7 +302,7 @@ Organization : OptiHK Limited
|
|||||||
height: 44px;
|
height: 44px;
|
||||||
border: 1px solid var(--border-strong);
|
border: 1px solid var(--border-strong);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: linear-gradient(180deg, var(--bg-soft), var(--bg-card));
|
background: linear-gradient(180deg, rgba(23, 36, 58, 0.37), rgba(17, 28, 46, 0.30));
|
||||||
color: var(--text-main);
|
color: var(--text-main);
|
||||||
display: grid;
|
display: grid;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
@@ -396,9 +357,9 @@ Organization : OptiHK Limited
|
|||||||
}
|
}
|
||||||
|
|
||||||
.login-card {
|
.login-card {
|
||||||
background:
|
background: rgba(17, 28, 46, 0.23);
|
||||||
linear-gradient(180deg, rgba(255, 255, 255, 0.032), transparent),
|
backdrop-filter: blur(16px);
|
||||||
var(--bg-card);
|
-webkit-backdrop-filter: blur(16px);
|
||||||
padding: 42px;
|
padding: 42px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -534,6 +495,50 @@ Organization : OptiHK Limited
|
|||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dash-clock {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 24px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
z-index: 10;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.digital-time {
|
||||||
|
font-size: clamp(2.6rem, 5vw, 4.2rem);
|
||||||
|
font-weight: 200;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
color: #f0f0f8;
|
||||||
|
text-shadow: 0 0 40px rgba(93, 216, 243, 0.25), 0 0 80px rgba(93, 216, 243, 0.1);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
font-family: 'IBM Plex Mono', Consolas, monospace;
|
||||||
|
line-height: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.digital-time .seconds {
|
||||||
|
color: #5dd8f3;
|
||||||
|
font-weight: 300;
|
||||||
|
animation: pulse-sec 1s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse-sec {
|
||||||
|
0%, 100% { opacity: 1; }
|
||||||
|
50% { opacity: 0.48; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.dash-time {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: rgba(200, 200, 220, 0.6);
|
||||||
|
letter-spacing: 0.15em;
|
||||||
|
font-weight: 300;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 860px) {
|
@media (max-width: 860px) {
|
||||||
body {
|
body {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -543,12 +548,6 @@ Organization : OptiHK Limited
|
|||||||
padding: 18px;
|
padding: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-toggle {
|
|
||||||
position: static;
|
|
||||||
align-self: flex-end;
|
|
||||||
margin-bottom: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-shell {
|
.login-shell {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
min-height: auto;
|
min-height: auto;
|
||||||
@@ -569,8 +568,9 @@ Organization : OptiHK Limited
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button class="theme-toggle" id="theme-toggle" type="button" aria-label="Switch color theme">Light mode</button>
|
<script>
|
||||||
|
(function(){var h=new Date().getHours();document.body.classList.add(h>=5&&h<12?'bg-morning':h>=12&&h<17?'bg-noon':h>=17&&h<19?'bg-sunset':'bg-night');})();
|
||||||
|
</script>
|
||||||
<main class="login-shell">
|
<main class="login-shell">
|
||||||
<section class="login-visual" aria-label="mxPIC EDA workspace preview">
|
<section class="login-visual" aria-label="mxPIC EDA workspace preview">
|
||||||
<div class="brand-row">
|
<div class="brand-row">
|
||||||
@@ -600,7 +600,7 @@ Organization : OptiHK Limited
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="system-title">Access</div>
|
<div class="system-title">Access</div>
|
||||||
<h2>Sign in</h2>
|
<h2>SIGN IN</h2>
|
||||||
|
|
||||||
{% if error %}
|
{% if error %}
|
||||||
<div class="error-message" role="alert">
|
<div class="error-message" role="alert">
|
||||||
@@ -622,36 +622,56 @@ Organization : OptiHK Limited
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="submit-btn" id="submit-btn" type="submit">Log in</button>
|
<button class="submit-btn" id="submit-btn" type="submit">Log In</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<div class="dash-clock" id="dash-clock">
|
||||||
|
<div class="digital-time" id="digitalTime">00:00:<span class="seconds">00</span></div>
|
||||||
|
<div class="dash-time" id="dateLabel"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var timeEl = document.getElementById('digitalTime');
|
||||||
|
var dateEl = document.getElementById('dateLabel');
|
||||||
|
var body = document.body;
|
||||||
|
var bgList = ['bg-morning', 'bg-noon', 'bg-sunset', 'bg-night'];
|
||||||
|
var currentBg = bgList.indexOf(body.className.match(/bg-\w+/)?.[0]) || 0;
|
||||||
|
var weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||||
|
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
var now = new Date();
|
||||||
|
var hh = String(now.getHours()).padStart(2, '0');
|
||||||
|
var mm = String(now.getMinutes()).padStart(2, '0');
|
||||||
|
var ss = String(now.getSeconds()).padStart(2, '0');
|
||||||
|
timeEl.innerHTML = hh + ':' + mm + ':<span class="seconds">' + ss + '</span>';
|
||||||
|
dateEl.textContent = weekdays[now.getDay()] + ', ' + months[now.getMonth()] + ' ' + now.getDate() + ', ' + now.getFullYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
timeEl.addEventListener('click', function() {
|
||||||
|
currentBg = (currentBg + 1) % bgList.length;
|
||||||
|
bgList.forEach(function(c) { body.classList.remove(c); });
|
||||||
|
body.classList.add(bgList[currentBg]);
|
||||||
|
});
|
||||||
|
|
||||||
|
update();
|
||||||
|
setInterval(update, 1000);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
<script>
|
<script>
|
||||||
const themeToggle = document.getElementById('theme-toggle');
|
|
||||||
const passwordInput = document.getElementById('password');
|
const passwordInput = document.getElementById('password');
|
||||||
const passwordToggle = document.getElementById('password-toggle');
|
const passwordToggle = document.getElementById('password-toggle');
|
||||||
const loginForm = document.getElementById('login-form');
|
const loginForm = document.getElementById('login-form');
|
||||||
const submitButton = document.getElementById('submit-btn');
|
const submitButton = document.getElementById('submit-btn');
|
||||||
|
|
||||||
function applyTheme(mode) {
|
|
||||||
const isLight = mode === 'light';
|
|
||||||
document.body.classList.toggle('light-mode', isLight);
|
|
||||||
themeToggle.textContent = isLight ? 'Dark mode' : 'Light mode';
|
|
||||||
localStorage.setItem('mxpic-theme', mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setSubmitState() {
|
function setSubmitState() {
|
||||||
submitButton.disabled = true;
|
submitButton.disabled = true;
|
||||||
submitButton.textContent = 'Signing in...';
|
submitButton.textContent = 'Signing in...';
|
||||||
}
|
}
|
||||||
|
|
||||||
applyTheme(localStorage.getItem('mxpic-theme') || 'dark');
|
|
||||||
|
|
||||||
themeToggle.addEventListener('click', () => {
|
|
||||||
applyTheme(document.body.classList.contains('light-mode') ? 'dark' : 'light');
|
|
||||||
});
|
|
||||||
|
|
||||||
passwordToggle.addEventListener('click', () => {
|
passwordToggle.addEventListener('click', () => {
|
||||||
const showPassword = passwordInput.type === 'password';
|
const showPassword = passwordInput.type === 'password';
|
||||||
passwordInput.type = showPassword ? 'text' : 'password';
|
passwordInput.type = showPassword ? 'text' : 'password';
|
||||||
|
|||||||
|
After Width: | Height: | Size: 555 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 689 KiB |
|
After Width: | Height: | Size: 256 KiB |
|
After Width: | Height: | Size: 221 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 212 KiB |
|
After Width: | Height: | Size: 116 KiB |
@@ -61,7 +61,6 @@ assert(
|
|||||||
'save-layout response should include an svg_url for the new layout tab'
|
'save-layout response should include an svg_url for the new layout tab'
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
<<<<<<< HEAD
|
|
||||||
serverPy.includes('svg_ready') &&
|
serverPy.includes('svg_ready') &&
|
||||||
serverPy.includes('svg_version') &&
|
serverPy.includes('svg_version') &&
|
||||||
serverPy.includes('file_version(svg_path)') &&
|
serverPy.includes('file_version(svg_path)') &&
|
||||||
@@ -74,8 +73,6 @@ assert(
|
|||||||
'save-layout should publish generated SVG previews atomically instead of serving partially written files'
|
'save-layout should publish generated SVG previews atomically instead of serving partially written files'
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
=======
|
|
||||||
>>>>>>> jingwen_main
|
|
||||||
serverPy.includes('RouterStackUnavailable') &&
|
serverPy.includes('RouterStackUnavailable') &&
|
||||||
serverPy.includes('except RouterStackUnavailable as e') &&
|
serverPy.includes('except RouterStackUnavailable as e') &&
|
||||||
serverPy.includes('"preview_status": preview_status') &&
|
serverPy.includes('"preview_status": preview_status') &&
|
||||||
|
|||||||
@@ -33,16 +33,6 @@ assert(
|
|||||||
'Build Layout should use the backend svg_url response'
|
'Build Layout should use the backend svg_url response'
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
<<<<<<< HEAD
|
|
||||||
canvasHtml.includes('result.svg_ready && result.svg_url') &&
|
|
||||||
canvasHtml.includes('buildLayoutRequestRef') &&
|
|
||||||
canvasHtml.includes('buildLayoutBusyRef') &&
|
|
||||||
canvasHtml.includes("cache: 'no-store'"),
|
|
||||||
'Build Layout should wait for a ready, versioned SVG response and prevent stale duplicate preview updates'
|
|
||||||
);
|
|
||||||
assert(
|
|
||||||
=======
|
|
||||||
>>>>>>> jingwen_main
|
|
||||||
canvasHtml.includes('result.preview_error') &&
|
canvasHtml.includes('result.preview_error') &&
|
||||||
canvasHtml.includes('Preview skipped: '),
|
canvasHtml.includes('Preview skipped: '),
|
||||||
'Build Layout should log when the backend saves YAML but skips SVG preview because the router stack is unavailable'
|
'Build Layout should log when the backend saves YAML but skips SVG preview because the router stack is unavailable'
|
||||||
@@ -60,8 +50,18 @@ assert(
|
|||||||
'layout SVG preview should expose an editable scale value'
|
'layout SVG preview should expose an editable scale value'
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
canvasHtml.includes('objectFit: \'contain\''),
|
canvasHtml.includes('objectFit: \'contain\'') &&
|
||||||
'100% layout preview scale should fit the full SVG within the screen'
|
canvasHtml.includes('previewCanvasRef') &&
|
||||||
|
canvasHtml.includes('ResizeObserver') &&
|
||||||
|
canvasHtml.includes('svgSize') &&
|
||||||
|
canvasHtml.includes('naturalWidth') &&
|
||||||
|
canvasHtml.includes('naturalHeight') &&
|
||||||
|
canvasHtml.includes('const fitScalePercent = clampLayoutScale(Math.floor') &&
|
||||||
|
canvasHtml.includes('layoutScale ?? fitScalePercent') &&
|
||||||
|
canvasHtml.includes('const stageWidth = baseWidth * normalizedScale / 100') &&
|
||||||
|
!canvasHtml.includes('useState(100)') &&
|
||||||
|
!canvasHtml.includes('baseWidth * fitScale * normalizedScale / 100'),
|
||||||
|
'layout preview should default to the actual fitted SVG scale percent instead of redefining 100% as fit'
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
canvasHtml.includes('className="build-gds-btn"'),
|
canvasHtml.includes('className="build-gds-btn"'),
|
||||||
@@ -354,7 +354,7 @@ assert(
|
|||||||
canvasHtml.includes('layoutBounds') &&
|
canvasHtml.includes('layoutBounds') &&
|
||||||
canvasHtml.includes('stageWidth') &&
|
canvasHtml.includes('stageWidth') &&
|
||||||
canvasHtml.includes('stageHeight'),
|
canvasHtml.includes('stageHeight'),
|
||||||
'layout preview should mouse-wheel zoom and size 100% from calculated box_size layout bounds'
|
'layout preview should mouse-wheel zoom from the actual calculated SVG scale'
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
canvasHtml.includes('reactFlowInstance.fitBounds') &&
|
canvasHtml.includes('reactFlowInstance.fitBounds') &&
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Description: Static regression tests for resilient project save/reopen behavior.
|
||||||
|
* Inside functions: N/A - assertion-based test/module script.
|
||||||
|
* Developer : Qin Yue @ 2026
|
||||||
|
* Organization : OptiHK Limited
|
||||||
|
*/
|
||||||
|
const assert = require('assert');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const root = path.resolve(__dirname, '..');
|
||||||
|
const backend = path.join(root, 'backend');
|
||||||
|
const layoutFilesPath = path.join(backend, 'layout_files.py');
|
||||||
|
const layoutFilesPy = fs.readFileSync(layoutFilesPath, 'utf8');
|
||||||
|
const serverPy = fs.readFileSync(path.join(backend, 'server.py'), 'utf8');
|
||||||
|
const gdsBuilderPy = fs.readFileSync(path.join(backend, 'gds_builder.py'), 'utf8');
|
||||||
|
const routedPreviewPy = fs.readFileSync(path.join(backend, 'routed_layout_preview.py'), 'utf8');
|
||||||
|
const canvasHtml = fs.readFileSync(path.join(root, 'frontend', 'canvas.html'), 'utf8');
|
||||||
|
|
||||||
|
assert(
|
||||||
|
fs.existsSync(layoutFilesPath),
|
||||||
|
'backend/layout_files.py should centralize saved layout YAML filtering and parsing'
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
layoutFilesPy.includes('ROUTE_SIDECAR_SUFFIXES') &&
|
||||||
|
layoutFilesPy.includes('def is_layout_cell_filename') &&
|
||||||
|
layoutFilesPy.includes('def parse_layout_cell_content') &&
|
||||||
|
layoutFilesPy.includes('def load_layout_cell_files'),
|
||||||
|
'layout file helpers should exclude route sidecars and validate saved layout cells'
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
serverPy.includes('is_layout_cell_filename') &&
|
||||||
|
serverPy.includes('load_layout_cell_files(root)') &&
|
||||||
|
serverPy.includes('parse_layout_cell_content(content') &&
|
||||||
|
serverPy.includes('except LayoutFileError as e'),
|
||||||
|
'project list/load/save endpoints should filter invalid YAML and reject malformed saves'
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
gdsBuilderPy.includes('TemporaryDirectory(prefix="mxpic_gds_project_"') &&
|
||||||
|
gdsBuilderPy.includes('write_layout_cells_to_directory(cells, staged_project_dir)'),
|
||||||
|
'Build GDS should call mxpic_router with a clean staged project directory'
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
routedPreviewPy.includes('staged_project_dir') &&
|
||||||
|
routedPreviewPy.includes('write_layout_cells_to_directory(staged_cells, staged_project_dir)') &&
|
||||||
|
routedPreviewPy.includes('project_dir=staged_project_dir'),
|
||||||
|
'Build Layout preview should stage valid cells before calling mxpic_router'
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
canvasHtml.includes('(data.warnings || []).forEach(warning => addLog(warning))') &&
|
||||||
|
canvasHtml.includes('const parsedCellPages = [];') &&
|
||||||
|
canvasHtml.includes('Skipped saved cell'),
|
||||||
|
'canvas project loading should report skipped files and keep loading remaining valid cells'
|
||||||
|
);
|
||||||
@@ -8,4 +8,39 @@
|
|||||||
|
|
||||||
4.Fixed the abnormal port shift after rotation.
|
4.Fixed the abnormal port shift after rotation.
|
||||||
|
|
||||||
5.Fixed the abnormal position of individual ports.
|
5.Fixed the abnormal position of individual ports.
|
||||||
|
|
||||||
|
06/15
|
||||||
|
|
||||||
|
Enhanced the contrast between the inside and outside of the canvas border.
|
||||||
|
|
||||||
|
Capped the maximum amount by which the canvas can be scaled down (set a minimum canvas size limit).
|
||||||
|
|
||||||
|
Labels/tags, once closed, will no longer be reloaded after a page refresh.
|
||||||
|
|
||||||
|
Modified the "select origin" functionality and set the default origin to the canvas position (500, 500).
|
||||||
|
|
||||||
|
Fixed a bug where the instance name counter was shared across different canvases within the same project.
|
||||||
|
|
||||||
|
06/16
|
||||||
|
|
||||||
|
Fixed a bug where component icons would not load when importing a YML file.
|
||||||
|
|
||||||
|
Added origin coordinates to the YML file; fixed a bug that caused component misalignment when opening a YML file with a different origin.
|
||||||
|
|
||||||
|
Fixed a bug where the default port would reload on every page refresh.
|
||||||
|
|
||||||
|
|
||||||
|
06/27
|
||||||
|
|
||||||
|
Add inverse name scaling to keep labels readable when zooming out
|
||||||
|
|
||||||
|
Switch canvas drag mode to direct panning
|
||||||
|
|
||||||
|
Replace widget selection with button-based toggle
|
||||||
|
|
||||||
|
Fix lag caused by duplicate image requests
|
||||||
|
|
||||||
|
Add rename functionality to project tabs
|
||||||
|
|
||||||
|
|
||||||
|
|||||||