diff --git a/sfm/sfm_webapp.html b/sfm/sfm_webapp.html index e02d8e7..b7c251f 100644 --- a/sfm/sfm_webapp.html +++ b/sfm/sfm_webapp.html @@ -1008,7 +1008,12 @@ ═══════════════════════════════════════════════════════════════════ -->
-
+ + +
@@ -1233,6 +1238,7 @@ +
@@ -1581,6 +1587,24 @@ function eventView(ev) { return { label, title: ev.record_type || '', peaks }; } +// What the Config tab's serial-mode Read shows for a UnitSettings reply. +function settingsRows(st) { + const dash = v => (v == null || v === '' ? '—' : v); + const hi = st.histogram_interval_s; + const rows = [ + ['Setup Name', dash(st.setup_name)], + ['Record Mode', dash(st.record_mode)], + ['Sample Rate', st.sample_rate != null ? `${st.sample_rate} sps` : '—'], + ['Record Time', st.record_time_s != null ? `${st.record_time_s.toFixed(2)} s` : '—'], + ['Histogram Interval', hi == null ? '—' : hi < 60 ? `${hi} s` : `${hi / 60} min`], + ['Geo Trigger', st.geo_trigger_ips != null ? `${st.geo_trigger_ips.toFixed(4)} in/s` : '—'], + ]; + const notes = Object.entries(st.notes || {}); + if (!notes.length) rows.push(['Notes', '—']); + for (const [k, v] of notes) rows.push([`Note: ${k}`, dash(v)]); + return rows; +} + function downloadSummary(body) { if (body.inserted === false) return `already stored — ${body.stored_filename}`; return `stored ${body.stored_filename}, ${body.filesize} bytes, check: ${(body.detail || {}).check}`; @@ -1686,7 +1710,11 @@ function applyControls() { cw.disabled = !c.configWrite; cw.title = c.reasons.configWrite; const hw = document.getElementById('ch-write-btn'); hw.disabled = !c.callHomeWrite; hw.title = c.reasons.callHomeWrite; - document.getElementById('ch-read-btn').disabled = !c.callHomeRead; + const chr = document.getElementById('ch-read-btn'); + chr.disabled = !c.callHomeRead; + const s4 = series === 4 ? 'Not yet available for Series 4' : ''; + chr.title = s4; + document.getElementById('ch-series-note').textContent = s4; setMonitorButtons(); } @@ -2069,6 +2097,19 @@ function populateDeviceTab() { renderTable('project-table', projectRows); } +function renderTextTable(id, rows) { + const el = document.getElementById(id); + el.innerHTML = ''; + for (const [label, value] of rows) { + const row = document.createElement('div'); + row.className = 'dev-table-row'; + const l = document.createElement('div'); l.className = 'dtr-label'; l.textContent = label; + const v = document.createElement('div'); v.className = 'dtr-value'; v.textContent = value; + row.append(l, v); + el.appendChild(row); + } +} + function renderTable(id, rows) { const el = document.getElementById(id); el.innerHTML = ''; @@ -2120,6 +2161,10 @@ function diagResult(id, text, cls) { async function refreshDiagnostics() { if (!devHost()) return; const st = document.getElementById('diag-status'); + if (!controlsFor(currentUnit()).diagnostics) { + if (st) { st.textContent = 'Diagnostics are MiniMate tools: connect to a Series-3 unit first.'; st.className = ''; } + return; + } if (st) { st.textContent = 'Reading…'; st.className = 'loading'; } const [mon, store, idx] = await Promise.all([ @@ -2259,8 +2304,29 @@ function clearConfigForm() { setCfgStatus(''); } +// Serial mode: the shared UnitSettings, read-only (writes wait for phase 5). +async function readSettingsBySerial() { + const btn = document.getElementById('cfg-read-btn'); + btn.disabled = true; + setCfgStatus('Reading settings from the unit…'); + try { + const st = await deviceFetch('settings'); + renderTextTable('cfg-settings-table', settingsRows(st)); + document.getElementById('cfg-settings').style.display = 'block'; + document.getElementById('cfg-form').style.display = 'none'; + setCfgStatus(`Settings read from ${st.serial}.`, 'ok'); + } catch (e) { + setCfgStatus(`Read failed: ${e.message}`, 'error'); + } finally { + btn.disabled = false; + } +} + async function readConfig() { if (!devHost()) { setCfgStatus('Not connected.', 'error'); return; } + if (serialMode()) { await readSettingsBySerial(); return; } + document.getElementById('cfg-settings').style.display = 'none'; + document.getElementById('cfg-form').style.display = ''; setCfgStatus('Reading config from device…'); document.getElementById('cfg-read-btn').disabled = true; try { diff --git a/tests/test_webapp_device_routing.py b/tests/test_webapp_device_routing.py index dac403a..7c91bfa 100644 --- a/tests/test_webapp_device_routing.py +++ b/tests/test_webapp_device_routing.py @@ -24,7 +24,7 @@ PAGE = Path(__file__).resolve().parent.parent / "sfm" / "sfm_webapp.html" NODE = shutil.which("node") pytestmark = pytest.mark.skipif(NODE is None, reason="node is not installed; the page-logic tests need it") -EXPORTS = ["seriesFromSerial", "unitQuery", "deviceUrl", "confirmedSeries", "controlsFor", "eventView", +EXPORTS = ["seriesFromSerial", "unitQuery", "deviceUrl", "confirmedSeries", "controlsFor", "eventView", "settingsRows", "changeSummary", "downloadSummary"] @@ -204,3 +204,19 @@ def test_event_view_reads_both_event_shapes(): assert b == {"label": "2026-10-26 16:06:37", "title": "Waveform", "peaks": {"tran": 0.03, "vert": 0.095, "long": 0.02, "pvs": 0.1, "micPsi": 0.0001}} assert c == {"label": "Event 5", "title": "", "peaks": None} + + +def test_settings_rows_show_unit_settings_with_a_dash_for_null(): + full = {"serial": "UM20147", "series": 4, "setup_name": "TMI default", "record_mode": "Waveform", + "sample_rate": 1024, "record_time_s": 2.0, "histogram_interval_s": 900, "geo_trigger_ips": 0.02, + "notes": {"project": "Bench", "client": ""}} + empty = {"serial": "BE9441", "series": 3, "setup_name": None, "record_mode": None, "sample_rate": None, + "record_time_s": None, "histogram_interval_s": None, "geo_trigger_ips": None, "notes": {}} + a, b, c = run(["settingsRows", [full]], ["settingsRows", [empty]], + ["settingsRows", [{**empty, "histogram_interval_s": 15}]]) + assert a == [["Setup Name", "TMI default"], ["Record Mode", "Waveform"], ["Sample Rate", "1024 sps"], + ["Record Time", "2.00 s"], ["Histogram Interval", "15 min"], ["Geo Trigger", "0.0200 in/s"], + ["Note: project", "Bench"], ["Note: client", "—"]] + assert b == [["Setup Name", "—"], ["Record Mode", "—"], ["Sample Rate", "—"], ["Record Time", "—"], + ["Histogram Interval", "—"], ["Geo Trigger", "—"], ["Notes", "—"]] + assert c[4] == ["Histogram Interval", "15 s"]