[refactor](trx-frontend-http): rename rig_id API fields to remote
Rename HTTP query params, JSON fields, and scheduler payloads to use remote names consistently while still accepting legacy `rig_id` inputs through serde aliases. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -1001,19 +1001,19 @@ async function refreshRigList() {
|
||||
if (!resp.ok) return;
|
||||
const data = await resp.json();
|
||||
const rigs = Array.isArray(data.rigs) ? data.rigs : [];
|
||||
const rigIds = rigs.map((r) => r && r.rig_id).filter(Boolean);
|
||||
const rigIds = rigs.map((r) => r && r.remote).filter(Boolean);
|
||||
const displayNames = {};
|
||||
rigs.forEach((r) => {
|
||||
if (!r || !r.rig_id) return;
|
||||
if (!r || !r.remote) return;
|
||||
if (typeof r.display_name === "string" && r.display_name.length > 0) {
|
||||
displayNames[r.rig_id] = r.display_name;
|
||||
displayNames[r.remote] = r.display_name;
|
||||
} else {
|
||||
displayNames[r.rig_id] = r.rig_id;
|
||||
displayNames[r.remote] = r.remote;
|
||||
}
|
||||
});
|
||||
serverRigs = rigs;
|
||||
serverActiveRigId = data.active_rig_id || null;
|
||||
applyRigList(data.active_rig_id, rigIds, displayNames);
|
||||
serverActiveRigId = data.active_remote || null;
|
||||
applyRigList(data.active_remote, rigIds, displayNames);
|
||||
} catch (e) {
|
||||
// Non-fatal: SSE/status path still drives main UI.
|
||||
}
|
||||
@@ -3248,8 +3248,8 @@ function render(update) {
|
||||
if (lastActiveRigId) {
|
||||
document.getElementById("about-active-rig").textContent = lastActiveRigId;
|
||||
}
|
||||
if (Array.isArray(update.rig_ids)) {
|
||||
applyRigList(update.active_rig_id, update.rig_ids);
|
||||
if (Array.isArray(update.remotes)) {
|
||||
applyRigList(update.active_remote, update.remotes);
|
||||
}
|
||||
if (typeof update.rigctl_clients === "number") {
|
||||
document.getElementById("about-rigctl-clients").textContent = update.rigctl_clients;
|
||||
@@ -3293,7 +3293,7 @@ function scheduleReconnect(delayMs = 1000) {
|
||||
async function pollFreshSnapshot() {
|
||||
try {
|
||||
const statusUrl = lastActiveRigId
|
||||
? `/status?rig_id=${encodeURIComponent(lastActiveRigId)}`
|
||||
? `/status?remote=${encodeURIComponent(lastActiveRigId)}`
|
||||
: "/status";
|
||||
const resp = await fetch(statusUrl, { cache: "no-store" });
|
||||
if (!resp.ok) return;
|
||||
@@ -3316,7 +3316,7 @@ function connect() {
|
||||
}
|
||||
pollFreshSnapshot();
|
||||
const eventsUrl = lastActiveRigId
|
||||
? `/events?rig_id=${encodeURIComponent(lastActiveRigId)}`
|
||||
? `/events?remote=${encodeURIComponent(lastActiveRigId)}`
|
||||
: "/events";
|
||||
es = new EventSource(eventsUrl);
|
||||
lastEventAt = Date.now();
|
||||
@@ -3442,11 +3442,11 @@ function scheduleUiFrameJob(key, job) {
|
||||
window.trxScheduleUiFrameJob = scheduleUiFrameJob;
|
||||
|
||||
async function postPath(path) {
|
||||
// Auto-append rig_id so each tab targets its own rig.
|
||||
// Skip when the caller already included rig_id (e.g. /select_rig).
|
||||
if (lastActiveRigId && !path.includes("rig_id=")) {
|
||||
// Auto-append remote so each tab targets its own rig.
|
||||
// Skip when the caller already included remote (e.g. /select_rig).
|
||||
if (lastActiveRigId && !path.includes("remote=")) {
|
||||
const sep = path.includes("?") ? "&" : "?";
|
||||
path = `${path}${sep}rig_id=${encodeURIComponent(lastActiveRigId)}`;
|
||||
path = `${path}${sep}remote=${encodeURIComponent(lastActiveRigId)}`;
|
||||
}
|
||||
const resp = await fetch(path, { method: "POST" });
|
||||
if (authEnabled && resp.status === 401) {
|
||||
@@ -3502,7 +3502,7 @@ async function switchRigFromSelect(selectEl) {
|
||||
// state channel.
|
||||
try {
|
||||
const sidParam = sseSessionId ? `&session_id=${encodeURIComponent(sseSessionId)}` : "";
|
||||
await postPath(`/select_rig?rig_id=${encodeURIComponent(selectEl.value)}${sidParam}`);
|
||||
await postPath(`/select_rig?remote=${encodeURIComponent(selectEl.value)}${sidParam}`);
|
||||
connect();
|
||||
} catch (err) {
|
||||
console.error("select_rig failed:", err);
|
||||
@@ -6061,7 +6061,7 @@ function buildReceiverPopupHtml() {
|
||||
}
|
||||
for (const rig of serverRigs) {
|
||||
const name = rig.display_name || `${rig.manufacturer} ${rig.model}`.trim();
|
||||
const active = rig.rig_id === serverActiveRigId
|
||||
const active = rig.remote === serverActiveRigId
|
||||
? ` <span class="receiver-popup-active">active</span>` : "";
|
||||
rows += `<tr><td class="aprs-popup-label">Rig</td><td>${escapeMapHtml(name)}${active}</td></tr>`;
|
||||
}
|
||||
@@ -7137,7 +7137,7 @@ window.mapAddLocator = function(message, grids, type = "ft8", station = null, de
|
||||
dt_s: Number.isFinite(details?.dt_s) ? Number(details.dt_s) : null,
|
||||
freq_hz: Number.isFinite(details?.freq_hz) ? Number(details.freq_hz) : null,
|
||||
message: String(details?.message || message || "").trim() || null,
|
||||
rig_id: lastActiveRigId || null,
|
||||
remote: lastActiveRigId || null,
|
||||
};
|
||||
const detailKey = detailStationId || `${targetId || "decode"}:${detailEntry.message || "decode"}:${detailEntry.ts_ms || Date.now()}`;
|
||||
const key = `${markerType}:${grid}`;
|
||||
@@ -7667,7 +7667,7 @@ function startRxAudio() {
|
||||
if (_audioChannelOverride) {
|
||||
audioPath = `/audio?channel_id=${encodeURIComponent(_audioChannelOverride)}`;
|
||||
} else if (lastActiveRigId) {
|
||||
audioPath = `/audio?rig_id=${encodeURIComponent(lastActiveRigId)}`;
|
||||
audioPath = `/audio?remote=${encodeURIComponent(lastActiveRigId)}`;
|
||||
} else {
|
||||
audioPath = "/audio";
|
||||
}
|
||||
@@ -8705,7 +8705,7 @@ function scheduleSpectrumReconnect() {
|
||||
function startSpectrumStreaming() {
|
||||
if (spectrumSource !== null) return;
|
||||
const spectrumUrl = lastActiveRigId
|
||||
? `/spectrum?rig_id=${encodeURIComponent(lastActiveRigId)}`
|
||||
? `/spectrum?remote=${encodeURIComponent(lastActiveRigId)}`
|
||||
: "/spectrum";
|
||||
spectrumSource = new EventSource(spectrumUrl);
|
||||
// Unnamed event = reset signal.
|
||||
|
||||
+4
-4
@@ -74,7 +74,7 @@
|
||||
if (!rigId) return;
|
||||
Promise.all([apiGetConfig(rigId), apiGetBookmarks()])
|
||||
.then(function ([config, bookmarks]) {
|
||||
currentConfig = config || { rig_id: rigId, enabled: false, bookmark_ids: [] };
|
||||
currentConfig = config || { remote: rigId, enabled: false, bookmark_ids: [] };
|
||||
bookmarkList = Array.isArray(bookmarks) ? bookmarks : [];
|
||||
renderBookmarkPick();
|
||||
renderBackgroundDecode();
|
||||
@@ -121,7 +121,7 @@
|
||||
|
||||
function renderBackgroundDecode() {
|
||||
if (!currentConfig) {
|
||||
currentConfig = { rig_id: currentRigId, enabled: false, bookmark_ids: [] };
|
||||
currentConfig = { remote: currentRigId, enabled: false, bookmark_ids: [] };
|
||||
}
|
||||
setCheckbox("background-decode-enabled", !!currentConfig.enabled);
|
||||
renderBookmarkList();
|
||||
@@ -178,7 +178,7 @@
|
||||
const sel = document.getElementById("background-decode-bookmark-pick");
|
||||
if (!sel || !sel.value) return;
|
||||
if (!currentConfig) {
|
||||
currentConfig = { rig_id: currentRigId, enabled: false, bookmark_ids: [] };
|
||||
currentConfig = { remote: currentRigId, enabled: false, bookmark_ids: [] };
|
||||
}
|
||||
if (!Array.isArray(currentConfig.bookmark_ids)) currentConfig.bookmark_ids = [];
|
||||
if (!currentConfig.bookmark_ids.includes(sel.value)) currentConfig.bookmark_ids.push(sel.value);
|
||||
@@ -191,7 +191,7 @@
|
||||
const rigId = currentRigId;
|
||||
if (!rigId) return;
|
||||
const payload = {
|
||||
rig_id: rigId,
|
||||
remote: rigId,
|
||||
enabled: !!document.getElementById("background-decode-enabled").checked,
|
||||
bookmark_ids: Array.isArray(currentConfig && currentConfig.bookmark_ids) ? currentConfig.bookmark_ids.slice() : [],
|
||||
};
|
||||
|
||||
@@ -511,7 +511,7 @@
|
||||
const extraBmIds = pendingExtraBmIds.slice();
|
||||
|
||||
if (!currentConfig) {
|
||||
currentConfig = { rig_id: currentRigId, mode: "time_span", entries: [] };
|
||||
currentConfig = { remote: currentRigId, mode: "time_span", entries: [] };
|
||||
}
|
||||
if (!currentConfig.entries) currentConfig.entries = [];
|
||||
|
||||
@@ -666,7 +666,7 @@
|
||||
const mode = modeEl ? modeEl.value : "disabled";
|
||||
|
||||
const config = {
|
||||
rig_id: rig,
|
||||
remote: rig,
|
||||
mode,
|
||||
grayline: null,
|
||||
entries: [],
|
||||
@@ -722,7 +722,7 @@
|
||||
apiDeleteScheduler(rig)
|
||||
.then(function () {
|
||||
currentConfig = {
|
||||
rig_id: rig,
|
||||
remote: rig,
|
||||
mode: "disabled",
|
||||
grayline: null,
|
||||
entries: [],
|
||||
@@ -756,7 +756,7 @@
|
||||
const modeEl = document.getElementById("scheduler-mode-select");
|
||||
if (modeEl) {
|
||||
modeEl.addEventListener("change", function () {
|
||||
if (!currentConfig) currentConfig = { rig_id: currentRigId, mode: modeEl.value, entries: [] };
|
||||
if (!currentConfig) currentConfig = { remote: currentRigId, mode: modeEl.value, entries: [] };
|
||||
currentConfig.mode = modeEl.value;
|
||||
renderScheduler();
|
||||
});
|
||||
|
||||
@@ -85,7 +85,7 @@ async function vchanToggleSchedulerRelease() {
|
||||
const resp = await fetch("/scheduler-control", {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ session_id: vchanSessionId, released: true, rig_id: rigId }),
|
||||
body: JSON.stringify({ session_id: vchanSessionId, released: true, remote: rigId }),
|
||||
});
|
||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
||||
schedulerReleaseState = await resp.json();
|
||||
@@ -128,7 +128,7 @@ function vchanHandleSession(data) {
|
||||
function vchanHandleChannels(data) {
|
||||
try {
|
||||
const d = JSON.parse(data);
|
||||
vchanRigId = d.rig_id || null;
|
||||
vchanRigId = d.remote || null;
|
||||
vchanChannels = d.channels || [];
|
||||
const ids = new Set(vchanChannels.map(c => c.id));
|
||||
if (!vchanActiveId && vchanChannels.length > 0 && vchanSessionId) {
|
||||
|
||||
Reference in New Issue
Block a user