feat(ui): drive workspaces from rig capabilities
This commit is contained in:
@@ -23,6 +23,7 @@ window.onDecoderRegistryReady = function (fn) {
|
||||
for (const fn of _decoderRegistryReadyCallbacks) fn();
|
||||
_decoderRegistryReadyCallbacks.length = 0;
|
||||
hideUnsupportedDecoderTabs();
|
||||
refreshOperatorLayoutCapabilities();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to fetch decoder registry:", e);
|
||||
@@ -333,8 +334,14 @@ function applyCapabilities(caps) {
|
||||
const txAudioBtn = document.getElementById("tx-audio-btn");
|
||||
const txVolSlider = document.getElementById("tx-vol");
|
||||
const txVolControl = txVolSlider ? txVolSlider.closest(".vol-label") : null;
|
||||
if (txPowerCol) txPowerCol.style.display = caps.tx ? "" : "none";
|
||||
if (txPowerCol) {
|
||||
txPowerCol.style.display = "";
|
||||
const label = txPowerCol.querySelector(".label span");
|
||||
if (label) label.textContent = caps.tx ? "Transmit / Power" : "Power / Tuning";
|
||||
}
|
||||
if (pttBtn) pttBtn.style.display = caps.tx ? "" : "none";
|
||||
if (powerBtn) powerBtn.style.display = "";
|
||||
if (lockBtn) lockBtn.style.display = caps.lockable ? "" : "none";
|
||||
if (txMetersRow) txMetersRow.style.display = caps.tx ? "" : "none";
|
||||
if (txAudioBtn) txAudioBtn.style.display = caps.tx ? "" : "none";
|
||||
if (txVolControl) txVolControl.style.display = caps.tx ? "" : "none";
|
||||
@@ -344,7 +351,7 @@ function applyCapabilities(caps) {
|
||||
|
||||
// TX limit row
|
||||
const txLimitRow = document.getElementById("tx-limit-row");
|
||||
if (txLimitRow && !caps.tx_limit) txLimitRow.style.display = "none";
|
||||
if (txLimitRow) txLimitRow.style.display = caps.tx_limit ? "" : "none";
|
||||
|
||||
// VFO row
|
||||
const vfoRow = document.getElementById("vfo-row");
|
||||
@@ -1305,10 +1312,7 @@ async function refreshRigList() {
|
||||
}
|
||||
});
|
||||
serverRigs = rigs;
|
||||
window.trxUi?.setBroadcastLayoutAvailable(rigs.some((rig) =>
|
||||
Array.isArray(rig?.supported_modes)
|
||||
&& rig.supported_modes.map(normalizeMode).includes("WFM")
|
||||
));
|
||||
refreshOperatorLayoutCapabilities();
|
||||
serverActiveRigId = data.active_remote || null;
|
||||
applyRigList(data.active_remote, rigIds, displayNames);
|
||||
window.trx.modules.map?.syncAprsReceiverMarker();
|
||||
@@ -1317,6 +1321,19 @@ async function refreshRigList() {
|
||||
}
|
||||
}
|
||||
|
||||
function refreshOperatorLayoutCapabilities() {
|
||||
const rigModes = serverRigs.map((rig) =>
|
||||
Array.isArray(rig?.supported_modes) ? rig.supported_modes.map(normalizeMode).filter(Boolean) : []
|
||||
);
|
||||
const decoderModes = new Set(decoderRegistry.flatMap((decoder) =>
|
||||
Array.isArray(decoder?.active_modes) ? decoder.active_modes.map(normalizeMode).filter(Boolean) : []
|
||||
));
|
||||
window.trxUi?.setLayoutCapabilities({
|
||||
broadcast: rigModes.some((modes) => modes.includes("WFM")),
|
||||
digital: decoderModes.size > 0 && rigModes.some((modes) => modes.some((mode) => decoderModes.has(mode))),
|
||||
});
|
||||
}
|
||||
|
||||
function showHint(msg, duration) {
|
||||
powerHint.textContent = msg;
|
||||
if (hintTimer) clearTimeout(hintTimer);
|
||||
|
||||
Reference in New Issue
Block a user