Add stat cards, lt-frame alert queue, and timeline for resolved alerts
- Four lt-stat-card widgets (Critical, Warning, Hosts, Resolved 24h) below the status bar; Critical card pulses red when count > 0 - Clicking Critical or Warning card filters the events table by severity - Events table wrapped in lt-frame with ASCII corner ornaments and lt-section-header; filter bar moved to lt-toolbar with lt-search icon - Recently Resolved table replaced with lt-timeline component - updateStatusBar() and updateHostGrid() keep stat card values live Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,6 +89,14 @@ function updateStatusBar(summary, lastCheck, daemonOk) {
|
||||
alertBadge.style.display = total ? '' : 'none';
|
||||
}
|
||||
|
||||
// Update stat cards
|
||||
const scCrit = document.getElementById('stat-critical-val');
|
||||
const scWarn = document.getElementById('stat-warning-val');
|
||||
if (scCrit) scCrit.textContent = critCount;
|
||||
if (scWarn) scWarn.textContent = warnCount;
|
||||
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) {
|
||||
@@ -112,6 +120,9 @@ function updateStatusBar(summary, lastCheck, daemonOk) {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -995,6 +995,17 @@
|
||||
.diag-pulse-link a { color: var(--cyan); }
|
||||
.diag-pulse-link a:hover { text-shadow: var(--glow-cyan); }
|
||||
|
||||
/* ── Stat card alert variant (pulsing border when critical > 0) ─── */
|
||||
.lt-stat-card--alert {
|
||||
border-color: var(--red) !important;
|
||||
box-shadow: 0 0 8px rgba(255,45,85,.25) !important;
|
||||
animation: topo-pulse-down 2s ease-in-out infinite;
|
||||
}
|
||||
.lt-stat-card--alert::before { background: var(--red); box-shadow: var(--glow-red); }
|
||||
|
||||
/* ── lt-frame inside g-section: no extra bottom margin ────────────── */
|
||||
.g-section > .lt-frame { margin-bottom: 0; }
|
||||
|
||||
/* ── Responsive ───────────────────────────────────────────────────── */
|
||||
@media (max-width: 768px) {
|
||||
.host-grid { grid-template-columns: 1fr; }
|
||||
|
||||
+85
-38
@@ -26,6 +26,42 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── Stats summary cards ──────────────────────────────────────────── -->
|
||||
<div class="lt-stats-grid">
|
||||
<div class="lt-stat-card{% if summary.critical %} lt-stat-card--alert{% endif %}"
|
||||
id="stat-critical" role="button" tabindex="0"
|
||||
data-stat-filter="critical" aria-label="{{ summary.critical or 0 }} critical alerts">
|
||||
<span class="lt-stat-icon" aria-hidden="true" style="color:var(--red);text-shadow:var(--glow-red)">●</span>
|
||||
<div class="lt-stat-info">
|
||||
<span class="lt-stat-value" id="stat-critical-val" style="color:var(--red)">{{ summary.critical or 0 }}</span>
|
||||
<span class="lt-stat-label">Critical</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lt-stat-card"
|
||||
id="stat-warning" role="button" tabindex="0"
|
||||
data-stat-filter="warning" aria-label="{{ summary.warning or 0 }} warning alerts">
|
||||
<span class="lt-stat-icon" aria-hidden="true" style="color:var(--amber)">●</span>
|
||||
<div class="lt-stat-info">
|
||||
<span class="lt-stat-value" id="stat-warning-val" style="color:var(--amber)">{{ summary.warning or 0 }}</span>
|
||||
<span class="lt-stat-label">Warning</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lt-stat-card" id="stat-hosts" aria-label="Monitored hosts">
|
||||
<span class="lt-stat-icon" aria-hidden="true" style="color:var(--cyan)">⬡</span>
|
||||
<div class="lt-stat-info">
|
||||
<span class="lt-stat-value" id="stat-hosts-val" style="color:var(--cyan)">{{ snapshot.hosts | length }}</span>
|
||||
<span class="lt-stat-label">Hosts</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lt-stat-card" id="stat-resolved" aria-label="{{ recent_resolved | length }} alerts resolved in last 24 hours">
|
||||
<span class="lt-stat-icon" aria-hidden="true" style="color:var(--green);text-shadow:var(--glow)">✔</span>
|
||||
<div class="lt-stat-info">
|
||||
<span class="lt-stat-value" id="stat-resolved-val" style="color:var(--green)">{{ recent_resolved | length }}</span>
|
||||
<span class="lt-stat-label">Resolved 24h</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── Network topology + host grid ───────────────────────────────── -->
|
||||
<section class="g-section">
|
||||
<div class="g-section-header">
|
||||
@@ -282,19 +318,25 @@
|
||||
<h2 class="g-section-title">Active Alerts</h2>
|
||||
<span class="g-section-badge" id="alert-count-badge"
|
||||
{% if not summary.critical and not summary.warning %}style="display:none"{% endif %}>{{ (summary.critical or 0) + (summary.warning or 0) }}</span>
|
||||
<div class="g-section-actions">
|
||||
<div class="events-filter-bar">
|
||||
<input type="search" class="lt-input lt-input-sm" id="events-search"
|
||||
</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"
|
||||
placeholder="Filter by target, type, description…" autocomplete="off">
|
||||
<div class="sev-pills">
|
||||
<button type="button" class="pill active" data-sev="">All</button>
|
||||
<button type="button" class="pill" data-sev="critical">Critical</button>
|
||||
<button type="button" class="pill" data-sev="warning">Warning</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sev-pills">
|
||||
<button type="button" class="pill active" data-sev="">All</button>
|
||||
<button type="button" class="pill" data-sev="critical">Critical</button>
|
||||
<button type="button" class="pill" data-sev="warning">Warning</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="events-table-wrap">
|
||||
<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 %}
|
||||
<div class="pagination-notice">Showing {{ events|length }} of {{ total_active }} active alerts — <a href="/api/events?limit=1000">view all via API</a></div>
|
||||
@@ -364,7 +406,8 @@
|
||||
<div class="lt-empty-state-title">No active alerts</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div><!-- /#events-table-wrap -->
|
||||
</div><!-- /.lt-frame -->
|
||||
</section>
|
||||
|
||||
<!-- ── Recently Resolved (last 24h) ───────────────────────────────── -->
|
||||
@@ -374,34 +417,24 @@
|
||||
<h2 class="g-section-title">Recently Resolved</h2>
|
||||
<span class="g-section-badge g-section-badge-resolved">{{ recent_resolved | length }} in last 24h</span>
|
||||
</div>
|
||||
<div class="lt-table-wrap">
|
||||
<table class="lt-table">
|
||||
<caption class="lt-sr-only">Recently resolved alerts</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sev</th>
|
||||
<th>Type</th>
|
||||
<th>Target</th>
|
||||
<th>Detail</th>
|
||||
<th>Resolved</th>
|
||||
<th>Duration</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for e in recent_resolved %}
|
||||
<tr class="row-resolved">
|
||||
<td><span class="lt-badge badge-resolved">{{ e.severity }}</span></td>
|
||||
<td>{{ e.event_type | replace('_', ' ') }}</td>
|
||||
<td><strong>{{ e.target_name }}</strong></td>
|
||||
<td>{{ e.target_detail or '–' }}</td>
|
||||
<td class="ts-cell">
|
||||
<span class="event-age" data-ts="{{ e.resolved_at }}">{{ e.resolved_at }}</span>
|
||||
</td>
|
||||
<td class="ts-cell event-duration" data-first="{{ e.first_seen }}" data-resolved="{{ e.resolved_at }}">–</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<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
|
||||
<span class="event-duration" data-first="{{ e.first_seen }}" data-resolved="{{ e.resolved_at }}">–</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
@@ -529,5 +562,19 @@
|
||||
// Re-apply filter after dynamic table updates
|
||||
new MutationObserver(applyEventsFilter)
|
||||
.observe(document.getElementById('events-table-wrap'), { childList: true, subtree: true });
|
||||
|
||||
// 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'));
|
||||
const matchPill = document.querySelector(`.sev-pills .pill[data-sev="${sev}"]`);
|
||||
if (matchPill) matchPill.classList.add('active');
|
||||
_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(); } });
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user