[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:
@@ -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>>,
|
||||
|
||||
Reference in New Issue
Block a user