Files
Logan Cusano 857325af85
CI / lint (push) Failing after 5s
CI / test (push) Successful in 19s
Build edge-node / build (push) Successful in 32s
feat: Add local system override and manual entry controls with offline systems caching
2026-07-12 23:06:05 -04:00

474 lines
16 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Scanner Display</title>
<style>
:root {
--bg: #000000;
--text: #ffffff;
--sys-color: #3b82f6; /* Blue for system */
--dept-color: #f97316; /* Orange for department */
--chan-color: #ffffff; /* White for channel */
--muted: #64748b;
--active-bg: #1e3a8a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background-color: var(--bg);
color: var(--text);
font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
overflow: hidden;
display: flex;
flex-direction: column;
height: 100vh;
width: 100vw;
}
/* Top Status Bar */
.status-bar {
display: flex;
justify-content: space-between;
padding: 4px 8px;
font-size: 14px;
font-weight: bold;
border-bottom: 2px solid #333;
background-color: #111;
align-items: center;
}
.legend-btn {
background: #333; color: #fff; border: 1px solid #555; padding: 2px 6px; font-size: 10px; cursor: pointer; border-radius: 4px;
}
.legend-modal {
display: none; position: absolute; top: 10%; left: 10%; right: 10%; bottom: 10%;
background: rgba(10,10,10,0.95); border: 2px solid #555; z-index: 200; padding: 20px; overflow-y: auto;
}
.legend-modal h2 { margin-bottom: 15px; color: var(--sys-color); }
.legend-modal ul { list-style: none; line-height: 1.8; margin-bottom: 20px; }
.legend-modal li { font-size: 14px; }
.legend-modal li span { display: inline-block; width: 100px; font-weight: bold; color: #fff; }
.close-legend { padding: 10px; background: #c00; color: #fff; border: none; cursor: pointer; width: 100%; font-weight: bold; border-radius: 4px;}
/* Main Display Area */
.main-display {
flex: 1;
display: flex;
flex-direction: column;
padding: 10px;
justify-content: space-around;
}
.row-large {
padding: 12px;
margin-bottom: 6px;
border-radius: 6px;
text-align: center;
background: #111;
border: 1px solid #222;
box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}
.system-row { color: var(--sys-color); font-size: 28px; font-weight: 800; text-transform: uppercase; }
.dept-row { color: var(--dept-color); font-size: 24px; font-weight: 700; }
.chan-row { color: var(--chan-color); font-size: 32px; font-weight: 900; letter-spacing: 1px; }
.receiving .chan-row {
background-color: var(--active-bg);
animation: pulse 1s infinite alternate;
}
@keyframes pulse {
from { box-shadow: 0 0 10px var(--sys-color); }
to { box-shadow: 0 0 20px var(--sys-color); }
}
/* Info Grid */
.info-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
padding: 10px;
font-size: 16px;
font-family: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;
color: #aaa;
}
.info-item {
background: #111;
padding: 8px;
border-radius: 4px;
}
.info-label { font-size: 12px; color: var(--muted); text-transform: uppercase; display: block; margin-bottom: 4px; }
.info-value { font-weight: bold; color: #fff; font-size: 18px; }
/* Softkeys Bar (Bottom) */
.softkeys {
display: flex;
border-top: 2px solid #333;
background: #111;
height: 50px;
}
.softkey {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
border-right: 1px solid #333;
color: #ccc;
}
.softkey:last-child { border-right: none; }
/* Overlay UI (Volume, Hold) */
.overlay {
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
background: rgba(0,0,0,0.9);
padding: 20px 40px;
border: 2px solid #fff;
border-radius: 12px;
font-size: 24px;
font-weight: bold;
display: none;
z-index: 100;
}
</style>
</head>
<body>
<div class="status-bar">
<div id="status-icon">▶ RUNNING</div>
<div><button class="legend-btn" onclick="document.getElementById('legend-modal').style.display='block'">KEY LEGEND</button></div>
<div id="clock">12:00:00</div>
<div id="vol-indicator">VOL: 100%</div>
</div>
<div class="legend-modal" id="legend-modal">
<h2>Hardware Key Legend</h2>
<ul>
<li><span>Up Arrow</span> Volume Up</li>
<li><span>Down Arrow</span> Volume Down</li>
<li><span>Enter / H</span> Toggle Hold (UI mock)</li>
<li><span>P</span> Play/Pause Stream</li>
<li><span>S</span> Select System</li>
<li><span>R</span> Revert Override</li>
</ul>
<button class="close-legend" onclick="document.getElementById('legend-modal').style.display='none'">CLOSE</button>
</div>
<div class="legend-modal" id="system-modal">
<h2>Select Radio System</h2>
<div id="system-list" style="max-height: 180px; overflow-y: auto; margin-bottom: 12px; border: 1px solid #333; padding: 5px; text-align: left;">
<!-- Systems list items loaded dynamically -->
</div>
<div style="border-top: 1px solid #333; padding-top: 8px; margin-bottom: 10px; text-align: left;">
<h3 style="color: var(--dept-color); margin-bottom: 6px; font-size: 13px;">Or Enter Freq Manually:</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 5px; font-size: 11px; margin-bottom: 8px;">
<div>
<label>Control Freq (MHz/Hz):</label>
<input type="text" id="manual-freq" style="background:#222; color:#fff; border:1px solid #555; padding:3px; width:100%; border-radius:2px;">
</div>
<div>
<label>System Type:</label>
<select id="manual-type" style="background:#222; color:#fff; border:1px solid #555; padding:3px; width:100%; border-radius:2px;">
<option value="P25">P25</option>
<option value="DMR">DMR</option>
<option value="NBFM">NBFM</option>
</select>
</div>
</div>
<button class="legend-btn" style="width:100%; padding:6px; font-weight:bold;" onclick="submitManualSystem()">Submit Manual Entry</button>
</div>
<button class="close-legend" onclick="closeSystemModal()" style="background:#333;">CANCEL</button>
</div>
<div class="main-display" id="main-display">
<div class="row-large system-row" id="disp-system">NO SYSTEM</div>
<div class="row-large dept-row" id="disp-dept">Scanning...</div>
<div class="row-large chan-row" id="disp-chan">IDLE</div>
</div>
<div class="info-grid">
<div class="info-item">
<span class="info-label">TGID</span>
<span class="info-value" id="info-tgid">---</span>
</div>
<div class="info-item">
<span class="info-label">Node ID</span>
<span class="info-value" id="info-node">---</span>
</div>
</div>
<div class="softkeys">
<div class="softkey">VOL (+/-)</div>
<div class="softkey">HOLD (H)</div>
<div class="softkey">PLAY (P)</div>
</div>
<div class="overlay" id="overlay">HOLD</div>
<!-- Audio element for local playback -->
<audio id="audio-player" autoplay></audio>
<script>
// Elements
const elSystem = document.getElementById('disp-system');
const elDept = document.getElementById('disp-dept');
const elChan = document.getElementById('disp-chan');
const elTgid = document.getElementById('info-tgid');
const elNode = document.getElementById('info-node');
const elClock = document.getElementById('clock');
const elMain = document.getElementById('main-display');
const audioPlayer = document.getElementById('audio-player');
const elVol = document.getElementById('vol-indicator');
const elOverlay = document.getElementById('overlay');
let currentIcecastUrl = null;
let isHolding = false;
let volume = 1.0;
// Clock updater
setInterval(() => {
const now = new Date();
elClock.textContent = now.toLocaleTimeString('en-US', { hour12: false });
}, 1000);
// API Poller
async function updateStatus() {
try {
const res = await fetch('/api/status');
if (!res.ok) return;
const data = await res.json();
elSystem.textContent = data.system_name || 'NO SYSTEM';
elNode.textContent = (data.node_id || '---').slice(0, 6).toUpperCase();
if (data.is_recording && data.active_tgid) {
elMain.classList.add('receiving');
elChan.textContent = data.active_tgid_name || `TG ${data.active_tgid}`;
elDept.textContent = 'Active Call';
elTgid.textContent = data.active_tgid;
} else {
elMain.classList.remove('receiving');
elChan.textContent = 'IDLE';
elDept.textContent = 'Scanning...';
elTgid.textContent = '---';
}
if (data.icecast_url) {
// Replace localhost with actual hostname for network access
const dynamicUrl = data.icecast_url.replace('localhost', window.location.hostname);
if (currentIcecastUrl !== dynamicUrl) {
currentIcecastUrl = dynamicUrl;
audioPlayer.src = currentIcecastUrl;
// Modern browsers might block autoplay without interaction
audioPlayer.play().catch(e => console.log('Autoplay blocked', e));
}
}
} catch (err) {
console.error('Failed to fetch status', err);
}
}
setInterval(updateStatus, 500);
updateStatus();
// Show temporary overlay
function showOverlay(text, timeout = 1000) {
elOverlay.textContent = text;
elOverlay.style.display = 'block';
setTimeout(() => { elOverlay.style.display = 'none'; }, timeout);
}
let systems = [];
let selectedSystemIndex = 0;
let isSystemModalOpen = false;
async function openSystemModal() {
try {
const res = await fetch('/api/systems');
if (!res.ok) return;
systems = await res.json();
isSystemModalOpen = true;
selectedSystemIndex = 0;
renderSystemList();
document.getElementById('system-modal').style.display = 'block';
} catch (err) {
console.error('Failed to load systems', err);
}
}
function renderSystemList() {
const container = document.getElementById('system-list');
container.innerHTML = '';
if (systems.length === 0) {
container.innerHTML = '<div style="padding: 10px; color: #888;">No cached systems found.</div>';
return;
}
systems.forEach((sys, index) => {
const item = document.createElement('div');
item.style.padding = '8px 12px';
item.style.margin = '4px 0';
item.style.border = '1px solid #444';
item.style.cursor = 'pointer';
item.style.borderRadius = '4px';
if (index === selectedSystemIndex) {
item.style.background = 'var(--active-bg)';
item.style.borderColor = 'var(--sys-color)';
item.style.color = '#fff';
item.style.fontWeight = 'bold';
} else {
item.style.background = '#151515';
item.style.color = '#ccc';
}
item.textContent = `${sys.name} (${sys.type})`;
item.onclick = () => {
selectedSystemIndex = index;
selectActiveSystem();
};
container.appendChild(item);
});
}
function closeSystemModal() {
isSystemModalOpen = false;
document.getElementById('system-modal').style.display = 'none';
}
async function selectActiveSystem() {
const selected = systems[selectedSystemIndex];
if (!selected) return;
closeSystemModal();
showOverlay(`APPLYING: ${selected.name.toUpperCase()}`, 3000);
try {
const res = await fetch('/api/config/override', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ system_id: selected.system_id })
});
if (res.ok) {
showOverlay('SYSTEM OVERRIDDEN', 1500);
} else {
showOverlay('OVERRIDE FAILED', 2000);
}
} catch (err) {
showOverlay('ERROR APPLYING', 2000);
}
}
async function submitManualSystem() {
const freqVal = document.getElementById('manual-freq').value.trim();
const typeVal = document.getElementById('manual-type').value;
if (!freqVal) {
alert("Please enter a frequency.");
return;
}
closeSystemModal();
showOverlay("APPLYING MANUAL", 3000);
const manualConfig = {
system_id: "manual-override",
name: `Freq ${freqVal} (${typeVal})`,
type: typeVal,
config: {
control_channels: [freqVal],
talkgroups: []
}
};
try {
const res = await fetch('/api/config/override', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ system_config: manualConfig })
});
if (res.ok) {
showOverlay('MANUAL OVERRIDE OK', 1500);
} else {
showOverlay('MANUAL OVERRIDE FAIL', 2000);
}
} catch (err) {
showOverlay('ERROR APPLYING', 2000);
}
}
async function revertConfig() {
showOverlay("REVERTING TO SERVER", 2000);
try {
const res = await fetch('/api/config/revert', { method: 'POST' });
if (res.ok) {
showOverlay('SERVER CONFIG LOADED', 1500);
} else {
showOverlay('REVERT FAILED', 2000);
}
} catch (err) {
showOverlay('REVERT ERROR', 2000);
}
}
// Keyboard bindings for hardware buttons
window.addEventListener('keydown', (e) => {
if (isSystemModalOpen) {
if (e.key === 'ArrowUp') {
selectedSystemIndex = (selectedSystemIndex - 1 + systems.length) % systems.length;
renderSystemList();
e.preventDefault();
} else if (e.key === 'ArrowDown') {
selectedSystemIndex = (selectedSystemIndex + 1) % systems.length;
renderSystemList();
e.preventDefault();
} else if (e.key === 'Enter') {
selectActiveSystem();
e.preventDefault();
} else if (e.key === 'Escape') {
closeSystemModal();
e.preventDefault();
}
return;
}
// Simulate hardware interactions
if (e.key === 'ArrowUp') {
volume = Math.min(1.0, volume + 0.1);
audioPlayer.volume = volume;
elVol.textContent = `VOL: ${Math.round(volume * 100)}%`;
showOverlay(`VOL: ${Math.round(volume * 100)}%`);
} else if (e.key === 'ArrowDown') {
volume = Math.max(0.0, volume - 0.1);
audioPlayer.volume = volume;
elVol.textContent = `VOL: ${Math.round(volume * 100)}%`;
showOverlay(`VOL: ${Math.round(volume * 100)}%`);
} else if (e.key === 'Enter' || e.key === 'h' || e.key === 'H') {
isHolding = !isHolding;
showOverlay(isHolding ? 'HOLD ON' : 'HOLD OFF');
} else if (e.key === 'p' || e.key === 'P') {
if (audioPlayer.paused) {
audioPlayer.play();
showOverlay('PLAY');
} else {
audioPlayer.pause();
showOverlay('PAUSED');
}
} else if (e.key === 's' || e.key === 'S') {
openSystemModal();
} else if (e.key === 'r' || e.key === 'R') {
revertConfig();
}
});
// Attempt to start audio on first click (browser policy bypass)
document.body.addEventListener('click', () => {
if (audioPlayer.paused && currentIcecastUrl) {
audioPlayer.play();
}
}, { once: true });
</script>
</body>
</html>