feat(admin): SFM + SLMM diagnostic pages under Developer settings

New /admin/sfm page (linked from Settings → Developer):
- Health banner — green/red with version + last-checked timestamp
- Connection panel — shows SFM_BASE_URL terra-view is configured with
- 4 KPI tiles — known units, total events, stale monitor_log rows,
  stale ach_sessions rows (the deprecated tables from the paused
  Python-ACH experiment, useful for confirming nothing's growing them)
- Per-unit roll-up table — serial, last_seen, event count, stale
  per-unit counts, sourced from SFM's /db/units
- Recent events with forwarding latency — color-coded gap between
  the event's recorded timestamp and SFM ingest time, so operators
  can spot watchers that are forwarding stale files (e.g. after a
  jobsite outage)
- Raw API tester — text input + GET button against any /api/sfm/*
  path, response rendered as prettified JSON

New /admin/slmm page — same layout, stripped down to health + connection
+ raw API tester.  For per-device SLM control the existing
/sound-level-meters dashboard remains the right entry point.

Backend (backend/routers/admin_modules.py):
- GET /admin/sfm, GET /admin/slmm — HTML pages
- GET /api/admin/sfm/overview — single aggregated probe that returns
  health, units, last 25 events with computed latency, stale-table
  counts, cache stats.  Tolerant of partial failures: any sub-fetch
  error is captured into errors{} so a flaky SFM endpoint doesn't
  break the whole page
- GET /api/admin/slmm/overview — health + connection info only for now

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-14 17:53:43 +00:00
parent 155f0b007a
commit 904ff04440
5 changed files with 641 additions and 1 deletions
+27 -1
View File
@@ -561,7 +561,33 @@
</a>
</div>
{# SFM Admin moved back to main nav as "Events" — see sidebar. #}
<!-- SFM Admin -->
<div class="flex items-center justify-between p-4 bg-gray-50 dark:bg-slate-700 rounded-lg">
<div>
<div class="font-medium text-gray-900 dark:text-white">SFM Admin</div>
<div class="text-sm text-gray-500 dark:text-gray-400 mt-0.5">
Diagnose the SFM backend — health, per-unit event counts, forwarding latency, stale tables, raw API probe.
</div>
</div>
<a href="/admin/sfm"
class="ml-6 px-4 py-2 bg-seismo-orange hover:bg-orange-600 text-white text-sm font-medium rounded-lg transition-colors whitespace-nowrap">
Open
</a>
</div>
<!-- SLMM Admin -->
<div class="flex items-center justify-between p-4 bg-gray-50 dark:bg-slate-700 rounded-lg">
<div>
<div class="font-medium text-gray-900 dark:text-white">SLMM Admin</div>
<div class="text-sm text-gray-500 dark:text-gray-400 mt-0.5">
Diagnose the SLMM backend — health check + raw API probe. For per-device control use the SLM dashboard.
</div>
</div>
<a href="/admin/slmm"
class="ml-6 px-4 py-2 bg-seismo-orange hover:bg-orange-600 text-white text-sm font-medium rounded-lg transition-colors whitespace-nowrap">
Open
</a>
</div>
{# Metadata Backfill + Project Tidy moved to Tools (they're
operator workflows, not admin/dev surfaces). Find them