[feat](trx-client): add configurable initial map zoom

Add an HTTP frontend config option for the initial APRS map zoom,
expose it through frontend metadata, and apply it in the web UI.

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-01 16:35:12 +01:00
parent 8c6c370563
commit f537e1a11b
5 changed files with 29 additions and 1 deletions
+3
View File
@@ -168,6 +168,8 @@ pub struct FrontendRuntimeContext {
pub http_auth_cookie_same_site: String,
/// Whether the HTTP UI should expose the RF Gain control.
pub http_show_sdr_gain_control: bool,
/// Initial APRS map zoom level when receiver coordinates are available.
pub http_initial_map_zoom: u8,
/// Currently selected remote rig id (used by remote client routing).
pub remote_active_rig_id: Arc<Mutex<Option<String>>>,
/// Cached remote rig list from GetRigs polling.
@@ -202,6 +204,7 @@ impl FrontendRuntimeContext {
http_auth_cookie_secure: false,
http_auth_cookie_same_site: "Lax".to_string(),
http_show_sdr_gain_control: true,
http_initial_map_zoom: 10,
remote_active_rig_id: Arc::new(Mutex::new(None)),
remote_rigs: Arc::new(Mutex::new(Vec::new())),
owner_callsign: None,
@@ -1247,6 +1247,7 @@ let serverCallsign = null;
let ownerCallsign = null;
let serverLat = null;
let serverLon = null;
let initialMapZoom = 10;
function updateFooterBuildInfo() {
const serverEl = document.getElementById("footer-server-build");
@@ -1274,6 +1275,9 @@ function render(update) {
}
if (update.server_latitude != null) serverLat = update.server_latitude;
if (update.server_longitude != null) serverLon = update.server_longitude;
if (typeof update.initial_map_zoom === "number" && Number.isFinite(update.initial_map_zoom)) {
initialMapZoom = Math.max(1, Math.round(update.initial_map_zoom));
}
updateTitle();
updateFooterBuildInfo();
@@ -2406,7 +2410,7 @@ function initAprsMap() {
const hasLocation = serverLat != null && serverLon != null;
const center = hasLocation ? [serverLat, serverLon] : [20, 0];
const zoom = hasLocation ? 10 : 2;
const zoom = hasLocation ? initialMapZoom : 2;
aprsMap = L.map("aprs-map").setView(center, zoom);
updateMapBaseLayerForTheme(currentTheme());
@@ -37,6 +37,7 @@ struct FrontendMeta {
rig_ids: Vec<String>,
owner_callsign: Option<String>,
show_sdr_gain_control: bool,
initial_map_zoom: u8,
}
#[get("/status")]
@@ -85,6 +86,10 @@ fn inject_frontend_meta(json: &str, meta: FrontendMeta) -> String {
"show_sdr_gain_control".to_string(),
serde_json::json!(meta.show_sdr_gain_control),
);
map.insert(
"initial_map_zoom".to_string(),
serde_json::json!(meta.initial_map_zoom),
);
serde_json::to_string(&value).unwrap_or_else(|_| json.to_string())
}
@@ -101,6 +106,7 @@ fn frontend_meta_from_context(
rig_ids: rig_ids_from_context(context),
owner_callsign: owner_callsign_from_context(context),
show_sdr_gain_control: show_sdr_gain_control_from_context(context),
initial_map_zoom: initial_map_zoom_from_context(context),
}
}
@@ -138,6 +144,10 @@ fn show_sdr_gain_control_from_context(context: &FrontendRuntimeContext) -> bool
context.http_show_sdr_gain_control
}
fn initial_map_zoom_from_context(context: &FrontendRuntimeContext) -> u8 {
context.http_initial_map_zoom
}
#[get("/events")]
pub async fn events(
state: web::Data<watch::Receiver<RigState>>,