diff --git a/app.js b/app.js index 6fde949..3fc6ff4 100644 --- a/app.js +++ b/app.js @@ -1,12 +1,3 @@ -// Reflector Dashboard — web front-end for SvxReflector -// Copyright (C) 2026 SA7AUX (Björn) -// SPDX-License-Identifier: AGPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under -// the terms of the GNU Affero General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) any -// later version. See the LICENSE file for details. - 'use strict'; let lastNodes = {}; @@ -29,6 +20,7 @@ function setActive(panel){ const trkP = document.getElementById('trunksPanel'); const topP = document.getElementById('topologyPanel'); const lhP = document.getElementById('lastheardPanel'); + const lhLiveP = document.getElementById('lastheardLivePanel'); const ctcP = document.getElementById('ctcssPanel'); const chgP = document.getElementById('changelogPanel'); const tgmP = document.getElementById('tgmonPanel'); @@ -39,6 +31,7 @@ function setActive(panel){ if(trkP) trkP.style.display = (panel === 'trunks') ? 'block' : 'none'; if(topP) topP.style.display = (panel === 'topology') ? 'block' : 'none'; if(lhP) lhP.style.display = (panel === 'lastheard') ? 'block' : 'none'; + if(lhLiveP) lhLiveP.style.display = (panel === 'lastheardLive') ? 'block' : 'none'; if(ctcP) ctcP.style.display = (panel === 'ctcss') ? 'block' : 'none'; if(chgP) chgP.style.display = (panel === 'changelog') ? 'block' : 'none'; if(tgmP) tgmP.style.display = (panel === 'tgmon') ? 'block' : 'none'; @@ -70,6 +63,7 @@ function render(status){ if (document.getElementById('trunksPanel')?.style.display !== 'none') window.renderTrunks?.(lastStatus); if (document.getElementById('topologyPanel')?.style.display !== 'none') window.renderTopology?.(lastStatus); if (document.getElementById('lastheardPanel')?.style.display !== 'none') window.refreshLastheard?.(); + if (document.getElementById('lastheardLivePanel')?.style.display !== 'none') window.refreshLastheardLive?.(); if (document.getElementById('ctcssPanel')?.style.display !== 'none') window.renderCTCSS?.(lastStatus); if (document.getElementById('tgmonPanel')?.style.display !== 'none') window.renderTgMon?.(); } @@ -79,33 +73,6 @@ async function refresh(){ if(!j) return; lastUpdated = Date.now(); render(j); - applyFederationExtra(j); -} - -// On the AlabamaLink box fold the AlabamaLink line INTO the existing -// federation marquee so both scroll together in the one bar — same style, no -// second banner. Every other box keeps just the federation line. Gated on the -// local reflector identity from the status (KT4ROY / alabama.reflector-network.com), -// so it's a no-op everywhere else. -let _fedExtraDone = false; -function applyFederationExtra(status){ - if(_fedExtraDone) return; - const track = document.querySelector('#federationBanner .fed-track'); - if(!track) return; - const refs = (status && status.network && Array.isArray(status.network.reflectors)) ? status.network.reflectors : []; - const isAlabama = refs.some(r => r && r.self && ( - String(r.name || '').toUpperCase() === 'KT4ROY' || - /alabama\.reflector-network\.com/i.test(String(r.hostname || '') + ' ' + String(r.name || '')) - )); - if(!isAlabama) return; - _fedExtraDone = true; - const fed = 'Part of the reflector-network.com federation — a growing mesh of independent networks.'; - const ala = 'Powered by Executor — a multi-mode digital voice server, part of the AlabamaLink network.'; - const sep = '  •  '; - const unit = fed + sep + ala; - const inner = document.createElement('span'); - inner.textContent = unit + sep + unit; // doubled so the loop stays seamless - track.replaceChildren(inner); } /* ===== Monitor submenu ===== */ @@ -123,6 +90,21 @@ document.addEventListener('click', (e) => { if(item && !item.contains(e.target)) closeMonitorSubMenu(); }); +/* ===== Last heard submenu ===== */ +function closeLastheardSubMenu(){ + const m = document.getElementById('lastheardSubMenu'); + if(m) m.style.display = 'none'; +} +function toggleLastheardSubMenu(){ + const m = document.getElementById('lastheardSubMenu'); + if(!m) return; + m.style.display = (m.style.display === 'none' || !m.style.display) ? 'block' : 'none'; +} +document.addEventListener('click', (e) => { + const item = document.getElementById('lastheardMenuItem'); + if(item && !item.contains(e.target)) closeLastheardSubMenu(); +}); + /* ===== Wire UI ===== */ document.getElementById('navList')?.addEventListener('click', (e) => { e.preventDefault(); @@ -172,6 +154,20 @@ document.getElementById('navMonitorTopology')?.addEventListener('click', (e) => document.getElementById('navLastheard')?.addEventListener('click', (e) => { e.preventDefault(); closeMonitorSubMenu(); + toggleLastheardSubMenu(); +}); + +document.getElementById('navLastheardLive')?.addEventListener('click', (e) => { + e.preventDefault(); + closeLastheardSubMenu(); + setNavActive('navLastheard'); + setActive('lastheardLive'); + window.refreshLastheardLive?.(); +}); + +document.getElementById('navLastheard24h')?.addEventListener('click', (e) => { + e.preventDefault(); + closeLastheardSubMenu(); setNavActive('navLastheard'); setActive('lastheard'); window.refreshLastheard?.(); @@ -202,7 +198,7 @@ document.getElementById('navTgmon')?.addEventListener('click', (e) => { }); /* ===== Remember the last view across reloads (Ctrl+Shift+R) ===== */ -const RESTORE_NAVS = ['navList','navClients','navMonitorNodes','navMonitorTrunks','navMonitorTopology','navTgmon','navLastheard','navCTCSS','navChangelog']; +const RESTORE_NAVS = ['navList','navClients','navMonitorNodes','navMonitorTrunks','navMonitorTopology','navTgmon','navLastheardLive','navLastheard24h','navCTCSS','navChangelog']; for (const id of RESTORE_NAVS) { document.getElementById(id)?.addEventListener('click', () => { try { localStorage.setItem('svxLastNav', id); } catch (_) {} }); } @@ -229,6 +225,8 @@ setInterval(() => { // keep Age ticking even without updates const sseTxt = document.getElementById('sseTxt'); function setSSE(state){ + window.__svxSSE = state; // read by the Live lastheard dot + window.updateLhLiveDot?.(); if(!sseTxt) return; sseTxt.textContent = "SSE: " + state; } diff --git a/auth/admin.js b/auth/admin.js index a5d7784..1556773 100644 --- a/auth/admin.js +++ b/auth/admin.js @@ -1,12 +1,3 @@ -// Reflector Dashboard — web front-end for SvxReflector -// Copyright (C) 2026 SA7AUX (Björn) -// SPDX-License-Identifier: AGPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under -// the terms of the GNU Affero General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) any -// later version. See the LICENSE file for details. - 'use strict'; var LEVEL_LABELS = {1:'Normal', 2:'Admin', 3:'SuperAdmin'}; diff --git a/auth/admin.php b/auth/admin.php index e4c2543..40b812f 100644 --- a/auth/admin.php +++ b/auth/admin.php @@ -1,14 +1,4 @@ "]/g, function (c) { + return { '&': '&', '<': '<', '>': '>', '"': '"' }[c]; }); } + + function render(filter) { + var tb = document.querySelector('#lpTable tbody'); if (!tb) return; + filter = (filter || '').toLowerCase().trim(); + tb.innerHTML = ''; + rows.forEach(function (tg) { + if (filter && (tg.tg + ' ' + (tg.name || '')).toLowerCase().indexOf(filter) < 0) return; + var cur = tg.listen || 'free'; + var opts = LEVELS.map(function (l) { + return ''; + }).join(''); + var tr = document.createElement('tr'); + tr.innerHTML = '' + tg.tg + '' + + '' + esc(tg.name || '') + '' + + ''; + tb.appendChild(tr); + }); + tb.querySelectorAll('select[data-tg]').forEach(function (s) { + s.addEventListener('change', function () { saveOne(parseInt(s.getAttribute('data-tg'), 10), s.value, s); }); + }); + } + + async function saveOne(tg, listen, selEl) { + selEl.disabled = true; + var res = null; + try { res = await api({ action: 'save', tg: tg, listen: listen }); } catch (_) {} + selEl.disabled = false; + if (res && res.ok) { + var r = rows.find(function (x) { return x.tg === tg; }); if (r) r.listen = listen; + msg('Saved TG ' + tg + ' → ' + listen); + } else { + msg('Save failed for TG ' + tg + (res && res.error ? ' (' + res.error + ')' : '')); + } + } + + async function load() { + var res = null; + try { res = await api({ action: 'list' }); } catch (_) {} + if (!res || !res.ok) { msg('Failed to load TG list'); return; } + if (res.can_admin === false) { msg('Admin access required.'); return; } + rows = (res.tgs || []).map(function (t) { return { tg: t.tg, name: t.name, listen: t.listen || 'free' }; }); + rows.sort(function (a, b) { return a.tg - b.tg; }); + render(''); + msg(rows.length + ' talkgroups.'); + } + + function init() { + var s = document.getElementById('lpSearch'); + s && s.addEventListener('input', function () { render(s.value); }); + // Grab the CSRF token (needed for save) from me.php, then load. + fetch('/auth/me.php', { credentials: 'same-origin' }) + .then(function (r) { return r.json(); }) + .then(function (j) { if (j && j.csrf_token) window._csrfToken = j.csrf_token; load(); }) + .catch(function () { load(); }); + } + + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init); + else init(); +})(); diff --git a/auth/admin_listen.php b/auth/admin_listen.php new file mode 100644 index 0000000..a0af6ba --- /dev/null +++ b/auth/admin_listen.php @@ -0,0 +1,39 @@ + + +
+
+
Listen Live — TG permissions
+ +
+
+
+ Who may listen to each talkgroup in the browser (the “Listen Live” page). + Free = anyone · Members = logged-in accounts only (every account is a + callsign-verified ham) · Off = hidden from Listen Live. Default is Free. + Changes take effect immediately. +
+
+ + + +
TGNameAccess
+
+
Loading…
+
+
+ +'; +require __DIR__ . '/footer.php'; +?> diff --git a/auth/admin_mqtt.php b/auth/admin_mqtt.php index 591c1a1..95a6320 100644 --- a/auth/admin_mqtt.php +++ b/auth/admin_mqtt.php @@ -1,14 +1,4 @@ name/system list (served publicly by // /tglist.php). Mirrors the Global Bans admin pattern. Add/delete are admin-only; diff --git a/auth/admin_tglist.php b/auth/admin_tglist.php index 90ad233..378fc3c 100644 --- a/auth/admin_tglist.php +++ b/auth/admin_tglist.php @@ -1,14 +1,4 @@