settings: add mic_unit_pref for event-report chart
New UserPreferences field controls the mic channel's unit on the SFM event-detail modal's waveform chart only. "dBL" default, "psi" alternate. Peaks everywhere else (tables, KPI tiles, modal summary) stay in dBL regardless — this is strictly a chart-axis preference. Surfaced as a single dropdown on Settings → General, below the auto-refresh interval. Setting up the storage half ahead of the chart port in the next commit, so the chart can read the value from /api/settings/preferences on first render instead of needing a follow-up wiring pass. Includes idempotent backend/migrate_add_mic_unit_pref.py for fleets already on an older schema. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+21
-1
@@ -122,6 +122,21 @@
|
||||
How often the dashboard should refresh automatically
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Event-Report Mic Units -->
|
||||
<div>
|
||||
<label for="mic-unit-pref" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
||||
Event Report — Mic Channel Units
|
||||
</label>
|
||||
<select id="mic-unit-pref"
|
||||
class="w-full max-w-md px-4 py-2 text-gray-900 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-seismo-orange">
|
||||
<option value="dBL" selected>dB(L) — sound pressure level</option>
|
||||
<option value="psi">psi — raw pressure</option>
|
||||
</select>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
||||
Applies only to the waveform chart inside the event detail modal. Peak values everywhere else (tables, KPIs, modal summary) stay in dB(L) regardless.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button onclick="saveGeneralSettings()" class="mt-6 px-6 py-3 bg-seismo-orange hover:bg-orange-600 text-white rounded-lg transition-colors">
|
||||
@@ -771,6 +786,9 @@ async function loadPreferences() {
|
||||
// Load auto-refresh interval
|
||||
document.getElementById('refresh-interval').value = prefs.auto_refresh_interval || 10;
|
||||
|
||||
// Load event-report mic units
|
||||
document.getElementById('mic-unit-pref').value = prefs.mic_unit_pref || 'dBL';
|
||||
|
||||
// Load status thresholds
|
||||
document.getElementById('ok-threshold').value = prefs.status_ok_threshold_hours || 12;
|
||||
document.getElementById('pending-threshold').value = prefs.status_pending_threshold_hours || 24;
|
||||
@@ -788,6 +806,7 @@ async function saveGeneralSettings() {
|
||||
const timezone = document.getElementById('timezone-select').value;
|
||||
const theme = document.querySelector('input[name="theme"]:checked').value;
|
||||
const autoRefreshInterval = parseInt(document.getElementById('refresh-interval').value);
|
||||
const micUnitPref = document.getElementById('mic-unit-pref').value;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/settings/preferences', {
|
||||
@@ -796,7 +815,8 @@ async function saveGeneralSettings() {
|
||||
body: JSON.stringify({
|
||||
timezone,
|
||||
theme,
|
||||
auto_refresh_interval: autoRefreshInterval
|
||||
auto_refresh_interval: autoRefreshInterval,
|
||||
mic_unit_pref: micUnitPref
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user