From 711ef41e5f932e49a6176d4fad58970e33b8bc5b Mon Sep 17 00:00:00 2001 From: serversdown Date: Wed, 10 Jun 2026 18:59:42 +0000 Subject: [PATCH] feat(slm): auto-populate live panel from cache, per-unit refresh, fix badge overlap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Live Measurements panel no longer sits blank until you click Start Live Stream: - On open it fills the KPI cards from the cached /status snapshot (lp/leq/lmax/ L1/L10) and backfills the chart from the /history DOD trail — both pure cache reads, no device hit. - Shows measuring state (● Measuring / ■ Stopped) and a freshness stamp ("as of 2:14 PM (12m ago)") that turns amber + "cached" when stale, so a cached value is never mistaken for a live reading. - Polls the cache every 15s while open so the cards stay current without opening a device stream; Start Live Stream takes over (and no longer wipes the backfilled trail). Chart cap raised 60 -> 600 so the 2h backfill isn't truncated. Refresh buttons (on-demand, user-initiated single device read via GET /live, which also updates the cache): - one per device row in the list, and one in the panel header. Spinner while in flight; toast on success/failure; reloads the list so badges + last-check update. Layout fix: the status badge (Measuring/Active/Idle/Benched) was rendered at the top-right of the card, colliding with the absolutely-positioned chart/gear icons. Moved it to the bottom meta row next to "Last check", padded the card content clear of the action icons, and added the refresh icon to that group. Co-Authored-By: Claude Opus 4.8 --- templates/partials/slm_device_list.html | 66 ++++--- templates/sound_level_meters.html | 239 +++++++++++++++++++++--- 2 files changed, 253 insertions(+), 52 deletions(-) diff --git a/templates/partials/slm_device_list.html b/templates/partials/slm_device_list.html index 117decb..810bd0f 100644 --- a/templates/partials/slm_device_list.html +++ b/templates/partials/slm_device_list.html @@ -2,7 +2,14 @@ {% if units %} {% for unit in units %}
-
+
+
- -
-
-
- {{ unit.id }} - {% if unit.slm_model %} - • {{ unit.slm_model }} - {% endif %} -
- {% if unit.address %} -

{{ unit.address }}

- {% elif unit.location %} -

{{ unit.location }}

+
+
+
+ {{ unit.id }} + {% if unit.slm_model %} + • {{ unit.slm_model }} {% endif %}
- - {% if unit.retired %} - Retired - {% elif not unit.deployed %} - Benched - {% elif unit.measurement_state == "Start" %} - Measuring - {% elif unit.is_recent %} - Active - {% else %} - Idle + {% if unit.address %} +

{{ unit.address }}

+ {% elif unit.location %} +

{{ unit.location }}

{% endif %}
-
diff --git a/templates/sound_level_meters.html b/templates/sound_level_meters.html index 3055db9..360ddbd 100644 --- a/templates/sound_level_meters.html +++ b/templates/sound_level_meters.html @@ -51,13 +51,31 @@