feat(dashboard): a curated default layout, merged duplicate widgets, a labelled Overview (#5213)
CI / lint (push) Successful in 2s
CI / integration (push) Successful in 50s
CI / unit (push) Failing after 1m16s
CI / publish (push) Skipped

- New installs start from widgets.RECOMMENDED, packed row by row for the
  enabled plugins; the edit drawer can reset a dashboard to it.
- Host Agent — Resources folds into Hosts — Overview (which gains load 1m),
  UniFi — Devices into UniFi — Overview; migration 0032 moves existing
  dashboards onto the survivors.
- The Overview labels what it counts (hosts, monitors up/down/pending,
  alerts firing) and lists firing alerts and down monitors with since-times.
- Uptime polls every 5 minutes (poll_seconds) instead of every cycle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 00:42:04 -04:00
co-authored by Claude Opus 5.5
parent 5ec930bf76
commit 5492336f1e
18 changed files with 381 additions and 309 deletions
+15 -2
View File
@@ -2,7 +2,7 @@ from __future__ import annotations
from quart import Blueprint, current_app, render_template, request
from sqlalchemy import func, select
from steward.alerts.service import active_alerts
from steward.alerts.service import active_alerts, alert_label
from steward.auth.middleware import require_role
from steward.core.status import collect_status, sparkline_svg
from steward.models.hosts import Host
@@ -53,10 +53,23 @@ async def widget():
entries = await collect_status(db)
total_hosts = (await db.execute(
select(func.count()).select_from(Host))).scalar()
alerts = await active_alerts(db)
up, down, pending = _summarize(entries)
return await render_template(
"status/widget.html",
entries=entries, up=up, down=down, pending=pending,
total_hosts=total_hosts,
total_hosts=total_hosts, alerts=overview_alerts(alerts),
widget_id=request.args.get("wid", "0"),
)
def overview_alerts(alerts) -> list[dict]:
"""The Overview's alert lines: breaching or silent first, then those
someone has taken; each {rule, label, since}."""
order = {"firing": 0, "no_data": 1, "pending": 2, "acknowledged": 3}
rows = []
for state, rule in alerts:
label = alert_label(state)
since = state.no_data_since if label == "no_data" else state.last_transition_at
rows.append({"rule": rule, "label": label, "since": since})
return sorted(rows, key=lambda r: order.get(r["label"], 9))