[feat](trx-client): support website_name in header
Add an optional website_name config field and prefer it over callsign for the linked web header title label. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -178,6 +178,8 @@ pub struct FrontendRuntimeContext {
|
||||
pub owner_callsign: Option<String>,
|
||||
/// Optional website URL for the web UI header title link.
|
||||
pub owner_website_url: Option<String>,
|
||||
/// Optional website name for the web UI header title label.
|
||||
pub owner_website_name: Option<String>,
|
||||
/// Latest spectrum frame from the active SDR rig; None for non-SDR backends.
|
||||
pub spectrum: Arc<Mutex<SharedSpectrum>>,
|
||||
}
|
||||
@@ -211,6 +213,7 @@ impl FrontendRuntimeContext {
|
||||
remote_rigs: Arc::new(Mutex::new(Vec::new())),
|
||||
owner_callsign: None,
|
||||
owner_website_url: None,
|
||||
owner_website_name: None,
|
||||
spectrum: Arc::new(Mutex::new(SharedSpectrum::default())),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1266,6 +1266,7 @@ let serverBuildDate = null;
|
||||
let serverCallsign = null;
|
||||
let ownerCallsign = null;
|
||||
let ownerWebsiteUrl = null;
|
||||
let ownerWebsiteName = null;
|
||||
let serverRigs = [];
|
||||
let serverActiveRigId = null;
|
||||
let serverLat = null;
|
||||
@@ -1284,7 +1285,7 @@ function updateTitle() {
|
||||
const titleEl = document.getElementById("rig-title");
|
||||
if (titleEl) {
|
||||
if (ownerWebsiteUrl) {
|
||||
const label = ownerCallsign || displayLabelFromUrl(ownerWebsiteUrl);
|
||||
const label = ownerWebsiteName || displayLabelFromUrl(ownerWebsiteUrl);
|
||||
titleEl.innerHTML =
|
||||
`<a class="title-link" href="${escapeMapHtml(ownerWebsiteUrl)}" target="_blank" rel="noopener">${escapeMapHtml(label)}</a>`;
|
||||
} else {
|
||||
@@ -1314,6 +1315,9 @@ function render(update) {
|
||||
if (typeof update.owner_website_url === "string" && update.owner_website_url.length > 0) {
|
||||
ownerWebsiteUrl = update.owner_website_url;
|
||||
}
|
||||
if (typeof update.owner_website_name === "string" && update.owner_website_name.length > 0) {
|
||||
ownerWebsiteName = update.owner_website_name;
|
||||
}
|
||||
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)) {
|
||||
|
||||
@@ -37,6 +37,7 @@ struct FrontendMeta {
|
||||
rig_ids: Vec<String>,
|
||||
owner_callsign: Option<String>,
|
||||
owner_website_url: Option<String>,
|
||||
owner_website_name: Option<String>,
|
||||
show_sdr_gain_control: bool,
|
||||
initial_map_zoom: u8,
|
||||
}
|
||||
@@ -86,6 +87,9 @@ fn inject_frontend_meta(json: &str, meta: FrontendMeta) -> String {
|
||||
if let Some(url) = meta.owner_website_url {
|
||||
map.insert("owner_website_url".to_string(), serde_json::json!(url));
|
||||
}
|
||||
if let Some(name) = meta.owner_website_name {
|
||||
map.insert("owner_website_name".to_string(), serde_json::json!(name));
|
||||
}
|
||||
map.insert(
|
||||
"show_sdr_gain_control".to_string(),
|
||||
serde_json::json!(meta.show_sdr_gain_control),
|
||||
@@ -110,6 +114,7 @@ fn frontend_meta_from_context(
|
||||
rig_ids: rig_ids_from_context(context),
|
||||
owner_callsign: owner_callsign_from_context(context),
|
||||
owner_website_url: owner_website_url_from_context(context),
|
||||
owner_website_name: owner_website_name_from_context(context),
|
||||
show_sdr_gain_control: show_sdr_gain_control_from_context(context),
|
||||
initial_map_zoom: initial_map_zoom_from_context(context),
|
||||
}
|
||||
@@ -149,6 +154,10 @@ fn owner_website_url_from_context(context: &FrontendRuntimeContext) -> Option<St
|
||||
context.owner_website_url.clone()
|
||||
}
|
||||
|
||||
fn owner_website_name_from_context(context: &FrontendRuntimeContext) -> Option<String> {
|
||||
context.owner_website_name.clone()
|
||||
}
|
||||
|
||||
fn show_sdr_gain_control_from_context(context: &FrontendRuntimeContext) -> bool {
|
||||
context.http_show_sdr_gain_control
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user