Cutsheet: port names in UniFi that no longer fit, document a cable from topology
Lint / JS (eslint) (push) Successful in 23s
Lint / Python (flake8) (push) Successful in 1m10s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / Python (flake8) (pull_request) Successful in 53s
Lint / JS (eslint) (pull_request) Successful in 11s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (push) Successful in 1m26s
Test / Python Tests (pytest) (push) Successful in 1m49s
Security / Python Security (bandit) (pull_request) Successful in 2m17s
Test / Python Tests (pytest) (pull_request) Successful in 2m12s
Lint / JS (eslint) (push) Successful in 23s
Lint / Python (flake8) (push) Successful in 1m10s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / Python (flake8) (pull_request) Successful in 53s
Lint / JS (eslint) (pull_request) Successful in 11s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (push) Successful in 1m26s
Test / Python Tests (pytest) (push) Successful in 1m49s
Security / Python Security (bandit) (pull_request) Successful in 2m17s
Test / Python Tests (pytest) (pull_request) Successful in 2m12s
- topology.port_name_report: switch port names that no longer fit what is plugged in, as a checklist with suggested names: named after the wrong device, named after a device that moved to another port, named with nothing plugged in (and who was last seen there), and still "Port N" with a known device on it. Ports named after a device that is only off are left alone. Gandalf only reports; it never renames anything in UniFi. - /api/cutsheet returns it as port_names; the cutsheet page shows it as "Port names in UniFi", grouped, with a summary chip. - The topology cable panel's "not documented" gets a "document it" link that opens the cutsheet's new-cable form with both ends, the NIC and DAC filled in; /cutsheet?... now takes b_device, b_port and cable_type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+18
-1
@@ -974,6 +974,23 @@ function endHtml(end, byId) {
|
||||
return `${name}${where ? ` · ${where}` : ''}`;
|
||||
}
|
||||
|
||||
// A link to the cutsheet's new-cable form, filled in with both ends as Gandalf sees them
|
||||
function documentLink(link, byId) {
|
||||
if (!TOPO_CAN_EDIT || link.ghost || link.bundle) return '';
|
||||
const sw = [link.a, link.b].find(e => e.port_idx != null && (byId[e.node] || {}).kind !== 'stub');
|
||||
if (!sw) return '';
|
||||
const far = sw === link.a ? link.b : link.a;
|
||||
const farNode = byId[far.node] || {};
|
||||
const q = new URLSearchParams({ a_device: sw.node, a_port: String(sw.port_idx) });
|
||||
if (farNode.kind && farNode.kind !== 'stub') {
|
||||
q.set('b_device', far.node);
|
||||
if (far.port_idx != null) q.set('b_port', String(far.port_idx));
|
||||
else if (far.iface) q.set('b_port', far.iface);
|
||||
}
|
||||
if (link.medium === 'dac') q.set('cable_type', 'DAC');
|
||||
return ` · <a class="device-link" href="/cutsheet?${esc(q.toString())}">document it</a>`;
|
||||
}
|
||||
|
||||
function showPanel(link) {
|
||||
const byId = Object.fromEntries(state.data.nodes.map(n => [n.id, n]));
|
||||
const panel = document.getElementById('tp-panel');
|
||||
@@ -1001,7 +1018,7 @@ function showPanel(link) {
|
||||
? `<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>');
|
||||
row('Cutsheet', `<span class="tp-dim-text">not documented</span>${documentLink(link, byId)}`);
|
||||
}
|
||||
const warn = link.name_mismatch
|
||||
? `<p class="tp-panel-warn">⚠ The port is named after <strong>${esc(link.name_mismatch.named)}</strong>, but <strong>${esc(link.name_mismatch.actual)}</strong> is plugged into it. Rename the port in UniFi, or check the cable.</p>`
|
||||
|
||||
Reference in New Issue
Block a user