[feat](trx-client): add bandplan display config to client settings

Add bandplan_enabled (default: true) and bandplan_region (default:
"iaru_r1") fields to [frontends.http] config section, allowing the
operator to control the initial bandplan display setting from the
server config rather than requiring each browser session to configure
it manually. The server-provided default is applied on first connect
only when the user has no existing localStorage override.

https://claude.ai/code/session_01H7427hzbJepJzkoUJzoDmH
Signed-off-by: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-03-29 22:27:21 +00:00
committed by Stan Grams
parent 6000c30d9c
commit 8c5706f6c3
5 changed files with 77 additions and 0 deletions
+4
View File
@@ -282,6 +282,8 @@ pub struct HttpUiConfig {
pub initial_map_zoom: u8,
pub spectrum_coverage_margin_hz: u32,
pub spectrum_usable_span_ratio: f32,
pub bandplan_enabled: bool,
pub bandplan_region: String,
pub decode_history_retention_min: u64,
pub decode_history_retention_min_by_rig: HashMap<String, u64>,
}
@@ -293,6 +295,8 @@ impl Default for HttpUiConfig {
initial_map_zoom: 10,
spectrum_coverage_margin_hz: 50_000,
spectrum_usable_span_ratio: 0.92,
bandplan_enabled: true,
bandplan_region: "iaru_r1".to_string(),
decode_history_retention_min: 24 * 60,
decode_history_retention_min_by_rig: HashMap::new(),
}
@@ -3177,6 +3177,22 @@ function render(update) {
if (typeof update.show_sdr_gain_control === "boolean") {
if (sdrSettingsRowEl) sdrSettingsRowEl.style.display = update.show_sdr_gain_control ? "" : "none";
}
// Apply server-configured bandplan defaults once, only when the user has not
// previously overridden the setting via the UI (localStorage).
if (!_bandplanServerDefaultApplied && typeof update.bandplan_enabled === "boolean"
&& typeof update.bandplan_region === "string") {
_bandplanServerDefaultApplied = true;
const hasUserOverride = localStorage.getItem(STORAGE_PREFIX + "bandplanRegion") !== null;
if (!hasUserOverride) {
const region = update.bandplan_enabled ? update.bandplan_region : "off";
bandplanRegion = region;
saveSetting("bandplanRegion", region);
if (bandplanRegionSelect) bandplanRegionSelect.value = region;
bandplanSegmentsCache = null;
bandplanCacheKey = "";
if (lastSpectrumData) scheduleSpectrumDraw();
}
}
if (update.filter && sdrAgcEl && typeof update.filter.sdr_agc_enabled === "boolean") {
sdrAgcEl.checked = update.filter.sdr_agc_enabled;
updateSdrGainInputState();
@@ -11279,6 +11295,7 @@ if (spectrumCenterRightBtn) {
let bandplanData = null;
let bandplanRegion = loadSetting("bandplanRegion", "off");
let bandplanShowLabels = loadSetting("bandplanLabels", true);
let _bandplanServerDefaultApplied = false;
let bandplanSegmentsCache = null;
let bandplanCacheKey = "";
@@ -82,6 +82,8 @@ struct FrontendMeta {
initial_map_zoom: u8,
spectrum_coverage_margin_hz: u32,
spectrum_usable_span_ratio: f32,
bandplan_enabled: bool,
bandplan_region: String,
decode_history_retention_min: u64,
server_connected: bool,
}
@@ -171,6 +173,8 @@ fn frontend_meta_from_context(
initial_map_zoom: initial_map_zoom_from_context(context),
spectrum_coverage_margin_hz: spectrum_coverage_margin_hz_from_context(context),
spectrum_usable_span_ratio: spectrum_usable_span_ratio_from_context(context),
bandplan_enabled: context.http_ui.bandplan_enabled,
bandplan_region: context.http_ui.bandplan_region.clone(),
decode_history_retention_min: decode_history_retention_min_from_context(context),
server_connected,
}