3 Commits

Author SHA1 Message Date
= 049293b3d8 Canvas break problem fixed with version problem 2026-06-22 10:08:05 +08:00
= a230f13cd7 icons updatted 2026-06-11 23:06:52 +08:00
PotatoMaxwell 69da8c4fbb Merge pull request 'port/anchor size adjustment' (#10) from jingwen_main into qinyue_main
Reviewed-on: #10
2026-06-11 13:45:08 +00:00
14 changed files with 377 additions and 1732 deletions
+4 -58
View File
@@ -44,9 +44,7 @@ FRONTEND_DIR = os.path.join(BASE_DIR, '..', 'frontend')
REPO_ROOT = os.path.abspath(os.path.join(BASE_DIR, '..', '..'))
# Component/category icons are served from backend/icons for the library panel.
ICONS_DIR = os.path.join(BASE_DIR, 'icons')
# Login page time-of-day background images.
PIC_DIR = os.path.join(FRONTEND_DIR, 'pic')
ICONS_DIR = os.path.join(BASE_DIR, 'icons')
# Flask serves the HTML/CSS/JS frontend and exposes JSON APIs for persistence,
@@ -450,14 +448,6 @@ def canvas_helpers():
"""Serve the shared canvas helper script used by canvas.html."""
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')
def logout():
"""Clear session and return to login."""
@@ -478,23 +468,18 @@ def list_technologies():
"""List technology choices from the active role-scoped PDK root."""
technologies = []
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
# role PDK root, and only folders with technology.yml are exposed.
if os.path.isdir(pdks_root):
for foundry in sorted(os.listdir(pdks_root)):
foundry_path = os.path.join(pdks_root, foundry)
if not os.path.isdir(foundry_path):
print(f"[TECH] skip non-dir foundry={foundry}")
continue
for technology in sorted(os.listdir(foundry_path)):
technology_path = os.path.join(foundry_path, technology)
if not os.path.isdir(technology_path):
print(f"[TECH] skip non-dir tech={technology}")
continue
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:
if not os.path.exists(os.path.join(technology_path, "technology.yml")):
continue
technologies.append({
"foundry": foundry,
@@ -502,7 +487,6 @@ def list_technologies():
"id": f"{foundry}/{technology}",
"label": f"{foundry} / {technology}"
})
print(f"[TECH] returning {len(technologies)} technologies: {[t['id'] for t in technologies]}")
return jsonify({"technologies": technologies})
@@ -712,36 +696,6 @@ def delete_project(project_name):
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'])
@login_required_json
def rename_cell(project_name, cell_name):
@@ -959,18 +913,10 @@ def getLib():
@app.route('/api/component/<component_name>')
@login_required_json
def getComp(component_name):
"""Return component YAML data with injected category."""
comps_root = pdk_root_for_request_project()
data = readCompYaml(component_name, comps_root)
"""Return component YAML data."""
data = readCompYaml(component_name, pdk_root_for_request_project())
if data is None:
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)
@app.route('/api/component/<component_name>/image')
+21 -66
View File
@@ -12,13 +12,6 @@
}
root.MxpicCanvasHelpers = helpers;
})(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.
const FORGE_COMPONENT_LABEL = 'generate with mxpic_forge';
// Serialized component type used when saving mxpic_forge-generated components.
@@ -27,16 +20,14 @@
const DEFAULT_COMPONENT_BOX_SIZE = { width: 132, height: 82 };
// Default editable canvas dimensions in micrometers.
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.
const PORT_NODE_SIZE = 11;
const PORT_NODE_SIZE = 30;
const FREE_WIRES_BUNDLE_GROUP = 'free_wires';
const PORT_LABEL_MIN_CHARS = 5;
const PORT_LABEL_CHAR_WIDTH = 7;
const PORT_LABEL_HORIZONTAL_PADDING = 12;
// Anchor body width used in the canvas visual representation.
const ANCHOR_NODE_WIDTH = 18;
const ANCHOR_NODE_WIDTH = 16;
// Default spacing between repeated anchor or port pins.
const DEFAULT_ELEMENT_PITCH = 10;
// Defines built-in port and anchor element metadata before per-node expansion.
@@ -316,35 +307,15 @@
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.
// Accepts either legacy {width,height} or new {xmin,xmax,ymin,ymax} canvasSize.
const clampPositionToCanvas = (position, canvasSize, boxSize) => {
const bounds = normalizeCanvasBounds(canvasSize);
const size = normalizeCanvasSize(canvasSize);
const box = normalizeBoxSize({ box_size: [boxSize && boxSize.width, boxSize && boxSize.height] });
const maxX = Math.max(bounds.xmin, bounds.xmax - box.width);
const maxY = Math.max(bounds.ymin, bounds.ymax - box.height);
const maxX = Math.max(0, size.width - box.width);
const maxY = Math.max(0, size.height - box.height);
return {
x: Math.min(maxX, Math.max(bounds.xmin, Number(position && position.x) || 0)),
y: Math.min(maxY, Math.max(bounds.ymin, Number(position && position.y) || 0))
x: Math.min(maxX, Math.max(0, Number(position && position.x) || 0)),
y: Math.min(maxY, Math.max(0, Number(position && position.y) || 0))
};
};
@@ -397,8 +368,8 @@
});
if (points.length === 0) {
const bounds = normalizeCanvasBounds(page.canvasSize || page.canvasBounds);
points.push({ x: bounds.xmin, y: bounds.ymin }, { x: bounds.xmax, y: bounds.ymax });
const size = normalizeCanvasSize(page.canvasSize || DEFAULT_CANVAS_SIZE);
points.push({ x: 0, y: 0 }, { x: size.width, y: size.height });
}
const minX = roundBoundsValue(Math.min(...points.map(point => point.x)));
@@ -680,20 +651,10 @@
return JSON.stringify(String(value));
};
// Convert canvas coordinates into layout/display coordinates.
// When origin is set, uses the RightPanel formula: displayY = originY - rfY
// Falls back to simple negation for backward compatibility.
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; };
// Convert canvas Y coordinates into layout Y coordinates.
const canvasToLayoutY = (value) => -Number(value || 0);
// Convert layout Y coordinates back into canvas Y coordinates.
const layoutToCanvasY = (value) => -Number(value || 0);
// Serialize nested component settings into YAML blocks.
const buildSettingsYaml = (settings, indent) => {
@@ -716,8 +677,8 @@
: '\n settings:\n length:';
return ` ${instanceName}:
component: "${componentValue}"
x: ${canvasToLayoutX(position.x).toFixed(1)}
component: ${componentValue}
x: ${Number(position.x || 0).toFixed(1)}
y: ${canvasToLayoutY(position.y).toFixed(1)}
rotation: ${Number(rotation || 0).toFixed(1)}
flip: ${flip ? 1 : 0}
@@ -832,7 +793,7 @@
return {
width: data && data.elementType === 'anchor' ? ANCHOR_NODE_WIDTH : PORT_NODE_SIZE,
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 / 2, PORT_NODE_SIZE / 2 + Math.max(0, portNumber - 1) * handleClearance)
: Math.max(PORT_NODE_SIZE, PORT_NODE_SIZE + Math.max(0, portNumber - 1) * handleClearance)
};
};
@@ -947,7 +908,7 @@
// Convert standalone port nodes into page-level layout pins.
const buildPageComponentPins = (port, nodes) => {
const portNodes = (nodes || []).filter(n => n.id === 'page-port');
const portNodes = (nodes || []).filter(isPortElementNode);
if (portNodes.length > 0) {
return portNodes.reduce((pins, node) => {
const data = node.data || {};
@@ -1001,7 +962,7 @@
${data.layer ? `layer: ${data.layer}` : 'layer: WG_CORE'}
element: ${info.element}
pin: ${info.pin}
x: ${canvasToLayoutX(info.x).toFixed(1)}
x: ${Number(info.x || 0).toFixed(1)}
y: ${canvasToLayoutY(info.y).toFixed(1)}
angle: ${Number(info.a || 0).toFixed(1)}
width: ${Number(info.width || 0.5)}${description}`;
@@ -1016,7 +977,7 @@
// Serialize built-in port and anchor nodes into layout element metadata.
const buildElementsYaml = (nodes) => {
const elementNodes = (nodes || []).filter(n => isElementNode(n) && n.id !== 'page-port');
const elementNodes = (nodes || []).filter(isElementNode);
if (elementNodes.length === 0) return 'elements: {}';
const lines = elementNodes.map(node => {
const data = node.data || {};
@@ -1029,7 +990,7 @@
.join('\n');
return ` ${name}:
type: ${data.elementType}
x: ${canvasToLayoutX((node.position && node.position.x) || 0).toFixed(1)}
x: ${Number((node.position && node.position.x) || 0).toFixed(1)}
y: ${canvasToLayoutY((node.position && node.position.y) || 0).toFixed(1)}
angle: ${Number(angle || 0).toFixed(1)}
pin_number: ${portNumber}
@@ -1094,7 +1055,7 @@ ${pinLines}`;
const storedPoints = Array.isArray(edge.data && edge.data.points) ? edge.data.points : [];
const points = storedPoints.length >= 2 ? getEdgeRoutePoints(edge, nodeMap) : [];
const pointsYaml = points.length > 0
? `\n points:\n${points.map(point => ` - x: ${canvasToLayoutX(point.x).toFixed(1)}\n y: ${canvasToLayoutY(point.y).toFixed(1)}`).join('\n')}`
? `\n points:\n${points.map(point => ` - x: ${Number(point.x || 0).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 linkYaml = isFreeRoute
@@ -1343,7 +1304,6 @@ bundles:${groupsYaml ? `\n${groupsYaml}` : ' {}'}`;
FORGE_COMPONENT_TYPE,
DEFAULT_COMPONENT_BOX_SIZE,
DEFAULT_CANVAS_SIZE,
DEFAULT_CANVAS_BOUNDS,
PORT_NODE_SIZE,
DEFAULT_ELEMENT_PITCH,
ELEMENT_COMPONENTS,
@@ -1351,12 +1311,8 @@ bundles:${groupsYaml ? `\n${groupsYaml}` : ' {}'}`;
DEFAULT_FORGE_ARGUMENTS,
FALLBACK_TECHNOLOGY_MANIFEST,
FREE_WIRES_BUNDLE_GROUP,
setExportOrigin,
getExportOrigin,
canvasToLayoutY,
canvasToLayoutX,
layoutToCanvasY,
layoutToCanvasX,
createForgeArguments,
createRouteSettings,
updateRouteField,
@@ -1374,7 +1330,6 @@ bundles:${groupsYaml ? `\n${groupsYaml}` : ' {}'}`;
normalizeBoxSize,
chooseCategoryComponent,
normalizeCanvasSize,
normalizeCanvasBounds,
clampPositionToCanvas,
calculateLayoutBounds,
calculateCompositeBoxSize,
+233 -1126
View File
File diff suppressed because it is too large Load Diff
+18 -326
View File
@@ -12,7 +12,7 @@ Organization : OptiHK Limited
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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&family=Varela+Round&family=Inter:wght@400;500&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&display=swap" rel="stylesheet">
<style>
:root {
@@ -42,12 +42,12 @@ Organization : OptiHK Limited
--bg-panel: #eef4fa;
--text-main: #142235;
--text-muted: #5f7085;
--accent: #3b82f6;
--accent-hover: #06b6d4;
--accent: #1d4ed8;
--accent-hover: #0f766e;
--accent-green: #15803d;
--accent-warm: #b45309;
--border: #b8c5d4;
--border-strong: #8fa2b8;
--border: #d6e0eb;
--border-strong: #b6c4d4;
--panel-soft: #f8fafc;
--folder-icon: #38bdf8;
--shadow: rgba(37, 99, 235, 0.1);
@@ -173,6 +173,7 @@ Organization : OptiHK Limited
justify-content: flex-end;
}
.theme-toggle,
.logout-btn,
.secondary-btn,
.profile-action,
@@ -195,80 +196,7 @@ Organization : OptiHK Limited
}
.theme-toggle {
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);
min-width: 92px;
}
.logout-btn:hover,
@@ -281,9 +209,9 @@ Organization : OptiHK Limited
.container {
width: 100%;
max-width: 1550px;
max-width: 1320px;
margin: 0 auto;
padding: 34px 8px 30px;
padding: 34px 16px 30px;
}
.hero {
@@ -363,7 +291,7 @@ Organization : OptiHK Limited
.dashboard-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) 420px;
grid-template-columns: minmax(0, 1fr) 300px;
gap: 18px;
align-items: start;
}
@@ -390,91 +318,11 @@ Organization : OptiHK Limited
.panel-title {
margin: 0;
font-size: 0.86rem;
font-family: 'Varela Round', sans-serif;
font-family: 'IBM Plex Mono', Consolas, monospace;
font-weight: 700;
letter-spacing: 0.05em;
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);
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 {
@@ -572,55 +420,6 @@ Organization : OptiHK Limited
font-size: 0.8rem;
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 {
display: flex;
@@ -706,7 +505,7 @@ Organization : OptiHK Limited
.profile-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-columns: 1fr;
gap: 10px;
}
@@ -768,7 +567,6 @@ Organization : OptiHK Limited
.activity-message {
color: var(--text-main);
font-family: 'Inter', sans-serif;
font-size: 0.88rem;
line-height: 1.42;
overflow-wrap: anywhere;
@@ -929,7 +727,7 @@ Organization : OptiHK Limited
}
.container {
padding: 26px 8px 24px;
padding: 26px 16px 24px;
}
.hero {
@@ -968,18 +766,14 @@ Organization : OptiHK Limited
</style>
</head>
<body class="light-mode">
<body>
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
MxPic - by <span class="company-wordmark">Opti<span class="company-hk">HK</span></span>
</div>
<div class="header-actions">
<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">&#9788;</span>
<span class="toggle-icon toggle-moon">&#9790;</span>
</button>
<button class="theme-toggle" id="theme-toggle" type="button" aria-label="Switch color theme">Light mode</button>
<a href="/logout" class="logout-btn">Logout</a>
</div>
</header>
@@ -1051,7 +845,6 @@ Organization : OptiHK Limited
<section class="panel">
<div class="panel-header">
<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 class="panel-body">
<div class="activity-list" id="activity-list" aria-live="polite">
@@ -1063,7 +856,6 @@ Organization : OptiHK Limited
</div>
</section>
</aside>
<div class="activity-backdrop" id="activity-backdrop" aria-hidden="true"></div>
</section>
<footer>
@@ -1157,7 +949,7 @@ Organization : OptiHK Limited
function applyTheme(mode) {
const isLight = mode === 'light';
document.body.classList.toggle('light-mode', isLight);
themeToggle.setAttribute('data-theme', isLight ? 'bright' : 'dark');
themeToggle.textContent = isLight ? 'Dark mode' : 'Light mode';
localStorage.setItem('mxpic-theme', mode);
}
@@ -1254,63 +1046,6 @@ Organization : OptiHK Limited
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() {
try {
const response = await fetch('/api/logs?limit=8');
@@ -1420,33 +1155,15 @@ Organization : OptiHK Limited
icon.setAttribute('aria-hidden', 'true');
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');
name.className = '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');
subtitle.className = 'project-subtitle';
subtitle.textContent = 'Photonic layout project';
details.append(nameRow, subtitle);
details.append(name, subtitle);
top.append(icon, details);
const chips = document.createElement('div');
@@ -1676,31 +1393,7 @@ Organization : OptiHK Limited
applyTheme(document.body.classList.contains('light-mode') ? 'dark' : 'light');
});
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');
applyTheme(localStorage.getItem('mxpic-theme') || 'dark');
loadTechnologies();
loadProfile();
loadProjects();
@@ -1709,4 +1402,3 @@ Organization : OptiHK Limited
</body>
</html>
+100 -120
View File
@@ -2,7 +2,7 @@
<!--
Description: Login page for authenticating users before entering the MXPIC EDA workspace.
Inside functions: setSubmitState
Inside functions: applyTheme, setSubmitState
Developer : Qin Yue @ 2026
Organization : OptiHK Limited
-->
@@ -35,6 +35,26 @@ Organization : OptiHK Limited
--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;
@@ -45,33 +65,23 @@ Organization : OptiHK Limited
min-height: 100dvh;
font-family: 'IBM Plex Sans', "Segoe UI", sans-serif;
color: var(--text-main);
background-color: var(--bg-main);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
position: relative;
background:
linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
linear-gradient(0deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
linear-gradient(135deg, var(--bg-main), #091526 62%, #0d1724);
background-size: 48px 48px, 48px 48px, auto;
display: grid;
place-items: center;
padding: 28px;
}
body::after {
content: '';
position: fixed;
inset: 0;
z-index: -1;
body.light-mode {
background:
linear-gradient(90deg, rgba(255,255,255,0.026) 1px, transparent 1px),
linear-gradient(0deg, rgba(255,255,255,0.026) 1px, transparent 1px);
background-size: 48px 48px;
linear-gradient(90deg, rgba(29, 78, 216, 0.04) 1px, transparent 1px),
linear-gradient(0deg, rgba(29, 78, 216, 0.04) 1px, transparent 1px),
linear-gradient(135deg, #f8fbff, var(--bg-main));
}
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,
input {
font: inherit;
@@ -83,25 +93,47 @@ Organization : OptiHK Limited
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 {
width: min(1040px, 100%);
min-height: 590px;
display: grid;
grid-template-columns: minmax(0, 1fr) 410px;
border: 1px solid rgba(42, 57, 79, 0.5);
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
background: rgba(12, 23, 40, 0.34);
backdrop-filter: blur(24px);
-webkit-backdrop-filter: blur(24px);
background: rgba(12, 23, 40, 0.88);
box-shadow: 0 30px 80px var(--shadow);
}
body.light-mode .login-shell {
background: rgba(255, 255, 255, 0.94);
}
.login-visual {
padding: 38px;
background: rgba(12, 23, 40, 0.22);
border-right: 1px solid rgba(42, 57, 79, 0.4);
background: var(--bg-panel);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
gap: 28px;
@@ -195,8 +227,8 @@ Organization : OptiHK Limited
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
background: rgba(17, 28, 46, 0.30);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
background: var(--bg-card);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
aspect-ratio: 16 / 9;
}
@@ -209,7 +241,7 @@ Organization : OptiHK Limited
.preview-bar {
height: 36px;
border-bottom: 1px solid rgba(42, 57, 79, 0.4);
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
@@ -231,8 +263,8 @@ Organization : OptiHK Limited
}
.preview-sidebar {
border-right: 1px solid rgba(42, 57, 79, 0.4);
background: rgba(9, 19, 32, 0.22);
border-right: 1px solid var(--border);
background: var(--input-bg);
padding: 14px;
}
@@ -282,7 +314,7 @@ Organization : OptiHK Limited
color: var(--text-muted);
font-family: 'IBM Plex Mono', Consolas, monospace;
font-size: 0.68rem;
background: rgba(23, 36, 58, 0.27);
background: var(--bg-soft);
}
.preview-canvas {
@@ -291,10 +323,17 @@ Organization : OptiHK Limited
background:
linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
rgba(17, 28, 46, 0.22);
var(--bg-card);
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 {
position: absolute;
@@ -302,7 +341,7 @@ Organization : OptiHK Limited
height: 44px;
border: 1px solid var(--border-strong);
border-radius: 8px;
background: linear-gradient(180deg, rgba(23, 36, 58, 0.37), rgba(17, 28, 46, 0.30));
background: linear-gradient(180deg, var(--bg-soft), var(--bg-card));
color: var(--text-main);
display: grid;
place-items: center;
@@ -357,9 +396,9 @@ Organization : OptiHK Limited
}
.login-card {
background: rgba(17, 28, 46, 0.23);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
background:
linear-gradient(180deg, rgba(255, 255, 255, 0.032), transparent),
var(--bg-card);
padding: 42px;
display: flex;
flex-direction: column;
@@ -495,50 +534,6 @@ Organization : OptiHK Limited
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) {
body {
display: flex;
@@ -548,6 +543,12 @@ Organization : OptiHK Limited
padding: 18px;
}
.theme-toggle {
position: static;
align-self: flex-end;
margin-bottom: 14px;
}
.login-shell {
grid-template-columns: 1fr;
min-height: auto;
@@ -568,9 +569,8 @@ Organization : OptiHK Limited
</style>
</head>
<body>
<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>
<button class="theme-toggle" id="theme-toggle" type="button" aria-label="Switch color theme">Light mode</button>
<main class="login-shell">
<section class="login-visual" aria-label="mxPIC EDA workspace preview">
<div class="brand-row">
@@ -600,7 +600,7 @@ Organization : OptiHK Limited
</div>
<div class="system-title">Access</div>
<h2>SIGN IN</h2>
<h2>Sign in</h2>
{% if error %}
<div class="error-message" role="alert">
@@ -622,56 +622,36 @@ Organization : OptiHK Limited
</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>
</section>
</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>
const themeToggle = document.getElementById('theme-toggle');
const passwordInput = document.getElementById('password');
const passwordToggle = document.getElementById('password-toggle');
const loginForm = document.getElementById('login-form');
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() {
submitButton.disabled = true;
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', () => {
const showPassword = passwordInput.type === 'password';
passwordInput.type = showPassword ? 'text' : 'password';
Binary file not shown.

Before

Width:  |  Height:  |  Size: 555 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

+1 -36
View File
@@ -8,39 +8,4 @@
4.Fixed the abnormal port shift after rotation.
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
5.Fixed the abnormal position of individual ports.