[fix](trx-frontend-http): APRS bar shows full history, no truncation
Drop APRS_BAR_MAX cap and the separate aprsBarFrames ring buffer; drive the bar directly from aprsPacketHistory (CRC-ok frames only). Remove the 60-char info truncation. CSS opacity fading still kicks in after frame 5; older frames are reachable by scrolling. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -4,13 +4,10 @@ const aprsPacketsEl = document.getElementById("aprs-packets");
|
|||||||
const aprsFilterInput = document.getElementById("aprs-filter");
|
const aprsFilterInput = document.getElementById("aprs-filter");
|
||||||
const aprsBarOverlay = document.getElementById("aprs-bar-overlay");
|
const aprsBarOverlay = document.getElementById("aprs-bar-overlay");
|
||||||
const APRS_MAX_PACKETS = 100;
|
const APRS_MAX_PACKETS = 100;
|
||||||
const APRS_BAR_MAX = 5;
|
|
||||||
let aprsFilterText = "";
|
let aprsFilterText = "";
|
||||||
|
|
||||||
// Persistent packet history
|
// Persistent packet history
|
||||||
let aprsPacketHistory = loadSetting("aprsPackets", []);
|
let aprsPacketHistory = loadSetting("aprsPackets", []);
|
||||||
// Ring buffer of last N packets for the overview bar
|
|
||||||
let aprsBarFrames = [];
|
|
||||||
|
|
||||||
function renderAprsInfo(pkt) {
|
function renderAprsInfo(pkt) {
|
||||||
const bytes = Array.isArray(pkt.info_bytes) ? pkt.info_bytes : null;
|
const bytes = Array.isArray(pkt.info_bytes) ? pkt.info_bytes : null;
|
||||||
@@ -110,16 +107,17 @@ function applyAprsFilterToAll() {
|
|||||||
function updateAprsBar() {
|
function updateAprsBar() {
|
||||||
if (!aprsBarOverlay) return;
|
if (!aprsBarOverlay) return;
|
||||||
const isPkt = (document.getElementById("mode")?.value || "").toUpperCase() === "PKT";
|
const isPkt = (document.getElementById("mode")?.value || "").toUpperCase() === "PKT";
|
||||||
if (!isPkt || aprsBarFrames.length === 0) {
|
const okFrames = aprsPacketHistory.filter((p) => p.crcOk);
|
||||||
|
if (!isPkt || okFrames.length === 0) {
|
||||||
aprsBarOverlay.style.display = "none";
|
aprsBarOverlay.style.display = "none";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let html = '<div class="aprs-bar-header">APRS</div>';
|
let html = '<div class="aprs-bar-header">APRS</div>';
|
||||||
for (const pkt of aprsBarFrames) {
|
for (const pkt of okFrames) {
|
||||||
const ts = pkt._ts ? `<span class="aprs-bar-time">${pkt._ts}</span>` : "";
|
const ts = pkt._ts ? `<span class="aprs-bar-time">${pkt._ts}</span>` : "";
|
||||||
const call = `<span class="aprs-bar-call">${escapeMapHtml(pkt.srcCall)}</span>`;
|
const call = `<span class="aprs-bar-call">${escapeMapHtml(pkt.srcCall)}</span>`;
|
||||||
const dest = escapeMapHtml(pkt.destCall || "");
|
const dest = escapeMapHtml(pkt.destCall || "");
|
||||||
const info = escapeMapHtml((pkt.info || "").slice(0, 60));
|
const info = escapeMapHtml(pkt.info || "");
|
||||||
html += `<div class="aprs-bar-frame">${ts}${call}>${dest}: ${info}</div>`;
|
html += `<div class="aprs-bar-frame">${ts}${call}>${dest}: ${info}</div>`;
|
||||||
}
|
}
|
||||||
aprsBarOverlay.innerHTML = html;
|
aprsBarOverlay.innerHTML = html;
|
||||||
@@ -140,11 +138,7 @@ function addAprsPacket(pkt) {
|
|||||||
saveSetting("aprsPackets", aprsPacketHistory);
|
saveSetting("aprsPackets", aprsPacketHistory);
|
||||||
|
|
||||||
// Update overview bar (CRC-failed frames excluded)
|
// Update overview bar (CRC-failed frames excluded)
|
||||||
if (pkt.crcOk) {
|
if (pkt.crcOk) updateAprsBar();
|
||||||
aprsBarFrames.unshift(pkt);
|
|
||||||
if (aprsBarFrames.length > APRS_BAR_MAX) aprsBarFrames.length = APRS_BAR_MAX;
|
|
||||||
updateAprsBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
const row = renderAprsRow(pkt);
|
const row = renderAprsRow(pkt);
|
||||||
if (pkt.lat != null && pkt.lon != null && window.aprsMapAddStation) {
|
if (pkt.lat != null && pkt.lon != null && window.aprsMapAddStation) {
|
||||||
@@ -160,7 +154,6 @@ document.getElementById("aprs-clear-btn").addEventListener("click", async () =>
|
|||||||
aprsPacketsEl.innerHTML = "";
|
aprsPacketsEl.innerHTML = "";
|
||||||
aprsPacketHistory = [];
|
aprsPacketHistory = [];
|
||||||
saveSetting("aprsPackets", []);
|
saveSetting("aprsPackets", []);
|
||||||
aprsBarFrames = [];
|
|
||||||
updateAprsBar();
|
updateAprsBar();
|
||||||
try { await postPath("/clear_aprs_decode"); } catch (e) { console.error("APRS clear failed", e); }
|
try { await postPath("/clear_aprs_decode"); } catch (e) { console.error("APRS clear failed", e); }
|
||||||
});
|
});
|
||||||
@@ -173,8 +166,6 @@ for (let i = aprsPacketHistory.length - 1; i >= 0; i--) {
|
|||||||
window.aprsMapAddStation(pkt.srcCall, pkt.lat, pkt.lon, pkt.info, pkt.symbolTable, pkt.symbolCode);
|
window.aprsMapAddStation(pkt.srcCall, pkt.lat, pkt.lon, pkt.info, pkt.symbolTable, pkt.symbolCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Pre-populate bar from history (most recent first, CRC-ok only)
|
|
||||||
aprsBarFrames = aprsPacketHistory.filter((p) => p.crcOk).slice(0, APRS_BAR_MAX);
|
|
||||||
updateAprsBar();
|
updateAprsBar();
|
||||||
|
|
||||||
if (aprsFilterInput) {
|
if (aprsFilterInput) {
|
||||||
|
|||||||
Reference in New Issue
Block a user