[feat](trx-frontend-http): add decoder toggle/clear UI and endpoints
Add POST endpoints for toggle_aprs_decode, toggle_cw_decode, clear_aprs_decode, and clear_cw_decode. Add toggle buttons in APRS and CW tabs. Render decoder enabled state from SSE updates. Clear button now also resets server-side decoder state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
@@ -362,6 +362,24 @@ function render(update) {
|
||||
if (typeof update.clients === "number") {
|
||||
document.getElementById("about-clients").textContent = update.clients;
|
||||
}
|
||||
// Decoder toggle buttons
|
||||
const aprsToggleBtn = document.getElementById("aprs-decode-toggle-btn");
|
||||
const cwToggleBtn = document.getElementById("cw-decode-toggle-btn");
|
||||
if (aprsToggleBtn) {
|
||||
const aprsOn = !!update.aprs_decode_enabled;
|
||||
aprsToggleBtn.textContent = aprsOn ? "Disable APRS" : "Enable APRS";
|
||||
aprsToggleBtn.style.borderColor = aprsOn ? "#00d17f" : "";
|
||||
aprsToggleBtn.style.color = aprsOn ? "#00d17f" : "";
|
||||
window.aprsDecodeEnabled = aprsOn;
|
||||
}
|
||||
if (cwToggleBtn) {
|
||||
const cwOn = !!update.cw_decode_enabled;
|
||||
cwToggleBtn.textContent = cwOn ? "Disable CW" : "Enable CW";
|
||||
cwToggleBtn.style.borderColor = cwOn ? "#00d17f" : "";
|
||||
cwToggleBtn.style.color = cwOn ? "#00d17f" : "";
|
||||
window.cwDecodeEnabled = cwOn;
|
||||
}
|
||||
|
||||
powerHint.textContent = readyText();
|
||||
lastLocked = update.status && update.status.lock === true;
|
||||
lockBtn.textContent = lastLocked ? "Unlock" : "Lock";
|
||||
|
||||
@@ -145,6 +145,7 @@
|
||||
</div>
|
||||
<div id="subtab-aprs" class="sub-tab-panel" style="display:none;">
|
||||
<div class="aprs-controls">
|
||||
<button id="aprs-decode-toggle-btn" type="button">Enable APRS</button>
|
||||
<button id="aprs-clear-btn" type="button">Clear</button>
|
||||
<small id="aprs-status" style="color:var(--text-muted);">Waiting for server decode</small>
|
||||
</div>
|
||||
@@ -152,6 +153,7 @@
|
||||
</div>
|
||||
<div id="subtab-cw" class="sub-tab-panel" style="display:none;">
|
||||
<div class="cw-controls">
|
||||
<button id="cw-decode-toggle-btn" type="button">Enable CW</button>
|
||||
<button id="cw-clear-btn" type="button">Clear</button>
|
||||
<small id="cw-status" style="color:var(--text-muted);">Waiting for server decode</small>
|
||||
<div id="cw-signal-indicator" class="cw-signal-off"></div>
|
||||
|
||||
@@ -72,10 +72,15 @@ function addAprsPacket(pkt) {
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("aprs-clear-btn").addEventListener("click", () => {
|
||||
document.getElementById("aprs-decode-toggle-btn").addEventListener("click", async () => {
|
||||
try { await postPath("/toggle_aprs_decode"); } catch (e) { console.error("APRS toggle failed", e); }
|
||||
});
|
||||
|
||||
document.getElementById("aprs-clear-btn").addEventListener("click", async () => {
|
||||
aprsPacketsEl.innerHTML = "";
|
||||
aprsPacketHistory = [];
|
||||
saveSetting("aprsPackets", []);
|
||||
try { await postPath("/clear_aprs_decode"); } catch (e) { console.error("APRS clear failed", e); }
|
||||
});
|
||||
|
||||
// Restore saved packets and map markers on page load
|
||||
|
||||
@@ -6,8 +6,13 @@ const cwToneInput = document.getElementById("cw-tone");
|
||||
const cwSignalIndicator = document.getElementById("cw-signal-indicator");
|
||||
const CW_MAX_LINES = 200;
|
||||
|
||||
document.getElementById("cw-clear-btn").addEventListener("click", () => {
|
||||
document.getElementById("cw-decode-toggle-btn").addEventListener("click", async () => {
|
||||
try { await postPath("/toggle_cw_decode"); } catch (e) { console.error("CW toggle failed", e); }
|
||||
});
|
||||
|
||||
document.getElementById("cw-clear-btn").addEventListener("click", async () => {
|
||||
cwOutputEl.innerHTML = "";
|
||||
try { await postPath("/clear_cw_decode"); } catch (e) { console.error("CW clear failed", e); }
|
||||
});
|
||||
|
||||
// --- Server-side CW decode handler ---
|
||||
|
||||
Reference in New Issue
Block a user