feat(webapp): config and call-home writes wait for phases 4-5; Diagnostics only for a confirmed Series-3 unit
- Config, with a serial: Read shows the unit's shared UnitSettings (setup, record mode, sample rate, record time, histogram interval, geo trigger, notes; — for null) in place of the write form. settingsRows() is in the device-routing block, Node-tested; the rows are rendered as text, since setup names and notes come from the unit. - Write stays off for both series (and without a serial), tooltip "Coming in phase 5 (#46)"; Call Home write likewise, "Coming in phase 4". - Call Home read follows controlsFor().callHomeRead; for a confirmed Series 4 the tab says "Not yet available for Series 4". - Diagnostics: every button follows controlsFor().diagnostics (Task 3), and a refresh for anything but a confirmed Series-3 unit sends nothing and says why. Its requests carry the typed serial, so the server guard checks it. - Without a serial the legacy reads are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
3f249e2322
commit
a709d2388d
2 files changed
+85
-3
No files matched your search
+68
-2
@@ -1008,7 +1008,12 @@
|
||||
═══════════════════════════════════════════════════════════════════ -->
|
||||
<div id="tab-config" class="tab-pane">
|
||||
|
||||
<div class="cfg-grid">
|
||||
<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">
|
||||
@@ -1233,6 +1238,7 @@
|
||||
<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 -->
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"]
|
||||
Reference in new issue
Block a user