Topology: tap to trace on phones, name cables into a patch panel
Lint / JS (eslint) (push) Successful in 19s
Lint / Python (flake8) (push) Successful in 1m20s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / JS (eslint) (pull_request) Successful in 27s
Lint / Python (flake8) (pull_request) Successful in 1m46s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m9s
Test / Python Tests (pytest) (pull_request) Successful in 1m23s
Security / Python Security (bandit) (push) Successful in 1m10s
Test / Python Tests (pytest) (push) Successful in 1m18s

- Touch screens have no hover, so the first tap on a device traces its path to
  the internet and its power feeds; a second tap opens it. Tapping empty canvas
  clears it, and the trace survives the 30 s refresh.
- A cutsheet cable now carries where its other end goes. An unknown device on a
  cable documented into a patch panel is drawn as that panel's jacks, named
  "Patch panel port N"; a named stub notes "via Patch panel port N". The cable
  panel shows the far end of the cutsheet cable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 22:16:16 -05:00
co-authored by Claude Opus 5.5
parent ab59b42bea
commit b9e008bc2b
5 changed files with 114 additions and 11 deletions
+6
View File
@@ -1495,6 +1495,12 @@ body.fp-marks-off .fp-svg .fp-mark { display: none; }
.tp-stub-q { font-family: var(--font); font-size: 30px; font-weight: 700; fill: #9aa3ad; }
.tp-st-down .tp-stub-body { stroke: #e0312b; }
.tp-stub-jack.tp-off { opacity: .4; }
.tp-pp-body { fill: #2b2f35; stroke: #1b1e22; stroke-width: 3; }
.tp-pp-jack rect { fill: #121417; stroke: #4a5059; stroke-width: 2; }
.tp-pp-jack.tp-pp-used rect { fill: #121417; stroke: #4aa3ff; stroke-width: 4; }
.tp-pp-num { font-family: var(--font); font-size: 18px; fill: #8a929c; }
.tp-pp-used .tp-pp-num { fill: #cfe6ff; font-weight: 700; }
.tp-st-down .tp-pp-body { stroke: #e0312b; }
.tp-group-body { stroke-dasharray: 10 8; stroke: #5d6670; }
.tp-group-hint { font-family: var(--font); font-size: 20px; fill: #9aa3ad; }
.tp-select { font-size: .95em; padding: 1px 4px; margin-left: 4px; }
+58 -5
View File
@@ -19,7 +19,10 @@ const state = {
filters: loadFilters(),
expanded: new Set(), // switches whose unknown devices are shown one by one
selected: null,
pinned: null, // the device a touch screen tapped to trace
};
// Whether the last press was a mouse, pen or finger: touch has no hover, so taps trace instead
let lastPointer = 'mouse';
function loadFilters() {
try {
@@ -323,6 +326,24 @@ function stubDrawing() {
};
}
// The far end of a cable the cutsheet says goes into a patch panel: the panel's row of jacks,
// with the cable landing on its documented port
function patchPanelDrawing(node) {
const n = 24, pitch = 42, w = 80 + n * pitch, h = 130;
const used = Number(node.via.port);
const jacks = Array.from({ length: n }, (_, i) => {
const x = 40 + i * pitch + 6;
const on = i + 1 === used;
return `<g class="tp-pp-jack${on ? ' tp-pp-used' : ''}"><rect x="${x}" y="46" width="30" height="34" rx="3"/>
<text class="tp-pp-num" x="${x + 15}" y="108" text-anchor="middle">${i + 1}</text></g>`;
}).join('');
return {
w, h,
svg: `<rect class="tp-pp-body" x="0" y="20" width="${w}" height="${h - 20}" rx="8"/>${jacks}`,
anchor: () => (used >= 1 && used <= n ? { x: 40 + (used - 1) * pitch + 21, y: 46, face: 'top' } : { x: w / 2, y: 20, face: 'top' }),
};
}
// A host's drawn front, from its cutsheet item's Front drawing
function hostFront(node) {
const ctx = { name: node.name, status: node.status, interfaces: node.interfaces || [] };
@@ -346,7 +367,7 @@ function artFor(node) {
switch (node.kind) {
case 'internet': return internetDrawing();
case 'modem': return modemDrawing(node);
case 'stub': return stubDrawing();
case 'stub': return node.via && node.via.kind === 'patch_panel' ? patchPanelDrawing(node) : stubDrawing();
case 'group': return groupDrawing(node);
case 'ap': return apDrawing(node);
case 'strip': return stripDrawing(node);
@@ -433,7 +454,8 @@ function cardFor(node, linksByIface) {
band = `${art}${sockets.svg}`;
anchorAt = end => (end.iface && sockets.pos[end.iface]) || null;
} else {
const small = ['internet', 'modem', 'stub', 'group', 'ap', 'strip'].includes(node.kind);
const panel = node.kind === 'stub' && node.via && node.via.kind === 'patch_panel';
const small = !panel && ['internet', 'modem', 'stub', 'group', 'ap', 'strip'].includes(node.kind);
w = Math.max(small ? CARD_SMALL_W : CARD_W, Math.min(node.name.length * 27 + 130, 980));
const art = artFor(node);
const f = fitArt(art, 28, BAND_Y, w - 56, BAND_H);
@@ -478,6 +500,8 @@ function cardFor(node, linksByIface) {
const name = node.name.length > maxChars ? `${node.name.slice(0, maxChars - 1)}…` : node.name;
let sub;
if (node.kind === 'group') sub = `on ${node.switch}`;
else if (node.kind === 'stub' && node.named_by_via) sub = `${node.via.cable ? `${node.via.cable} · ` : ''}device beyond it unknown`;
else if (node.kind === 'stub' && node.via) sub = `via ${node.via.name}`;
else if (node.kind === 'stub') sub = node.ip ? `${node.switch} port ${node.port_idx}` : (node.mac || `${node.switch} port ${node.port_idx}`);
else if (node.kind === 'host') sub = node.status === 'up' ? 'server' : `server · ${node.status}`;
else if (node.kind === 'internet') sub = node.status === 'up' ? 'connected' : node.status;
@@ -846,7 +870,10 @@ function renderNode(node, lay) {
<g class="tp-badge tp-badge-${esc(node.severity)}" transform="translate(${d.w - 6} 6)"><circle r="30"/><text y="11" text-anchor="middle">${node.alert_count}</text></g>`
: '';
const alertText = (node.alerts || []).map(a => `${a.severity}: ${a.type.replace(/_/g, ' ')}${a.detail ? ` ${a.detail}` : ''}`).join('; ');
const label = `${node.name}${node.kind === 'stub' ? ' (not identified)' : ''} · ${node.status}${alertText ? ` · ${alertText}` : ''}`;
const what = node.kind !== 'stub' ? ''
: node.named_by_via ? ` (${node.via.device}; what is patched in beyond it is not identified)`
: ` (not identified${node.via ? `; via ${node.via.name}` : ''})`;
const label = `${node.name}${what} · ${node.status}${alertText ? ` · ${alertText}` : ''}`;
const open = node.kind === 'group'
? `<g class="tp-node-link" tabindex="0" role="button" data-expand="${esc(node.switch)}" aria-label="${esc(`${node.name} on ${node.switch}: show them`)}">`
: (href ? `<a class="tp-node-link" href="${esc(href)}" aria-label="${esc(label)}">` : `<g class="tp-node-link" tabindex="0" aria-label="${esc(label)}">`);
@@ -902,6 +929,11 @@ function render() {
if (link) showPanel(link);
else hidePanel();
}
// A refresh redraws everything: keep a tapped device traced
if (state.pinned) {
if (lay.pos[state.pinned]) highlight(state.pinned);
else state.pinned = null;
}
}
// ── Cable panel ─────────────────────────────────────────────────────────
@@ -943,7 +975,10 @@ function showPanel(link) {
}
if (link.cable) {
const label = link.cable.label || `cable #${link.cable.id}`;
row('Cutsheet', `<a class="device-link" href="/cutsheet#cable-${esc(link.cable.id)}">${esc(label)}</a>${link.cable.type ? ` · ${esc(link.cable.type)}` : ''}${link.cable.color ? ` · ${esc(link.cable.color)}` : ''}`);
const far = link.cable.far;
const to = far && far.device && !byId[far.device]
? `<br><span class="tp-dim-text">into ${esc(far.device)}${far.port ? ` port ${esc(far.port)}` : ''}</span>` : '';
row('Cutsheet', `<a class="device-link" href="/cutsheet#cable-${esc(link.cable.id)}">${esc(label)}</a>${link.cable.type ? ` · ${esc(link.cable.type)}` : ''}${link.cable.color ? ` · ${esc(link.cable.color)}` : ''}${to}`);
} else if (!link.wan) {
row('Cutsheet', '<span class="tp-dim-text">not documented</span>');
}
@@ -1169,6 +1204,22 @@ function initEvents() {
return;
}
if (!e.target.closest('#tp-pop')) closeOutletEditor();
// A touch screen has no hover: the first tap on a device traces it (its path to the internet
// and its power feeds), a second tap opens it
const tapped = e.target.closest('.tp-node');
if (lastPointer === 'touch') {
const id = tapped && tapped.querySelector('a.tp-node-link') ? tapped.dataset.node : null;
if (id && state.pinned !== id && !e.target.closest('[data-action="select-port"]')) {
e.preventDefault();
state.pinned = id;
highlight(id);
return;
}
if (!tapped) {
state.pinned = null;
highlight(null);
}
}
const port = e.target.closest('[data-action="select-port"]');
if (port) {
e.preventDefault();
@@ -1212,12 +1263,14 @@ function initEvents() {
}
});
const trace = e => {
if (lastPointer === 'touch') return; // taps trace in the click handler instead
const node = e.target.closest('.tp-node');
highlight(node ? node.dataset.node : null);
};
svg.addEventListener('pointerdown', e => { lastPointer = e.pointerType; }, true);
svg.addEventListener('mouseover', trace);
svg.addEventListener('focusin', trace);
svg.addEventListener('mouseleave', () => highlight(null));
svg.addEventListener('mouseleave', () => { if (lastPointer !== 'touch') highlight(null); });
svg.addEventListener('focusout', e => { if (!svg.contains(e.relatedTarget)) highlight(null); });
document.getElementById('tp-pop').addEventListener('click', e => {