Dashboard: one Needs attention list from every page; say what GANDALF stands for
attention.build gathers alerts, power faults, cutsheet mismatches, UniFi port names, undocumented links, labels to print and rack overlaps into Broken now and Tidy up, each linking to where it is fixed. /api/attention serves it; the dashboard renders it and refreshes it with everything else. The header, help dialog, footer and page description spell out Global Advanced Network Detection And Link Facilitator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,7 @@ from urllib.parse import quote, urlparse
|
||||
|
||||
from flask import Flask, jsonify, make_response, redirect, render_template, request, send_file, url_for
|
||||
|
||||
import attention
|
||||
import cutsheet
|
||||
import db
|
||||
import devices
|
||||
@@ -1335,6 +1336,32 @@ def api_topology():
|
||||
return jsonify(_topology_graph(events, sheet, feeds))
|
||||
|
||||
|
||||
@app.route('/api/attention')
|
||||
@require_auth
|
||||
def api_attention():
|
||||
"""Everything that needs looking at, from every page, for the dashboard (see attention.build)."""
|
||||
return jsonify(_attention())
|
||||
|
||||
|
||||
def _attention() -> dict:
|
||||
events = db.get_active_events(limit=_PAGE_LIMIT)
|
||||
_annotate_suppressions(events, db.get_active_suppressions())
|
||||
view, racks, feeds = None, {}, []
|
||||
try:
|
||||
view = _cutsheet_view()
|
||||
feeds = db.get_power_feeds()
|
||||
all_racks = _racks(view['items'])
|
||||
for rack in all_racks:
|
||||
here = [i for i in view['items'] if not i.get('shelf')
|
||||
and (i.get('rack') or all_racks[0]['name']) == rack['name']]
|
||||
racks[rack['name']] = cutsheet.rack_layout(here, rack['units'])
|
||||
except Exception as e:
|
||||
logger.error(f'Cutsheet unavailable for the attention list: {e}')
|
||||
sheet = {'items': (view or {}).get('items') or [], 'cables': (view or {}).get('cables') or []}
|
||||
power = _topology_graph(events, sheet, feeds).get('power') or []
|
||||
return attention.build(events, power, view, racks)
|
||||
|
||||
|
||||
def _topology_graph(events: list, sheet: dict, feeds: list) -> dict:
|
||||
return topology.build_graph(
|
||||
_state_json('network_snapshot'), _state_json('link_stats'), _state_json('modem_stats'),
|
||||
|
||||
Reference in New Issue
Block a user