Files
seismo-relay/sfm/sfm_webapp.html
T
serversdownandClaude Opus 5.5 8123d75d72 fix(sfm): page polish from the 1c bench -- #6, #10, #12, #16 (Batch 2)
- #6 Config tab by serial: the empty legacy edit form stays hidden (settings
  are read-only until phase 5); the settings box shows from the start, 'Not read
  yet', and a different unit's settings are never left on screen.
- #10 A start/stop that went out but was not confirmed is no longer called
  'failed'.  The route now adds 'sent' (acknowledged / unknown) and 'audit_id'
  to a ChangeUnconfirmed -- same status, same message -- and the page says
  'Start monitoring not confirmed: <what happened, audit record>'.
- #12 Device tab by serial: the empty legacy Compliance/Project tables are
  hidden behind a pointer to the Config tab; a Micromate's Firmware card reads
  'Thor line (version not read)' (its version string is in 0x01, undecoded).
- #16 A 504 with nothing sent adds: the connection opened, so the modem is
  reachable -- another program (THOR or Blastware) may be holding the line, or
  the unit is busy.  Measured 2026-10-29: THOR polling leaves SFM a 0-byte 504.

New logic lives in sfm/static/device_routing.js (firmwareLabel,
deviceErrorText, changeErrorText, serialPanes) under Node tests; the page glue
in sfm_webapp.js only applies them.  Checked in jsdom against the real page
(served at a fake origin, /static from disk): all four, legacy mode unchanged,
no script errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-11-02 16:22:22 -05:00

1570 lines
59 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SFM — Seismograph Field Module</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0d1117;
--surface: #161b22;
--surface2: #21262d;
--border: #30363d;
--border2: #21262d;
--text: #c9d1d9;
--text-dim: #8b949e;
--text-mute: #484f58;
--blue: #1f6feb;
--blue-lt: #388bfd;
--green: #238636;
--green-lt: #3fb950;
--yellow: #d29922;
--red: #f85149;
--purple: #bc8cff;
--radius: 6px;
}
body {
background: var(--bg);
color: var(--text);
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
font-size: 13px;
display: flex;
flex-direction: column;
height: 100vh;
overflow: hidden;
}
/* ── Header ── */
header {
background: var(--surface);
border-bottom: 1px solid var(--border);
padding: 10px 18px;
display: flex;
align-items: center;
gap: 14px;
flex-wrap: wrap;
flex-shrink: 0;
}
.app-title {
font-size: 14px;
font-weight: 700;
color: #f0f6fc;
letter-spacing: 0.03em;
white-space: nowrap;
}
.app-title span { color: var(--text-dim); font-weight: 400; }
.hdr-group {
display: flex;
align-items: center;
gap: 6px;
}
.hdr-sep {
width: 1px;
height: 20px;
background: var(--border);
}
label.hdr { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
input[type="text"], input[type="number"], select {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius);
color: var(--text);
padding: 5px 8px;
font-size: 12px;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
outline: none;
border-color: var(--blue);
}
input#api-base { width: 170px; }
input#dev-host { width: 120px; }
input#dev-port { width: 60px; }
.btn {
border: none;
border-radius: var(--radius);
cursor: pointer;
font-size: 12px;
font-weight: 500;
padding: 5px 14px;
transition: background 0.12s;
white-space: nowrap;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-lt); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: var(--green-lt); }
.btn-ghost {
background: var(--surface2);
border: 1px solid var(--border);
color: var(--text);
}
.btn-ghost:hover { border-color: var(--blue-lt); color: var(--blue-lt); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.15); }
.diag-result { display:block; margin-top:6px; font-size:12px; opacity:.85;
white-space:pre-wrap; word-break:break-word; }
.diag-result.ok { color: var(--green); }
.diag-result.error { color: var(--red); }
.btn:disabled { background: var(--surface2) !important; color: var(--text-mute) !important; cursor: not-allowed; border-color: var(--border2) !important; }
/* #connect-btn styles moved to #live-connect-bar block */
/* ── Device info bar ── */
#device-bar {
background: var(--bg);
border-bottom: 1px solid var(--border2);
padding: 7px 18px;
display: none;
align-items: center;
gap: 20px;
flex-wrap: wrap;
flex-shrink: 0;
}
.di-field { display: flex; flex-direction: column; gap: 1px; }
.di-label { color: var(--text-mute); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.di-value { color: var(--text); font-family: monospace; font-size: 13px; }
.di-value.accent { color: var(--blue-lt); font-weight: 600; }
.di-value.project-val { color: #e6edf3; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ── Monitor panel ── */
#monitor-panel {
background: var(--surface);
border-bottom: 1px solid var(--border2);
padding: 8px 18px;
display: none;
align-items: center;
gap: 24px;
flex-shrink: 0;
}
#monitor-panel.monitoring { border-left: 3px solid var(--green); }
#monitor-panel.idle { border-left: 3px solid var(--text-mute); }
.series-badge {
font-size: 12px;
font-weight: 700;
padding: 2px 10px;
border-radius: 10px;
border: 1px solid var(--accent, #58a6ff);
color: var(--accent, #58a6ff);
align-self: center;
}
.mon-status-badge {
font-size: 12px;
font-weight: 700;
padding: 2px 10px;
border-radius: 10px;
letter-spacing: 0.04em;
}
.mon-status-badge.monitoring { background: rgba(46,160,67,0.2); color: var(--green-lt); }
.mon-status-badge.idle { background: var(--surface2); color: var(--text-mute); }
.mon-field { display: flex; flex-direction: column; gap: 1px; }
.mon-label { color: var(--text-mute); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.mon-value { color: var(--text); font-family: monospace; font-size: 13px; }
#mon-start-btn { background: var(--green); color: #fff; }
#mon-start-btn:hover { background: var(--green-lt); }
#mon-stop-btn { background: var(--red); color: #fff; }
#mon-stop-btn:hover { filter: brightness(1.15); }
.mon-spacer { flex: 1; }
/* ── Status bar ── */
#status-bar {
background: var(--surface);
border-bottom: 1px solid var(--border2);
padding: 5px 18px;
font-size: 11px;
color: var(--text-dim);
min-height: 24px;
display: flex;
align-items: center;
gap: 12px;
flex-shrink: 0;
}
#status-bar.error { color: var(--red); }
#status-bar.ok { color: var(--green-lt); }
#status-bar.loading { color: var(--yellow); }
.meta-pill {
background: var(--surface2);
border-radius: 4px;
padding: 1px 7px;
color: var(--text);
font-family: monospace;
font-size: 11px;
}
/* ── Tabs ── */
.tab-bar {
background: var(--surface);
border-bottom: 1px solid var(--border);
padding: 0 18px;
display: flex;
gap: 2px;
flex-shrink: 0;
}
.tab-btn {
background: none;
border: none;
border-bottom: 2px solid transparent;
color: var(--text-dim);
cursor: pointer;
font-size: 13px;
font-weight: 500;
padding: 9px 14px 7px;
transition: color 0.12s, border-color 0.12s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: #f0f6fc; border-bottom-color: var(--blue-lt); }
/* ── Tab panes ── */
.tab-pane { display: none; flex: 1; overflow-y: auto; }
.tab-pane.active { display: block; }
/* ── Events tab ── */
#tab-events {
display: none;
flex-direction: column;
}
#tab-events.active { display: flex; }
.event-toolbar {
background: var(--surface);
border-bottom: 1px solid var(--border2);
padding: 8px 18px;
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
flex-shrink: 0;
}
.event-chips {
display: flex;
gap: 5px;
flex-wrap: wrap;
}
.event-chip {
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 5px;
color: var(--text-dim);
cursor: pointer;
font-size: 11px;
padding: 3px 9px;
transition: all 0.1s;
}
.event-chip:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.event-chip.active { background: var(--blue); border-color: var(--blue-lt); color: #fff; font-weight: 600; }
.peaks-bar {
background: var(--bg);
border-bottom: 1px solid var(--border2);
padding: 6px 18px;
display: none;
gap: 20px;
flex-wrap: wrap;
align-items: center;
flex-shrink: 0;
}
.peaks-bar.visible { display: flex; }
.pk { display: flex; flex-direction: column; gap: 1px; }
.pk-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-mute); }
.pk-value { font-family: monospace; font-size: 13px; font-weight: 600; }
.pk-tran { color: #58a6ff; }
.pk-vert { color: var(--green-lt); }
.pk-long { color: var(--yellow); }
.pk-mic { color: var(--purple); }
.pk-pvs { color: #f0f6fc; }
#waveform-area { flex: 1; overflow-y: auto; }
#charts { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.chart-wrap {
background: var(--surface);
border: 1px solid var(--border2);
border-radius: 8px;
padding: 8px 12px 6px;
}
.chart-label {
font-size: 11px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
margin-bottom: 4px;
}
.chart-canvas-wrap { position: relative; height: 130px; }
.ch-tran { color: #58a6ff; }
.ch-vert { color: var(--green-lt); }
.ch-long { color: var(--yellow); }
.ch-mic { color: var(--purple); }
#empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
min-height: 200px;
color: var(--text-mute);
gap: 8px;
}
#empty-state p { font-size: 13px; }
/* ── Config tab ── */
#tab-config { padding: 20px 24px; }
.cfg-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
max-width: 860px;
}
@media (max-width: 640px) { .cfg-grid { grid-template-columns: 1fr; } }
.cfg-section {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 16px;
}
.cfg-section-title {
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--text-dim);
margin-bottom: 14px;
padding-bottom: 8px;
border-bottom: 1px solid var(--border2);
}
.cfg-field {
display: flex;
flex-direction: column;
gap: 4px;
margin-bottom: 12px;
}
.cfg-field:last-child { margin-bottom: 0; }
.cfg-field label {
font-size: 11px;
color: var(--text-dim);
font-weight: 500;
}
.cfg-field .hint {
font-size: 10px;
color: var(--text-mute);
margin-top: 2px;
}
.cfg-field input[type="text"],
.cfg-field input[type="number"],
.cfg-field select {
width: 100%;
padding: 6px 9px;
font-size: 13px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius);
color: var(--text);
}
.cfg-field input:focus, .cfg-field select:focus {
outline: none;
border-color: var(--blue);
}
.cfg-actions {
display: flex;
gap: 10px;
align-items: center;
margin-top: 20px;
max-width: 860px;
}
.cfg-actions .btn { padding: 7px 18px; font-size: 13px; }
#cfg-status {
font-size: 12px;
color: var(--text-dim);
}
#cfg-status.ok { color: var(--green-lt); }
#cfg-status.error { color: var(--red); }
/* ── Device tab ── */
#tab-device { padding: 20px 24px; }
.dev-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 12px;
max-width: 860px;
margin-bottom: 20px;
}
.dev-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 14px 16px;
}
.dev-card-label {
font-size: 10px;
color: var(--text-mute);
text-transform: uppercase;
letter-spacing: 0.06em;
margin-bottom: 5px;
}
.dev-card-value {
font-size: 15px;
font-weight: 600;
color: #f0f6fc;
font-family: monospace;
}
.dev-card-sub {
font-size: 11px;
color: var(--text-dim);
margin-top: 2px;
}
.dev-section-title {
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--text-dim);
margin: 20px 0 10px;
max-width: 860px;
padding-bottom: 6px;
border-bottom: 1px solid var(--border2);
}
.dev-table {
max-width: 860px;
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
}
.dev-table-row {
display: flex;
align-items: center;
padding: 9px 16px;
border-bottom: 1px solid var(--border2);
}
.dev-table-row:last-child { border-bottom: none; }
.dev-table-row:nth-child(even) { background: var(--surface); }
.dtr-label { color: var(--text-dim); font-size: 12px; width: 200px; flex-shrink: 0; }
.dtr-value { color: var(--text); font-family: monospace; font-size: 13px; }
.dtr-value.accent { color: var(--blue-lt); }
#no-device-msg {
color: var(--text-mute);
font-size: 14px;
margin-top: 40px;
}
/* ── DB tabs (History / Units / Monitor Log / Sessions) ── */
.db-tab-pane { padding: 0; flex-direction: column; overflow: hidden; }
.db-tab-pane.active { display: flex; }
.db-toolbar {
background: var(--surface);
border-bottom: 1px solid var(--border2);
padding: 8px 18px;
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
flex-shrink: 0;
}
.db-toolbar label { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.db-toolbar input[type="text"],
.db-toolbar input[type="date"],
.db-toolbar select { font-size: 12px; padding: 4px 8px; }
.db-toolbar select#db-serial-filter { width: 120px; }
.db-toolbar input.date-input { width: 130px; }
.db-toolbar-spacer { flex: 1; }
.db-count-badge {
color: var(--text-mute);
font-size: 11px;
white-space: nowrap;
}
.db-scroll { flex: 1; overflow-y: auto; padding: 14px 18px; }
.db-table-wrap {
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
max-width: 100%;
}
table.db-table {
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
table.db-table thead th {
background: var(--surface2);
color: var(--text-dim);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
padding: 7px 12px;
text-align: left;
border-bottom: 1px solid var(--border);
white-space: nowrap;
position: sticky;
top: 0;
z-index: 1;
}
table.db-table thead th[data-sort]:hover {
background: var(--border2);
color: var(--text);
}
table.db-table thead th .sort-arrow {
display: inline-block;
width: 10px;
color: var(--accent, #58a6ff);
font-weight: 900;
text-align: center;
}
table.db-table tbody tr { border-bottom: 1px solid var(--border2); }
table.db-table tbody tr:last-child { border-bottom: none; }
table.db-table tbody tr:nth-child(even) { background: var(--surface); }
table.db-table tbody tr:hover { background: var(--surface2); }
table.db-table tbody td {
padding: 7px 12px;
color: var(--text);
white-space: nowrap;
font-family: monospace;
font-size: 12px;
}
table.db-table tbody td.td-text {
font-family: inherit;
max-width: 180px;
overflow: hidden;
text-overflow: ellipsis;
}
table.db-table tbody td.td-dim { color: var(--text-mute); }
table.db-table tbody td.td-key { color: var(--blue-lt); }
/* PPV color tiers: green < 0.5, amber < 2.0, red ≥ 2.0 in/s */
.ppv-ok { color: var(--green-lt); font-weight: 600; }
.ppv-warn { color: var(--yellow); font-weight: 600; }
.ppv-high { color: var(--red); font-weight: 600; }
.ft-badge {
background: rgba(248,81,73,0.15);
border: 1px solid rgba(248,81,73,0.4);
border-radius: 4px;
color: var(--red);
font-family: inherit;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.05em;
padding: 1px 6px;
}
.ft-toggle-btn {
background: none;
border: 1px solid var(--border);
border-radius: var(--radius);
color: var(--text-dim);
cursor: pointer;
font-size: 11px;
padding: 2px 8px;
}
.ft-toggle-btn:hover { border-color: var(--red); color: var(--red); }
.ft-toggle-btn.flagged { border-color: var(--red); color: var(--red); background: rgba(248,81,73,0.1); }
.db-empty {
color: var(--text-mute);
font-size: 13px;
padding: 40px 0;
text-align: center;
}
/* Units tab cards */
.units-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 12px;
max-width: 900px;
}
.unit-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 14px 16px;
cursor: pointer;
}
.unit-card:hover { border-color: var(--blue-lt); }
.unit-card .uc-serial {
font-size: 16px;
font-weight: 700;
font-family: monospace;
color: var(--blue-lt);
margin-bottom: 8px;
}
.unit-card .uc-stat {
display: flex;
justify-content: space-between;
margin-bottom: 4px;
}
.unit-card .uc-label { font-size: 11px; color: var(--text-mute); }
.unit-card .uc-val { font-size: 12px; color: var(--text); font-family: monospace; }
/* ── Section switcher ── */
.section-switcher {
display: flex;
gap: 3px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 7px;
padding: 3px;
}
.section-btn {
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 12px;
font-weight: 600;
padding: 4px 14px;
transition: background 0.12s, color 0.12s;
background: none;
color: var(--text-dim);
white-space: nowrap;
}
.section-btn:hover { color: var(--text); }
.section-btn.active { background: var(--blue); color: #fff; }
/* ── Force-refresh toggle ── */
.force-toggle {
display: flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--bg);
cursor: pointer;
font-size: 11px;
font-weight: 600;
color: var(--text-dim);
user-select: none;
white-space: nowrap;
transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.force-toggle input { margin: 0; cursor: pointer; }
.force-toggle:hover { color: var(--text); }
.force-toggle.active {
background: rgba(248, 81, 73, 0.18);
border-color: #f85149;
color: #ff7b72;
}
.force-toggle .ft-dot {
width: 6px; height: 6px; border-radius: 50%;
background: var(--text-mute);
}
.force-toggle.active .ft-dot { background: #f85149; box-shadow: 0 0 6px #f85149; }
/* ── Sidecar review modal ── */
.sc-overlay {
position: fixed; inset: 0;
background: rgba(0,0,0,0.55);
display: none;
align-items: center;
justify-content: center;
z-index: 100;
}
.sc-overlay.visible { display: flex; }
.sc-modal {
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 8px;
width: min(720px, 92vw);
max-height: 88vh;
display: flex;
flex-direction: column;
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.sc-header {
display: flex; align-items: center; justify-content: space-between;
padding: 14px 18px;
border-bottom: 1px solid var(--border);
}
.sc-header h3 {
margin: 0; font-size: 14px; font-weight: 600;
color: var(--text); font-family: monospace;
}
.sc-close {
background: none; border: none; cursor: pointer;
color: var(--text-mute); font-size: 18px; line-height: 1;
padding: 4px 8px; border-radius: 4px;
}
.sc-close:hover { background: var(--surface); color: var(--text); }
.sc-body {
flex: 1; overflow-y: auto;
padding: 16px 18px;
display: flex; flex-direction: column; gap: 14px;
}
.sc-section {
display: flex; flex-direction: column; gap: 6px;
}
.sc-section h4 {
margin: 0 0 4px;
font-size: 11px; font-weight: 600;
color: var(--text-mute); text-transform: uppercase;
letter-spacing: 0.6px;
}
.sc-grid {
display: grid;
grid-template-columns: 130px 1fr;
gap: 4px 12px;
font-size: 12px;
}
.sc-grid dt { color: var(--text-mute); }
.sc-grid dd { margin: 0; color: var(--text); font-family: monospace; word-break: break-all; }
.sc-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sc-row label { color: var(--text-dim); }
.sc-row input[type="checkbox"] { cursor: pointer; }
.sc-row input[type="text"], .sc-body textarea {
flex: 1;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 5px;
padding: 6px 9px;
font-size: 12px;
color: var(--text);
font-family: monospace;
}
.sc-body textarea {
width: 100%;
min-height: 80px;
resize: vertical;
font-family: inherit;
}
.sc-raw {
border: 1px solid var(--border);
border-radius: 5px;
background: var(--bg);
}
.sc-raw summary {
padding: 6px 10px;
cursor: pointer;
font-size: 11px;
color: var(--text-dim);
user-select: none;
}
.sc-raw pre {
margin: 0;
padding: 8px 12px;
max-height: 240px;
overflow: auto;
font-size: 11px;
color: var(--text);
border-top: 1px solid var(--border);
}
.sc-footer {
display: flex; justify-content: flex-end; gap: 8px;
padding: 12px 18px;
border-top: 1px solid var(--border);
}
.sc-status {
flex: 1; align-self: center;
font-size: 11px; color: var(--text-mute);
}
.sc-status.error { color: #f85149; }
.sc-status.ok { color: #56d364; }
table.db-table tbody tr.clickable { cursor: pointer; }
table.db-table tbody tr.clickable:hover { background: var(--surface2); }
/* ── Section containers ── */
#section-live, #section-db {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
min-height: 0;
}
/* Default to Database view on page load — most users are here to
browse stored events, not connect to a live unit. */
#section-live { display: none; }
/* ── Live connect bar (host/port/connect, live section only) ── */
#live-connect-bar {
background: var(--surface);
border-bottom: 1px solid var(--border2);
padding: 8px 18px;
display: flex;
align-items: center;
gap: 10px;
flex-shrink: 0;
flex-wrap: wrap;
}
#live-connect-bar label.hdr { color: var(--text-dim); font-size: 11px; }
#live-connect-bar input[type="text"],
#live-connect-bar input[type="number"] { font-size: 12px; padding: 5px 8px; }
#live-connect-bar #dev-host { width: 150px; }
#live-connect-bar #dev-port { width: 70px; }
#connect-btn { margin-left: auto; background: var(--green); color: #fff; }
#connect-btn:hover { background: var(--green-lt); }
</style>
</head>
<body>
<!-- ── Header ─────────────────────────────────────────────────────── -->
<header>
<div class="app-title">SFM <span>Seismograph Field Module</span></div>
<div class="hdr-sep"></div>
<div class="hdr-group">
<label class="hdr">API</label>
<input type="text" id="api-base" />
</div>
<div class="hdr-sep"></div>
<div class="section-switcher">
<button class="section-btn" onclick="switchSection('live')">Live Device</button>
<button class="section-btn active" onclick="switchSection('db')">Database</button>
</div>
<div class="hdr-sep"></div>
<label class="force-toggle" id="force-toggle"
title="Bypass server cache and dedup. Forces a fresh download from the device on every live request — useful when the device has been erased and the cache is showing stale events.">
<input type="checkbox" id="force-cb" onchange="onForceToggle()">
<span class="ft-dot"></span>
<span>Force refresh</span>
</label>
<div class="hdr-sep"></div>
<button id="mic-unit-toggle" class="section-btn"
onclick="_setMicUnit(_getMicUnit() === 'dBL' ? 'psi' : 'dBL')"
title="Toggle microphone display unit (dBL ↔ psi) for waveform plots. Affects all mic charts; persists across page loads.">
Mic: dBL
</button>
</header>
<!-- ════════════════════════════════════════════════════════════════
SECTION: Live Device
═══════════════════════════════════════════════════════════════════ -->
<div id="section-live">
<!-- ── Live connect bar ────────────────────────────────────────────── -->
<div id="live-connect-bar">
<label class="hdr">Host</label>
<input type="text" id="dev-host" placeholder="e.g. 63.43.212.232" />
<label class="hdr">Port</label>
<input type="number" id="dev-port" value="9034" />
<label class="hdr">Serial</label>
<input type="text" id="dev-serial" placeholder="BE…/BA… or UM… (optional)"
title="With a serial, SFM talks to the unit through the serial-based endpoints (both series)" />
<button class="btn" id="connect-btn" onclick="connectUnit()">Connect</button>
<span class="series-badge" id="series-badge" hidden></span>
<button class="btn" id="hangup-btn" onclick="hangUp()" hidden
title="Release the line SFM holds open to this Micromate">Hang up</button>
</div>
<!-- ── Device info bar ─────────────────────────────────────────────── -->
<div id="device-bar">
<div class="di-field">
<span class="di-label">Serial</span>
<span class="di-value" id="di-serial">—</span>
</div>
<div class="di-field">
<span class="di-label">Firmware</span>
<span class="di-value" id="di-fw">—</span>
</div>
<div class="di-field">
<span class="di-label">Sample rate</span>
<span class="di-value accent" id="di-sr">—</span>
</div>
<div class="di-field">
<span class="di-label">Record time</span>
<span class="di-value" id="di-rt">—</span>
</div>
<div class="di-field">
<span class="di-label">Trigger</span>
<span class="di-value" id="di-trig">—</span>
</div>
<div class="di-field">
<span class="di-label">Events</span>
<span class="di-value accent" id="di-count">—</span>
</div>
<div class="di-field" style="margin-left:12px">
<span class="di-label">Project</span>
<span class="di-value project-val" id="di-project">—</span>
</div>
<div class="di-field">
<span class="di-label">Client</span>
<span class="di-value project-val" id="di-client">—</span>
</div>
<div class="di-field">
<span class="di-label">Operator</span>
<span class="di-value project-val" id="di-operator">—</span>
</div>
</div>
<!-- ── Monitor panel ───────────────────────────────────────────────── -->
<div id="monitor-panel">
<span class="mon-status-badge idle" id="mon-badge">IDLE</span>
<div class="mon-field">
<span class="mon-label">Battery</span>
<span class="mon-value" id="mon-battery">—</span>
</div>
<div class="mon-field">
<span class="mon-label">Memory total</span>
<span class="mon-value" id="mon-mem-total">—</span>
</div>
<div class="mon-field">
<span class="mon-label">Memory free</span>
<span class="mon-value" id="mon-mem-free">—</span>
</div>
<div class="mon-field" style="display:none" title="The unit's own clock">
<span class="mon-label">Unit time</span>
<span class="mon-value" id="mon-time">—</span>
</div>
<div class="mon-field" style="display:none" title="Read only where it is cheap (Series 4)">
<span class="mon-label">Events</span>
<span class="mon-value" id="mon-events">—</span>
</div>
<div class="mon-spacer"></div>
<button class="btn" id="mon-refresh-btn" onclick="refreshMonitorStatus()" title="Refresh monitoring status">↻ Status</button>
<button class="btn" id="mon-start-btn" onclick="startMonitoring()" title="Start monitoring">▶ Start</button>
<button class="btn" id="mon-stop-btn" onclick="stopMonitoring()" title="Stop monitoring">■ Stop</button>
</div>
<!-- ── Status bar ─────────────────────────────────────────────────── -->
<div id="status-bar">Ready — enter device host and click Connect.</div>
<!-- ── Live tab bar ───────────────────────────────────────────────── -->
<div class="tab-bar" id="live-tab-bar">
<button class="tab-btn active" data-tab="device" onclick="switchTab('device')">Device</button>
<button class="tab-btn" data-tab="events" onclick="switchTab('events')">Events</button>
<button class="tab-btn" data-tab="config" onclick="switchTab('config')">Config</button>
<button class="tab-btn" data-tab="call-home" onclick="switchTab('call-home')">Call Home</button>
<button class="tab-btn" data-tab="diagnostics" onclick="switchTab('diagnostics')">Diagnostics</button>
</div>
<!-- ════════════════════════════════════════════════════════════════
TAB: Device
═══════════════════════════════════════════════════════════════════ -->
<div id="tab-device" class="tab-pane active">
<div style="padding:24px">
<div id="no-device-msg">Connect to a device to view its information.</div>
<div id="device-detail" style="display:none">
<div class="dev-grid" id="dev-cards"></div>
<div id="dev-serial-note" class="dev-section-title" hidden>Settings: Config tab → Read from Device</div>
<div id="dev-legacy-tables">
<div class="dev-section-title">Compliance Config</div>
<div class="dev-table" id="compliance-table"></div>
<div class="dev-section-title">Project Info</div>
<div class="dev-table" id="project-table"></div>
</div>
</div>
</div>
</div>
<!-- ════════════════════════════════════════════════════════════════
TAB: Events
═══════════════════════════════════════════════════════════════════ -->
<div id="tab-events" class="tab-pane" style="display:flex; flex-direction:column; overflow:hidden;">
<div class="event-toolbar">
<button class="btn btn-ghost" id="load-events-btn" onclick="loadEventList()" disabled
title="Walk the device's event chain and list its stored events. This is the slow one — it reads every event header over the cellular link.">
⟳ Load events
</button>
<button class="btn btn-ghost" id="load-btn" onclick="loadWaveform()" disabled>Load Waveform</button>
<button class="btn btn-ghost" id="save-btn" onclick="saveEventToDb()" disabled
title="Download the full waveform from the device and save it to the SFM database + waveform store. Honors the Force refresh toggle.">
💾 Save to DB
</button>
<button class="btn btn-ghost" id="download-btn" onclick="downloadEventFile()" disabled
title="Download the Blastware-format event file to your computer (also saves it to the server's database + store).">
⬇ Download
</button>
<button class="btn btn-ghost" id="prev-btn" onclick="stepEvent(-1)" disabled>◀</button>
<button class="btn btn-ghost" id="next-btn" onclick="stepEvent(+1)" disabled>▶</button>
<div class="event-chips" id="event-chips"></div>
</div>
<div class="peaks-bar" id="peaks-bar">
<div class="pk"><div class="pk-label">Tran</div><div class="pk-value pk-tran" id="pk-tran">—</div></div>
<div class="pk"><div class="pk-label">Vert</div><div class="pk-value pk-vert" id="pk-vert">—</div></div>
<div class="pk"><div class="pk-label">Long</div><div class="pk-value pk-long" id="pk-long">—</div></div>
<div class="pk"><div class="pk-label">MicL</div><div class="pk-value pk-mic" id="pk-mic">—</div></div>
<div class="pk"><div class="pk-label">PVS</div><div class="pk-value pk-pvs" id="pk-pvs">—</div></div>
</div>
<div id="waveform-area" style="flex:1; overflow-y:auto;">
<div class="db-table-wrap" id="serial-events-wrap" style="display:none; margin:12px;">
<table class="db-table">
<thead><tr><th>#</th><th>Time</th><th>Type</th><th>PVS</th><th>Tran</th><th>Vert</th><th>Long</th><th></th></tr></thead>
<tbody id="serial-events-tbody"></tbody>
</table>
</div>
<div id="empty-state">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/>
</svg>
<p>No waveform loaded</p>
</div>
<div id="charts" style="display:none"></div>
</div>
</div>
<!-- ════════════════════════════════════════════════════════════════
TAB: Config
═══════════════════════════════════════════════════════════════════ -->
<div id="tab-config" class="tab-pane">
<div id="cfg-settings" style="display:none; margin-bottom:12px">
<div class="cfg-section-title">On the unit (read by serial)</div>
<div class="dev-table" id="cfg-settings-table"></div>
</div>
<div class="cfg-grid" id="cfg-form">
<!-- Recording parameters -->
<div class="cfg-section">
<div class="cfg-section-title">Recording</div>
<div class="cfg-field">
<label>Recording Mode</label>
<select id="cfg-recording-mode">
<option value="">— unchanged —</option>
<option value="0">Single Shot</option>
<option value="1">Continuous</option>
<option value="3">Histogram</option>
<option value="4">Histogram + Continuous</option>
</select>
</div>
<div class="cfg-field">
<label>Sample Rate</label>
<select id="cfg-sample-rate">
<option value="">— unchanged —</option>
<option value="1024">1024 sps (standard compliance)</option>
<option value="2048">2048 sps</option>
<option value="4096">4096 sps (high-speed)</option>
</select>
</div>
<div class="cfg-field">
<label>Histogram Interval</label>
<select id="cfg-histogram-interval">
<option value="">— unchanged —</option>
<option value="2">2 seconds</option>
<option value="5">5 seconds</option>
<option value="15">15 seconds</option>
<option value="60">1 minute</option>
<option value="300">5 minutes</option>
<option value="900">15 minutes</option>
</select>
<div class="hint">Only active in Histogram / Histogram + Continuous mode</div>
</div>
<div class="cfg-field">
<label>Record Time (seconds)</label>
<input type="number" id="cfg-record-time" step="0.5" min="0.5" max="60" placeholder="e.g. 3.0" />
<div class="hint">Waveform capture duration per trigger event</div>
</div>
<div class="cfg-field">
<label>Trigger Level — Geo (in/s)</label>
<input type="number" id="cfg-trigger" step="0.01" min="0.01" placeholder="e.g. 0.50" />
<div class="hint">Recording starts when any geo channel exceeds this level</div>
</div>
<div class="cfg-field">
<label>Alarm Level — Geo (in/s)</label>
<input type="number" id="cfg-alarm" step="0.01" min="0.01" placeholder="e.g. 1.00" />
<div class="hint">Alarm flagged when any geo channel exceeds this level</div>
</div>
<div class="cfg-field">
<label>Maximum Range — Geo</label>
<select id="cfg-geo-range">
<option value="">— unchanged —</option>
<option value="0">Normal — 10.000 in/s</option>
<option value="1">Sensitive — 1.250 in/s</option>
</select>
<div class="hint">Geophone sensitivity (applies to Tran / Vert / Long channels)</div>
</div>
</div>
<!-- Project / operator strings -->
<div class="cfg-section">
<div class="cfg-section-title">Project Info</div>
<div class="cfg-field">
<label>Project</label>
<input type="text" id="cfg-project" maxlength="41" placeholder="Project description" />
</div>
<div class="cfg-field">
<label>Client</label>
<input type="text" id="cfg-client" maxlength="41" placeholder="Client / company name" />
</div>
<div class="cfg-field">
<label>Operator</label>
<input type="text" id="cfg-operator" maxlength="41" placeholder="Technician name" />
</div>
<div class="cfg-field">
<label>Sensor Location</label>
<input type="text" id="cfg-seis-loc" maxlength="41" placeholder="e.g. South Abutment" />
</div>
<div class="cfg-field">
<label>Notes</label>
<input type="text" id="cfg-notes" maxlength="41" placeholder="Extended notes" />
</div>
</div>
</div>
<div class="cfg-actions">
<button class="btn btn-ghost" id="cfg-read-btn" onclick="readConfig()" disabled>Read from Device</button>
<button class="btn btn-success" id="cfg-write-btn" onclick="writeConfig()" disabled>Write to Device</button>
<button class="btn btn-ghost" onclick="clearConfigForm()">Clear Form</button>
<span id="cfg-status"></span>
</div>
</div><!-- end #tab-config -->
<!-- ════════════════════════════════════════════════════════════════
TAB: Call Home
═══════════════════════════════════════════════════════════════════ -->
<div id="tab-call-home" class="tab-pane">
<div class="cfg-grid">
<!-- Enable / dial -->
<div class="cfg-section">
<div class="cfg-section-title">Auto Call Home</div>
<div class="cfg-field">
<label>Enable Auto Call Home</label>
<select id="ch-enabled">
<option value="">— unchanged —</option>
<option value="true">Enabled</option>
<option value="false">Disabled</option>
</select>
</div>
<div class="cfg-field">
<label>Dial String</label>
<input type="text" id="ch-dial-string" disabled placeholder="Read-only (e.g. RADIO RING)" />
<div class="hint">Read from device — not writable via this interface</div>
</div>
<div class="cfg-section-title" style="margin-top:16px">When to Call</div>
<div class="cfg-field">
<label>After Event Recorded</label>
<select id="ch-after-event">
<option value="">— unchanged —</option>
<option value="true">Yes</option>
<option value="false">No</option>
</select>
</div>
<div class="cfg-field">
<label>At Specified Times</label>
<select id="ch-at-times">
<option value="">— unchanged —</option>
<option value="true">Yes</option>
<option value="false">No</option>
</select>
</div>
</div>
<!-- Scheduled call times -->
<div class="cfg-section">
<div class="cfg-section-title">Scheduled Call Times</div>
<div class="cfg-field">
<label>Time Slot 1</label>
<div style="display:flex;gap:8px;align-items:center">
<select id="ch-t1-enabled" style="width:120px">
<option value="">— enable —</option>
<option value="true">Enabled</option>
<option value="false">Disabled</option>
</select>
<input type="number" id="ch-t1-hour" min="0" max="23" step="1" placeholder="HH" style="width:64px" />
<span>:</span>
<input type="number" id="ch-t1-min" min="0" max="59" step="1" placeholder="MM" style="width:64px" />
</div>
<div class="hint">Hour (0-23) and minute (0-59). Avoid value 3 (DLE limitation).</div>
</div>
<div class="cfg-field">
<label>Time Slot 2</label>
<div style="display:flex;gap:8px;align-items:center">
<select id="ch-t2-enabled" style="width:120px">
<option value="">— enable —</option>
<option value="true">Enabled</option>
<option value="false">Disabled</option>
</select>
<input type="number" id="ch-t2-hour" min="0" max="23" step="1" placeholder="HH" style="width:64px" />
<span>:</span>
<input type="number" id="ch-t2-min" min="0" max="59" step="1" placeholder="MM" style="width:64px" />
</div>
<div class="hint">Hour (0-23) and minute (0-59). Avoid value 3 (DLE limitation).</div>
</div>
<div class="cfg-section-title" style="margin-top:16px">Retry Settings (read-only)</div>
<div class="cfg-field">
<label>Number of Retries</label>
<input type="text" id="ch-num-retries" disabled placeholder="—" />
</div>
<div class="cfg-field">
<label>Time Between Retries (s)</label>
<input type="text" id="ch-retry-gap" disabled placeholder="—" />
</div>
<div class="cfg-field">
<label>Wait for Connection (s)</label>
<input type="text" id="ch-wait-conn" disabled placeholder="—" />
</div>
<div class="cfg-field">
<label>Warm-up Time (s)</label>
<input type="text" id="ch-warmup" disabled placeholder="—" />
</div>
</div>
</div>
<div class="cfg-actions">
<button class="btn btn-ghost" id="ch-read-btn" onclick="readCallHome()" disabled>Read from Device</button>
<button class="btn btn-success" id="ch-write-btn" onclick="writeCallHome()" disabled>Write to Device</button>
<button class="btn btn-ghost" onclick="clearCallHomeForm()">Clear Form</button>
<span id="ch-status"></span>
<span id="ch-series-note" style="color:var(--text-dim)"></span>
</div>
</div><!-- end #tab-call-home -->
<!-- ════════════════════════════════════════════════════════════════
TAB: Diagnostics
═══════════════════════════════════════════════════════════════════ -->
<div id="tab-diagnostics" class="tab-pane">
<div class="cfg-grid">
<div class="cfg-section">
<div class="cfg-section-title">Device State</div>
<div class="hint" style="margin-bottom:10px">
Fast probes — POLL plus one read each, about 2 s. None of these walk the event chain.
</div>
<div class="dev-table" id="diag-table"></div>
<div class="cfg-actions" style="margin-top:12px">
<button class="btn btn-ghost" id="diag-refresh-btn" onclick="refreshDiagnostics()" disabled>Refresh</button>
<span id="diag-status"></span>
</div>
</div>
<div class="cfg-section">
<div class="cfg-section-title">Actions</div>
<div class="cfg-field">
<label>Stop Monitoring</label>
<button class="btn btn-ghost" id="diag-stop-btn" onclick="diagStopMonitoring()" disabled>Send Stop (SUB 0x97)</button>
<div class="hint">Halts recording. On a unit triggering continuously, this is what breaks the call-home loop.</div>
<span class="diag-result" id="diag-stop-result"></span>
</div>
<div class="cfg-field">
<label>Disable Auto Call Home</label>
<button class="btn btn-ghost" id="diag-ach-btn" onclick="diagDisableAch()" disabled>Disable ACH</button>
<div class="hint">Stored events are left untouched (<code>rescue?erase=false</code>). The unit stops dialing out until ACH is re-enabled.</div>
<span class="diag-result" id="diag-ach-result"></span>
</div>
<div class="cfg-field">
<label>Erase All Events</label>
<input type="text" id="diag-erase-confirm" placeholder="Type the serial to enable"
oninput="diagCheckEraseConfirm()" autocomplete="off" />
<button class="btn btn-danger" id="diag-erase-btn" onclick="diagEraseEvents()" disabled>Erase Events</button>
<div class="hint">⚠ Permanent, and resets the event chain to key <code>0x01110000</code>. Download anything worth keeping first.</div>
<span class="diag-result" id="diag-erase-result"></span>
</div>
</div>
<div class="cfg-section">
<div class="cfg-section-title">Unresponsive Unit</div>
<div class="hint" style="margin-bottom:10px">
The escalation ladder from <code>docs/runbooks/wedged_unit_recovery.md</code>, for a unit too busy
to answer normal request/response. Prefer <b>Method A</b> — point the modem at an
<code>ach_server</code> and answer its call — before racing it with these.
</div>
<div class="cfg-field">
<label>Slow drip <span class="hint" style="display:inline">(one held session, a stop every 3 s)</span></label>
<button class="btn btn-ghost" id="diag-drip-btn" onclick="diagSlowDrip()" disabled>Run 120 s drip</button>
<div class="hint">Success is <code>bytes_received &gt; 0</code>. A full duration with <code>send_error: null</code> is <b>not</b> success on its own.</div>
<span class="diag-result" id="diag-drip-result"></span>
</div>
<div class="cfg-field">
<label>Blind stop <span class="hint" style="display:inline">(fire-and-forget, one attempt)</span></label>
<button class="btn btn-ghost" id="diag-blind-btn" onclick="diagBlindStop()" disabled>Send blind stop</button>
<span class="diag-result" id="diag-blind-result"></span>
</div>
</div>
</div>
</div><!-- end #tab-diagnostics -->
</div><!-- end #section-live -->
<!-- ════════════════════════════════════════════════════════════════
SECTION: Database
═══════════════════════════════════════════════════════════════════ -->
<div id="section-db">
<!-- ── Database tab bar ──────────────────────────────────────────── -->
<div class="tab-bar" id="db-tab-bar">
<button class="tab-btn active" data-tab="history" onclick="switchTab('history')">History</button>
<button class="tab-btn" data-tab="units" onclick="switchTab('units')">Units</button>
<button class="tab-btn" data-tab="monlog" onclick="switchTab('monlog')">Monitor Log</button>
<button class="tab-btn" data-tab="sessions" onclick="switchTab('sessions')">Sessions</button>
</div>
<!-- ════════════════════════════════════════════════════════════════
TAB: History (events from DB)
═══════════════════════════════════════════════════════════════════ -->
<div id="tab-history" class="tab-pane db-tab-pane">
<div class="db-toolbar">
<label>Serial</label>
<select id="hist-serial-filter" onchange="loadHistory()">
<option value="">All units</option>
</select>
<label>From</label>
<input type="date" class="date-input" id="hist-from" onchange="loadHistory()" />
<label>To</label>
<input type="date" class="date-input" id="hist-to" onchange="loadHistory()" />
<label style="display:flex;align-items:center;gap:5px;cursor:pointer;">
<input type="checkbox" id="hist-hide-ft" onchange="loadHistory()" />
Hide false triggers
</label>
<div class="db-toolbar-spacer"></div>
<button class="btn btn-ghost" onclick="loadHistory()">↻ Refresh</button>
<span class="db-count-badge" id="hist-count"></span>
</div>
<div class="db-scroll" id="hist-scroll">
<div class="db-empty" id="hist-empty" style="display:none">No events found.</div>
<div class="db-table-wrap" id="hist-table-wrap" style="display:none">
<table class="db-table" id="hist-table">
<thead>
<tr id="hist-header-row">
<th data-sort="timestamp">Timestamp <span class="sort-arrow"></span></th>
<th data-sort="serial">Serial <span class="sort-arrow"></span></th>
<th data-sort="tran_ppv">Tran (in/s) <span class="sort-arrow"></span></th>
<th data-sort="vert_ppv">Vert (in/s) <span class="sort-arrow"></span></th>
<th data-sort="long_ppv">Long (in/s) <span class="sort-arrow"></span></th>
<th data-sort="peak_vector_sum">PVS (in/s) <span class="sort-arrow"></span></th>
<th data-sort="mic_ppv">Mic (dBL) <span class="sort-arrow"></span></th>
<th data-sort="project">Project <span class="sort-arrow"></span></th>
<th data-sort="client">Client <span class="sort-arrow"></span></th>
<th data-sort="record_type">Type <span class="sort-arrow"></span></th>
<th data-sort="waveform_key">Key <span class="sort-arrow"></span></th>
<th></th>
</tr>
</thead>
<tbody id="hist-tbody"></tbody>
</table>
</div>
</div>
</div>
<!-- ════════════════════════════════════════════════════════════════
TAB: Units
═══════════════════════════════════════════════════════════════════ -->
<div id="tab-units" class="tab-pane db-tab-pane">
<div class="db-toolbar">
<div class="db-toolbar-spacer"></div>
<button class="btn btn-ghost" onclick="loadUnits()">↻ Refresh</button>
<span class="db-count-badge" id="units-count"></span>
</div>
<div class="db-scroll">
<div class="db-empty" id="units-empty" style="display:none">No units in database yet.</div>
<div class="units-grid" id="units-grid"></div>
</div>
</div>
<!-- ════════════════════════════════════════════════════════════════
TAB: Monitor Log
═══════════════════════════════════════════════════════════════════ -->
<div id="tab-monlog" class="tab-pane db-tab-pane">
<div class="db-toolbar">
<label>Serial</label>
<select id="monlog-serial-filter" onchange="loadMonitorLog()">
<option value="">All units</option>
</select>
<label>From</label>
<input type="date" class="date-input" id="monlog-from" onchange="loadMonitorLog()" />
<label>To</label>
<input type="date" class="date-input" id="monlog-to" onchange="loadMonitorLog()" />
<div class="db-toolbar-spacer"></div>
<button class="btn btn-ghost" onclick="loadMonitorLog()">↻ Refresh</button>
<span class="db-count-badge" id="monlog-count"></span>
</div>
<div class="db-scroll" id="monlog-scroll">
<div class="db-empty" id="monlog-empty" style="display:none">No monitor log entries found.</div>
<div class="db-table-wrap" id="monlog-table-wrap" style="display:none">
<table class="db-table" id="monlog-table">
<thead>
<tr>
<th>Start Time</th>
<th>Stop Time</th>
<th>Duration</th>
<th>Serial</th>
<th>Geo Threshold</th>
<th>Key</th>
</tr>
</thead>
<tbody id="monlog-tbody"></tbody>
</table>
</div>
</div>
</div>
<!-- ════════════════════════════════════════════════════════════════
TAB: Sessions
═══════════════════════════════════════════════════════════════════ -->
<div id="tab-sessions" class="tab-pane db-tab-pane">
<div class="db-toolbar">
<label>Serial</label>
<select id="sess-serial-filter" onchange="loadSessions()">
<option value="">All units</option>
</select>
<div class="db-toolbar-spacer"></div>
<button class="btn btn-ghost" onclick="loadSessions()">↻ Refresh</button>
<span class="db-count-badge" id="sess-count"></span>
</div>
<div class="db-scroll" id="sess-scroll">
<div class="db-empty" id="sess-empty" style="display:none">No ACH sessions recorded yet.</div>
<div class="db-table-wrap" id="sess-table-wrap" style="display:none">
<table class="db-table" id="sess-table">
<thead>
<tr>
<th>Session Time</th>
<th>Serial</th>
<th>Peer</th>
<th>Events DL'd</th>
<th>Monitor Entries</th>
<th>Duration (s)</th>
</tr>
</thead>
<tbody id="sess-tbody"></tbody>
</table>
</div>
</div>
</div><!-- end #tab-sessions -->
</div><!-- end #section-db -->
<!-- ── Script ─────────────────────────────────────────────────────── -->
<script src="static/device_routing.js"></script>
<script src="static/sfm_webapp.js"></script>
<!-- ════════════════════════════════════════════════════════════════
Sidecar review modal (Database events table → row click)
═══════════════════════════════════════════════════════════════════ -->
<div class="sc-overlay" id="sc-overlay" onclick="onSidecarOverlayClick(event)">
<div class="sc-modal" id="sc-modal">
<div class="sc-header">
<h3 id="sc-title">Event</h3>
<button class="sc-close" onclick="closeSidecarModal()">×</button>
</div>
<div class="sc-body">
<!-- Waveform plot — 4 channels stacked (MicL, Long, Vert, Tran) — -->
<div class="sc-section" id="sc-section-waveform">
<h4>Waveform</h4>
<div id="sc-waveform-status" style="color:var(--text-dim);font-size:11px;margin-bottom:6px">Loading…</div>
<div id="sc-waveform-charts" style="display:flex;flex-direction:column;gap:6px"></div>
</div>
<div class="sc-section">
<h4>Event</h4>
<dl class="sc-grid">
<dt>Serial</dt> <dd id="sc-f-serial">—</dd>
<dt title="When the seismograph recorded this event (from the BW report's Event Time field)">Recorded at</dt>
<dd id="sc-f-ts">—</dd>
<dt>Record type</dt> <dd id="sc-f-rt">—</dd>
<dt>Sample rate</dt> <dd id="sc-f-sr">—</dd>
<dt>Waveform key</dt> <dd id="sc-f-key">—</dd>
</dl>
</div>
<div class="sc-section">
<h4>Peaks</h4>
<dl class="sc-grid">
<dt>Tran</dt> <dd id="sc-f-tran">—</dd>
<dt>Vert</dt> <dd id="sc-f-vert">—</dd>
<dt>Long</dt> <dd id="sc-f-long">—</dd>
<dt>PVS</dt> <dd id="sc-f-pvs">—</dd>
<dt>Mic</dt> <dd id="sc-f-mic">—</dd>
</dl>
</div>
<div class="sc-section">
<h4>Project</h4>
<dl class="sc-grid">
<dt>Project</dt> <dd id="sc-f-project">—</dd>
<dt>Client</dt> <dd id="sc-f-client">—</dd>
<dt>Operator</dt> <dd id="sc-f-operator">—</dd>
<dt>Location</dt> <dd id="sc-f-loc">—</dd>
</dl>
</div>
<div class="sc-section">
<h4>Source / files</h4>
<dl class="sc-grid">
<dt id="sc-l-bw">Event file</dt> <dd id="sc-f-bw">—</dd>
<dt id="sc-l-bwsize">File size</dt> <dd id="sc-f-bwsize">—</dd>
<dt id="sc-l-sha">File sha256</dt> <dd id="sc-f-sha">—</dd>
<dt>Source kind</dt> <dd id="sc-f-src">—</dd>
<dt title="When SFM received and stored this event — NOT the unit-local trigger time (see Timestamp at the top of the modal for that).">Time received</dt>
<dd id="sc-f-cap">—</dd>
</dl>
</div>
<div class="sc-section">
<h4>Review (editable)</h4>
<div class="sc-row">
<input type="checkbox" id="sc-edit-ft" />
<label for="sc-edit-ft">False trigger</label>
</div>
<div class="sc-row">
<label for="sc-edit-reviewer" style="min-width:60px">Reviewer</label>
<input type="text" id="sc-edit-reviewer" placeholder="e.g. brian" />
</div>
<label for="sc-edit-notes" style="font-size:11px;color:var(--text-mute)">Notes</label>
<textarea id="sc-edit-notes" placeholder="e.g. truck thump near sensor 14:23 — false trigger"></textarea>
</div>
<details class="sc-raw">
<summary>Raw sidecar JSON (read-only peek)</summary>
<pre id="sc-raw-json"></pre>
</details>
</div>
<div class="sc-footer">
<span class="sc-status" id="sc-status"></span>
<button class="btn btn-ghost" id="sc-pdf-btn" onclick="downloadEventReport()"
title="Download an Instantel-style Event Report PDF for this event">
Download PDF
</button>
<button class="btn btn-ghost" onclick="closeSidecarModal()">Cancel</button>
<button class="btn" id="sc-save-btn" onclick="saveSidecarReview()">Save</button>
</div>
</div>
</div>
</body>
</html>