fix(http-frontend): use configured rig display name in header
This commit is contained in:
@@ -321,6 +321,7 @@ let jogAngle = 0;
|
|||||||
let lastClientCount = null;
|
let lastClientCount = null;
|
||||||
let lastLocked = false;
|
let lastLocked = false;
|
||||||
let lastRigIds = [];
|
let lastRigIds = [];
|
||||||
|
let lastRigDisplayNames = {};
|
||||||
const originalTitle = document.title;
|
const originalTitle = document.title;
|
||||||
const savedTheme = loadSetting("theme", null);
|
const savedTheme = loadSetting("theme", null);
|
||||||
|
|
||||||
@@ -375,9 +376,18 @@ function populateRigPicker(selectEl, rigIds, activeRigId, disabled) {
|
|||||||
selectEl.disabled = disabled;
|
selectEl.disabled = disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyRigList(activeRigId, rigIds) {
|
function updateRigSubtitle(activeRigId) {
|
||||||
|
if (!rigSubtitle) return;
|
||||||
|
const name = (activeRigId && lastRigDisplayNames[activeRigId]) || activeRigId || "--";
|
||||||
|
rigSubtitle.textContent = `Rig: ${name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyRigList(activeRigId, rigIds, displayNames) {
|
||||||
if (!Array.isArray(rigIds)) return;
|
if (!Array.isArray(rigIds)) return;
|
||||||
lastRigIds = rigIds.filter((id) => typeof id === "string" && id.length > 0);
|
lastRigIds = rigIds.filter((id) => typeof id === "string" && id.length > 0);
|
||||||
|
if (displayNames && typeof displayNames === "object") {
|
||||||
|
lastRigDisplayNames = { ...displayNames };
|
||||||
|
}
|
||||||
const aboutList = document.getElementById("about-rig-list");
|
const aboutList = document.getElementById("about-rig-list");
|
||||||
if (aboutList) {
|
if (aboutList) {
|
||||||
aboutList.textContent = lastRigIds.length ? lastRigIds.join(", ") : "--";
|
aboutList.textContent = lastRigIds.length ? lastRigIds.join(", ") : "--";
|
||||||
@@ -391,6 +401,7 @@ function applyRigList(activeRigId, rigIds) {
|
|||||||
populateRigPicker(headerRigSwitchSelect, lastRigIds, activeRigId, lastRigIds.length === 0);
|
populateRigPicker(headerRigSwitchSelect, lastRigIds, activeRigId, lastRigIds.length === 0);
|
||||||
if (rigSwitchBtn) rigSwitchBtn.disabled = disableSwitch;
|
if (rigSwitchBtn) rigSwitchBtn.disabled = disableSwitch;
|
||||||
if (headerRigSwitchBtn) headerRigSwitchBtn.disabled = disableSwitch;
|
if (headerRigSwitchBtn) headerRigSwitchBtn.disabled = disableSwitch;
|
||||||
|
updateRigSubtitle(activeRigId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshRigList() {
|
async function refreshRigList() {
|
||||||
@@ -398,8 +409,18 @@ async function refreshRigList() {
|
|||||||
const resp = await fetch("/rigs", { cache: "no-store" });
|
const resp = await fetch("/rigs", { cache: "no-store" });
|
||||||
if (!resp.ok) return;
|
if (!resp.ok) return;
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
const rigIds = Array.isArray(data.rigs) ? data.rigs.map((r) => r && r.rig_id).filter(Boolean) : [];
|
const rigs = Array.isArray(data.rigs) ? data.rigs : [];
|
||||||
applyRigList(data.active_rig_id, rigIds);
|
const rigIds = rigs.map((r) => r && r.rig_id).filter(Boolean);
|
||||||
|
const displayNames = {};
|
||||||
|
rigs.forEach((r) => {
|
||||||
|
if (!r || !r.rig_id) return;
|
||||||
|
if (typeof r.display_name === "string" && r.display_name.length > 0) {
|
||||||
|
displayNames[r.rig_id] = r.display_name;
|
||||||
|
} else {
|
||||||
|
displayNames[r.rig_id] = r.rig_id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
applyRigList(data.active_rig_id, rigIds, displayNames);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Non-fatal: SSE/status path still drives main UI.
|
// Non-fatal: SSE/status path still drives main UI.
|
||||||
}
|
}
|
||||||
@@ -731,7 +752,6 @@ let serverVersion = null;
|
|||||||
let serverBuildDate = null;
|
let serverBuildDate = null;
|
||||||
let serverCallsign = null;
|
let serverCallsign = null;
|
||||||
let ownerCallsign = null;
|
let ownerCallsign = null;
|
||||||
let rigDisplayName = null;
|
|
||||||
let serverLat = null;
|
let serverLat = null;
|
||||||
let serverLon = null;
|
let serverLon = null;
|
||||||
|
|
||||||
@@ -749,9 +769,6 @@ function updateTitle() {
|
|||||||
|
|
||||||
function render(update) {
|
function render(update) {
|
||||||
if (!update) return;
|
if (!update) return;
|
||||||
if (update.info && typeof update.info.model === "string" && update.info.model.length > 0) {
|
|
||||||
rigDisplayName = update.info.model;
|
|
||||||
}
|
|
||||||
if (update.server_version) serverVersion = update.server_version;
|
if (update.server_version) serverVersion = update.server_version;
|
||||||
if (update.server_build_date) serverBuildDate = update.server_build_date;
|
if (update.server_build_date) serverBuildDate = update.server_build_date;
|
||||||
if (update.server_callsign) serverCallsign = update.server_callsign;
|
if (update.server_callsign) serverCallsign = update.server_callsign;
|
||||||
@@ -801,9 +818,7 @@ function render(update) {
|
|||||||
serverSubtitle.textContent = `trx-server hosted by ${update.server_callsign}`;
|
serverSubtitle.textContent = `trx-server hosted by ${update.server_callsign}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rigSubtitle) {
|
updateRigSubtitle(update.active_rig_id);
|
||||||
rigSubtitle.textContent = `Rig: ${rigDisplayName || "--"}`;
|
|
||||||
}
|
|
||||||
if (ownerSubtitle) {
|
if (ownerSubtitle) {
|
||||||
ownerSubtitle.textContent = `Owner: ${ownerCallsign || "--"}`;
|
ownerSubtitle.textContent = `Owner: ${ownerCallsign || "--"}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -526,6 +526,7 @@ pub async fn clear_cw_decode(
|
|||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
struct RigListItem {
|
struct RigListItem {
|
||||||
rig_id: String,
|
rig_id: String,
|
||||||
|
display_name: Option<String>,
|
||||||
manufacturer: String,
|
manufacturer: String,
|
||||||
model: String,
|
model: String,
|
||||||
initialized: bool,
|
initialized: bool,
|
||||||
@@ -554,6 +555,7 @@ fn build_rig_list_payload(context: &FrontendRuntimeContext) -> RigListResponse {
|
|||||||
fn map_rig_entry(entry: &RemoteRigEntry) -> RigListItem {
|
fn map_rig_entry(entry: &RemoteRigEntry) -> RigListItem {
|
||||||
RigListItem {
|
RigListItem {
|
||||||
rig_id: entry.rig_id.clone(),
|
rig_id: entry.rig_id.clone(),
|
||||||
|
display_name: entry.display_name.clone(),
|
||||||
manufacturer: entry.state.info.manufacturer.clone(),
|
manufacturer: entry.state.info.manufacturer.clone(),
|
||||||
model: entry.state.info.model.clone(),
|
model: entry.state.info.model.clone(),
|
||||||
initialized: entry.state.initialized,
|
initialized: entry.state.initialized,
|
||||||
|
|||||||
Reference in New Issue
Block a user