diff --git a/src/static/dashboard.html b/src/static/dashboard.html index 5de11a8..6aafb9c 100644 --- a/src/static/dashboard.html +++ b/src/static/dashboard.html @@ -202,9 +202,9 @@
-
Reporting stations
with current readings
-
Combined discharge
sum of reported flows · m³/s
-
Strongest flow
Awaiting station data
+
Reporting stations
RID gauges with current readings
+
Chiang Mai river flow
P.1 Nawarat Bridge · m³/s
+
Most stressed gauge
Awaiting station data
Last updated
Loading latest readings
@@ -284,6 +284,14 @@
Stations
distinct in database
Coverage
of RID hourly slots recorded
+ + @@ -676,6 +684,7 @@ const additional = sensors .filter((sensor) => !existingCodes.has(sensor.station_code)) .sort((a, b) => (Number(b.bank_percent) || -1) - (Number(a.bank_percent) || -1)); + state.hiiReportingCount = additional.length; $('thaiwater-count').textContent = `${additional.length} Ping basin stations · ThaiWater/HII water level`; additional.forEach((sensor) => { const percent = sensor.bank_percent == null ? null : Number(sensor.bank_percent); @@ -713,15 +722,26 @@ function renderSummary(stations, readings) { const current = stations.map((s) => readings.get(s.station_code)).filter(Boolean); - const flows = current.filter((m) => m.discharge != null).map((m) => ({ code: m.station_code, value: Number(m.discharge) })); - const total = flows.reduce((sum, item) => sum + item.value, 0); - const peak = flows.length ? flows.reduce((max, item) => item.value > max.value ? item : max) : null; const timestamps = current.map((m) => new Date(m.timestamp)).filter((date) => !Number.isNaN(date.getTime())); const latest = timestamps.length ? new Date(Math.max(...timestamps.map((date) => date.getTime()))) : null; $('station-count').textContent = `${current.length} / ${stations.length}`; - $('total-flow').textContent = flows.length ? total.toLocaleString(undefined, { maximumFractionDigits: 1 }) : '—'; - $('peak-flow').textContent = peak ? peak.value.toFixed(1) : '—'; - $('peak-station').textContent = peak ? `${peak.code} · m³/s` : 'No discharge reported'; + if (state.hiiReportingCount != null) { + $('station-count-note').textContent = `RID gauges · +${state.hiiReportingCount} ThaiWater/HII reporting`; + } + // Flow at the basin anchor (summing sequential mainstem gauges would + // double-count the same water, so no basin-wide total is shown). + const p1 = readings.get('P.1'); + const p1Flow = p1?.discharge == null ? null : Number(p1.discharge); + $('total-flow').textContent = p1Flow == null ? '—' : p1Flow.toLocaleString(undefined, { maximumFractionDigits: 1 }); + $('cm-flow-note').textContent = p1?.discharge_percent != null + ? `P.1 Nawarat Bridge · ${Number(p1.discharge_percent).toFixed(0)}% of channel capacity · m³/s` + : 'P.1 Nawarat Bridge · m³/s'; + const stressed = current + .filter((m) => m.discharge_percent != null) + .map((m) => ({ code: m.station_code, percent: Number(m.discharge_percent) })); + const worst = stressed.length ? stressed.reduce((max, item) => item.percent > max.percent ? item : max) : null; + $('peak-flow').textContent = worst ? `${worst.percent.toFixed(0)}%` : '—'; + $('peak-station').textContent = worst ? `${worst.code} · of channel capacity` : 'No capacity data'; $('last-updated').textContent = latest ? latest.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) : '—'; if (latest) { const minutes = Math.max(0, Math.round((Date.now() - latest.getTime()) / 60000));