diff --git a/static/cutsheet.js b/static/cutsheet.js
index 63511da..9524906 100644
--- a/static/cutsheet.js
+++ b/static/cutsheet.js
@@ -67,16 +67,19 @@ function renderSummary() {
const problems = cables.filter(c => c.problem).length;
const matches = cables.filter(c => c.verdict === 'match').length;
const labels = _cs.labels.cables.length + _cs.labels.ports.length;
- const chip = (n, text, cls, target) =>
- `${n} ${esc(text)} `;
- document.getElementById('cs-summary').innerHTML = [
- chip(cables.length, 'cables', '', 'cs-cables-section'),
- 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('');
+ document.getElementById('cs-summary').innerHTML =
+ `${matches} of ${cables.length} match what Gandalf sees`
+ + (problems ? ` · ${problems} ${problems === 1 ? 'problem' : 'problems'}` : '');
+ // Each tab says how much is in it; To do counts what needs doing
+ const todo = _cs.suggestions.length + portFixes() + labels;
+ const tabCount = (id, n, cls) => {
+ const el = document.getElementById(`cs-tabcount-${id}`);
+ el.textContent = n ? String(n) : '';
+ el.className = `cs-tab-count${cls ? ` ${cls}` : ''}`;
+ };
+ tabCount('cables', cables.length, problems ? 'cs-tab-count-bad' : '');
+ tabCount('todo', todo, todo ? 'cs-tab-count-warn' : '');
+ tabCount('items', _cs.items.length, '');
}
function cableMatches(c, words, status, problemsOnly) {
@@ -209,6 +212,9 @@ function farEnd(c, name, port, side) {
return endText(c, end);
}
+// Panels whose every port is shown, not just the ones with something on them
+const _panelsShowAll = new Set();
+
function renderPanels() {
const panels = _cs.items.filter(i => i.kind === 'patch_panel').sort((a, b) => natural(a.name, b.name));
const wrap = document.getElementById('cs-panels');
@@ -220,10 +226,14 @@ function renderPanels() {
for (const l of _cs.port_labels) labels[`${l.item_id}|${l.port}`] = l;
wrap.innerHTML = panels.map(p => {
const rows = [];
+ const all = _panelsShowAll.has(p.id);
+ let used = 0;
for (let n = 1; n <= (p.port_count || 0); n++) {
const front = cableAt(p.name, n, 'front');
const rear = cableAt(p.name, n, 'rear');
const lab = labels[`${p.id}|${n}`];
+ if (front || rear || lab) used += 1;
+ else if (!all) continue;
const cell = (c, side) => c
? `${esc(c.label || 'unlabeled')} → ${farEnd(c, p.name, n, side)}`
: '- ';
@@ -236,17 +246,24 @@ function renderPanels() {
${cell(rear, 'rear')}
`);
}
- return `
-
-
╚ ╝
-
+ const total = p.port_count || 0;
+ const toggle = total && used < total
+ ? `
${all ? `Show only the ${used} in use` : `Show all ${total} ports`} `
+ : '';
+ const table = rows.length ? `
Ports on ${esc(p.name)}
Port Label Front (patch cord) Rear (run)
${rows.join('')}
-
+
` : '';
+ return `
+
+
╚ ╝
+
+
${used} of ${total} ports have a cable or label${used ? '' : '; nothing documented yet'}. ${toggle}
+ ${table}
`;
}).join('');
}
@@ -282,27 +299,6 @@ function renderLabels() {
${unlabeled.length ? `${unlabeled.length} more cable(s) have no ID yet.
` : ''}`;
}
-function renderRack() {
- const placed = _cs.items.filter(i => i.rack_u).sort((a, b) => (b.rack_u + (b.rack_height || 1)) - (a.rack_u + (a.rack_height || 1)));
- const wrap = document.getElementById('cs-rack');
- if (!placed.length) {
- wrap.innerHTML = emptyState('🗄️', 'No rack positions recorded', CS_CAN_EDIT ? 'Set a rack unit on a panel, shelf or device in the inventory.' : '');
- return;
- }
- wrap.innerHTML = `
-
- ${placed.map(i => {
- const top = i.rack_u + (i.rack_height || 1) - 1;
- return `
-
- ${i.rack_height > 1 ? `U${esc(top)}-${esc(i.rack_u)}` : `U${esc(i.rack_u)}`}
- ${deviceLink(i.name)}
- ${esc(KIND_TEXT[i.kind] || i.kind)}
-
`;
- }).join('')}
-
`;
-}
-
function rackText(i) {
if (i.shelf) return `on ${esc(i.shelf)}${i.slot ? `, position ${esc(i.slot)}` : ''}`;
if (!i.rack_u) return '-';
@@ -380,7 +376,6 @@ function render() {
renderPortNames();
renderPanels();
renderLabels();
- renderRack();
renderItems();
renderHistory();
renderDatalists();
@@ -396,13 +391,39 @@ async function load() {
return;
}
render();
- const hash = window.location.hash;
- if (hash && /^#(cable|item)-\d+$/.test(hash)) {
- const el = document.getElementById(hash.slice(1));
- if (el) { el.classList.add('cs-flash'); el.scrollIntoView({ block: 'center' }); }
- }
+ reveal(window.location.hash);
}
+// Open the tab holding a section, cable or item (links from the dashboard, the rack and
+// other tabs point at them), then scroll to it. Cables and items flash so they're easy to spot.
+function reveal(hash) {
+ if (!hash || !/^#[\w-]+$/.test(hash)) return false;
+ const el = document.getElementById(hash.slice(1));
+ if (!el) return false;
+ const panel = el.closest('.lt-tab-panel');
+ if (panel && !panel.classList.contains('active')) lt.tabs.switch(panel.id);
+ if (el.classList.contains('lt-tab-panel')) return true;
+ if (/^#(cable|item)-\d+$/.test(hash)) {
+ el.classList.remove('cs-flash');
+ void el.offsetWidth;
+ el.classList.add('cs-flash');
+ el.scrollIntoView({ block: 'center' });
+ } else {
+ el.scrollIntoView({ block: 'start' });
+ }
+ return true;
+}
+
+window.addEventListener('hashchange', () => reveal(window.location.hash));
+document.addEventListener('click', e => {
+ // A link to something on another tab: switch tabs even when the hash is already set
+ const a = e.target.closest('a[href^="#"]');
+ if (a && a.getAttribute('href').length > 1 && reveal(a.getAttribute('href'))) {
+ e.preventDefault();
+ history.replaceState(null, '', a.getAttribute('href'));
+ }
+});
+
// ── Editing ─────────────────────────────────────────────────────────────
function fillPorts(end) {
const device = document.querySelector(`#cs-cable-form [name="${end}_device"]`).value;
@@ -706,6 +727,11 @@ document.addEventListener('click', e => {
else if (action === 'edit-item') openItem(_cs.items.find(i => String(i.id) === btn.dataset.id));
else if (action === 'edit-port-label') openPortLabel(btn.dataset.item, btn.dataset.port);
else if (action === 'print-labels') printLabels();
+ else if (action === 'panel-all') {
+ const id = Number(btn.dataset.id);
+ if (_panelsShowAll.has(id)) _panelsShowAll.delete(id); else _panelsShowAll.add(id);
+ renderPanels();
+ }
else if (action === 'trace-start') startTrace();
else if (action === 'trace-stop') { stopTrace(); traceStatus('Stopped.'); }
else if (action === 'trace-record') {
diff --git a/static/style.css b/static/style.css
index 6ce3fe0..ed26e49 100644
--- a/static/style.css
+++ b/static/style.css
@@ -1094,7 +1094,6 @@ polygon.fp-led-off { fill: #6b6c71; }
.cs-trace-status { margin-top: 10px; font-size: .88rem; line-height: 1.6; }
.cs-trace-found { font-size: 1rem; margin-bottom: 6px; }
.cs-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
-.cs-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.cs-chip { padding: 5px 10px; border: 1px solid var(--border-color, #234); border-radius: 3px; font-size: .82rem;
color: inherit; text-decoration: none; }
.cs-chip b { font-size: .95rem; }
@@ -1102,6 +1101,16 @@ polygon.fp-led-off { fill: #6b6c71; }
.cs-chip-bad { border-color: var(--status-critical, #e0312b); }
.cs-chip-bad b { color: var(--status-critical, #e0312b); }
.cs-chip-warn b { color: var(--accent-amber, #f0a020); }
+.cs-summary { font-size: .82rem; color: var(--text-secondary); margin: 0 0 10px; }
+.cs-summary .cs-ok { color: var(--accent-green); }
+.cs-summary .cs-bad { color: var(--accent-red); }
+/* Tabs: wrap on phones rather than scroll the page sideways */
+.cs-tabs { flex-wrap: wrap; }
+.cs-tab-count { color: var(--text-secondary); font-weight: 400; margin-left: 2px; }
+.cs-tab-count:empty { display: none; }
+.cs-tab-count-bad { color: var(--accent-red); }
+.cs-tab-count-warn { color: var(--accent-amber); }
+.cs-panel-use { font-size: .8rem; color: var(--text-secondary); margin: 6px 12px 8px; }
.cs-portname-group { margin: 0 0 12px; }
.cs-portname-group > summary { cursor: pointer; list-style-position: inside; margin-bottom: 8px; }
.cs-portname-group code { white-space: nowrap; }
@@ -1130,12 +1139,6 @@ polygon.fp-led-off { fill: #6b6c71; }
.cs-label-text { font-family: var(--font-mono, monospace); font-size: 1.05rem; font-weight: 700; letter-spacing: .05em; }
.cs-label-copies { font-size: .8rem; color: var(--text-muted, #8aa); }
.cs-label-where { grid-column: 1 / -1; font-size: .74rem; color: var(--text-muted, #8aa); }
-.cs-rack { display: flex; flex-direction: column; gap: 3px; max-width: 560px; }
-.cs-rack-unit { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center;
- min-height: calc(var(--u, 1) * 26px); padding: 4px 10px; border: 1px solid var(--border-color, #234);
- border-radius: 2px; background: rgba(255,255,255,.02); }
-.cs-rack-u { font-family: var(--font-mono, monospace); font-size: .78rem; color: var(--text-muted, #8aa); }
-.cs-rack-kind { font-size: .74rem; color: var(--text-muted, #8aa); }
.cs-end { border: 1px solid var(--border-color, #234); border-radius: 3px; padding: 4px 12px 0; margin: 0 0 12px; }
.cs-end legend { font-size: .78rem; padding: 0 6px; color: var(--text-muted, #8aa); text-transform: uppercase; }
.cs-side[hidden] { display: none; }
@@ -1153,11 +1156,11 @@ polygon.fp-led-off { fill: #6b6c71; }
.cs-table td.cs-id { font-size: 1rem; }
.cs-row-problem { box-shadow: inset 3px 0 0 var(--status-critical, #e0312b); }
.cs-row-problem td:first-child { box-shadow: none; }
- .cs-rack-unit { grid-template-columns: 56px 1fr; }
- .cs-rack-kind { display: none; }
}
@media print {
.no-print, .lt-header, .lt-nav-drawer, .lt-nav-drawer-overlay { display: none !important; }
+ /* Printing shows every tab, or only the labels */
+ .lt-tab-panel { display: block !important; }
body.cs-print-labels .g-section:not(#cs-labels-section),
body.cs-print-labels .lt-page-header, body.cs-print-labels .cs-summary { display: none !important; }
.cs-label-card { break-inside: avoid; border-color: #000; color: #000; }
@@ -1747,3 +1750,5 @@ body.fp-marks-off .fp-svg .fp-mark { display: none; }
.g-brand-expansion b { color: var(--accent-cyan); font-weight: 700; }
.g-help-about { font-size: .86em; color: var(--text-secondary); margin: 0 0 12px; line-height: 1.5; }
.g-help-about b { color: var(--accent-cyan); }
+/* A tab holding one section already says what it is: skip the repeated heading */
+.lt-tab-panel > .g-section:only-child > .g-section-header { display: none; }
diff --git a/templates/cutsheet.html b/templates/cutsheet.html
index 6bc5598..42d8930 100644
--- a/templates/cutsheet.html
+++ b/templates/cutsheet.html
@@ -5,7 +5,7 @@
-
+
+ Cables
+ To do
+ Patch panels
+ Inventory
+ History
+
-
-
-
-
- Switch ports with a live link that no cable record mentions. Adding one pre-fills what Gandalf already knows; insert the patch panel hop if the cable runs through one.
-
-
-
-
-
- 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.
-
-
-
-
-
- {% if can_edit %}
-
-
╚ ╝
-
-
-
Find which switch port a panel port's cord goes to: start, then unplug that cord at the panel.
- Gandalf watches every switch port and shows the one that drops. Plug it back in afterwards. The device on it
- loses its link for those few seconds.
-
-
+
+
- {% endif %}
-
-
+
+
+
+
+ All statuses
+ Installed
+ Planned
+ Dark
+ Retired
+
+ Problems only
+
+
+
+
-
-
- Type these on the label maker. Cable IDs go on both ends of the cord; panel labels go on the port. Tick each one once it's stuck on.
-
-
+
+
+
+ Live switch ports no cable record mentions. Add pre-fills what Gandalf knows.
+
+
-
+
+
+ Names that no longer fit what is plugged in. Rename them in UniFi; Gandalf never changes UniFi.
+
+
-
-
- Things Gandalf can't discover: patch panels, wall jacks, shelves, and rack positions for devices.
-
-
+
+
+ Cable IDs go on both ends of the cord, panel labels on the port. Tick each once it's stuck on.
+
+
+
-
+
+
+
+ {% if can_edit %}
+
+
╚ ╝
+
+
+
Press Start, then unplug the panel port's cord: the switch port that drops is where it goes.
+ The device on it loses its link until you plug it back in.
+
+
+
+
+ {% endif %}
+
+
+
+
+
+
+