2026-03-01 23:03:18 -05:00
{% extends "base.html" %}
2026-11-10 20:47:14 -05:00
{% block title %}Dashboard{% endblock %}
2026-03-01 23:03:18 -05:00
{% block content %}
2026-03-02 12:43:11 -05:00
<!-- ── Status bar ──────────────────────────────────────────────────── -->
2026-03-01 23:03:18 -05:00
< div class = "status-bar" >
2026-05-10 23:53:17 -04:00
< div class = "status-chips" id = "status-chips" aria-live = "polite" aria-atomic = "true" >
2026-04-30 21:09:56 -04:00
{% if not daemon_ok %}
< span class = "chip chip-critical" > ⚠ MONITOR OFFLINE</ span >
{% endif %}
2026-03-01 23:03:18 -05:00
{% if summary.critical %}
2026-03-02 12:43:11 -05:00
< span class = "chip chip-critical" > ● {{ summary.critical }} CRITICAL</ span >
2026-03-01 23:03:18 -05:00
{% endif %}
{% if summary.warning %}
2026-03-02 12:43:11 -05:00
< span class = "chip chip-warning" > ● {{ summary.warning }} WARNING</ span >
2026-03-01 23:03:18 -05:00
{% endif %}
2026-04-30 21:09:56 -04:00
{% if daemon_ok and not summary.critical and not summary.warning %}
2026-03-02 12:43:11 -05:00
< span class = "chip chip-ok" > ✔ ALL SYSTEMS NOMINAL</ span >
2026-03-01 23:03:18 -05:00
{% endif %}
2026-11-14 15:57:58 -05:00
{% set followups = (stale_tickets | length) + (stale_alerts or 0) %}
{% if followups %}
< a class = "chip chip-warning chip-followup" href = "{{ '#followup' if stale_tickets else '#events-table-wrap' }}" > ⏳ {{ followups }} TO FOLLOW UP</ a >
{% endif %}
2026-03-01 23:03:18 -05:00
</ div >
< div class = "status-meta" >
2026-04-30 21:09:56 -04:00
< span class = "last-check" id = "last-check" data-tooltip = "Last monitor poll timestamp" data-tooltip-pos = "bottom" > {{ last_check }}</ span >
< span class = "lt-spinner lt-spinner--sm lt-spinner--cyan" id = "refresh-spinner" style = "display:none" ></ span >
< button class = "lt-btn lt-btn-ghost lt-btn-sm" data-action = "refresh" data-tooltip = "Refresh all data now" data-tooltip-pos = "bottom" > ↻ REFRESH</ button >
2026-03-01 23:03:18 -05:00
</ div >
</ div >
2026-11-15 14:56:13 -05:00
<!-- ── Needs attention: every page's problems in one place ──────────── -->
< section class = "g-section attention" id = "attention" aria-labelledby = "attention-title" >
< div class = "g-section-header" >< h2 class = "g-section-title" id = "attention-title" > Needs attention</ h2 ></ div >
< div class = "attention-groups" id = "attention-body" aria-live = "polite" >
< p class = "attention-empty" > Checking every page…</ p >
</ div >
</ section >
2026-11-04 23:40:17 -05:00
<!-- ── Device search ──────────────────────────────────────────────── -->
< section class = "g-section device-search" id = "device-search" role = "search" >
< label class = "g-section-title" for = "device-search-input" > Find a device</ label >
< div class = "lt-search" >
< input type = "search" class = "lt-input lt-search-input device-search-input" id = "device-search-input"
placeholder = "Hostname, IP, MAC, model, interface… ( / )" autocomplete = "off" spellcheck = "false"
role = "combobox" aria-expanded = "false" aria-controls = "device-search-results" aria-autocomplete = "list" >
</ div >
< div class = "device-search-results" id = "device-search-results" role = "listbox" hidden ></ div >
</ section >
2026-05-10 23:07:53 -04:00
<!-- ── Active alerts ─────────────────────────────── (above the fold) -->
< section class = "g-section" >
< div class = "g-section-header" >
< h2 class = "g-section-title" > Active Alerts</ h2 >
2026-11-18 01:36:20 -05:00
< span class = "g-section-badge g-section-badge-alert" id = "alert-count-badge"
2026-05-10 23:07:53 -04:00
{% if not summary . critical and not summary . warning %} style = "display:none" {% endif %} > {{ (summary.critical or 0) + (summary.warning or 0) }}</ span >
</ div >
< div class = "lt-toolbar" >
< div class = "lt-toolbar-left" >
< div class = "lt-search" >
< input type = "search" class = "lt-input lt-search-input" id = "events-search"
2026-05-10 23:34:16 -04:00
placeholder = "Filter by target, type, description…" autocomplete = "off"
aria-label = "Filter active alerts" >
2026-05-10 23:07:53 -04:00
</ div >
2026-05-10 23:34:16 -04:00
< div class = "sev-pills" role = "group" aria-label = "Filter by severity" >
< button type = "button" class = "pill active" data-sev = "" aria-pressed = "true" > All</ button >
< button type = "button" class = "pill" data-sev = "critical" aria-pressed = "false" > Critical</ button >
< button type = "button" class = "pill" data-sev = "warning" aria-pressed = "false" > Warning</ button >
2026-05-10 23:07:53 -04:00
</ div >
</ div >
</ div >
< div class = "lt-frame" >
< span class = "lt-frame-bl" > ╚ </ span >
< span class = "lt-frame-br" > ╝ </ span >
< div class = "lt-section-header" > Alert Queue</ div >
< div id = "events-table-wrap" >
{% if events %}
{% if total_active is defined and total_active > events|length %}
2026-11-10 23:37:56 -05:00
< div class = "pagination-notice" > Showing {{ events|length }} of {{ total_active }} active alerts. Use the search box to filter, or < a href = "/api/events?limit=1000" target = "_blank" rel = "noopener" > export all as JSON</ a ></ div >
2026-05-10 23:07:53 -04:00
{% endif %}
< div class = "lt-table-wrap" >
2026-11-18 01:36:20 -05:00
< table class = "lt-table lt-table-responsive" id = "events-table" >
2026-05-10 23:07:53 -04:00
< caption class = "lt-sr-only" > Active network alerts</ caption >
< thead >
< tr >
< th data-tooltip = "Alert severity level" data-tooltip-pos = "bottom" > Sev</ th >
< th > Type</ th >
< th > Target</ th >
< th > Detail</ th >
< th > Description</ th >
< th data-tooltip = "When this alert was first raised" data-tooltip-pos = "bottom" > First Seen</ th >
< th data-tooltip = "Most recent check failure" data-tooltip-pos = "bottom" > Last Seen</ th >
< th data-tooltip = "Consecutive check failures since first seen" data-tooltip-pos = "bottom" > Failures</ th >
< th > Ticket</ th >
< th > Actions</ th >
</ tr >
</ thead >
< tbody >
{% for e in events %}
{% if e.severity != 'info' %}
2026-05-10 23:11:15 -04:00
< tr class = "row-{{ e.severity }}{% if e.is_suppressed %} row-suppressed{% endif %}" >
2026-11-18 01:36:20 -05:00
< td data-label = "Sev" >
2026-05-10 23:11:15 -04:00
< span class = "lt-badge badge-{{ e.severity }}" > {{ e.severity }}</ span >
{% if e.is_suppressed %}< span class = "lt-badge badge-suppressed" title = "Alert suppressed" > 🔕 sup</ span > {% endif %}
2026-11-14 15:57:58 -05:00
{% if e.stale_days is not none %}< span class = "lt-badge badge-stale" title = "Active for {{ e.stale_days }} days with no fix yet" > ⏳ {{ e.stale_days }}d</ span > {% endif %}
{% if e.ticket_closed %}< span class = "lt-badge badge-ticket-closed" title = "Ticket #{{ e.ticket_id }} was closed in Tinker, but this alert is still active" > ticket closed</ span > {% endif %}
2026-05-10 23:11:15 -04:00
</ td >
2026-11-18 01:36:20 -05:00
< td data-label = "Type" > {{ e.event_type | replace('_', ' ') }}</ td >
< td data-label = "Target" >< strong > {{ e.target_name }}</ strong ></ td >
< td data-label = "Detail" > {{ e.target_detail or '-' }}</ td >
< td data-label = "Description" class = "desc-cell" title = "{{ e.description | e }}" > {{ e.description | truncate(60) }}</ td >
< td data-label = "First seen" class = "ts-cell" title = "{{ e.first_seen }}" >
2026-05-10 23:07:53 -04:00
< span class = "event-age" data-ts = "{{ e.first_seen }}" > {{ e.first_seen }}</ span >
</ td >
2026-11-18 01:36:20 -05:00
< td data-label = "Last seen" class = "ts-cell" title = "{{ e.last_seen }}" >
2026-05-10 23:07:53 -04:00
< span class = "event-age" data-ts = "{{ e.last_seen }}" > {{ e.last_seen }}</ span >
</ td >
2026-11-18 01:36:20 -05:00
< td data-label = "Failures" > {{ e.consecutive_failures }}</ td >
< td data-label = "Ticket" >
2026-05-10 23:07:53 -04:00
{% if e.ticket_id %}
< a href = "{{ config.ticket_api.web_url }}{{ e.ticket_id }}" target = "_blank"
class = "ticket-link" > #{{ e.ticket_id }}</ a >
2026-11-10 23:37:56 -05:00
{% else %}-{% endif %}
2026-05-10 23:07:53 -04:00
</ td >
2026-11-18 01:36:20 -05:00
< td data-label = "Actions" >
2026-05-10 23:07:53 -04:00
< button class = "lt-btn lt-btn-ghost lt-btn-sm btn-suppress"
data-sup-type = "{{ 'unifi_device' if e.event_type == 'unifi_device_offline' else 'interface' if e.event_type == 'interface_down' else 'host' }}"
data-sup-name = "{{ e.target_name }}"
data-sup-detail = "{{ e.target_detail or '' }}"
title = "Suppress" aria-label = "Suppress alert for {{ e.target_name }}" > 🔕</ button >
</ td >
</ tr >
{% endif %}
{% else %}
< tr >< td colspan = "10" >
< div class = "lt-empty-state lt-empty-state--sm" >
< div class = "lt-empty-state-icon" > ✔</ div >
< div class = "lt-empty-state-title" > No active alerts</ div >
</ div >
</ td ></ tr >
{% endfor %}
</ tbody >
</ table >
</ div >
{% else %}
< div class = "lt-empty-state lt-empty-state--sm" >
< div class = "lt-empty-state-icon" > ✔</ div >
< div class = "lt-empty-state-title" > No active alerts</ div >
</ div >
{% endif %}
</ div > <!-- /#events-table-wrap -->
</ div > <!-- /.lt-frame -->
</ section >
2026-11-14 15:57:58 -05:00
<!-- ── Needs follow-up: tickets left open after their alert cleared ── -->
< section class = "g-section" id = "followup" {% if not stale_tickets %} hidden {% endif %} >
< div class = "g-section-header" >
< h2 class = "g-section-title" > Needs Follow-up</ h2 >
2026-11-18 01:36:20 -05:00
< span class = "g-section-badge g-section-badge-alert" id = "followup-badge" > {{ stale_tickets | length }}</ span >
2026-11-14 15:57:58 -05:00
</ div >
< p class = "followup-intro" > These tickets are still open in Tinker, but their alert cleared over a day ago. Close them if the problem is fixed.</ p >
< div class = "lt-frame" >
< span class = "lt-frame-bl" > ╚ </ span >
< span class = "lt-frame-br" > ╝ </ span >
< div class = "lt-section-header" > Tickets Left Open</ div >
< div class = "lt-table-wrap" >
< table class = "lt-table" id = "followup-table" >
< caption class = "lt-sr-only" > Tickets still open after their alert cleared</ caption >
< thead >
< tr >< th > Ticket</ th >< th > Target</ th >< th > Alert</ th >< th > Cleared</ th >< th > Alerts on ticket</ th ></ tr >
</ thead >
< tbody >
{% for t in stale_tickets %}
< tr >
< td >< a href = "{{ config.ticket_api.web_url }}{{ t.ticket_id }}" target = "_blank" rel = "noopener" class = "ticket-link" > #{{ t.ticket_id }}</ a ></ td >
< td >< strong > {{ t.target_name }}</ strong ></ td >
< td > {{ t.event_type | replace('_', ' ') }}{% if t.target_detail %} < span class = "lt-text-muted" > {{ t.target_detail }}</ span > {% endif %}</ td >
< td class = "ts-cell" title = "{{ t.cleared_at }}" >< span class = "event-age" data-ts = "{{ t.cleared_at }}" > {{ t.cleared_at }}</ span ></ td >
< td > {{ t.events }}</ td >
</ tr >
{% endfor %}
</ tbody >
</ table >
</ div >
</ div >
</ section >
2026-11-04 23:40:17 -05:00
<!-- ── WAN / fiber ──────────────────────────────────────────────────── -->
{% include "_modem_panel.html" %}
<!-- ── Hosts ────────────────────────────────────────────────────────── -->
< section class = "g-section" >
< div class = "g-section-header" >
< h2 class = "g-section-title" > Hosts</ h2 >
</ div >
< div class = "host-grid" id = "host-grid" >
{%- set has_global_sup = suppressions | selectattr('target_type', 'equalto', 'all') | list | length > 0 -%}
{% for name, host in snapshot.hosts.items() %}
{% set suppressed = suppressions | selectattr('target_name', 'equalto', name) | list %}
< div class = "host-card host-card-{{ host.status }}" data-host = "{{ name }}" >
< div class = "host-card-header" >
< div class = "host-name-row" >
< span class = "host-status-dot dot-{{ host.status }}" ></ span >
< a class = "host-name device-link" href = "{{ url_for('device_page', name=name) }}" > {{ name }}</ a >
{% if suppressed or has_global_sup %}
< span class = "badge-suppressed" title = "Suppressed" > 🔕</ span >
{% endif %}
2026-11-15 15:04:34 -05:00
< button class = "lt-btn lt-btn-ghost lt-btn-sm btn-suppress host-suppress"
data-sup-type = "host" data-sup-name = "{{ name }}" data-sup-detail = ""
title = "Suppress alerts for {{ name }}" aria-label = "Suppress alerts for {{ name }}" > 🔕</ button >
2026-11-04 23:40:17 -05:00
</ div >
< div class = "host-meta" >
< span class = "host-ip" > {{ host.ip }}</ span >
2026-11-18 01:36:20 -05:00
{% if host.source != 'prometheus' %}< span class = "host-source source-{{ host.source }}" > {{ host.source }}</ span > {% endif %}
2026-11-04 23:40:17 -05:00
</ div >
</ div >
{% if host.interfaces %}
2026-11-15 15:04:34 -05:00
{% set in_use = host.interfaces | dictsort | rejectattr(1, 'equalto', 'unused') | list %}
{% set unused = (host.interfaces | length) - (in_use | length) %}
2026-11-04 23:40:17 -05:00
< div class = "iface-list" >
2026-11-15 15:04:34 -05:00
{% for iface, state in in_use %}
2026-11-04 23:40:17 -05:00
< div class = "iface-row" >
< span class = "iface-dot dot-{{ state }}" ></ span >
< span class = "iface-name" > {{ iface }}</ span >
< span class = "iface-state state-{{ state }}" > {{ state }}</ span >
</ div >
{% endfor %}
2026-11-15 15:04:34 -05:00
{% if unused %}< div class = "iface-unused" > +{{ unused }} unused</ div > {% endif %}
2026-11-04 23:40:17 -05:00
</ div >
{% else %}
< div class = "host-ping-note" > {% if host.source == 'ping' %}ping-only / no node_exporter{% else %}no metrics from node_exporter{% endif %}</ div >
{% endif %}
</ div >
{% else %}
< div class = "lt-empty-state lt-empty-state--sm" >
< div class = "lt-empty-state-icon" > ⌛</ div >
< div class = "lt-empty-state-title" > No host data yet</ div >
< div class = "lt-empty-state-body" > The monitor daemon may still be starting up.</ div >
</ div >
{% endfor %}
</ div >
</ section >
<!-- ── UniFi devices ────────────────────────────────────────────────── -->
{% if snapshot.unifi %}
2026-04-18 21:01:20 -04:00
< section class = "g-section" >
< div class = "g-section-header" >
2026-11-04 23:40:17 -05:00
< h2 class = "g-section-title" > UniFi Devices</ h2 >
</ div >
2026-11-15 15:04:34 -05:00
< ul class = "unifi-grid" id = "unifi-grid" >
{% for d in snapshot.unifi %}
< li class = "unifi-chip{% if not d.connected %} unifi-chip-down{% endif %}" >
< span class = "dot-{{ 'up' if d.connected else 'down' }}" title = "{{ 'Online' if d.connected else 'Offline' }}" ></ span >
< a class = "device-link unifi-chip-name" href = "{{ url_for('device_page', name=d.name) }}" > {{ d.name }}</ a >
< span class = "unifi-chip-model" > {{ d.model }}</ span >
{% if not d.connected %}
< button class = "lt-btn lt-btn-ghost lt-btn-sm btn-suppress" data-sup-type = "unifi_device"
data-sup-name = "{{ d.name }}" data-sup-detail = "" title = "Suppress alerts for {{ d.name }}"
aria-label = "Suppress alerts for {{ d.name }}" > 🔕</ button >
{% endif %}
</ li >
{% endfor %}
</ ul >
2026-11-04 23:40:17 -05:00
</ section >
{% endif %}
2026-03-14 21:48:40 -04:00
<!-- ── Recently Resolved (last 24h) ───────────────────────────────── -->
{% if recent_resolved %}
2026-11-15 15:04:34 -05:00
< details class = "g-section resolved-fold" >
< summary class = "g-section-header" >
2026-04-18 21:01:20 -04:00
< h2 class = "g-section-title" > Recently Resolved</ h2 >
< span class = "g-section-badge g-section-badge-resolved" > {{ recent_resolved | length }} in last 24h</ span >
2026-11-15 15:04:34 -05:00
</ summary >
2026-04-30 22:19:50 -04:00
< div class = "lt-timeline" >
{% for e in recent_resolved %}
{%- set dot_cls = 'lt-timeline-item--green' if e.severity == 'info' else 'lt-timeline-item--dim' -%}
< div class = "lt-timeline-item {{ dot_cls }}" >
< div class = "lt-timeline-meta" >
< strong class = "lt-timeline-actor" > {{ e.target_name }}</ strong >
{% if e.target_detail %}< span > · {{ e.target_detail }}</ span > {% endif %}
< span class = "lt-timeline-time event-age" data-ts = "{{ e.resolved_at }}" > {{ e.resolved_at }}</ span >
</ div >
< div class = "lt-timeline-body" >
{{ e.event_type | replace('_', ' ') }}
·
< span class = "lt-badge badge-resolved" > {{ e.severity }}</ span >
· duration
2026-11-10 23:37:56 -05:00
< span class = "event-duration" data-first = "{{ e.first_seen }}" data-resolved = "{{ e.resolved_at }}" > -</ span >
2026-04-30 22:19:50 -04:00
</ div >
</ div >
{% endfor %}
2026-03-14 21:48:40 -04:00
</ div >
2026-11-15 15:04:34 -05:00
</ details >
2026-03-14 21:48:40 -04:00
{% endif %}
2026-03-01 23:03:18 -05:00
{% endblock %}
{% block scripts %}
< script >
2026-11-04 23:40:17 -05:00
// Load once even when auto-refresh is set to Off
refreshModem ();
2026-11-15 14:56:13 -05:00
refreshAttention ();
2026-11-04 23:40:17 -05:00
2026-04-30 21:33:02 -04:00
// Start auto-refresh using saved settings interval (default 30 s)
2026-05-13 13:19:44 -04:00
const _savedInterval = window . gandalfSettings ? . refreshInterval ?? 30 ;
2026-04-30 21:33:02 -04:00
if ( _savedInterval > 0 ) lt . autoRefresh . start ( refreshAll , _savedInterval * 1000 );
// When settings change, restart auto-refresh with new interval
window . onGandalfSettingsChanged = function ( s ) {
lt . autoRefresh . stop ();
if ( s . refreshInterval > 0 ) lt . autoRefresh . start ( refreshAll , s . refreshInterval * 1000 );
};
2026-03-14 21:46:11 -04:00
function updateEventAges () {
document . querySelectorAll ( '.event-age[data-ts]' ). forEach ( el => {
2026-04-18 23:46:44 -04:00
el . textContent = lt . time . ago ( _toIso ( el . dataset . ts ));
2026-03-14 21:46:11 -04:00
});
}
updateEventAges ();
setInterval ( updateEventAges , 60000 );
2026-03-14 21:48:40 -04:00
// ── Event duration (resolved_at - first_seen) ──────────────────
function fmtDuration ( firstTs , resolvedTs ) {
2026-11-10 23:37:56 -05:00
if ( ! firstTs || ! resolvedTs ) return '-' ;
2026-04-18 23:46:44 -04:00
const secs = Math . floor (( new Date ( _toIso ( resolvedTs )) - new Date ( _toIso ( firstTs ))) / 1000 );
2026-11-10 23:37:56 -05:00
if ( secs < 0 ) return '-' ;
2026-03-14 21:48:40 -04:00
if ( secs < 60 ) return ` ${ secs } s` ;
if ( secs < 3600 ) return ` ${ Math . floor ( secs / 60 ) } m` ;
if ( secs < 86400 ) return ` ${ Math . floor ( secs / 3600 ) } h ${ Math . floor (( secs % 3600 ) / 60 ) } m` ;
return ` ${ Math . floor ( secs / 86400 ) } d` ;
}
document . querySelectorAll ( '.event-duration[data-first][data-resolved]' ). forEach ( el => {
el . textContent = fmtDuration ( el . dataset . first , el . dataset . resolved );
});
2026-04-19 23:35:02 -04:00
// ── Events table filter ────────────────────────────────────────
let _filterSev = '' ;
function applyEventsFilter () {
const q = ( document . getElementById ( 'events-search' ) ? . value || '' ). toLowerCase ();
const tbody = document . querySelector ( '#events-table tbody' );
if ( ! tbody ) return ;
tbody . querySelectorAll ( 'tr' ). forEach ( row => {
if ( row . children . length < 3 ) { row . style . display = '' ; return ; }
const sevMatch = ! _filterSev || row . classList . contains ( `row- ${ _filterSev } ` );
const textMatch = ! q || row . textContent . toLowerCase (). includes ( q );
row . style . display = ( sevMatch && textMatch ) ? '' : 'none' ;
});
}
document . getElementById ( 'events-search' ) ? . addEventListener ( 'input' , applyEventsFilter );
document . querySelector ( '.sev-pills' ) ? . addEventListener ( 'click' , e => {
const pill = e . target . closest ( '.pill[data-sev]' );
if ( ! pill ) return ;
2026-05-10 23:34:16 -04:00
document . querySelectorAll ( '.sev-pills .pill' ). forEach ( p => {
p . classList . remove ( 'active' );
p . setAttribute ( 'aria-pressed' , 'false' );
});
2026-04-19 23:35:02 -04:00
pill . classList . add ( 'active' );
2026-05-10 23:34:16 -04:00
pill . setAttribute ( 'aria-pressed' , 'true' );
2026-04-19 23:35:02 -04:00
_filterSev = pill . dataset . sev ;
applyEventsFilter ();
});
// Re-apply filter after dynamic table updates
new MutationObserver ( applyEventsFilter )
. observe ( document . getElementById ( 'events-table-wrap' ), { childList : true , subtree : true });
2026-04-30 22:19:50 -04:00
2026-11-04 23:40:17 -05:00
initDeviceSearch ();
2026-03-01 23:03:18 -05:00
</ script >
{% endblock %}