[fix](trx-frontend-http): separate bookmark overlay list from editor list
Scope picker filters the bookmarks table for editing. Spectrum and map always show merged general + active rig bookmarks via bmOverlayList. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -640,12 +640,12 @@ function setTheme(theme) {
|
|||||||
|
|
||||||
// Recolour bookmark chips after any palette/theme change (setTheme or setStyle).
|
// Recolour bookmark chips after any palette/theme change (setTheme or setStyle).
|
||||||
function invalidateBookmarkColors() {
|
function invalidateBookmarkColors() {
|
||||||
if (typeof bmRevision === "undefined") return;
|
if (typeof bmOverlayRevision === "undefined") return;
|
||||||
bmRevision++;
|
bmOverlayRevision++;
|
||||||
// Force the browser to recalculate styles so getComputedStyle reads new values.
|
// Force the browser to recalculate styles so getComputedStyle reads new values.
|
||||||
void getComputedStyle(document.documentElement).getPropertyValue("--bg");
|
void getComputedStyle(document.documentElement).getPropertyValue("--bg");
|
||||||
const colorMap = bmCategoryColorMap();
|
const colorMap = bmCategoryColorMap();
|
||||||
const ref = typeof bmList !== "undefined" ? bmList : [];
|
const ref = typeof bmOverlayList !== "undefined" ? bmOverlayList : [];
|
||||||
document.querySelectorAll(".spectrum-bookmark-chip").forEach((chip) => {
|
document.querySelectorAll(".spectrum-bookmark-chip").forEach((chip) => {
|
||||||
const bm = ref.find((b) => b.id === chip.dataset.bmId);
|
const bm = ref.find((b) => b.id === chip.dataset.bmId);
|
||||||
if (!bm) return;
|
if (!bm) return;
|
||||||
@@ -1156,7 +1156,7 @@ function drawSignalOverlay() {
|
|||||||
const bwEdge = BW_OVERLAY_COLORS.edge;
|
const bwEdge = BW_OVERLAY_COLORS.edge;
|
||||||
const bwStroke = BW_OVERLAY_COLORS.stroke;
|
const bwStroke = BW_OVERLAY_COLORS.stroke;
|
||||||
const bwHard = BW_OVERLAY_COLORS.hard;
|
const bwHard = BW_OVERLAY_COLORS.hard;
|
||||||
const bmRef = typeof bmList !== "undefined" ? bmList : null;
|
const bmRef = typeof bmOverlayList !== "undefined" ? bmOverlayList : null;
|
||||||
if (Array.isArray(bmRef) && bmRef.length > 0) {
|
if (Array.isArray(bmRef) && bmRef.length > 0) {
|
||||||
const colorMap = bmCategoryColorMap();
|
const colorMap = bmCategoryColorMap();
|
||||||
const grouped = new Map();
|
const grouped = new Map();
|
||||||
@@ -6010,7 +6010,7 @@ function buildBookmarkTooltipText(bm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nearestBookmarkForHz(hz, widthPx, range) {
|
function nearestBookmarkForHz(hz, widthPx, range) {
|
||||||
const ref = typeof bmList !== "undefined" ? bmList : null;
|
const ref = typeof bmOverlayList !== "undefined" ? bmOverlayList : null;
|
||||||
if (!Array.isArray(ref) || !Number.isFinite(hz) || !widthPx || !range || !Number.isFinite(range.visSpanHz) || range.visSpanHz <= 0) {
|
if (!Array.isArray(ref) || !Number.isFinite(hz) || !widthPx || !range || !Number.isFinite(range.visSpanHz) || range.visSpanHz <= 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -9237,7 +9237,7 @@ function bmThemePalette() {
|
|||||||
|
|
||||||
// Returns a map of category → hex colour, including "" for uncategorised.
|
// Returns a map of category → hex colour, including "" for uncategorised.
|
||||||
function bmCategoryColorMap() {
|
function bmCategoryColorMap() {
|
||||||
const ref = typeof bmList !== "undefined" ? bmList : [];
|
const ref = typeof bmOverlayList !== "undefined" ? bmOverlayList : [];
|
||||||
const cats = [...new Set(ref.map((b) => b.category).filter(Boolean))].sort();
|
const cats = [...new Set(ref.map((b) => b.category).filter(Boolean))].sort();
|
||||||
const palette = bmThemePalette();
|
const palette = bmThemePalette();
|
||||||
const map = { "": palette[0] };
|
const map = { "": palette[0] };
|
||||||
@@ -9289,7 +9289,7 @@ function createBookmarkChip(bm, colorMap, options = {}) {
|
|||||||
|
|
||||||
function updateSideBookmarkStack(container, bookmarks, colorMap) {
|
function updateSideBookmarkStack(container, bookmarks, colorMap) {
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
const rev = typeof bmRevision !== "undefined" ? bmRevision : 0;
|
const rev = typeof bmOverlayRevision !== "undefined" ? bmOverlayRevision : 0;
|
||||||
const nextKey = Array.isArray(bookmarks) ? `${rev}:${bookmarks.map((bm) => bm.id).join(",")}` : "";
|
const nextKey = Array.isArray(bookmarks) ? `${rev}:${bookmarks.map((bm) => bm.id).join(",")}` : "";
|
||||||
if (!Array.isArray(bookmarks) || bookmarks.length === 0) {
|
if (!Array.isArray(bookmarks) || bookmarks.length === 0) {
|
||||||
if (container.dataset.bmKey) {
|
if (container.dataset.bmKey) {
|
||||||
@@ -9317,7 +9317,7 @@ function updateBookmarkAxis(range) {
|
|||||||
const rightSideEl = document.getElementById("spectrum-bookmark-side-right");
|
const rightSideEl = document.getElementById("spectrum-bookmark-side-right");
|
||||||
if (!axisEl) return;
|
if (!axisEl) return;
|
||||||
|
|
||||||
const _bmRef = typeof bmList !== "undefined" ? bmList : null;
|
const _bmRef = typeof bmOverlayList !== "undefined" ? bmOverlayList : null;
|
||||||
const allBookmarks = Array.isArray(_bmRef) ? _bmRef : [];
|
const allBookmarks = Array.isArray(_bmRef) ? _bmRef : [];
|
||||||
const visBookmarks = allBookmarks.filter((bm) => bm.freq_hz >= range.visLoHz && bm.freq_hz <= range.visHiHz);
|
const visBookmarks = allBookmarks.filter((bm) => bm.freq_hz >= range.visLoHz && bm.freq_hz <= range.visHiHz);
|
||||||
const leftBookmarks = allBookmarks
|
const leftBookmarks = allBookmarks
|
||||||
@@ -9343,7 +9343,7 @@ function updateBookmarkAxis(range) {
|
|||||||
|
|
||||||
// Only rebuild DOM when the set of visible bookmarks changes.
|
// Only rebuild DOM when the set of visible bookmarks changes.
|
||||||
// Positions are always updated to handle pan/zoom smoothly.
|
// Positions are always updated to handle pan/zoom smoothly.
|
||||||
const rev = typeof bmRevision !== "undefined" ? bmRevision : 0;
|
const rev = typeof bmOverlayRevision !== "undefined" ? bmOverlayRevision : 0;
|
||||||
const newKey = `${rev}:${visBookmarks.map((b) => b.id).join(",")}`;
|
const newKey = `${rev}:${visBookmarks.map((b) => b.id).join(",")}`;
|
||||||
if (axisEl.dataset.bmKey !== newKey) {
|
if (axisEl.dataset.bmKey !== newKey) {
|
||||||
axisEl.dataset.bmKey = newKey;
|
axisEl.dataset.bmKey = newKey;
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ function bmScopeParam(prefix, scope) {
|
|||||||
|
|
||||||
var bmList = [];
|
var bmList = [];
|
||||||
var bmRevision = 0;
|
var bmRevision = 0;
|
||||||
|
/** Overlay list: always merged general + active rig bookmarks (for spectrum/map). */
|
||||||
|
var bmOverlayList = [];
|
||||||
|
var bmOverlayRevision = 0;
|
||||||
let bmFilteredList = [];
|
let bmFilteredList = [];
|
||||||
let bmEditId = null;
|
let bmEditId = null;
|
||||||
let bmEditScope = null;
|
let bmEditScope = null;
|
||||||
@@ -54,6 +57,23 @@ function bmListScope() {
|
|||||||
return rig || "general";
|
return rig || "general";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function bmFetchOverlay() {
|
||||||
|
const overlayScope = bmListScope();
|
||||||
|
try {
|
||||||
|
const resp = await fetch("/bookmarks" + bmScopeParam(false, overlayScope));
|
||||||
|
if (!resp.ok) throw new Error("HTTP " + resp.status);
|
||||||
|
bmOverlayList = await resp.json();
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to fetch overlay bookmarks:", e);
|
||||||
|
bmOverlayList = [];
|
||||||
|
}
|
||||||
|
bmOverlayRevision++;
|
||||||
|
if (typeof window.syncBookmarkMapLocators === "function") {
|
||||||
|
window.syncBookmarkMapLocators(bmOverlayList);
|
||||||
|
}
|
||||||
|
if (typeof scheduleSpectrumDraw === "function") scheduleSpectrumDraw();
|
||||||
|
}
|
||||||
|
|
||||||
async function bmFetch(categoryFilter) {
|
async function bmFetch(categoryFilter) {
|
||||||
let url = "/bookmarks";
|
let url = "/bookmarks";
|
||||||
let hasQuery = false;
|
let hasQuery = false;
|
||||||
@@ -61,7 +81,8 @@ async function bmFetch(categoryFilter) {
|
|||||||
url += "?category=" + encodeURIComponent(categoryFilter);
|
url += "?category=" + encodeURIComponent(categoryFilter);
|
||||||
hasQuery = true;
|
hasQuery = true;
|
||||||
}
|
}
|
||||||
url += bmScopeParam(hasQuery, bmListScope());
|
url += bmScopeParam(hasQuery);
|
||||||
|
const overlayPromise = bmFetchOverlay();
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(url);
|
const resp = await fetch(url);
|
||||||
if (!resp.ok) throw new Error("HTTP " + resp.status);
|
if (!resp.ok) throw new Error("HTTP " + resp.status);
|
||||||
@@ -71,15 +92,12 @@ async function bmFetch(categoryFilter) {
|
|||||||
bmList = [];
|
bmList = [];
|
||||||
}
|
}
|
||||||
bmRevision++;
|
bmRevision++;
|
||||||
if (typeof window.syncBookmarkMapLocators === "function") {
|
|
||||||
window.syncBookmarkMapLocators(bmList);
|
|
||||||
}
|
|
||||||
bmSelected.clear();
|
bmSelected.clear();
|
||||||
bmUpdateSelectionUi();
|
bmUpdateSelectionUi();
|
||||||
bmSyncAccess();
|
bmSyncAccess();
|
||||||
bmApplyFilters();
|
bmApplyFilters();
|
||||||
bmRefreshCategoryFilter(categoryFilter);
|
bmRefreshCategoryFilter(categoryFilter);
|
||||||
if (typeof scheduleSpectrumDraw === "function") scheduleSpectrumDraw();
|
await overlayPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bmApplyFilters() {
|
function bmApplyFilters() {
|
||||||
@@ -106,7 +124,7 @@ async function bmRefreshCategoryFilter(keepValue) {
|
|||||||
const modeSel = document.getElementById("bm-mode-filter");
|
const modeSel = document.getElementById("bm-mode-filter");
|
||||||
if (!sel && !modeSel) return;
|
if (!sel && !modeSel) return;
|
||||||
try {
|
try {
|
||||||
const resp = await fetch("/bookmarks" + bmScopeParam(false, bmListScope()));
|
const resp = await fetch("/bookmarks" + bmScopeParam(false));
|
||||||
if (!resp.ok) return;
|
if (!resp.ok) return;
|
||||||
const all = await resp.json();
|
const all = await resp.json();
|
||||||
if (sel) {
|
if (sel) {
|
||||||
|
|||||||
Reference in New Issue
Block a user