Polish topology editor for denser industrial NMS look.

Use SVG sidebar icons and ASCII separators, tighten chrome, add connect-mode hint, and drop the redundant status bar.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-01 14:04:18 +08:00
parent 728ec815a3
commit 6ea0a09274
5 changed files with 272 additions and 134 deletions

View file

@ -129,6 +129,7 @@ src/
- 未保存切换地图会确认;Ctrl+S 保存;发现可取消;禁止自环与重复连线;PUT 保留 `discovered_at`;发现边键对端口名做规范化 - 未保存切换地图会确认;Ctrl+S 保存;发现可取消;禁止自环与重复连线;PUT 保留 `discovered_at`;发现边键对端口名做规范化
- 发现进度主区只显示摘要与入口;点「详情」打开列表弹窗,再点设备打开链路复核弹窗 - 发现进度主区只显示摘要与入口;点「详情」打开列表弹窗,再点设备打开链路复核弹窗
- 工具栏可搜索定位并高亮;侧栏已上图网元点击可定位 - 工具栏可搜索定位并高亮;侧栏已上图网元点击可定位
- 连线模式画布顶提示;侧栏折叠/编辑/删除使用内联 SVG 图标;名称与 IP/端口间隔统一为 ASCII ` / `(避免 Unicode 损坏)
- 链路右键可跳转端口流量(`/network/tasks/port-traffic?ne_id=&source=&ifname=`) - 链路右键可跳转端口流量(`/network/tasks/port-traffic?ne_id=&source=&ifname=`)
## WebCRT ## WebCRT

View file

@ -1029,6 +1029,7 @@ const en = {
removeStale: "Clear missing ({{count}})", removeStale: "Clear missing ({{count}})",
removeStaleHint: "Delete red-marked missing edges", removeStaleHint: "Delete red-marked missing edges",
staleRemoved: "Removed {{count}} missing edge(s)", staleRemoved: "Removed {{count}} missing edge(s)",
connectHint: "Connect mode: click source node, then target (Esc or Select to exit)",
}, },
}; };

View file

@ -1025,6 +1025,7 @@ const zh = {
removeStale: "清除未发现 ({{count}})", removeStale: "清除未发现 ({{count}})",
removeStaleHint: "删除红色标记的未发现链路", removeStaleHint: "删除红色标记的未发现链路",
staleRemoved: "已删除 {{count}} 条未发现链路", staleRemoved: "已删除 {{count}} 条未发现链路",
connectHint: "连线模式:依次点击源节点 → 目标节点(Esc 或切回选择退出)",
}, },
}; };

View file

@ -1945,32 +1945,32 @@ pre {
/* ---- Topology ---- */ /* ---- Topology ---- */
.topo-page { .topo-page {
display: grid; display: grid;
grid-template-columns: 280px 1fr; grid-template-columns: 260px 1fr;
gap: 12px; gap: 8px;
height: calc(100vh - 72px); height: calc(100vh - 72px);
min-height: 520px; min-height: 520px;
padding: 12px 16px 16px; padding: 8px 12px 12px;
transition: grid-template-columns 0.18s ease; transition: grid-template-columns 0.18s ease;
} }
.topo-page.is-sidebar-collapsed { .topo-page.is-sidebar-collapsed {
grid-template-columns: 40px 1fr; grid-template-columns: 36px 1fr;
} }
.topo-sidebar { .topo-sidebar {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 12px; gap: 8px;
min-height: 0; min-height: 0;
background: #fff; background: #f8fafc;
border: 1px solid #dbe3ee; border: 1px solid #c5ced9;
border-radius: 10px; border-radius: 4px;
padding: 12px; padding: 8px;
overflow: hidden; overflow: hidden;
} }
.topo-page.is-sidebar-collapsed .topo-sidebar { .topo-page.is-sidebar-collapsed .topo-sidebar {
padding: 6px; padding: 4px;
align-items: stretch; align-items: stretch;
} }
@ -1980,23 +1980,26 @@ pre {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
gap: 10px; gap: 8px;
width: 100%; width: 100%;
border: 0; border: 0;
background: transparent; background: transparent;
padding: 8px 0; padding: 6px 0;
cursor: pointer; cursor: pointer;
color: #475569; color: #475569;
border-radius: 8px; border-radius: 4px;
} }
.topo-sidebar__rail:hover { .topo-sidebar__rail:hover {
background: #f1f5f9; background: #e8eef5;
color: #0f172a; color: #0f172a;
} }
.topo-sidebar__rail-icon { .topo-sidebar__rail-icon {
font-size: 18px; display: inline-flex;
align-items: center;
justify-content: center;
font-size: 14px;
line-height: 1; line-height: 1;
font-weight: 600; font-weight: 600;
} }
@ -2004,15 +2007,16 @@ pre {
.topo-sidebar__rail-label { .topo-sidebar__rail-label {
writing-mode: vertical-rl; writing-mode: vertical-rl;
text-orientation: mixed; text-orientation: mixed;
font-size: 12px; font-size: 11px;
font-weight: 600; font-weight: 600;
letter-spacing: 0.06em; letter-spacing: 0.08em;
text-transform: uppercase;
} }
.topo-sidebar__section { .topo-sidebar__section {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 8px; gap: 6px;
min-height: 0; min-height: 0;
min-width: 0; min-width: 0;
} }
@ -2037,18 +2041,18 @@ pre {
.topo-palette-source { .topo-palette-source {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
gap: 4px; gap: 2px;
padding: 2px; padding: 2px;
background: #f1f5f9; background: #e2e8f0;
border-radius: 8px; border-radius: 4px;
} }
.topo-palette-source__btn { .topo-palette-source__btn {
border: 0; border: 0;
background: transparent; background: transparent;
border-radius: 6px; border-radius: 3px;
padding: 6px 8px; padding: 5px 6px;
font-size: 12px; font-size: 11px;
font-weight: 600; font-weight: 600;
color: #64748b; color: #64748b;
cursor: pointer; cursor: pointer;
@ -2057,7 +2061,7 @@ pre {
.topo-palette-source__btn.is-active { .topo-palette-source__btn.is-active {
background: #fff; background: #fff;
color: #0f172a; color: #0f172a;
box-shadow: 0 1px 2px rgb(15 23 42 / 8%); box-shadow: inset 0 0 0 1px #c5ced9;
} }
.topo-map-list, .topo-map-list,
@ -2072,7 +2076,7 @@ pre {
.topo-map-list li, .topo-map-list li,
.topo-palette > li { .topo-palette > li {
margin: 0 0 6px; margin: 0 0 4px;
width: 100%; width: 100%;
min-width: 0; min-width: 0;
} }
@ -2088,16 +2092,16 @@ pre {
align-items: stretch; align-items: stretch;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid #e2e8f0; border: 1px solid #c5ced9;
border-radius: 8px; border-radius: 3px;
background: #fff; background: #fff;
overflow: hidden; overflow: hidden;
min-width: 0; min-width: 0;
} }
.topo-map-list li.is-active .topo-map-list__row { .topo-map-list li.is-active .topo-map-list__row {
border-color: #93c5fd; border-color: #64748b;
background: #e8f1fb; background: #e8eef5;
} }
.topo-palette > li.is-on-canvas .topo-palette__row { .topo-palette > li.is-on-canvas .topo-palette__row {
@ -2114,7 +2118,7 @@ pre {
text-align: left; text-align: left;
border: 0; border: 0;
background: transparent; background: transparent;
padding: 8px 10px; padding: 6px 8px;
cursor: pointer; cursor: pointer;
border-radius: 0; border-radius: 0;
min-width: 0; min-width: 0;
@ -2135,11 +2139,11 @@ pre {
.app-main .topo-palette__item { .app-main .topo-palette__item {
display: block; display: block;
width: 100%; width: 100%;
padding: 8px 10px; padding: 6px 8px;
} }
.app-main .topo-map-list__icon { .app-main .topo-map-list__icon {
width: 32px; width: 28px;
height: auto; height: auto;
padding: 0; padding: 0;
color: #64748b; color: #64748b;
@ -2149,29 +2153,29 @@ pre {
.topo-map-list__item:hover, .topo-map-list__item:hover,
.topo-palette__item:hover:not(:disabled) { .topo-palette__item:hover:not(:disabled) {
background: #f1f5f9; background: #eef2f7;
} }
.topo-map-list li.is-active .topo-map-list__item:hover { .topo-map-list li.is-active .topo-map-list__item:hover {
background: #dbeafe; background: #dbe4ef;
} }
.topo-map-list__actions { .topo-map-list__actions {
display: flex; display: flex;
align-items: stretch; align-items: stretch;
flex: 0 0 auto; flex: 0 0 auto;
border-left: 1px solid #e2e8f0; border-left: 1px solid #c5ced9;
} }
.topo-map-list li.is-active .topo-map-list__actions { .topo-map-list li.is-active .topo-map-list__actions {
border-left-color: #bfdbfe; border-left-color: #94a3b8;
} }
.topo-map-list__icon { .topo-map-list__icon {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 32px; width: 28px;
min-height: 100%; min-height: 100%;
border: 0; border: 0;
background: transparent; background: transparent;
@ -2180,7 +2184,7 @@ pre {
} }
.topo-map-list__icon:hover:not(:disabled) { .topo-map-list__icon:hover:not(:disabled) {
background: #f1f5f9; background: #e2e8f0;
color: #0f172a; color: #0f172a;
} }
@ -2204,6 +2208,7 @@ pre {
.topo-palette__name { .topo-palette__name {
display: block; display: block;
font-weight: 600; font-weight: 600;
font-size: 12px;
color: #0f172a; color: #0f172a;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
@ -2213,8 +2218,9 @@ pre {
.topo-map-list__meta, .topo-map-list__meta,
.topo-palette__meta { .topo-palette__meta {
display: block; display: block;
font-size: 12px; font-size: 11px;
color: #64748b; color: #64748b;
font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
@ -2226,34 +2232,34 @@ pre {
min-width: 0; min-width: 0;
min-height: 0; min-height: 0;
background: #fff; background: #fff;
border: 1px solid #dbe3ee; border: 1px solid #c5ced9;
border-radius: 10px; border-radius: 4px;
overflow: hidden; overflow: hidden;
} }
.topo-toolbar { .topo-toolbar {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 8px; gap: 6px;
padding: 10px 12px; padding: 6px 8px;
border-bottom: 1px solid #e2e8f0; border-bottom: 1px solid #c5ced9;
background: #f8fafc; background: #eef2f7;
} }
.topo-toolbar__row { .topo-toolbar__row {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 12px; gap: 8px;
min-width: 0; min-width: 0;
} }
.topo-toolbar__row--tools { .topo-toolbar__row--tools {
justify-content: flex-start; justify-content: flex-start;
flex-wrap: wrap; flex-wrap: wrap;
gap: 10px; gap: 8px;
padding-top: 2px; padding-top: 4px;
border-top: 1px solid #e2e8f0; border-top: 1px solid #d0d7e2;
} }
.topo-toolbar__group + .topo-toolbar__group, .topo-toolbar__group + .topo-toolbar__group,
@ -2268,16 +2274,16 @@ pre {
.topo-toolbar__panel { .topo-toolbar__panel {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 8px; gap: 6px;
flex-shrink: 0; flex-shrink: 0;
padding: 4px 8px; padding: 3px 6px;
background: #f1f5f9; background: #e2e8f0;
border: 1px solid #e2e8f0; border: 1px solid #c5ced9;
border-radius: 10px; border-radius: 4px;
} }
.topo-toolbar__panel .topo-tools { .topo-toolbar__panel .topo-tools {
background: #e2e8f0; background: #d5dde8;
} }
.topo-toolbar__panel .topo-toolbar__display > summary { .topo-toolbar__panel .topo-toolbar__display > summary {
@ -2299,13 +2305,13 @@ pre {
right: 0; right: 0;
left: auto; left: auto;
z-index: 30; z-index: 30;
width: min(320px, 70vw); width: min(340px, 72vw);
max-height: 280px; max-height: 280px;
overflow: auto; overflow: auto;
background: #fff; background: #fff;
border: 1px solid #cbd5e1; border: 1px solid #94a3b8;
border-radius: 8px; border-radius: 4px;
box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
} }
.topo-find-suggest__item { .topo-find-suggest__item {
@ -2323,7 +2329,7 @@ pre {
.topo-find-suggest__item:hover, .topo-find-suggest__item:hover,
.topo-find-suggest__item.is-active { .topo-find-suggest__item.is-active {
background: #eff6ff; background: #e8eef5;
} }
.topo-find-suggest__name { .topo-find-suggest__name {
@ -2335,6 +2341,7 @@ pre {
.topo-find-suggest__meta { .topo-find-suggest__meta {
font-size: 11px; font-size: 11px;
color: #64748b; color: #64748b;
font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
} }
.topo-find-suggest__empty, .topo-find-suggest__empty,
@ -2345,12 +2352,12 @@ pre {
} }
.topo-toolbar__find { .topo-toolbar__find {
width: 150px; width: 190px;
max-width: 28vw; max-width: 36vw;
height: 30px; height: 28px;
padding: 0 8px; padding: 0 8px;
border: 1px solid #cbd5e1; border: 1px solid #94a3b8;
border-radius: 6px; border-radius: 3px;
font-size: 12px; font-size: 12px;
background: #fff; background: #fff;
} }
@ -2370,7 +2377,8 @@ pre {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
font-size: 14px; font-size: 13px;
letter-spacing: 0.01em;
} }
.topo-toolbar__meta { .topo-toolbar__meta {
@ -2398,37 +2406,56 @@ pre {
gap: 2px; gap: 2px;
padding: 2px; padding: 2px;
background: #e2e8f0; background: #e2e8f0;
border-radius: 8px; border-radius: 4px;
flex-shrink: 0; flex-shrink: 0;
} }
.topo-tools__btn { .topo-tools__btn {
display: inline-flex;
align-items: center;
gap: 4px;
border: 0; border: 0;
background: transparent; background: transparent;
color: #475569; color: #475569;
font-size: 12px; font-size: 12px;
font-weight: 600; font-weight: 600;
padding: 5px 10px; padding: 4px 8px;
border-radius: 6px; border-radius: 3px;
cursor: pointer; cursor: pointer;
white-space: nowrap; line-height: 1.2;
} }
.topo-tools__btn:hover { .topo-tools__btn:hover {
background: #cbd5e1; background: #fff;
color: #0f172a; color: #0f172a;
} }
.topo-tools__btn.is-active { .topo-tools__btn.is-active {
background: #0f172a; background: #334155;
color: #f8fafc; color: #f8fafc;
} }
.topo-tools__key {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 14px;
height: 14px;
padding: 0 3px;
border: 1px solid currentColor;
border-radius: 2px;
font-size: 10px;
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
font-weight: 700;
opacity: 0.75;
line-height: 1;
}
.topo-toolbar__select { .topo-toolbar__select {
min-width: 88px; min-width: 88px;
height: 30px; height: 28px;
border: 1px solid #cbd5e1; border: 1px solid #94a3b8;
border-radius: 6px; border-radius: 3px;
background: #fff; background: #fff;
color: #0f172a; color: #0f172a;
font-size: 12px; font-size: 12px;
@ -2443,10 +2470,10 @@ pre {
list-style: none; list-style: none;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
height: 30px; height: 28px;
padding: 0 10px; padding: 0 10px;
border: 1px solid #cbd5e1; border: 1px solid #94a3b8;
border-radius: 6px; border-radius: 3px;
background: #fff; background: #fff;
color: #0f172a; color: #0f172a;
font-size: 12px; font-size: 12px;
@ -2472,11 +2499,44 @@ pre {
display: grid; display: grid;
gap: 6px; gap: 6px;
min-width: 260px; min-width: 260px;
padding: 10px 12px; padding: 8px 10px;
border: 1px solid #e2e8f0; border: 1px solid #94a3b8;
border-radius: 8px; border-radius: 4px;
background: #fff; background: #fff;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
}
.topo-mode-hint {
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
z-index: 6;
padding: 6px 12px;
border-radius: 3px;
border: 1px solid #0ea5e9;
background: rgba(15, 23, 42, 0.9);
color: #e0f2fe;
font-size: 12px;
font-weight: 600;
pointer-events: none;
white-space: nowrap;
max-width: calc(100% - 24px);
overflow: hidden;
text-overflow: ellipsis;
}
.topo-svg-icon {
display: block;
}
.topo-icon-btn {
display: inline-flex !important;
align-items: center;
justify-content: center;
width: 28px;
min-width: 28px;
padding: 0 !important;
} }
.topo-display-defaults { .topo-display-defaults {
@ -2529,18 +2589,18 @@ pre {
.topo-legend { .topo-legend {
position: absolute; position: absolute;
left: 12px; left: 10px;
bottom: 12px; bottom: 10px;
z-index: 5; z-index: 5;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 8px 12px; gap: 8px 12px;
padding: 6px 10px; padding: 5px 9px;
border-radius: 8px; border-radius: 3px;
background: rgba(255, 255, 255, 0.92); background: rgba(15, 23, 42, 0.88);
border: 1px solid #e2e8f0; border: 1px solid #334155;
font-size: 11px; font-size: 11px;
color: #475569; color: #e2e8f0;
pointer-events: none; pointer-events: none;
} }
@ -2552,9 +2612,9 @@ pre {
.topo-legend__swatch { .topo-legend__swatch {
display: inline-block; display: inline-block;
width: 16px; width: 18px;
height: 0; height: 0;
border-top: 2px solid #64748b; border-top: 2px solid #94a3b8;
vertical-align: middle; vertical-align: middle;
} }
@ -2567,8 +2627,8 @@ pre {
} }
.react-flow__selection { .react-flow__selection {
background: rgba(37, 99, 235, 0.08); background: rgba(51, 65, 85, 0.08);
border: 1px solid rgba(37, 99, 235, 0.55); border: 1px solid rgba(51, 65, 85, 0.7);
} }
.topo-display-toggles { .topo-display-toggles {
@ -3043,8 +3103,9 @@ pre {
.topo-discover-modal__sub { .topo-discover-modal__sub {
margin: 4px 0 0; margin: 4px 0 0;
font-size: 13px; font-size: 12px;
color: #64748b; color: #64748b;
font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
} }
.topo-discover-modal__stats { .topo-discover-modal__stats {
@ -3225,18 +3286,20 @@ pre {
} }
.react-flow__node.is-search-hit .topo-node__glyph { .react-flow__node.is-search-hit .topo-node__glyph {
box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.85); box-shadow: none;
border-radius: 10px; outline: 2px solid rgba(245, 158, 11, 0.95);
outline-offset: 3px;
border-radius: 4px;
animation: topo-search-pulse 0.85s ease 2; animation: topo-search-pulse 0.85s ease 2;
} }
@keyframes topo-search-pulse { @keyframes topo-search-pulse {
0%, 0%,
100% { 100% {
box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.85); outline-color: rgba(245, 158, 11, 0.95);
} }
50% { 50% {
box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.25); outline-color: rgba(245, 158, 11, 0.35);
} }
} }
@ -3264,18 +3327,18 @@ pre {
} }
.topo-node.is-selected .topo-node__glyph { .topo-node.is-selected .topo-node__glyph {
outline: 2px solid #2563eb; outline: 2px solid #334155;
outline-offset: 5px; outline-offset: 3px;
border-radius: 999px; border-radius: 4px;
} }
.topo-node.is-selected .topo-node__icon { .topo-node.is-selected .topo-node__icon {
transform: scale(1.08); transform: none;
filter: var(--topo-icon-filter, none) drop-shadow(0 0 8px rgba(37, 99, 235, 0.55)); filter: var(--topo-icon-filter, none);
} }
.topo-node.is-selected .topo-node__caption { .topo-node.is-selected .topo-node__caption {
color: #1d4ed8; color: #0f172a;
font-weight: 700; font-weight: 700;
} }
@ -3291,15 +3354,38 @@ pre {
transition: transform 0.12s ease, filter 0.12s ease; transition: transform 0.12s ease, filter 0.12s ease;
} }
/* Same plain-text style as edge port labels */
.topo-node__caption { .topo-node__caption {
margin-top: 2px; display: flex;
color: #475569; flex-direction: column;
line-height: 1.25; align-items: center;
gap: 1px;
margin-top: 3px;
color: #334155;
line-height: 1.2;
max-width: 160px;
pointer-events: none;
}
.topo-node__caption-name {
display: block;
max-width: 100%;
font-size: 11px;
font-weight: 700;
color: #0f172a;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.topo-node__caption-meta {
display: block;
max-width: 100%;
font-size: 10px;
color: #64748b;
font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
pointer-events: none;
} }
.react-flow__edge-textbg { .react-flow__edge-textbg {

View file

@ -74,6 +74,43 @@ function FullscreenIcon({ exit }: { exit?: boolean }) {
); );
} }
/** ASCII-safe separators ? avoid Unicode middots that corrupt on some editors. */
const SEP = " / ";
function ChevronIcon({ dir }: { dir: "left" | "right" }) {
const d = dir === "left" ? "M15 6l-6 6 6 6" : "M9 6l6 6-6 6";
return (
<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true" className="topo-svg-icon">
<path fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" d={d} />
</svg>
);
}
function PencilIcon() {
return (
<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true" className="topo-svg-icon">
<path
fill="currentColor"
d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"
/>
</svg>
);
}
function CloseIcon() {
return (
<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true" className="topo-svg-icon">
<path
fill="none"
stroke="currentColor"
strokeWidth="2.2"
strokeLinecap="round"
d="M6 6l12 12M18 6L6 18"
/>
</svg>
);
}
type NeNodeData = { type NeNodeData = {
label: string; label: string;
managed_ne_id: string; managed_ne_id: string;
@ -193,15 +230,10 @@ function NeNode({ data, selected }: NodeProps<Node<NeNodeData>>) {
const { hideIp, hideVendor, connectMode } = useContext(TopoDisplayContext); const { hideIp, hideVendor, connectMode } = useContext(TopoDisplayContext);
const tone = vendorTone(data.vendor); const tone = vendorTone(data.vendor);
const name = data.label || (!hideIp ? data.ne_ip : "") || "NE"; const name = data.label || (!hideIp ? data.ne_ip : "") || "NE";
const bits = [ const secondary = [
name, hideIp || !data.ne_ip || data.ne_ip === name ? "" : data.ne_ip,
hideIp ? "" : data.ne_ip, hideVendor || !data.vendor ? "" : data.vendor,
hideVendor ? "" : data.vendor, ].filter(Boolean);
].filter((x, i, arr) => {
const s = String(x || "").trim();
if (!s) return false;
return arr.findIndex((y) => String(y || "").trim() === s) === i;
});
return ( return (
<div <div
className={`topo-node topo-node--${tone}${selected ? " is-selected" : ""}${ className={`topo-node topo-node--${tone}${selected ? " is-selected" : ""}${
@ -223,7 +255,12 @@ function NeNode({ data, selected }: NodeProps<Node<NeNodeData>>) {
/> />
<RouterIcon /> <RouterIcon />
</div> </div>
<div className="topo-node__caption">{bits.join(" ? ")}</div> <div className="topo-node__caption">
<span className="topo-node__caption-name">{name}</span>
{secondary.length ? (
<span className="topo-node__caption-meta">{secondary.join(SEP)}</span>
) : null}
</div>
</div> </div>
); );
} }
@ -359,7 +396,7 @@ function graphToFlow(nodes: TopologyNodeItem[], edges: TopologyEdgeItem[], defau
})); }));
const rfEdges: Edge[] = edges.map((e) => { const rfEdges: Edge[] = edges.map((e) => {
const src = e.source || "manual"; const src = e.source || "manual";
const label = [e.source_port, e.target_port].filter(Boolean).join(" ? "); const label = [e.source_port, e.target_port].filter(Boolean).join(SEP);
const data: EdgeStyleData = { const data: EdgeStyleData = {
source: src, source: src,
source_port: e.source_port || "", source_port: e.source_port || "",
@ -1115,7 +1152,7 @@ export function TopologyPage() {
source_port: patch.source_port !== undefined ? patch.source_port : prev.source_port || "", source_port: patch.source_port !== undefined ? patch.source_port : prev.source_port || "",
target_port: patch.target_port !== undefined ? patch.target_port : prev.target_port || "", target_port: patch.target_port !== undefined ? patch.target_port : prev.target_port || "",
}; };
const portLabel = [data.source_port, data.target_port].filter(Boolean).join(" ? "); const portLabel = [data.source_port, data.target_port].filter(Boolean).join(SEP);
return withEdgeVisual({ ...e, data, label: portLabel || undefined }, edgeDefaults); return withEdgeVisual({ ...e, data, label: portLabel || undefined }, edgeDefaults);
}), }),
); );
@ -1212,6 +1249,8 @@ export function TopologyPage() {
if (e.key === "Escape") { if (e.key === "Escape") {
closeCtxMenu(); closeCtxMenu();
clearSelection(); clearSelection();
connectClickRef.current = null;
setToolMode((m) => (m === "connect" ? "select" : m));
return; return;
} }
const mode = toolModeFromKey(e.key); const mode = toolModeFromKey(e.key);
@ -1541,7 +1580,7 @@ export function TopologyPage() {
name, name,
ip: ne.ip_address || "", ip: ne.ip_address || "",
vendor: "ZTE", vendor: "ZTE",
meta: `${ne.ip_address || "-"} ? ${ne.ne_type || "UME"}`, meta: `${ne.ip_address || "-"}${SEP}${ne.ne_type || "UME"}`,
connect_status: ne.connection_status || "", connect_status: ne.connection_status || "",
}; };
}); });
@ -1554,7 +1593,7 @@ export function TopologyPage() {
name: ne.name || ne.ip_address, name: ne.name || ne.ip_address,
ip: ne.ip_address, ip: ne.ip_address,
vendor: ne.vendor, vendor: ne.vendor,
meta: `${ne.ip_address} · ${ne.vendor}`, meta: `${ne.ip_address}${SEP}${ne.vendor}`,
connect_status: ne.connect_status, connect_status: ne.connect_status,
})); }));
}, [paletteSource, neQuery.data, umeQuery.data]); }, [paletteSource, neQuery.data, umeQuery.data]);
@ -1594,7 +1633,7 @@ export function TopologyPage() {
onClick={() => setSidebarCollapsed(false)} onClick={() => setSidebarCollapsed(false)}
> >
<span className="topo-sidebar__rail-icon" aria-hidden="true"> <span className="topo-sidebar__rail-icon" aria-hidden="true">
? <ChevronIcon dir="right" />
</span> </span>
<span className="topo-sidebar__rail-label">{t("topology.maps")}</span> <span className="topo-sidebar__rail-label">{t("topology.maps")}</span>
</button> </button>
@ -1617,12 +1656,12 @@ export function TopologyPage() {
</button> </button>
<button <button
type="button" type="button"
className="btn btn--sm btn--ghost" className="btn btn--sm btn--ghost topo-icon-btn"
title={t("topology.collapseSidebar")} title={t("topology.collapseSidebar")}
aria-label={t("topology.collapseSidebar")} aria-label={t("topology.collapseSidebar")}
onClick={() => setSidebarCollapsed(true)} onClick={() => setSidebarCollapsed(true)}
> >
? <ChevronIcon dir="left" />
</button> </button>
</div> </div>
</div> </div>
@ -1656,7 +1695,7 @@ export function TopologyPage() {
disabled={renameMapMut.isPending} disabled={renameMapMut.isPending}
onClick={() => promptRenameMap(m.id, m.name)} onClick={() => promptRenameMap(m.id, m.name)}
> >
? <PencilIcon />
</button> </button>
<button <button
type="button" type="button"
@ -1667,7 +1706,7 @@ export function TopologyPage() {
if (window.confirm(msg)) deleteMapMut.mutate(m.id); if (window.confirm(msg)) deleteMapMut.mutate(m.id);
}} }}
> >
? <CloseIcon />
</button> </button>
</div> </div>
</div> </div>
@ -1777,7 +1816,10 @@ export function TopologyPage() {
<div className="topo-toolbar"> <div className="topo-toolbar">
<div className="topo-toolbar__row"> <div className="topo-toolbar__row">
<div className="topo-toolbar__title"> <div className="topo-toolbar__title">
<strong>{maps.find((m) => m.id === mapId)?.name || t("topology.selectMap")}</strong> <strong>
{maps.find((m) => m.id === mapId)?.name || t("topology.selectMap")}
{mapId && dirty ? " *" : ""}
</strong>
{selectedNodes.length > 0 || selectedEdgeId ? ( {selectedNodes.length > 0 || selectedEdgeId ? (
<span className="topo-toolbar__meta"> <span className="topo-toolbar__meta">
{selectedNodes.length > 0 {selectedNodes.length > 0
@ -1868,7 +1910,8 @@ export function TopologyPage() {
connectClickRef.current = null; connectClickRef.current = null;
}} }}
> >
{label} <span className="topo-tools__label">{label}</span>
<kbd className="topo-tools__key">{key}</kbd>
</button> </button>
))} ))}
</div> </div>
@ -2085,7 +2128,7 @@ export function TopologyPage() {
> >
<span className="topo-find-suggest__name">{n.data.label || n.id}</span> <span className="topo-find-suggest__name">{n.data.label || n.id}</span>
<span className="topo-find-suggest__meta"> <span className="topo-find-suggest__meta">
{[n.data.ne_ip, n.data.vendor].filter(Boolean).join(" ? ")} {[n.data.ne_ip, n.data.vendor].filter(Boolean).join(SEP)}
</span> </span>
</button> </button>
)) ))
@ -2101,6 +2144,7 @@ export function TopologyPage() {
</div> </div>
</div> </div>
{discoverOpen ? ( {discoverOpen ? (
<div className="topo-discover"> <div className="topo-discover">
<div className="topo-discover__head"> <div className="topo-discover__head">
@ -2272,7 +2316,12 @@ export function TopologyPage() {
deleteKeyCode={null} deleteKeyCode={null}
edgesFocusable edgesFocusable
> >
<Background variant={BackgroundVariant.Dots} gap={16} size={1} color="#cbd5e1" /> <Background variant={BackgroundVariant.Dots} gap={16} size={1} color="#d8dee8" />
{toolMode === "connect" ? (
<div className="topo-mode-hint" role="status">
{t("topology.connectHint")}
</div>
) : null}
<Controls showInteractive> <Controls showInteractive>
<ControlButton <ControlButton
className="topo-fs-control" className="topo-fs-control"
@ -2680,7 +2729,7 @@ export function TopologyPage() {
{discoverDetail.ne_name || discoverDetail.ne_ip || discoverDetail.ne_id} {discoverDetail.ne_name || discoverDetail.ne_ip || discoverDetail.ne_id}
</h3> </h3>
<p className="topo-discover-modal__sub"> <p className="topo-discover-modal__sub">
{[discoverDetail.ne_ip, discoverDetail.command].filter(Boolean).join(" ? ")} {[discoverDetail.ne_ip, discoverDetail.command].filter(Boolean).join(SEP)}
</p> </p>
</div> </div>
<span <span