From abac6983b2adbfd676d6527dd83f1741db411d39 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sun, 15 Nov 2026 15:04:34 -0500 Subject: [PATCH] Calmer dashboard and navigation, short page intros Dashboard: the stat cards are gone (Needs attention says it better); host cards fold unused NICs into one line and move Suppress to a small icon; UniFi devices become a compact list; recently resolved alerts fold. Navigation keeps Dashboard, Topology, Rack and Cutsheet in view with Alert history and Suppressions under More; the phone drawer groups them the same way and gains Start maintenance, and the phone header hides the user name and the Ctrl+K hint so GANDALF fits. Rack and topology intros are one line with the how-to behind a ?; the topology problem bar is one line until opened. README updated. Co-Authored-By: Claude Opus 5.5 --- README.md | 40 +++++++--- static/app.js | 63 +++++----------- static/style.css | 63 ++++++++++++++++ static/topology.js | 15 +++- templates/base.html | 88 ++++++++++++---------- templates/events.html | 2 +- templates/index.html | 144 +++++++----------------------------- templates/rack.html | 3 +- templates/suppressions.html | 2 +- templates/topology.html | 3 +- tests/test_app.py | 25 ++++++- 11 files changed, 230 insertions(+), 218 deletions(-) diff --git a/README.md b/README.md index ebec010..b4ef7ca 100644 --- a/README.md +++ b/README.md @@ -106,17 +106,30 @@ Ping-only (no node_exporter): **pbs** (10.10.10.3) ## Pages ### Dashboard (`/`) +- **Needs attention** at the top gathers what every page would flag into two lists, each line linking to + where it is fixed: + - *Broken now*: active alerts (one line, with the devices), an outlet that is off but feeds a device, + frozen outlet readings, and cables not where the cutsheet says. + - *Tidy up*: UniFi port names pointing at the wrong device or at an empty port, live links not on the + cutsheet, labels to print, powered outlets with no device assigned, and rack items that overlap or sit + outside the rack. + + Served by `GET /api/attention` (`attention.py`) and refreshed with the rest of the page. - Device search (see Device pages below) -- Active alerts first, then the WAN / Fiber panel, hosts, UniFi devices, and recently resolved alerts -- Real-time host status grid with per-NIC link state (UP / DOWN / degraded) -- WAN / Fiber panel: WAN and PON state, Rx/Tx power, optics temperature, throughput, errors, gateway uptime and last restart, 7-day Rx trend, recent WAN outages -- UniFi device table (switches, APs, gateway) - Active alerts table with severity, target, consecutive failures, ticket link +- WAN / Fiber panel: WAN and PON state, Rx/Tx power, optics temperature, throughput, errors, gateway uptime and last restart, 7-day Rx trend, recent WAN outages +- Hosts with per-NIC link state; NICs marked unused fold into a "+N unused" line +- UniFi devices as a compact list (name and model; offline ones turn red with a suppress button) +- Recently resolved alerts, folded until opened - Follow-up flags (see Follow-up below): a โณ badge on alerts active for days, a "ticket closed" badge when the ticket was closed but the alert is still active, and a Needs Follow-up panel of tickets left open after their alert cleared. A "TO FOLLOW UP" chip in the status bar counts them all. -- Quick-suppress modal: apply timed or manual suppression from any alert row -- Auto-refreshes every 30 seconds via `/api/status` + `/api/network` +- Quick-suppress modal: apply timed or manual suppression from any alert row or host card +- Auto-refreshes every 30 seconds via `/api/status` + `/api/network` + `/api/attention` + +The header spells out the name; the navigation keeps Dashboard, Topology, Rack and Cutsheet in view, with +Alert history and Suppressions under **More** (and in the command palette, Ctrl+K). On a phone the drawer +holds every page and Start maintenance. ### Alert history (`/events`) Every alert Gandalf raised in the last 24 hours to 90 days, including ones that cleared before anyone @@ -185,9 +198,11 @@ The rack front, drawn from the rack units set on cutsheet items, top first. The whole network as the switches see it now, top down: the internet, the modem, the gateway, then each switch by how many hops it is from the gateway, the gear and unknown devices below them, and the servers along the bottom. Power gear (PDU, UPS, power strip) sits in a rail on the right. -- **What needs a look** is listed above the diagram: devices down, degraded or with active alerts, - cables down or last seen elsewhere, ports named after the wrong device, and cables with errors. - Click one to jump to it. With nothing to report it says all clear. Problem cables are drawn in full +- **What needs a look** sits above the diagram as one line ("7 to look at" and the first two): + devices down, degraded or with active alerts, cables down or last seen elsewhere, ports named after + the wrong device, and cables with errors. Open it to list them all and click one to jump to it; it + remembers whether it was open. With nothing to report it says all clear. The how-to hides behind the + **?** next to the page intro. Problem cables are drawn in full colour with a glow and always shown, whatever the filters; healthy cables are drawn quietly. - **A card per device**, all the same height so the whole network reads at a glance: name, state (coloured edge and dot), and a picture: UniFi gear shows its real faceplate (the same drawings as the @@ -339,8 +354,13 @@ entry in `FACEPLATES`. Where every cable is meant to go, checked against what Gandalf actually sees. Anyone who can log in can view it; only the `admin` group can edit, and every change is logged with who made it and when. +The page has five tabs, each with its count: **Cables**, **To do** (undocumented links, port names +in UniFi, labels to make), **Patch panels**, **Inventory** and **History**. A link to a section, cable +or item (`/cutsheet#cable-7`, `#cs-portnames-section`) opens the tab that holds it, and +`/cutsheet?problems=1` opens the cables with problems. Printing prints every tab. + - **Inventory**: things discovery can't see: patch panels, wall jacks, shelves, and rack positions - for devices (use a device's exact Gandalf name). Panels and jacks are passive: a cable on a + for devices (use a device's exact Gandalf name). The rack page draws them. Panels and jacks are passive: a cable on a port's front continues through the same port's rear. - **Cables**: two endpoints each (device or item, port, and front/rear for panels and jacks), plus ID, type, length, color, status (`planned`, `installed`, `dark`, `retired`) and notes. Leave the diff --git a/static/app.js b/static/app.js index 34c606e..86a6fe1 100644 --- a/static/app.js +++ b/static/app.js @@ -140,16 +140,6 @@ function updateStatusBar(summary, lastCheck, daemonOk, followUps = 0, hasStaleTi alertBadge.style.display = total ? '' : 'none'; } - // Update stat cards - const scCrit = document.getElementById('stat-critical-val'); - const scWarn = document.getElementById('stat-warning-val'); - const scRes = document.getElementById('stat-resolved-val'); - if (scCrit) scCrit.textContent = critCount; - if (scWarn) scWarn.textContent = warnCount; - if (scRes && summary.resolved_24h !== null && summary.resolved_24h !== undefined) scRes.textContent = summary.resolved_24h; - const statCritCard = document.getElementById('stat-critical'); - if (statCritCard) statCritCard.classList.toggle('lt-stat-card--alert', critCount > 0); - // Stale data banner: warn if last_check is older than 15 minutes let staleBanner = document.getElementById('stale-banner'); if (lastCheck) { @@ -173,9 +163,6 @@ function updateStatusBar(summary, lastCheck, daemonOk, followUps = 0, hasStaleTi } function updateHostGrid(hosts) { - const scHosts = document.getElementById('stat-hosts-val'); - if (scHosts) scHosts.textContent = Object.keys(hosts).length; - for (const [name, host] of Object.entries(hosts)) { const card = document.querySelector(`.host-card[data-host="${CSS.escape(name)}"]`); if (!card) continue; @@ -188,15 +175,17 @@ function updateHostGrid(hosts) { const ifaceList = card.querySelector('.iface-list'); if (ifaceList && host.interfaces && Object.keys(host.interfaces).length > 0) { - ifaceList.innerHTML = Object.entries(host.interfaces) - .sort(([a], [b]) => a.localeCompare(b)) - .map(([iface, state]) => ` + // NICs marked unused fold into one line, so the card shows what is cabled + const all = Object.entries(host.interfaces).sort(([a], [b]) => a.localeCompare(b)); + const inUse = all.filter(([, state]) => state !== 'unused'); + const unused = all.length - inUse.length; + ifaceList.innerHTML = inUse.map(([iface, state]) => `
- + ${lt.escHtml(iface)} - ${state} + ${lt.escHtml(state)}
- `).join(''); + `).join('') + (unused ? `
+${unused} unused
` : ''); } } } @@ -452,30 +441,18 @@ function updateModem(data) { } function updateUnifiTable(devices) { - const tbody = document.querySelector('#unifi-table tbody'); - if (!tbody || !devices.length) return; - - tbody.innerHTML = devices.map(d => { - const statusClass = d.connected ? '' : 'row-critical'; - const dotClass = d.connected ? 'dot-up' : 'dot-down'; - const statusText = d.connected ? 'ONLINE' : 'OFFLINE'; - const suppressBtn = !d.connected - ? `` - : ''; - return ` - - ${statusText} - ${lt.escHtml(d.name)} - ${lt.escHtml(d.type)} - ${lt.escHtml(d.model)} - ${lt.escHtml(d.ip)} - ${suppressBtn} - `; - }).join(''); + const grid = document.getElementById('unifi-grid'); + if (!grid || !devices.length) return; + const esc = lt.escHtml; + grid.innerHTML = devices.map(d => ` +
  • + + ${esc(d.name)} + ${esc(d.model)} + ${d.connected ? '' : ``} +
  • `).join(''); } function updateEventsTable(events, totalActive) { diff --git a/static/style.css b/static/style.css index ed26e49..8c26cbd 100644 --- a/static/style.css +++ b/static/style.css @@ -1752,3 +1752,66 @@ body.fp-marks-off .fp-svg .fp-mark { display: none; } .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; } + +/* โ”€โ”€ Dashboard: calmer host cards and device list โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ */ +.host-suppress { margin-left: auto; padding: 0 6px; opacity: .45; } +.host-suppress:hover, .host-suppress:focus-visible { opacity: 1; } +.iface-unused { font-size: .74em; color: var(--text-muted); padding: 2px 0 0 14px; } +.unifi-grid { + list-style: none; margin: 0; padding: 0; + display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; +} +.unifi-chip { + display: flex; align-items: center; gap: 8px; min-width: 0; + padding: 6px 10px; border: 1px solid var(--border-color); background: var(--bg-card); + font-size: .84em; +} +.unifi-chip-down { border-color: var(--accent-red); } +.unifi-chip-name { color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.unifi-chip-model { margin-left: auto; color: var(--text-muted); font-size: .86em; } +.unifi-chip .btn-suppress { padding: 0 6px; } +.resolved-fold > summary { cursor: pointer; list-style: none; } +.resolved-fold > summary::-webkit-details-marker { display: none; } +.resolved-fold > summary::after { content: 'โ–ธ show'; margin-left: auto; font-size: .72em; color: var(--text-muted); } +.resolved-fold[open] > summary::after { content: 'โ–พ hide'; } + +/* โ”€โ”€ Navigation: More menu โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ */ +.g-nav-more { position: relative; } +.g-nav-more > summary { list-style: none; cursor: pointer; } +.g-nav-more > summary::-webkit-details-marker { display: none; } +.g-nav-more-menu { + position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; + display: flex; flex-direction: column; min-width: 180px; + background: var(--bg-secondary); border: 1px solid var(--border-color); + box-shadow: 0 8px 24px rgba(0,0,0,.35); +} +.g-nav-more-link { + padding: 9px 14px; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; + color: var(--text-secondary); text-decoration: none; +} +.g-nav-more-link:hover, .g-nav-more-link:focus-visible { color: var(--accent-cyan); background: rgba(0,212,255,.05); } +.g-nav-more-link.active { color: var(--accent-orange); } +.g-drawer-group { + display: block; margin: 14px 0 4px; padding: 0 16px; font-size: .66rem; + letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); +} + +/* โ”€โ”€ Page intros: the how-to sits behind a small "?" โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ */ +.g-howto { display: inline; } +.g-howto > summary { + display: inline-flex; align-items: center; justify-content: center; + width: 1.5em; height: 1.5em; margin-left: 4px; cursor: pointer; list-style: none; + border: 1px solid var(--border-color); border-radius: 50%; color: var(--accent-cyan); font-size: .9em; +} +.g-howto > summary::-webkit-details-marker { display: none; } +.g-howto[open] > span { display: block; margin-top: 6px; color: var(--text-secondary); max-width: 70ch; } +.tp-summary-toggle { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; cursor: pointer; color: inherit; } +.tp-summary-bad .tp-summary-toggle { color: var(--red); } +.tp-summary-warn .tp-summary-toggle { color: var(--amber); } +.tp-summary-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 0; } + +/* โ”€โ”€ Phone header: room for the GANDALF name โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ */ +@media (max-width: 767px) { + .lt-header-user, .lt-cmd-hint-btn, .lt-header-right [data-action="start-maintenance"] { display: none; } +} +.g-drawer-action { background: none; border: 0; width: 100%; text-align: left; font: inherit; cursor: pointer; } diff --git a/static/topology.js b/static/topology.js index 6a752a5..d9e1fb7 100644 --- a/static/topology.js +++ b/static/topology.js @@ -8,6 +8,7 @@ const PER_MM = 1100 / 482.6; const NODE_GAP = 90; const REFRESH_MS = 30000; const FILTER_KEY = 'gandalf.topology.filters'; +const PROBLEMS_KEY = 'gandalf.topology.problemsOpen'; const DEFAULT_FILTERS = { stubs: 'grouped', power: true, traffic: true, mgmt: false, alerts: false }; const STUB_MODES = ['grouped', 'all', 'none']; @@ -20,6 +21,7 @@ const state = { expanded: new Set(), // switches whose unknown devices are shown one by one selected: null, pinned: null, // the device a touch screen tapped to trace + problemsOpen: (() => { try { return localStorage.getItem(PROBLEMS_KEY) === '1'; } catch (_) { return false; } })(), }; // Whether the last press was a mouse, pen or finger: touch has no hover, so taps trace instead let lastPointer = 'mouse'; @@ -1323,6 +1325,12 @@ function initEvents() { if (e.key === 'Escape') closeOutletEditor(); }); document.getElementById('tp-summary').addEventListener('click', e => { + if (e.target.closest('[data-action="toggle-problems"]')) { + state.problemsOpen = !state.problemsOpen; + try { localStorage.setItem(PROBLEMS_KEY, state.problemsOpen ? '1' : '0'); } catch (_) { /* private mode */ } + renderSummary(); + return; + } const chip = e.target.closest('.tp-problem-chip'); if (!chip) return; if (chip.dataset.focusNode) focusOn('node', chip.dataset.focusNode); @@ -1422,8 +1430,11 @@ function renderSummary() { return; } box.className = `tp-summary ${problems.some(p => p.severity === 'bad') ? 'tp-summary-bad' : 'tp-summary-warn'}`; - box.innerHTML = `โš  ${problems.length} to look at - ${problems.map(p => ``).join('')}`; + // One line by default: the dashboard already lists these; open it to jump to each on the map + const open = state.problemsOpen; + box.innerHTML = ` + ${open ? '' : `${esc(problems.slice(0, 2).map(p => p.text).join(' ยท '))}${problems.length > 2 ? ' ...' : ''}`} + ${!open ? '' : problems.map(p => ``).join('')}`; } // Centre the view on a device or cable and show what is wrong with it diff --git a/templates/base.html b/templates/base.html index 5d9c8a4..dabad7c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -38,22 +38,26 @@ Dashboard - History - Cutsheet - Rack Topology + Rack + Cutsheet + More + Alert history {% if user.groups and 'admin' in user.groups %} Suppressions + {% if not maintenance %} + + {% endif %} {% endif %} @@ -85,40 +89,34 @@ Global Advanced Network
    Detection And Link Facilitator
    - + @@ -419,6 +417,20 @@ ]); } + // โ”€โ”€ More menu: close on a click elsewhere or Escape โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + document.addEventListener('click', function(e) { + document.querySelectorAll('.g-nav-more[open]').forEach(function(d) { + if (!d.contains(e.target)) d.removeAttribute('open'); + }); + }); + document.addEventListener('keydown', function(e) { + if (e.key !== 'Escape') return; + document.querySelectorAll('.g-nav-more[open]').forEach(function(d) { + d.removeAttribute('open'); + d.querySelector('summary').focus(); + }); + }); + // โ”€โ”€ Global footer + key actions โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ document.addEventListener('click', function(e) { const btn = e.target.closest('[data-action]'); diff --git a/templates/events.html b/templates/events.html index 78cdd7e..5096736 100644 --- a/templates/events.html +++ b/templates/events.html @@ -5,7 +5,7 @@

    Alert History

    -

    Every alert Gandalf raised, including the ones that cleared on their own. Resolved alerts are kept 90 days.

    +

    Every alert raised, including ones that cleared on their own; kept 90 days.

    diff --git a/templates/index.html b/templates/index.html index 1b0d63d..3938266 100644 --- a/templates/index.html +++ b/templates/index.html @@ -38,44 +38,6 @@ - -
    -
    - -
    - {{ summary.critical or 0 }} - Critical -
    -
    -
    - -
    - {{ summary.warning or 0 }} - Warning -
    -
    -
    - -
    - {{ snapshot.hosts | length }} - Hosts -
    -
    -
    - -
    - {{ recent_resolved | length }} - Resolved 24h -
    -
    -
    - {% endif %} {% if recent_resolved %} -
    -
    +
    +

    Recently Resolved

    {{ recent_resolved | length }} in last 24h -
    +
    {% for e in recent_resolved %} {%- set dot_cls = 'lt-timeline-item--green' if e.severity == 'info' else 'lt-timeline-item--dim' -%} @@ -369,7 +292,7 @@
    {% endfor %} -
    + {% endif %} {% endblock %} @@ -449,22 +372,5 @@ .observe(document.getElementById('events-table-wrap'), { childList: true, subtree: true }); initDeviceSearch(); - - // Stat card clicks: filter events table by severity - document.querySelectorAll('.lt-stat-card[data-stat-filter]').forEach(card => { - card.addEventListener('click', () => { - const sev = card.dataset.statFilter; - document.querySelectorAll('.sev-pills .pill').forEach(p => { - p.classList.remove('active'); - p.setAttribute('aria-pressed', 'false'); - }); - const matchPill = document.querySelector(`.sev-pills .pill[data-sev="${sev}"]`); - if (matchPill) { matchPill.classList.add('active'); matchPill.setAttribute('aria-pressed', 'true'); } - _filterSev = sev; - applyEventsFilter(); - document.getElementById('events-table-wrap')?.scrollIntoView({ behavior: 'smooth', block: 'start' }); - }); - card.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); card.click(); } }); - }); {% endblock %} diff --git a/templates/rack.html b/templates/rack.html index 63f2739..e71dd7a 100644 --- a/templates/rack.html +++ b/templates/rack.html @@ -5,7 +5,8 @@

    Rack

    -

    The rack front, drawn from the rack units on the cutsheet with live port state. Hover a port to light up every port on the same cable run; click it to open the port or the cable.

    +
    The rack, drawn from the cutsheet with live port state. +
    ?Hover a port to light up every port on the same cable run; click it to open the port or the cable.
    diff --git a/templates/suppressions.html b/templates/suppressions.html index 923cbab..744a215 100644 --- a/templates/suppressions.html +++ b/templates/suppressions.html @@ -6,7 +6,7 @@

    Alert Suppressions

    -

    Manage maintenance windows and per-target alert suppression rules.

    +

    Maintenance windows and alert suppression rules.

    diff --git a/templates/topology.html b/templates/topology.html index 2a1a1d7..bb11dcb 100644 --- a/templates/topology.html +++ b/templates/topology.html @@ -5,7 +5,8 @@

    Topology

    -

    Every device and cable as the switches see them right now. Drag to pan, scroll or pinch to zoom. Hover a device to trace its path to the internet and its power (on a touch screen, tap it once to trace and again to open it); click a cable for its details, or a group of unknown devices to open it.

    +
    Every device and cable, as the switches see them now. +
    ?Drag to pan; scroll or pinch to zoom. Hover a device to trace its path to the internet and its power (on a touch screen, tap once to trace and again to open it). Click a cable for its details, or a group of unknown devices to open it.
    diff --git a/tests/test_app.py b/tests/test_app.py index f40c508..e7eae05 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -95,10 +95,12 @@ class TestPagesAndNav: def test_home_section_order(self, client): html = client.get('/', headers=AUTH).get_data(as_text=True) order = [html.index(m) for m in ( - 'id="device-search"', 'Alert Queue', 'WAN / Fiber', 'g-section-title">Hosts<', - 'Device Inventory', + 'id="attention"', 'id="device-search"', 'Alert Queue', 'WAN / Fiber', 'g-section-title">Hosts<', + 'id="unifi-grid"', )] assert order == sorted(order) + # The needs-attention list replaced the stat cards + assert 'lt-stat-card' not in html def test_dashboard_topology_moved_to_its_own_page(self, client): html = client.get('/', headers=AUTH).get_data(as_text=True) @@ -822,3 +824,22 @@ class TestAttention: html = client.get('/', headers=AUTH).get_data(as_text=True) assert 'id="attention-body"' in html assert 'Global Advanced Network Detection And Link Facilitator' in html + + +class TestCalmDashboard: + def test_unused_nics_fold_into_one_line(self, client): + snap = json.dumps({'hosts': {'large1': {'ip': '10.0.0.2', 'status': 'up', 'source': 'prometheus', + 'interfaces': {'eth0': 'up', 'eth1': 'unused', 'eth2': 'unused'}}}, + 'unifi': []}) + state = dict(STATE, network_snapshot=snap) + with patch.object(gandalf.db, 'get_state', side_effect=lambda k, d=None: state.get(k, d)): + html = client.get('/', headers=AUTH).get_data(as_text=True) + assert '>eth0<' in html and '>eth1<' not in html + assert '+2 unused' in html + + def test_resolved_alerts_are_folded(self, client): + ev = {'target_name': 'large1', 'target_detail': '', 'severity': 'warning', 'event_type': 'host_down', + 'first_seen': '2026-11-15 01:00:00 UTC', 'resolved_at': '2026-11-15 02:00:00 UTC'} + with patch.object(gandalf.db, 'get_recent_resolved', return_value=[ev]): + html = client.get('/', headers=AUTH).get_data(as_text=True) + assert '
    ' in html