admin_events: wire shared event-detail modal into the page

/admin/events previously rendered events as a flat table with no
detail view — admins had to copy an event ID and open the standalone
SFM webapp on port 8200 to see the chart, PDF, or sidecar metadata.

Adds:
- {% include 'partials/event_detail_modal.html' %} + script tag at
  the bottom of the page (mirrors the pattern in /sfm, /unit/{id},
  /projects/.../nrl/...).
- onclick on the table <tr> opens the modal via showEventDetail(id).
- event.stopPropagation() on the checkbox <td> so selection clicks
  don't also open the modal.
- Listener for the 'sfm-event-review-saved' CustomEvent fired by
  event-modal.js — reloads the table so any FT-flag changes made in
  the modal's review form land on the row without a full reload.

Also propagates the same listener pattern to the three other pages
that already include the modal (sfm.html, unit_detail.html,
vibration_location_detail.html) — they call their respective
loadEvents / loadUnitEvents / loadLocationEvents on the fire.  Keeps
the refresh-on-save UX consistent across every page that hosts the
modal.

Phase 1 of the SFM-into-Terra-View integration is now complete:
chart, PDF preview, .TXT download, review form, and per-unit + admin
event browsing are all native in Terra-View.  The standalone SFM
webapp on port 8200 remains as a diagnostic fallback but operators
no longer need to bounce to it for routine workflows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-29 01:06:44 +00:00
parent 4b2bb9a9c9
commit 2905a327be
4 changed files with 32 additions and 2 deletions
+13 -2
View File
@@ -192,8 +192,9 @@ function renderTable() {
? '<span class="px-2 py-0.5 rounded text-xs bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300">FT</span>'
: '';
const checked = _selected.has(ev.id) ? 'checked' : '';
return `<tr class="hover:bg-gray-50 dark:hover:bg-slate-700/50">
<td class="px-3 py-2"><input type="checkbox" class="row-check" data-event-id="${_esc(ev.id)}" ${checked} onchange="onRowCheck(this)"></td>
return `<tr class="hover:bg-gray-50 dark:hover:bg-slate-700/50 cursor-pointer"
onclick="showEventDetail('${_esc(ev.id)}')">
<td class="px-3 py-2" onclick="event.stopPropagation()"><input type="checkbox" class="row-check" data-event-id="${_esc(ev.id)}" ${checked} onchange="onRowCheck(this)"></td>
<td class="px-3 py-2 text-sm font-mono text-gray-700 dark:text-gray-300">${_esc(ev.serial)}</td>
<td class="px-3 py-2 text-sm text-gray-900 dark:text-white whitespace-nowrap">${_esc(ts)}</td>
<td class="px-3 py-2 text-sm font-mono text-right">${_fmtPpv(ev.tran_ppv)}</td>
@@ -355,5 +356,15 @@ async function flagSelected(value) {
}
// Initial empty state — let the user choose to load.
// Refresh the events table when the modal's review form saves — keeps
// the FT badge in sync without a full page reload.
window.addEventListener('sfm-event-review-saved', () => {
if (_events.length) loadEvents();
});
</script>
{# Shared event-detail modal — rendered by /static/event-modal.js #}
{% include 'partials/event_detail_modal.html' %}
<script src="/static/event-modal.js"></script>
{% endblock %}
+7
View File
@@ -118,6 +118,13 @@
{# Shared event-detail modal — rendered by /static/event-modal.js #}
{% include 'partials/event_detail_modal.html' %}
<script src="/static/event-modal.js"></script>
<script>
// Refresh the events table when the modal's review form saves —
// keeps the FT badge in sync without a full page reload.
window.addEventListener('sfm-event-review-saved', () => {
if (typeof loadEvents === 'function') loadEvents();
});
</script>
<style>
.sfm-tab {
+6
View File
@@ -3720,5 +3720,11 @@ function showToast(message, type = 'info') {
{# Shared event-detail modal (clicking a row in the SFM Events table) #}
{% include 'partials/event_detail_modal.html' %}
<script src="/static/event-modal.js"></script>
<script>
// Refresh the unit's events table when the modal's review form saves.
window.addEventListener('sfm-event-review-saved', () => {
if (typeof loadUnitEvents === 'function') loadUnitEvents();
});
</script>
{% endblock %}
+6
View File
@@ -992,4 +992,10 @@ document.getElementById('swap-modal')?.addEventListener('click', function(e) {
{# Shared event-detail modal (clicking an event row in the Events tab) #}
{% include 'partials/event_detail_modal.html' %}
<script src="/static/event-modal.js"></script>
<script>
// Refresh the location's events table when the modal's review form saves.
window.addEventListener('sfm-event-review-saved', () => {
if (typeof loadLocationEvents === 'function') loadLocationEvents();
});
</script>
{% endblock %}