Compare commits

..
5 Commits
Author SHA1 Message Date
iv3jdv e92a37f02a fix(modes): visibilità pannello admin e sincronizzazione hangtime MQTT
- Nascosto il pannello "Operating Modes" per gli utenti non autenticati o senza permessi admin, risolvendo l'errore 403 e il falso allarme "CFG MEMORY EMPTY".
- Risolto il bug dell'hangtime RF (Hold) a fine trasmissione: rimosso il timer asincrono locale lato frontend.
- La UI ora legge lo stato di hold sincronizzandosi esclusivamente col flag "idle" in arrivo dal broker MQTT (MMDVMHost).
- Mantenimento corretto a schermo dell'ultimo modo operativo utilizzato (es. [ DMR ] o [ NXDN ]) durante l'intera durata della coda del ponte.
2026-10-31 21:18:33 +01:00
iv3jdv 2456f462fe fix secure mode change 2026-10-31 20:49:05 +01:00
iv3jdv 34180df506 feat(modes): controllo interattivo modi operativi MMDVM e sync gateway
- Aggiunti pulsanti toggle interattivi per DMR, YSF, D-Star, NXDN e P25 nella vista Focus
- Aggiornamento automatico e persistenza del file di configurazione MMDVMHost
- Sincronizzazione automatica start/stop dei relativi demoni Gateway al cambio modo
- Aggiornamento ottimistico dell'interfaccia utente con feedback visivo immediato
- Allineamento immediato della cache backend in memoria al salvataggio config
2026-10-31 20:27:16 +01:00
iv3jdv 99c5d4f431 fix enable/disable mode 2026-10-31 16:45:20 +01:00
iv3jdv c47377a22c add enable/disable mode 2026-10-31 16:32:31 +01:00
5 changed files with 326 additions and 38 deletions
+1
View File
@@ -47,6 +47,7 @@ node_versions = {}
gateway_states = {} gateway_states = {}
active_warnings = {} active_warnings = {}
active_calls = {} active_calls = {}
operating_modes = {}
# Caricamento iniziale cache telemetria # Caricamento iniziale cache telemetria
if os.path.exists(CACHE_FILE): if os.path.exists(CACHE_FILE):
+7 -1
View File
@@ -104,7 +104,8 @@ def get_states():
"uptime": int(time.time() - state.START_TIME), "uptime": int(time.time() - state.START_TIME),
"versions": clean_versions, "versions": clean_versions,
"gateway_states": enriched_gateway_states, "gateway_states": enriched_gateway_states,
"warnings": state.active_warnings "warnings": state.active_warnings,
"modes": getattr(state, "operating_modes", {})
}) })
@api_bp.route('/api/stats') @api_bp.route('/api/stats')
@@ -346,6 +347,11 @@ def save_config_file():
if not mqtt_publish(f"devices/{cid}/config_set/{service}", json.dumps(new_config)): if not mqtt_publish(f"devices/{cid}/config_set/{service}", json.dumps(new_config)):
return err("Broker MQTT non raggiungibile", 503) return err("Broker MQTT non raggiungibile", 503)
audit(auth['username'], cid, f"EDIT_CONFIG_{service.upper()}") audit(auth['username'], cid, f"EDIT_CONFIG_{service.upper()}")
if cid not in state.device_configs:
state.device_configs[cid] = {}
state.device_configs[cid][service] = new_config
return jsonify({"success": True}) return jsonify({"success": True})
# --- AGGIORNAMENTO SERVER OTA --- # --- AGGIORNAMENTO SERVER OTA ---
+10
View File
@@ -334,6 +334,16 @@ def on_message(client, userdata, msg):
if m and "running" not in m.lower(): if m and "running" not in m.lower():
save_to_sqlite(cid, {'src_id': f"🌐 {m}", 'dst_id': 'NET'}, protocol=proto) save_to_sqlite(cid, {'src_id': f"🌐 {m}", 'dst_id': 'NET'}, protocol=proto)
# --- LETTURA STATO MODI DA TOPIC data/+/MMDVM ---
elif len(parts) == 3 and p0 == 'data' and p2 == 'mmdvm':
try:
cid = parts[1].lower()
data = json.loads(payload)
state.operating_modes[cid] = data
state.notify_update()
except Exception as e:
logger.error(f"Errore parsing MMDVM modes per {cid}: {e}")
# --- 8. TRAFFICO VOCE MMDVM (DMR & MODI DIGITALI) --- # --- 8. TRAFFICO VOCE MMDVM (DMR & MODI DIGITALI) ---
elif parts[0] == 'mmdvm': elif parts[0] == 'mmdvm':
data = json.loads(payload) data = json.loads(payload)
+297 -33
View File
@@ -1,5 +1,4 @@
// --- VARIABILI GLOBALI E UI VIEW --- // --- VARIABILI GLOBALI E UI VIEW ---
const HANG_TIME_MS = 3000;
let clients = []; let clients = [];
let me = { logged_in: false, user: '', role: '', allowed_nodes: '' }; let me = { logged_in: false, user: '', role: '', allowed_nodes: '' };
let isAuthenticated = false; let isAuthenticated = false;
@@ -17,6 +16,18 @@ let fleetMap = null;
let mapMarkers = {}; let mapMarkers = {};
let currentFocusedNode = null; let currentFocusedNode = null;
let currentMmdvmConfig = "";
let currentMmdvmConfigAlias = "";
let currentMmdvmServiceName = "";
// Mappatura Modo -> Gateway service name
const MODE_GATEWAYS = {
'DMR': ['dmrgateway'],
'NXDN': ['nxdngateway'],
'System Fusion': ['ysfgateway'],
'D-Star': ['dstargateway', 'dstar-gateway'],
'P25': ['p25gateway']
};
function switchView(viewName) { function switchView(viewName) {
currentFocusedNode = null; currentFocusedNode = null;
@@ -58,6 +69,20 @@ function openNodeFocus(clientId) {
document.getElementById('view-focus').style.display = 'block'; document.getElementById('view-focus').style.display = 'block';
window.scrollTo({ top: 0, behavior: 'smooth' }); window.scrollTo({ top: 0, behavior: 'smooth' });
const role = me.role || '';
const allowedList = String(me.allowed_nodes || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
let canControl = isAuthenticated && (role === 'admin' || allowedList.includes('all') || allowedList.includes(clientId.toLowerCase()));
const modesCard = document.getElementById('focus-modes-card');
if (modesCard) {
modesCard.style.display = canControl ? 'block' : 'none';
}
if (canControl) {
document.getElementById('focus-modes-toggles').innerHTML = '<span style="color:var(--text-muted); font-size: 0.9rem;" class="blink">FETCHING CONFIG...</span>';
fetchNodeConfigForModes(clientId);
}
refreshStates(); refreshStates();
refreshLogs(); refreshLogs();
} }
@@ -65,6 +90,8 @@ function openNodeFocus(clientId) {
function closeNodeFocus() { function closeNodeFocus() {
currentFocusedNode = null; currentFocusedNode = null;
document.getElementById('view-focus').style.display = 'none'; document.getElementById('view-focus').style.display = 'none';
const modesCard = document.getElementById('focus-modes-card');
if (modesCard) modesCard.style.display = 'none';
switchView(localStorage.getItem('fleetDefaultView') || 'home'); switchView(localStorage.getItem('fleetDefaultView') || 'home');
} }
@@ -216,6 +243,215 @@ function sendTgCommand(clientId, comando) {
}); });
} }
// --- LOGICA MODI OPERATIVI E GATEWAYS ---
async function fetchNodeConfigForModes(clientId) {
const role = me.role || '';
const allowedList = String(me.allowed_nodes || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
let canControl = isAuthenticated && (role === 'admin' || allowedList.includes('all') || allowedList.includes(clientId.toLowerCase()));
const modesCard = document.getElementById('focus-modes-card');
if (!canControl) {
if (modesCard) modesCard.style.display = 'none';
return;
}
if (modesCard) modesCard.style.display = 'block';
try {
const healthObj = globalHealthData[clientId.toLowerCase()];
if (!healthObj) {
document.getElementById('focus-modes-toggles').innerHTML = '<span style="color:var(--danger); font-size: 0.9rem;">NO DAEMON DATA YET. RETRYING...</span>';
setTimeout(() => { if (currentFocusedNode === clientId) fetchNodeConfigForModes(clientId); }, 2000);
return;
}
let filesList = healthObj.files || healthObj.config_files || [];
let iniFile = filesList.find(f => String(f).toLowerCase().includes('mmdvm') && String(f).toLowerCase().endsWith('.ini'));
if(!iniFile) iniFile = "MMDVMHost.ini";
let svcName = Object.keys(healthObj.processes || {}).find(k => k.toLowerCase().includes('mmdvm')) || "mmdvmhost";
currentMmdvmServiceName = svcName;
let candidates = ["mmdvm", svcName, "mmdvmhost", iniFile, "MMDVMHost.ini"];
let foundText = null;
for (let candidate of candidates) {
if(!candidate) continue;
try {
let res = await fetch(`/api/config_file/${encodeURIComponent(clientId)}/${encodeURIComponent(candidate)}`);
let data = await res.json();
if (data.success && data.data && data.data.raw_text && data.data.raw_text.length > 100) {
foundText = data.data.raw_text;
currentMmdvmConfigAlias = candidate; // Alias con cui salvare
break;
}
} catch(e) {}
}
if (foundText) {
currentMmdvmConfig = foundText;
renderModeToggles(clientId);
} else {
document.getElementById('focus-modes-toggles').innerHTML = `
<div style="display:flex; justify-content:space-between; align-items:center; width: 100%;">
<span style="color:var(--accent); font-size: 0.8rem;">[!] CFG MEMORY EMPTY</span>
<button class="btn-cmd" style="border-color:var(--accent); color:var(--accent)!important; width:auto; padding:4px 10px; flex:none;" onclick="fetch('/api/update_nodes', {method: 'POST'}); this.innerText='WAIT...'; setTimeout(() => fetchNodeConfigForModes('${clientId}'), 5000);">[ REQ_DATA ]</button>
</div>
`;
}
} catch (e) {
console.error(e);
document.getElementById('focus-modes-toggles').innerHTML = '<span style="color:var(--danger); font-size: 0.9rem;">NETWORK ERROR</span>';
}
}
function renderModeToggles(clientId, statusMsg = "") {
const role = me.role || '';
const allowedList = String(me.allowed_nodes || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
let canControl = isAuthenticated && (role === 'admin' || allowedList.includes('all') || allowedList.includes(clientId.toLowerCase()));
const modesCard = document.getElementById('focus-modes-card');
if (modesCard) {
modesCard.style.display = canControl ? 'block' : 'none';
}
let container = document.getElementById('focus-modes-toggles');
if (!container) return;
if (!canControl) {
container.innerHTML = '<span style="color:var(--danger); font-size: 0.9rem;">[ ACCESS DENIED ]</span>';
return;
}
const modes = [
{ id: 'DMR', label: 'DMR', color: 'var(--primary)' },
{ id: 'D-Star', label: 'D-STAR', color: '#f97316' },
{ id: 'System Fusion', label: 'YSF', color: '#8b5cf6' },
{ id: 'NXDN', label: 'NXDN', color: 'var(--success)' },
{ id: 'P25', label: 'P25', color: 'var(--accent)' }
];
let html = "";
let lines = currentMmdvmConfig.split('\n');
modes.forEach(m => {
let enabled = false;
let sectionFound = false;
let currentSection = "";
for (let i = 0; i < lines.length; i++) {
let line = lines[i].trim();
if (line.startsWith('[') && line.endsWith(']')) {
currentSection = line.substring(1, line.length - 1);
}
if (currentSection.toLowerCase() === m.id.toLowerCase() && line.toLowerCase().startsWith('enable')) {
sectionFound = true;
let parts = line.split('=');
if (parts.length === 2 && parts[1].trim() === '1') {
enabled = true;
}
break;
}
}
if (sectionFound) {
let btnStyle = enabled
? `border-color: ${m.color}; color: ${m.color} !important; box-shadow: inset 0 0 8px ${m.color}; font-weight: bold;`
: `border-color: var(--border-light); color: var(--text-muted) !important; opacity: 0.4;`;
html += `<button class="btn-cmd" style="padding: 10px 15px; font-size: 1.1rem; width: auto; flex: 1; min-width: 80px; transition: all 0.2s ease; ${btnStyle}" onclick="toggleOperatingMode('${clientId}', '${m.id}', ${!enabled})">${m.label}</button>`;
}
});
if (html === "") html = '<span style="color:var(--text-muted); font-size: 0.9rem;">NO MODES FOUND IN CONFIG</span>';
if (statusMsg) {
html += `<div style="width: 100%; margin-top: 8px; font-family: 'JetBrains Mono', monospace;">${statusMsg}</div>`;
}
container.innerHTML = html;
}
function toggleOperatingMode(clientId, section, enable) {
const title = currentLang === 'it' ? "[ CAMBIO_MODO ]" : "[ MODE_TOGGLE ]";
const msg = currentLang === 'it'
? `Vuoi ${enable ? 'ABILITARE' : 'DISABILITARE'} il modo <b>${section}</b>?<br><br><span style="font-size:0.8rem; color:var(--text-muted);">Verranno aggiornati MMDVMHost e il relativo Gateway.</span>`
: `${enable ? 'ENABLE' : 'DISABLE'} mode <b>${section}</b>?<br><br><span style="font-size:0.8rem; color:var(--text-muted);">This will update MMDVMHost and its Gateway.</span>`;
customConfirm(title, msg, enable ? "var(--success)" : "var(--danger)", async () => {
// 1. Aggiorna subito il testo locale del file INI
let lines = currentMmdvmConfig.split('\n');
let currentSection = "";
for (let i = 0; i < lines.length; i++) {
let cleanLine = lines[i].trim();
if (cleanLine.startsWith('[') && cleanLine.endsWith(']')) {
currentSection = cleanLine.substring(1, cleanLine.length - 1);
}
if (currentSection.toLowerCase() === section.toLowerCase() && cleanLine.toLowerCase().startsWith('enable')) {
lines[i] = lines[i].replace(/Enable\s*=\s*[01]/i, `Enable=${enable ? "1" : "0"}`);
break;
}
}
currentMmdvmConfig = lines.join('\n');
// 2. Ridisegna SUBITO i pulsanti (così il tasto cambia stato all'istante) e mostra la nota di caricamento
renderModeToggles(clientId, '<span style="color:var(--accent); font-size:0.8rem;" class="blink">⏳ SALVATAGGIO & RIAVVIO IN CORSO...</span>');
try {
// 3. Salva il file INI
const resSave = await fetch('/api/config_file', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
clientId: clientId,
service: currentMmdvmConfigAlias,
config_data: { "raw_text": currentMmdvmConfig }
})
});
const dataSave = await resSave.json();
if (!dataSave.success) throw new Error("SAVE ERR: " + dataSave.error);
// 4. Invia start/stop al Gateway associato
const healthObj = globalHealthData[clientId.toLowerCase()] || {};
const gwCandidates = MODE_GATEWAYS[section] || [];
const runningProcs = Object.keys(healthObj.processes || {});
const targetGw = gwCandidates.find(g => runningProcs.some(p => p.toLowerCase() === g.toLowerCase()));
if (targetGw) {
const gwAction = enable ? 'start' : 'stop';
await fetch('/api/service_control', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ clientId: clientId, service: targetGw, action: gwAction })
});
}
// 5. Riavvia MMDVMHost
const resRst = await fetch('/api/service_control', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ clientId: clientId, service: currentMmdvmServiceName, action: 'restart' })
});
const dataRst = await resRst.json();
if (!dataRst.success) throw new Error("RESTART ERR: " + dataRst.error);
// 6. Conferma avvenuta applicazione senza ricaricare file vecchi
renderModeToggles(clientId, '<span style="color:var(--success); font-size:0.8rem;">✅ STATO AGGIORNATO CON SUCCESSO!</span>');
// Rimuove il messaggio di conferma dopo 3 secondi lasciando i bottoni nello stato nuovo
setTimeout(() => {
if (currentFocusedNode === clientId) {
renderModeToggles(clientId);
}
}, 3000);
} catch (e) {
console.error(e);
customAlert(t('titleError'), String(e), true);
fetchNodeConfigForModes(clientId);
}
});
}
// --- INIT APP ---
async function initUI() { async function initUI() {
applyTranslations(); applyTranslations();
try { try {
@@ -473,7 +709,6 @@ async function refreshStates() {
let txModeStr = "TX"; let txModeStr = "TX";
let isIdle = telemetryObj.idle === true; let isIdle = telemetryObj.idle === true;
// 1. Usa la logica ORIGINALE, testando solo il contenuto di ts1, ts2 e alt per capire se stiamo trasmettendo.
if (telemetryObj.alt && telemetryObj.alt !== "") { if (telemetryObj.alt && telemetryObj.alt !== "") {
let altText = telemetryObj.alt.toUpperCase(); let altText = telemetryObj.alt.toUpperCase();
if (altText.includes("NXDN")) { activeModeColor = "var(--success)"; txModeStr = "TX NXDN"; } if (altText.includes("NXDN")) { activeModeColor = "var(--success)"; txModeStr = "TX NXDN"; }
@@ -499,7 +734,6 @@ async function refreshStates() {
cardDiv.dataset.status = isOnline ? 'online' : 'offline'; cardDiv.dataset.status = isOnline ? 'online' : 'offline';
renderSeen(c, data, isOnline); renderSeen(c, data, isOnline);
// Gestione Avvisi
const warns = (data.warnings && data.warnings[c.id.toLowerCase()]) || []; const warns = (data.warnings && data.warnings[c.id.toLowerCase()]) || [];
cardDiv.dataset.hasWarn = (warns.length > 0) ? 'true' : 'false'; cardDiv.dataset.hasWarn = (warns.length > 0) ? 'true' : 'false';
const diagDiv = document.getElementById(`diag-warn-${c.id}`); const diagDiv = document.getElementById(`diag-warn-${c.id}`);
@@ -513,7 +747,6 @@ async function refreshStates() {
} }
} }
// Intestazione Card
const nameSpan = cardDiv.querySelector('.client-name'); const nameSpan = cardDiv.querySelector('.client-name');
const idBadge = cardDiv.querySelector('.badge-id'); const idBadge = cardDiv.querySelector('.badge-id');
const typeBadge = document.getElementById(`type-badge-${c.id}`); const typeBadge = document.getElementById(`type-badge-${c.id}`);
@@ -532,7 +765,6 @@ async function refreshStates() {
if (typeBadge) typeBadge.style.display = 'none'; if (typeBadge) typeBadge.style.display = 'none';
} }
// Timeslots
const tsContainer = document.getElementById(`ts-container-${c.id}`); const ts1Div = document.getElementById(`dmr-ts1-${c.id}`); const ts2Div = document.getElementById(`dmr-ts2-${c.id}`); const altDiv = document.getElementById(`dmr-alt-${c.id}`); const tsContainer = document.getElementById(`ts-container-${c.id}`); const ts1Div = document.getElementById(`dmr-ts1-${c.id}`); const ts2Div = document.getElementById(`dmr-ts2-${c.id}`); const altDiv = document.getElementById(`dmr-alt-${c.id}`);
if (telemetryObj.alt && telemetryObj.alt !== "") { if (telemetryObj.alt && telemetryObj.alt !== "") {
@@ -632,8 +864,16 @@ async function refreshStates() {
if (healthContainer) healthContainer.style.display = 'none'; if (healthContainer) healthContainer.style.display = 'none';
} }
// Logica tollerante per i Gateway in standby (spenti dalla UI)
let hasOfflineService = false; let hasOfflineService = false;
if (healthObj && healthObj.processes) { for (const [svcName, svcStatus] of Object.entries(healthObj.processes)) { if (svcStatus.toLowerCase() !== 'online') { hasOfflineService = true; break; } } } if (healthObj && healthObj.processes) {
for (const [svcName, svcStatus] of Object.entries(healthObj.processes)) {
let s = svcStatus.toLowerCase();
if (s !== 'online' && s !== 'standby') {
hasOfflineService = true; break;
}
}
}
const warnBadge = document.getElementById(`svc-warn-${c.id}`); const btnSvc = document.getElementById(`btn-svc-${c.id}`); const warnBadge = document.getElementById(`svc-warn-${c.id}`); const btnSvc = document.getElementById(`btn-svc-${c.id}`);
if (warnBadge) warnBadge.style.display = hasOfflineService ? 'block' : 'none'; if (warnBadge) warnBadge.style.display = hasOfflineService ? 'block' : 'none';
if (btnSvc) { if (hasOfflineService) { btnSvc.style.borderColor = 'var(--danger)'; btnSvc.style.color = 'var(--danger)'; } else { btnSvc.style.borderColor = 'var(--text-main)'; btnSvc.style.color = 'var(--text-main)'; } } if (btnSvc) { if (hasOfflineService) { btnSvc.style.borderColor = 'var(--danger)'; btnSvc.style.color = 'var(--danger)'; } else { btnSvc.style.borderColor = 'var(--text-main)'; btnSvc.style.color = 'var(--text-main)'; } }
@@ -651,17 +891,18 @@ async function refreshStates() {
} }
} }
// 2. TIMEOUT LOCALE PER L'EFFETTO CODA VISIVO (Sostituisce il check di isIdle) // --- NESSUN TIMER LOCALE: COMANDA MQTT ---
let timeSinceTx = 0; // Memorizza l'ultimo modo in trasmissione per usarlo durante l'Hangtime
if (isTx && isOnline) { if (isTx && isOnline) {
cardDiv.dataset.lastTx = Date.now(); cardDiv.dataset.lastMode = txModeStr.replace("TX ", "").trim();
} else { cardDiv.dataset.lastColor = activeModeColor;
timeSinceTx = Date.now() - (parseInt(cardDiv.dataset.lastTx) || 0);
} }
// L'interfaccia mantiene lo stato solo se non sta trasmettendo E se sono passati meno di 6 secondi (Hold). // Se non è in TX e MMDVM NON ha ancora dichiarato 'idle' -> siamo in Hold
// In questo modo i micro-pacchetti D-STAR che non inviano l'end di chiamata svaniranno dopo 6s per forza. let isHold = (!isTx && !isIdle && isOnline);
let isHold = (!isTx && timeSinceTx < 6000);
let holdMode = cardDiv.dataset.lastMode || "DMR";
let holdColor = cardDiv.dataset.lastColor || "var(--primary)";
let displayState = stateValue; let displayState = stateValue;
let statusColor = ""; let statusColor = "";
@@ -677,19 +918,32 @@ async function refreshStates() {
statusBorder = activeModeColor; statusBorder = activeModeColor;
cBorder = activeModeColor; cBorder = activeModeColor;
} else if (isHold) { } else if (isHold) {
displayState = `[ ${txModeStr.replace("TX ", "")} ]`; displayState = `[ ${holdMode} ]`;
statusColor = activeModeColor; statusColor = holdColor;
statusBorder = activeModeColor; statusBorder = holdColor;
} else { cBorder = holdColor;
// Quando scade l'Hold, FORZIAMO la scomparsa di ogni traccia di D-STAR / YSF
isIdle = true;
} }
// Applica i calcoli alla Card Principale
if (isOnline) { if (isOnline) {
cardDiv.classList.add('online'); statusDiv.classList.remove('status-offline'); cardDiv.classList.add('online'); statusDiv.classList.remove('status-offline');
cardDiv.style.opacity = "1"; cardDiv.style.filter = "none";
cardDiv.style.setProperty('border-top-color', (isTx || isHold) ? statusColor : "var(--border-color)", 'important');
if(isTx) {
let shadowRGB = '59, 130, 246';
if (activeModeColor === '#10b981') shadowRGB = '16, 185, 129';
else if (activeModeColor === '#8b5cf6') shadowRGB = '139, 92, 246';
else if (activeModeColor === '#06b6d4') shadowRGB = '6, 182, 212';
else if (activeModeColor === '#f59e0b') shadowRGB = '245, 158, 11';
cardDiv.style.boxShadow = `0 0 20px rgba(${shadowRGB}, 0.5) !important`;
} else {
cardDiv.style.boxShadow = '0 4px 12px rgba(0,0,0,0.2) !important';
}
} else { } else {
cardDiv.classList.remove('online'); statusDiv.classList.add('status-offline'); cardDiv.classList.remove('online'); statusDiv.classList.add('status-offline');
cardDiv.style.opacity = "0.7"; cardDiv.style.filter = "grayscale(80%)";
cardDiv.style.setProperty('border-top-color', '#64748b', 'important');
cardDiv.style.boxShadow = 'none !important';
} }
cardDiv.style.borderColor = cBorder; cardDiv.style.borderColor = cBorder;
@@ -699,18 +953,21 @@ async function refreshStates() {
statusDiv.style.borderColor = statusBorder; statusDiv.style.borderColor = statusBorder;
} }
// Applica i calcoli alla Mini Card in HOME
const miniCard = document.getElementById(`mini-card-${c.id}`); const miniCard = document.getElementById(`mini-card-${c.id}`);
const miniStatus = document.getElementById(`mini-status-${c.id}`); const miniStatus = document.getElementById(`mini-status-${c.id}`);
const miniName = document.getElementById(`mini-name-${c.id}`);
const miniId = document.getElementById(`mini-id-${c.id}`);
if (miniCard && miniStatus) { if (miniCard && miniStatus) {
if (genObj && isOnline) { if (genObj && isOnline) {
const miniName = document.getElementById(`mini-name-${c.id}`); if(miniName) miniName.innerText = genObj.callsign;
const miniId = document.getElementById(`mini-id-${c.id}`); if(miniId) miniId.innerText = `ID:${genObj.radio_id}`;
if (miniName) miniName.innerText = genObj.callsign;
if (miniId) miniId.innerText = `ID:${genObj.radio_id}`;
} }
if (isOnline) { if (isOnline) {
miniCard.style.opacity = "1";
miniCard.style.filter = "none";
if (warns.length > 0 && !isTx && !isHold) { if (warns.length > 0 && !isTx && !isHold) {
miniCard.style.borderColor = "var(--accent)"; miniCard.style.borderColor = "var(--accent)";
miniStatus.innerText = "(!) ALERT"; miniStatus.innerText = "(!) ALERT";
@@ -729,9 +986,10 @@ async function refreshStates() {
mColor = activeModeColor; mColor = activeModeColor;
mBorderColor = activeModeColor; mBorderColor = activeModeColor;
} else if (isHold) { } else if (isHold) {
mStatus = `[ ${txModeStr.replace("TX ", "")} ]`; mcBorder = holdColor;
mColor = activeModeColor; mStatus = `[ ${holdMode} ]`;
mBorderColor = activeModeColor; mColor = holdColor;
mBorderColor = holdColor;
} }
miniCard.style.borderColor = mcBorder; miniCard.style.borderColor = mcBorder;
@@ -741,6 +999,8 @@ async function refreshStates() {
miniStatus.style.borderColor = mBorderColor; miniStatus.style.borderColor = mBorderColor;
} }
} else { } else {
miniCard.style.opacity = "0.7";
miniCard.style.filter = "grayscale(80%)";
miniCard.style.borderColor = "var(--border-light)"; miniCard.style.borderColor = "var(--border-light)";
miniStatus.innerText = "OFFLINE"; miniStatus.innerText = "OFFLINE";
miniStatus.title = "OFFLINE"; miniStatus.title = "OFFLINE";
@@ -749,7 +1009,6 @@ async function refreshStates() {
} }
} }
// Applica i calcoli al Nodo Singolo (Focus Mode)
if (currentFocusedNode === c.id) { if (currentFocusedNode === c.id) {
let focusStatus = document.getElementById('focus-status'); let focusStatus = document.getElementById('focus-status');
@@ -761,15 +1020,15 @@ async function refreshStates() {
fsState = `( ${txModeStr} )`; fsState = `( ${txModeStr} )`;
fsColor = activeModeColor; fsColor = activeModeColor;
} else if (isHold) { } else if (isHold) {
fsState = `[ ${txModeStr.replace("TX ", "")} ]`; fsState = `[ ${holdMode} ]`;
fsColor = activeModeColor; fsColor = holdColor;
} }
} }
focusStatus.innerText = fsState; focusStatus.innerText = fsState;
focusStatus.style.color = fsColor; focusStatus.style.color = fsColor;
let focusLedColor = isOnline ? (isTx ? activeModeColor : 'var(--success)') : 'var(--border-light)'; let focusLedColor = isOnline ? (isTx ? activeModeColor : (isHold ? holdColor : 'var(--success)')) : 'var(--border-light)';
let focusLedBg = (isOnline && isTx) ? activeModeColor : 'transparent'; let focusLedBg = (isOnline && isTx) ? activeModeColor : 'transparent';
document.getElementById('focus-name').innerHTML = `<span style="display:inline-block; border-radius:50%; width:20px; height:20px; border:2px solid ${focusLedColor}; background:${focusLedBg}"></span> ${esc(genObj ? genObj.callsign : c.name)}`; document.getElementById('focus-name').innerHTML = `<span style="display:inline-block; border-radius:50%; width:20px; height:20px; border:2px solid ${focusLedColor}; background:${focusLedBg}"></span> ${esc(genObj ? genObj.callsign : c.name)}`;
@@ -801,6 +1060,11 @@ async function refreshStates() {
} }
document.getElementById('focus-ts').innerHTML = focusTsHtml || "--"; document.getElementById('focus-ts').innerHTML = focusTsHtml || "--";
const modesCard = document.getElementById('focus-modes-card');
if (modesCard) {
modesCard.style.display = canControl ? 'block' : 'none';
}
const focusControls = document.getElementById('focus-controls'); const focusControls = document.getElementById('focus-controls');
if (canControl || showReboot) { if (canControl || showReboot) {
focusControls.style.display = 'block'; focusControls.style.display = 'block';
+8 -1
View File
@@ -107,6 +107,13 @@
<div style="display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border-light); padding-bottom: 8px;"><span>LOCATION:</span> <span id="focus-loc" style="color: var(--text-main);">--</span></div> <div style="display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border-light); padding-bottom: 8px;"><span>LOCATION:</span> <span id="focus-loc" style="color: var(--text-main);">--</span></div>
</div> </div>
</div> </div>
<div class="card" id="focus-modes-card" style="border-width: 1px !important; display: none;">
<h3 style="margin: 0 0 15px 0; color: #fff; font-weight: 300; font-size: 1.3rem; letter-spacing: 2px;">[ OPERATING_MODES ]</h3>
<div id="focus-modes-toggles" style="display: flex; flex-wrap: wrap; gap: 10px; font-family: 'JetBrains Mono', monospace;">
<span style="color:var(--text-muted); font-size: 0.9rem;">WAITING FOR CONFIG...</span>
</div>
</div>
</div> </div>
<!-- COLONNA DX: SOFTWARE E LOG --> <!-- COLONNA DX: SOFTWARE E LOG -->
@@ -433,7 +440,7 @@
<!-- MOTORE MODULARIZZATO JS (Cache Buster aggiunto per forzare il refresh) --> <!-- MOTORE MODULARIZZATO JS (Cache Buster aggiunto per forzare il refresh) -->
<script src="/static/js/modals.js?v=blueprint4"></script> <script src="/static/js/modals.js?v=blueprint4"></script>
<script src="/static/js/app.js?v=blueprint-header-fix2"></script> <script src="/static/js/app.js?v=blueprint-modes-admin-only-final"></script>
<!-- SERVICE WORKER --> <!-- SERVICE WORKER -->
<script> <script>