feat(dashboard): merge top summary strip + Status widget into one Overview
Operator chose a single canonical summary. Repurpose the status_overview widget into 'Overview' (host count + monitor up/down/pending + Alerts link; key kept so existing dashboards upgrade in place) and remove the redundant fixed top strip from the dashboard view. Drops _get_summary_stats and its now-unused PingResult/DnsResult imports (rule 22). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
from __future__ import annotations
|
||||
from quart import Blueprint, current_app, render_template, request
|
||||
from sqlalchemy import func, select
|
||||
|
||||
from steward.auth.middleware import require_role
|
||||
from steward.core.status import collect_status, sparkline_svg
|
||||
from steward.models.hosts import Host
|
||||
from steward.models.users import UserRole
|
||||
|
||||
status_bp = Blueprint("status", __name__, url_prefix="/status")
|
||||
@@ -40,12 +42,17 @@ async def rows():
|
||||
@status_bp.get("/widget")
|
||||
@require_role(UserRole.viewer)
|
||||
async def widget():
|
||||
"""HTMX dashboard widget — compact up/down/pending summary + problem list."""
|
||||
"""HTMX dashboard 'Overview' widget — the single at-a-glance summary that
|
||||
replaced the old fixed top strip: host count + monitor up/down/pending +
|
||||
problem list + an alerts link."""
|
||||
async with current_app.db_sessionmaker() as db:
|
||||
entries = await collect_status(db)
|
||||
total_hosts = (await db.execute(
|
||||
select(func.count()).select_from(Host))).scalar()
|
||||
up, down, pending = _summarize(entries)
|
||||
return await render_template(
|
||||
"status/widget.html",
|
||||
entries=entries, up=up, down=down, pending=pending,
|
||||
total_hosts=total_hosts,
|
||||
widget_id=request.args.get("wid", "0"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user