diff --git a/README.md b/README.md index 66fa7c7..ebec010 100644 --- a/README.md +++ b/README.md @@ -353,7 +353,16 @@ can view it; only the `admin` group can edit, and every change is logged with wh cables in one port). Runs that end at a jack are *unverified* while linked and *idle* when not. Planned, dark and retired cables aren't checked. - **Undocumented links**: live switch ports no cable mentions, with an Add button that pre-fills - what Gandalf knows. Each switch port panel also shows its planned cable, or links to add one. + what Gandalf knows. Each switch port panel also shows its planned cable, or links to add one. On + the topology page, a cable with no record has a **document it** link that opens this form with both + ends (and the NIC, and DAC when it is one) filled in. `/cutsheet?a_device=&a_port=&b_device=&b_port=&cable_type=` + opens it the same way. +- **Port names in UniFi**: a checklist of switch port names that no longer fit what is plugged in: + named after the wrong device, named after a device that has moved to another port, named but with + nothing plugged in (with who was last seen there), and still "Port N" with a known device on it + (folded). Each comes with a suggested name: the device, the device and NIC for a server with two + cables, "Uplink" or "Downlink to X" between switches. A port named after a device that is only + switched off is left alone. Rename them in UniFi yourself; Gandalf never changes UniFi. - **Labels to make**: cable IDs (one per cord end) and panel-port labels not yet stuck on, sized for typing on a handheld label maker. Tick each off once it's applied; **Print list** prints just this. - **CSV**: export, and import that adds or updates cables by ID. A file with any invalid row imports diff --git a/app.py b/app.py index ef0dd89..27ff38a 100644 --- a/app.py +++ b/app.py @@ -1032,6 +1032,9 @@ def _cutsheet_view() -> dict: snapshot = _state_json('network_snapshot') data['devices'] = sorted(set(switches) | set(snapshot.get('hosts') or {}) | {u['name'] for u in snapshot.get('unifi') or [] if u.get('name')}, key=str.lower) + # UniFi port names that no longer fit what is plugged in (Gandalf never renames them) + data['port_names'] = topology.port_name_report( + snapshot, link_stats, _state_json('modem_stats'), _state_json('known_uplinks')) data['verdicts'] = cutsheet.VERDICTS data['chassis'] = cutsheet.CHASSIS data['options'] = {'kinds': cutsheet.ITEM_KINDS, 'passive_kinds': cutsheet.PASSIVE_KINDS, diff --git a/static/cutsheet.js b/static/cutsheet.js index df9ee84..95f51b3 100644 --- a/static/cutsheet.js +++ b/static/cutsheet.js @@ -74,6 +74,7 @@ function renderSummary() { chip(matches, 'match what Gandalf sees', 'cs-chip-ok', 'cs-cables-section'), chip(problems, problems === 1 ? 'problem' : 'problems', problems ? 'cs-chip-bad' : '', 'cs-cables-section'), chip(_cs.suggestions.length, 'undocumented links', _cs.suggestions.length ? 'cs-chip-warn' : '', 'cs-suggest-section'), + chip(portFixes(), 'port names to fix', portFixes() ? 'cs-chip-warn' : '', 'cs-portnames-section'), chip(labels, 'labels to make', labels ? 'cs-chip-warn' : '', 'cs-labels-section'), ].join(''); } @@ -153,6 +154,51 @@ function renderSuggestions() { ${_showAllSuggestions ? 'Show fewer' : `Show all ${list.length}`}` : ''}`; } +// ── Port names in UniFi ───────────────────────────────────────────────── +const PORT_NAME_GROUPS = [ + ['wrong', 'Named after the wrong device', 'cs-chip-bad'], + ['moved', 'Named after a device that moved', 'cs-chip-warn'], + ['empty', 'Named, but nothing is plugged in', ''], + ['unnamed', 'Unnamed, with a known device plugged in', ''], +]; + +// Wrong and moved names are worth fixing; empty and unnamed ports are only worth a look +function portFixes() { + return (_cs.port_names || []).filter(r => r.kind === 'wrong' || r.kind === 'moved').length; +} + +function renderPortNames() { + const rows = _cs.port_names || []; + document.getElementById('cs-portnames-count').textContent = rows.length; + const wrap = document.getElementById('cs-portnames'); + if (!rows.length) { + wrap.innerHTML = emptyState('✅', 'Every port name fits what is plugged in', ''); + return; + } + wrap.innerHTML = PORT_NAME_GROUPS.map(([kind, title, cls]) => { + const list = rows.filter(r => r.kind === kind); + if (!list.length) return ''; + const table = `
| Switch port | Name in UniFi | What Gandalf sees | Suggested name |
|---|---|---|---|
| ${deviceLink(r.switch)} port ${esc(r.port_idx)} | +${esc(r.port_name)} | +${esc(r.detail)} | +${r.suggestion ? `${esc(r.suggestion)}` : 'your call'} |
+
⚠ The port is named after ${esc(link.name_mismatch.named)}, but ${esc(link.name_mismatch.actual)} is plugged into it. Rename the port in UniFi, or check the cable.
` diff --git a/templates/cutsheet.html b/templates/cutsheet.html index 5894592..6bc5598 100644 --- a/templates/cutsheet.html +++ b/templates/cutsheet.html @@ -47,6 +47,15 @@ +Switch port names that no longer fit what is plugged in, as a checklist. Rename them in UniFi: Gandalf only reports them and never changes UniFi.
+ +