Compare commits
11
Commits
793b06b4e3
...
v5.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e92a37f02a | ||
|
|
2456f462fe | ||
|
|
34180df506 | ||
|
|
99c5d4f431 | ||
|
|
c47377a22c | ||
|
|
b684976665 | ||
|
|
77edeef8ac | ||
|
|
68fe4f9d61 | ||
|
|
eea2fae2d4 | ||
|
|
ea505f22aa | ||
|
|
5a21cf8eb9 |
+2
-1
@@ -15,7 +15,8 @@
|
||||
"dstar-gateway/+/json",
|
||||
"mmdvm/+/json",
|
||||
"devices/#",
|
||||
"data/#"
|
||||
"data/#",
|
||||
"aprs-gateway/aprs"
|
||||
]
|
||||
},
|
||||
"web_admin": {
|
||||
|
||||
@@ -47,6 +47,7 @@ node_versions = {}
|
||||
gateway_states = {}
|
||||
active_warnings = {}
|
||||
active_calls = {}
|
||||
operating_modes = {}
|
||||
|
||||
# Caricamento iniziale cache telemetria
|
||||
if os.path.exists(CACHE_FILE):
|
||||
|
||||
@@ -104,7 +104,8 @@ def get_states():
|
||||
"uptime": int(time.time() - state.START_TIME),
|
||||
"versions": clean_versions,
|
||||
"gateway_states": enriched_gateway_states,
|
||||
"warnings": state.active_warnings
|
||||
"warnings": state.active_warnings,
|
||||
"modes": getattr(state, "operating_modes", {})
|
||||
})
|
||||
|
||||
@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)):
|
||||
return err("Broker MQTT non raggiungibile", 503)
|
||||
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})
|
||||
|
||||
# --- AGGIORNAMENTO SERVER OTA ---
|
||||
|
||||
@@ -334,6 +334,16 @@ def on_message(client, userdata, msg):
|
||||
if m and "running" not in m.lower():
|
||||
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) ---
|
||||
elif parts[0] == 'mmdvm':
|
||||
data = json.loads(payload)
|
||||
|
||||
+18
-18
@@ -26,25 +26,24 @@ body {
|
||||
margin: 0; padding: 0; color: var(--text-main); min-height: 100vh;
|
||||
}
|
||||
|
||||
/* TOP BAR */
|
||||
#top-bar-container { position: sticky; top: 0; z-index: 100; padding: 15px 20px; display: flex; justify-content: center; background: rgba(6, 36, 111, 0.8); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-main); margin-bottom: 30px; }
|
||||
/* Modified #top-bar for specific alignment */
|
||||
#top-bar { padding: 12px 30px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border-main); width: 100%; max-width: 1400px; background: rgba(6, 36, 111, 0.5); }
|
||||
.title-brand { font-size: 1.2rem; font-weight: 300; letter-spacing: 4px; color: var(--text-main); text-transform: uppercase; white-space: nowrap; flex-shrink: 0;}
|
||||
/* TOP BAR - OTTIMIZZATA RIMUOVENDO BACKDROP-FILTER E RISOLVENDO WRAP */
|
||||
#top-bar-container { position: sticky; top: 0; z-index: 100; padding: 15px 20px; display: flex; justify-content: center; background: rgba(6, 36, 111, 0.95); border-bottom: 1px solid var(--border-main); margin-bottom: 30px; }
|
||||
#top-bar { padding: 12px 20px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 15px; border: 1px solid var(--border-main); width: 100%; max-width: 1400px; background: rgba(6, 36, 111, 0.5); }
|
||||
.title-brand { font-size: 1.2rem; font-weight: 300; letter-spacing: 4px; color: var(--text-main); text-transform: uppercase; white-space: nowrap; flex-shrink: 0; margin-right: 10px;}
|
||||
|
||||
.nav-tabs { display: flex; gap: 15px; margin-left: 30px; flex: 1; flex-wrap: wrap; justify-content: flex-start;}
|
||||
.nav-tabs { display: flex; gap: 10px; flex: 1 1 auto; min-width: 250px; flex-wrap: wrap; justify-content: flex-start; margin-left: 0;}
|
||||
.nav-tab { background: transparent; border: 1px solid transparent; color: var(--text-muted); font-size: 0.85rem; font-weight: 300; letter-spacing: 2px; cursor: pointer; padding: 6px 16px; transition: all 0.2s ease; text-transform: uppercase; white-space: nowrap;}
|
||||
.nav-tab:hover { color: var(--text-main); border: 1px solid var(--border-light); }
|
||||
.nav-tab.active { color: var(--text-main); border: 1px solid var(--border-main); }
|
||||
|
||||
.theme-switch { background: transparent; border: 1px dashed var(--border-main); color: var(--text-main); padding: 6px 14px; cursor: pointer; font-weight: 300; font-size: 0.75rem; letter-spacing: 1px; transition: all 0.2s; text-transform: uppercase; white-space: nowrap;}
|
||||
.theme-switch { background: transparent; border: 1px dashed var(--border-main); color: var(--text-main); padding: 6px 14px; cursor: pointer; font-weight: 300; font-size: 0.75rem; letter-spacing: 1px; transition: all 0.2s ease; text-transform: uppercase; white-space: nowrap;}
|
||||
.theme-switch:hover { background: rgba(255,255,255,0.1); }
|
||||
|
||||
/* Container for right side items (auth and other buttons) */
|
||||
.top-bar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0;}
|
||||
.top-bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; flex: 1 1 auto; }
|
||||
|
||||
/* FILTRI E CONTROLLI VIEW */
|
||||
.filter-bar { background: rgba(6, 36, 111, 0.6); border: 1px solid var(--border-main); padding: 10px 20px; display: flex; gap: 15px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 20px; }
|
||||
.filter-bar { background: rgba(6, 36, 111, 0.90); border: 1px solid var(--border-main); padding: 10px 20px; display: flex; gap: 15px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 20px; }
|
||||
.filter-pill { background: transparent; border: 1px dashed var(--border-light); color: var(--text-muted); padding: 6px 14px; font-size: 0.75rem; font-weight: 300; letter-spacing: 1px; cursor: pointer; transition: all 0.2s ease; text-transform: uppercase; font-family: 'JetBrains Mono', monospace; }
|
||||
.filter-pill:hover { border-style: solid; border-color: var(--border-main); color: var(--text-main); }
|
||||
.filter-pill.active { background: rgba(123, 198, 255, 0.15); color: var(--text-main); border: 1px solid var(--text-main); }
|
||||
@@ -64,8 +63,8 @@ body {
|
||||
.list-view .node-meta { margin-bottom: 0; text-align: left; }
|
||||
.list-view .admin-dropdown { width: auto; flex: 0 0 auto; }
|
||||
|
||||
/* CARDS */
|
||||
.card { background: rgba(6, 36, 111, 0.6) !important; padding: 20px; border: 1px solid var(--border-main) !important; display: flex; flex-direction: column; transition: all 0.3s ease; backdrop-filter: blur(2px); box-shadow: none !important; border-radius: 0; }
|
||||
/* CARDS - OTTIMIZZATE RIMUOVENDO BACKDROP-FILTER */
|
||||
.card { background: rgba(6, 36, 111, 0.90) !important; padding: 20px; border: 1px solid var(--border-main) !important; display: flex; flex-direction: column; transition: all 0.3s ease; box-shadow: none !important; border-radius: 0; }
|
||||
.card:hover { border-color: #fff !important; }
|
||||
|
||||
/* HEADER FISSO SU 2 RIGHE ALLINEATO A SINISTRA */
|
||||
@@ -113,7 +112,7 @@ details.admin-dropdown summary::-webkit-details-marker { display: none; }
|
||||
.mqtt-online { background: transparent; color: var(--success); border-color: var(--success); }
|
||||
.mqtt-offline { background: transparent; color: var(--danger); border-color: var(--danger); animation: danger-glow 2s infinite; }
|
||||
|
||||
.table-container { background: rgba(6, 36, 111, 0.6); border: 1px solid var(--border-main); overflow-x: auto; overflow-y: auto; max-height: 500px; margin: 0 20px 40px 20px; -webkit-overflow-scrolling: touch; }
|
||||
.table-container { background: rgba(6, 36, 111, 0.90); border: 1px solid var(--border-main); overflow-x: auto; overflow-y: auto; max-height: 500px; margin: 0 20px 40px 20px; -webkit-overflow-scrolling: touch; }
|
||||
thead th { position: sticky; top: 0; z-index: 10; background: var(--bg-base); border-bottom: 1px dashed var(--border-main); font-weight: 400; letter-spacing: 1px; color: var(--border-main); }
|
||||
table { width: 100%; min-width: 100%; border-collapse: collapse; text-align: left; font-size: 0.85rem; font-family: 'Inter', sans-serif; white-space: nowrap; }
|
||||
th, td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); line-height: 1.6; vertical-align: middle; }
|
||||
@@ -126,9 +125,9 @@ tbody tr:hover { background-color: rgba(123, 198, 255, 0.1); }
|
||||
@keyframes danger-glow { 0% { box-shadow: inset 0 0 5px var(--danger); border-color: var(--border-light); } 50% { box-shadow: inset 0 0 15px var(--danger); border-color: var(--danger); } 100% { box-shadow: inset 0 0 5px var(--danger); border-color: var(--border-light); } }
|
||||
.blink { animation: danger-glow 1.5s infinite; color: var(--danger) !important; border: 1px solid var(--danger) !important; }
|
||||
|
||||
/* MODALS - OTTIMIZZATE */
|
||||
.modal-overlay { display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(6, 36, 111, 0.85); z-index:1000; align-items:center; justify-content:center; backdrop-filter: blur(8px); }
|
||||
.modal-top { z-index: 5000 !important; }
|
||||
/* FONDAMENTALE: width: 90% in modo che prenda lo spazio massimo e spinga gli elementi allineati a dx verso il bordo */
|
||||
.modal-content { background: var(--bg-base); border: 1px solid var(--border-main); padding: 25px; max-height: 90vh; overflow-y: auto; width: 90%; }
|
||||
|
||||
.auth-btn { background: transparent; color: var(--text-main); border: 1px solid var(--border-main); padding: 6px 12px; font-weight: 300; cursor: pointer; font-size: 0.8rem; font-family: 'Inter', sans-serif; transition: all 0.2s; letter-spacing: 1px; text-transform: uppercase; white-space: nowrap;}
|
||||
@@ -138,7 +137,8 @@ input:focus, select:focus { border-color: #fff; border-style: solid; }
|
||||
input:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
option { background: var(--bg-base); color: var(--text-main); }
|
||||
|
||||
.mini-card { background: rgba(6, 36, 111, 0.6); border: 1px solid var(--border-main); padding: 15px 10px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; transition: all 0.2s ease; cursor: pointer; height: 105px; width: 160px; overflow: hidden; backdrop-filter: blur(2px); }
|
||||
/* MINI CARD - OTTIMIZZATA */
|
||||
.mini-card { background: rgba(6, 36, 111, 0.90); border: 1px solid var(--border-main); padding: 15px 10px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; transition: all 0.2s ease; cursor: pointer; height: 105px; width: 160px; overflow: hidden; }
|
||||
.mini-card:hover { background: rgba(123, 198, 255, 0.15); border-color: #fff; }
|
||||
.mini-card-content { width: 100%; overflow: hidden; }
|
||||
.mini-card-name { font-weight: 300; font-size: 1.1rem; width: 100%; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.5px; }
|
||||
@@ -148,7 +148,7 @@ option { background: var(--bg-base); color: var(--text-main); }
|
||||
#map-container { max-width: 1400px; height: calc(100vh - 200px); min-height: 550px; margin: 0 auto; border: 1px solid var(--border-main); overflow: hidden; }
|
||||
/* Filtro CAD per la mappa */
|
||||
.dark-tiles { filter: invert(1) sepia(1) hue-rotate(180deg) saturate(3) brightness(0.8) contrast(1.2); }
|
||||
.custom-map-pin { display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid white; font-size: 0.9rem; background: transparent; backdrop-filter: blur(2px); font-family: 'JetBrains Mono', monospace; font-weight: normal; transition: all 0.3s ease;}
|
||||
.custom-map-pin { display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid white; font-size: 0.9rem; background: transparent; font-family: 'JetBrains Mono', monospace; font-weight: normal; transition: all 0.3s ease;}
|
||||
.pin-online { border-color: var(--success); color: var(--success); }
|
||||
.pin-offline { border-color: var(--text-muted); color: var(--text-muted); border-style: dashed; }
|
||||
.pin-warn { border-color: var(--accent) !important; color: var(--accent) !important; }
|
||||
@@ -159,7 +159,7 @@ option { background: var(--bg-base); color: var(--text-main); }
|
||||
/* Responsive rules */
|
||||
@media (max-width: 1200px) {
|
||||
#top-bar { flex-direction: column; align-items: stretch;}
|
||||
.title-brand { text-align: center; margin-bottom: 10px;}
|
||||
.title-brand { text-align: center; margin-bottom: 10px; margin-right: 0;}
|
||||
.nav-tabs { justify-content: center; margin-left: 0; margin-bottom: 10px;}
|
||||
.top-bar-right { justify-content: center;}
|
||||
}
|
||||
@@ -167,12 +167,12 @@ option { background: var(--bg-base); color: var(--text-main); }
|
||||
@media (max-width: 768px) {
|
||||
#top-bar-container { top: 0; padding: 10px; margin-bottom: 15px; border-bottom: 1px solid var(--border-main); }
|
||||
#top-bar { padding: 15px; gap: 12px; }
|
||||
.title-brand { font-size: 1.1rem; text-align: center; width: 100%; }
|
||||
.title-brand { font-size: 1.1rem; text-align: center; width: 100%; margin-right: 0;}
|
||||
.top-bar-right { width: 100%; flex-wrap: wrap; justify-content: center; gap: 8px !important; }
|
||||
#auth-container { width: 100%; justify-content: center; flex-wrap: wrap; padding-top: 12px; border-top: 1px dashed var(--border-main); margin-top: 5px;}
|
||||
#auth-container > span { width: 100%; text-align: center; margin-bottom: 8px; font-family: 'Inter', sans-serif; }
|
||||
.auth-btn, .theme-switch { flex: 1 1 auto; text-align: center; }
|
||||
.nav-tabs { position: fixed; bottom: 0; left: 0; width: 100%; background: var(--bg-base); border-top: 1px solid var(--border-main); margin: 0; padding: 10px 0; justify-content: space-around; z-index: 1000; flex-direction: row; gap: 0; padding-bottom: env(safe-area-inset-bottom, 10px); }
|
||||
.nav-tabs { position: fixed; bottom: 0; left: 0; width: 100%; background: var(--bg-base); border-top: 1px solid var(--border-main); margin: 0; padding: 10px 0; justify-content: space-around; z-index: 1000; flex-direction: row; gap: 0; padding-bottom: env(safe-area-bottom, 10px); }
|
||||
.nav-tab { font-size: 0.85rem; padding: 10px; flex: 1; text-align: center; }
|
||||
body { padding-bottom: 70px; }
|
||||
.filter-bar { flex-direction: column; clip-path: none; border: 1px solid var(--border-light); margin-bottom: 10px;}
|
||||
|
||||
+386
-46
@@ -1,5 +1,4 @@
|
||||
// --- VARIABILI GLOBALI E UI VIEW ---
|
||||
const HANG_TIME_MS = 3000;
|
||||
let clients = [];
|
||||
let me = { logged_in: false, user: '', role: '', allowed_nodes: '' };
|
||||
let isAuthenticated = false;
|
||||
@@ -17,6 +16,18 @@ let fleetMap = null;
|
||||
let mapMarkers = {};
|
||||
|
||||
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) {
|
||||
currentFocusedNode = null;
|
||||
@@ -58,6 +69,20 @@ function openNodeFocus(clientId) {
|
||||
document.getElementById('view-focus').style.display = 'block';
|
||||
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();
|
||||
refreshLogs();
|
||||
}
|
||||
@@ -65,6 +90,8 @@ function openNodeFocus(clientId) {
|
||||
function closeNodeFocus() {
|
||||
currentFocusedNode = null;
|
||||
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');
|
||||
}
|
||||
|
||||
@@ -77,7 +104,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
setInterval(() => { refreshLogs(); refreshStats(); }, 60000);
|
||||
checkServerUpdate();
|
||||
setInterval(checkServerUpdate, 3600000);
|
||||
refreshAprs(); // Fetch iniziale APRS
|
||||
refreshAprs();
|
||||
});
|
||||
|
||||
// --- FUNZIONI FILTRO E LAYOUT ---
|
||||
@@ -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() {
|
||||
applyTranslations();
|
||||
try {
|
||||
@@ -468,27 +704,34 @@ async function refreshStates() {
|
||||
let canControl = isAuthenticated && (role === 'admin' || allowedList.includes('all') || allowedList.includes(c.id.toLowerCase()));
|
||||
let showReboot = (role === 'admin');
|
||||
|
||||
let isTx = false; let activeModeColor = "var(--primary)"; let isIdle = telemetryObj.idle === true;
|
||||
let isTx = false;
|
||||
let activeModeColor = "var(--primary)";
|
||||
let txModeStr = "TX";
|
||||
let isIdle = telemetryObj.idle === true;
|
||||
|
||||
if (telemetryObj.alt && telemetryObj.alt !== "") {
|
||||
let altText = telemetryObj.alt.toUpperCase();
|
||||
if (altText.includes("NXDN")) activeModeColor = "var(--success)"; else if (altText.includes("YSF")) activeModeColor = "var(--primary)"; else if (altText.includes("D-STAR")) activeModeColor = "var(--primary)"; else if (altText.includes("P25")) activeModeColor = "var(--accent)";
|
||||
isTx = altText.includes("🟢") || altText.includes("🟣") || altText.includes("🔵") || altText.includes("🟠");
|
||||
if (altText.includes("NXDN")) { activeModeColor = "var(--success)"; txModeStr = "TX NXDN"; }
|
||||
else if (altText.includes("YSF")) { activeModeColor = "#8b5cf6"; txModeStr = "TX YSF"; }
|
||||
else if (altText.includes("D-STAR")) { activeModeColor = "#f97316"; txModeStr = "TX D-STAR"; }
|
||||
else if (altText.includes("P25")) { activeModeColor = "var(--accent)"; txModeStr = "TX P25"; }
|
||||
|
||||
isTx = (altText.includes("🟢") || altText.includes("🟣") || altText.includes("🔵") || altText.includes("🟠"));
|
||||
} else {
|
||||
let v1 = String(telemetryObj.ts1 ?? '');
|
||||
let v2 = String(telemetryObj.ts2 ?? '');
|
||||
if (v1.includes("🎙️") || v1.includes("TX") || v2.includes("🎙️") || v2.includes("TX")) {
|
||||
isTx = true;
|
||||
activeModeColor = "var(--primary)";
|
||||
txModeStr = "TX DMR";
|
||||
}
|
||||
}
|
||||
|
||||
// Aggiorna logic card nel grid normale
|
||||
const statusDiv = document.getElementById(`status-${c.id}`);
|
||||
const cardDiv = document.getElementById(`card-${c.id}`);
|
||||
|
||||
if (cardDiv) {
|
||||
cardDiv.dataset.status = isOnline ? 'online' : 'offline';
|
||||
if (statusDiv) statusDiv.innerText = stateValue;
|
||||
renderSeen(c, data, isOnline);
|
||||
|
||||
const warns = (data.warnings && data.warnings[c.id.toLowerCase()]) || [];
|
||||
@@ -572,7 +815,7 @@ async function refreshStates() {
|
||||
let gwHtml = "";
|
||||
if (gwBar && healthObj) {
|
||||
let gwData = data.gateway_states && data.gateway_states[c.id.toLowerCase()] ? data.gateway_states[c.id.toLowerCase()] : {}; let processes = healthObj.processes || {}; let activeGatewaysStr = "";
|
||||
const gwMap = [{ id: 'dmrgateway', label: 'DMR', color: 'var(--primary)', proto: 'DMR' }, { id: 'ysfgateway', label: 'YSF', color: '#8b5cf6', proto: 'YSF' }, { id: 'dstargateway', label: 'D-STAR', color: 'var(--primary)', proto: 'D-STAR' }, { id: 'nxdngateway', label: 'NXDN', color: 'var(--success)', proto: 'NXDN' }, { id: 'p25gateway', label: 'P25', color: 'var(--accent)', proto: 'P25' }];
|
||||
const gwMap = [{ id: 'dmrgateway', label: 'DMR', color: 'var(--primary)', proto: 'DMR' }, { id: 'ysfgateway', label: 'YSF', color: '#8b5cf6', proto: 'YSF' }, { id: 'dstargateway', label: 'D-STAR', color: '#f97316', proto: 'D-STAR' }, { id: 'nxdngateway', label: 'NXDN', color: 'var(--success)', proto: 'NXDN' }, { id: 'p25gateway', label: 'P25', color: 'var(--accent)', proto: 'P25' }];
|
||||
|
||||
if (isOnline) {
|
||||
gwMap.forEach(gw => {
|
||||
@@ -621,8 +864,16 @@ async function refreshStates() {
|
||||
if (healthContainer) healthContainer.style.display = 'none';
|
||||
}
|
||||
|
||||
// Logica tollerante per i Gateway in standby (spenti dalla UI)
|
||||
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}`);
|
||||
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)'; } }
|
||||
@@ -640,60 +891,148 @@ async function refreshStates() {
|
||||
}
|
||||
}
|
||||
|
||||
// --- NESSUN TIMER LOCALE: COMANDA MQTT ---
|
||||
// Memorizza l'ultimo modo in trasmissione per usarlo durante l'Hangtime
|
||||
if (isTx && isOnline) {
|
||||
cardDiv.dataset.lastMode = txModeStr.replace("TX ", "").trim();
|
||||
cardDiv.dataset.lastColor = activeModeColor;
|
||||
}
|
||||
|
||||
// Se non è in TX e MMDVM NON ha ancora dichiarato 'idle' -> siamo in Hold
|
||||
let isHold = (!isTx && !isIdle && isOnline);
|
||||
|
||||
let holdMode = cardDiv.dataset.lastMode || "DMR";
|
||||
let holdColor = cardDiv.dataset.lastColor || "var(--primary)";
|
||||
|
||||
let displayState = stateValue;
|
||||
let statusColor = "";
|
||||
let statusBorder = "";
|
||||
let cBorder = "var(--border-main)";
|
||||
|
||||
if (!isOnline) {
|
||||
displayState = stateValue;
|
||||
cBorder = "var(--border-light)";
|
||||
} else if (isTx) {
|
||||
displayState = `( ${txModeStr} )`;
|
||||
statusColor = activeModeColor;
|
||||
statusBorder = activeModeColor;
|
||||
cBorder = activeModeColor;
|
||||
} else if (isHold) {
|
||||
displayState = `[ ${holdMode} ]`;
|
||||
statusColor = holdColor;
|
||||
statusBorder = holdColor;
|
||||
cBorder = holdColor;
|
||||
}
|
||||
|
||||
if (isOnline) {
|
||||
cardDiv.classList.add('online'); statusDiv.classList.remove('status-offline');
|
||||
if (isTx) cardDiv.dataset.lastTx = Date.now();
|
||||
let timeSinceTx = Date.now() - (parseInt(cardDiv.dataset.lastTx) || 0);
|
||||
let showActiveColor = isTx || (!isIdle && timeSinceTx < HANG_TIME_MS);
|
||||
cardDiv.style.opacity = "1"; cardDiv.style.filter = "none";
|
||||
|
||||
if (showActiveColor) { cardDiv.style.borderColor = activeModeColor; }
|
||||
else { cardDiv.style.borderColor = "var(--border-main)"; }
|
||||
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 {
|
||||
cardDiv.classList.remove('online'); statusDiv.classList.add('status-offline');
|
||||
cardDiv.style.borderColor = "var(--border-light)";
|
||||
}
|
||||
cardDiv.style.opacity = "0.7"; cardDiv.style.filter = "grayscale(80%)";
|
||||
cardDiv.style.setProperty('border-top-color', '#64748b', 'important');
|
||||
cardDiv.style.boxShadow = 'none !important';
|
||||
}
|
||||
|
||||
// Aggiornamento Mini-Cards
|
||||
const miniCard = document.getElementById(`mini-card-${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}`);
|
||||
cardDiv.style.borderColor = cBorder;
|
||||
if (statusDiv) {
|
||||
statusDiv.innerText = displayState;
|
||||
statusDiv.style.color = statusColor;
|
||||
statusDiv.style.borderColor = statusBorder;
|
||||
}
|
||||
|
||||
const miniCard = document.getElementById(`mini-card-${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 (genObj && isOnline) { if (miniName) miniName.innerText = genObj.callsign; if (miniId) miniId.innerText = `ID:${genObj.radio_id}`; }
|
||||
else { if (miniName) miniName.innerText = c.name; if (miniId) miniId.innerText = `ID:${c.id.toUpperCase()}`; }
|
||||
if (genObj && isOnline) {
|
||||
if(miniName) miniName.innerText = genObj.callsign;
|
||||
if(miniId) miniId.innerText = `ID:${genObj.radio_id}`;
|
||||
}
|
||||
|
||||
if (isOnline) {
|
||||
let timeSinceTx = (cardDiv && cardDiv.dataset.lastTx) ? Date.now() - parseInt(cardDiv.dataset.lastTx) : 0;
|
||||
let showActiveColor = isTx || (!isIdle && timeSinceTx < HANG_TIME_MS);
|
||||
if (showActiveColor) {
|
||||
miniCard.style.borderColor = activeModeColor;
|
||||
miniStatus.innerText = "( TX )"; miniStatus.title = "Transmitting..."; miniStatus.style.color = activeModeColor; miniStatus.style.borderColor = activeModeColor;
|
||||
} else {
|
||||
const warns = (data.warnings && data.warnings[c.id.toLowerCase()]) || [];
|
||||
if (warns.length > 0) {
|
||||
miniCard.style.opacity = "1";
|
||||
miniCard.style.filter = "none";
|
||||
|
||||
if (warns.length > 0 && !isTx && !isHold) {
|
||||
miniCard.style.borderColor = "var(--accent)";
|
||||
miniStatus.innerText = "(!) ALERT"; miniStatus.title = warns.join(" | "); miniStatus.style.color = "var(--accent)"; miniStatus.style.borderColor = "var(--accent)";
|
||||
miniStatus.innerText = "(!) ALERT";
|
||||
miniStatus.title = warns.join(" | ");
|
||||
miniStatus.style.color = "var(--accent)";
|
||||
miniStatus.style.borderColor = "var(--accent)";
|
||||
} else {
|
||||
miniCard.style.borderColor = "var(--border-main)";
|
||||
miniStatus.innerText = stateValue; miniStatus.title = stateValue; miniStatus.style.color = "var(--success)"; miniStatus.style.borderColor = "var(--border-light)";
|
||||
let mcBorder = "var(--border-main)";
|
||||
let mStatus = stateValue;
|
||||
let mColor = "var(--success)";
|
||||
let mBorderColor = "var(--border-light)";
|
||||
|
||||
if (isTx) {
|
||||
mcBorder = activeModeColor;
|
||||
mStatus = `( ${txModeStr} )`;
|
||||
mColor = activeModeColor;
|
||||
mBorderColor = activeModeColor;
|
||||
} else if (isHold) {
|
||||
mcBorder = holdColor;
|
||||
mStatus = `[ ${holdMode} ]`;
|
||||
mColor = holdColor;
|
||||
mBorderColor = holdColor;
|
||||
}
|
||||
|
||||
miniCard.style.borderColor = mcBorder;
|
||||
miniStatus.innerText = mStatus;
|
||||
miniStatus.title = mStatus;
|
||||
miniStatus.style.color = mColor;
|
||||
miniStatus.style.borderColor = mBorderColor;
|
||||
}
|
||||
} else {
|
||||
miniCard.style.opacity = "0.7";
|
||||
miniCard.style.filter = "grayscale(80%)";
|
||||
miniCard.style.borderColor = "var(--border-light)";
|
||||
miniStatus.innerText = "OFFLINE"; miniStatus.title = "OFFLINE"; miniStatus.style.color = "var(--danger)"; miniStatus.style.borderColor = "var(--border-light)";
|
||||
miniStatus.innerText = "OFFLINE";
|
||||
miniStatus.title = "OFFLINE";
|
||||
miniStatus.style.color = "var(--danger)";
|
||||
miniStatus.style.borderColor = "var(--border-light)";
|
||||
}
|
||||
}
|
||||
|
||||
// Aggiornamento Focus View (se il nodo corrente è in focus)
|
||||
if (currentFocusedNode === c.id) {
|
||||
let timeSinceTx = (cardDiv && cardDiv.dataset.lastTx) ? Date.now() - parseInt(cardDiv.dataset.lastTx) : 0;
|
||||
let showActiveColor = isTx || (!isIdle && timeSinceTx < HANG_TIME_MS);
|
||||
|
||||
document.getElementById('focus-name').innerHTML = `<span style="display:inline-block; border-radius:50%; width:20px; height:20px; border:2px solid ${isOnline ? (showActiveColor ? activeModeColor : 'var(--success)') : 'var(--border-light)'}; background:${isOnline && showActiveColor ? activeModeColor : 'transparent'}"></span> ${esc(genObj ? genObj.callsign : c.name)}`;
|
||||
document.getElementById('focus-id').innerText = `NET-ID: ${genObj ? genObj.radio_id : c.id.toUpperCase()}`;
|
||||
|
||||
let focusStatus = document.getElementById('focus-status');
|
||||
focusStatus.innerText = stateValue;
|
||||
focusStatus.style.color = isOnline ? (showActiveColor ? activeModeColor : 'var(--success)') : 'var(--danger)';
|
||||
|
||||
let fsState = stateValue;
|
||||
let fsColor = isOnline ? 'var(--success)' : 'var(--danger)';
|
||||
|
||||
if (isOnline) {
|
||||
if (isTx) {
|
||||
fsState = `( ${txModeStr} )`;
|
||||
fsColor = activeModeColor;
|
||||
} else if (isHold) {
|
||||
fsState = `[ ${holdMode} ]`;
|
||||
fsColor = holdColor;
|
||||
}
|
||||
}
|
||||
|
||||
focusStatus.innerText = fsState;
|
||||
focusStatus.style.color = fsColor;
|
||||
|
||||
let focusLedColor = isOnline ? (isTx ? activeModeColor : (isHold ? holdColor : 'var(--success)')) : 'var(--border-light)';
|
||||
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-id').innerText = `NET-ID: ${genObj ? genObj.radio_id : c.id.toUpperCase()}`;
|
||||
document.getElementById('focus-cpu').innerText = healthObj && isOnline ? healthObj.cpu + "%" : "--";
|
||||
document.getElementById('focus-temp').innerText = healthObj && isOnline ? healthObj.temp + "°C" : "--";
|
||||
document.getElementById('focus-ram').innerText = healthObj && isOnline ? healthObj.ram + "%" : "--";
|
||||
@@ -704,11 +1043,9 @@ async function refreshStates() {
|
||||
document.getElementById('focus-rx').innerText = infoObj && isOnline ? infoObj.rx : "--";
|
||||
document.getElementById('focus-loc').innerText = infoObj && isOnline ? infoObj.loc : "--";
|
||||
|
||||
// Gateway riciclati dal loop
|
||||
let gwBar = document.getElementById(`gw-bar-${c.id}`);
|
||||
document.getElementById('focus-gw').innerHTML = (gwBar && gwBar.innerHTML) ? gwBar.innerHTML : '<span style="color:var(--border-main); font-family:JetBrains Mono;">NO_ACTIVE_GATEWAYS</span>';
|
||||
|
||||
// TS
|
||||
let focusTsHtml = "";
|
||||
if (telemetryObj.alt && telemetryObj.alt !== "") {
|
||||
focusTsHtml = `<div style="padding: 10px; border: 1px dashed var(--border-light); color: ${activeModeColor}">${esc(telemetryObj.alt)}</div>`;
|
||||
@@ -723,12 +1060,15 @@ async function refreshStates() {
|
||||
}
|
||||
document.getElementById('focus-ts').innerHTML = focusTsHtml || "--";
|
||||
|
||||
// Controlli Admin
|
||||
const modesCard = document.getElementById('focus-modes-card');
|
||||
if (modesCard) {
|
||||
modesCard.style.display = canControl ? 'block' : 'none';
|
||||
}
|
||||
|
||||
const focusControls = document.getElementById('focus-controls');
|
||||
if (canControl || showReboot) {
|
||||
focusControls.style.display = 'block';
|
||||
let btnHtml = '';
|
||||
|
||||
if (canControl) {
|
||||
btnHtml += `<button class="btn-cmd" style="padding: 12px 25px; font-size: 1.1rem; flex: none; width: auto;" onclick="sendTgCommand('${c.id}', 'TG:ON')">[ TG_ON ]</button>`;
|
||||
btnHtml += `<button class="btn-cmd" style="padding: 12px 25px; font-size: 1.1rem; flex: none; width: auto;" onclick="sendTgCommand('${c.id}', 'TG:OFF')">[ TG_OFF ]</button>`;
|
||||
@@ -747,7 +1087,6 @@ async function refreshStates() {
|
||||
btnHtml += `<button class="btn-cmd" style="padding: 12px 25px; font-size: 1.1rem; flex: none; width: auto; border-color: var(--accent); color: var(--accent) !important;" onclick="openConfigsModal('${c.id}')">[ CFG ]</button>`;
|
||||
btnHtml += `<button class="btn-cmd" style="padding: 12px 25px; font-size: 1.1rem; flex: none; width: auto; border-color: var(--danger); color: var(--danger) !important;" onclick="confirmHatReset('${c.id}')">[ HAT ]</button>`;
|
||||
btnHtml += `<button class="btn-cmd" style="padding: 12px 25px; font-size: 1.1rem; flex: none; width: auto; border-color: var(--danger); color: var(--danger) !important;" onclick="confirmReboot('${c.id}')">[ RBT ]</button>`;
|
||||
|
||||
let otaColor = (healthObj && healthObj.agent_update_available) ? 'var(--danger)' : 'var(--primary)';
|
||||
btnHtml += `<button class="btn-cmd" style="padding: 12px 25px; font-size: 1.1rem; flex: none; width: auto; border-color: ${otaColor}; color: ${otaColor} !important;" onclick="confirmUpdateAgent('${c.id}')">[ OTA ]</button>`;
|
||||
}
|
||||
@@ -756,6 +1095,7 @@ async function refreshStates() {
|
||||
focusControls.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
globalHealthData[c.id.toLowerCase()] = healthObj;
|
||||
} catch(err) { console.error("Error updating state for node", c.id, err); }
|
||||
|
||||
+10
-3
@@ -19,7 +19,7 @@
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
||||
|
||||
<!-- Foglio di Stile Esterno Modularizzato (Cache Buster) -->
|
||||
<link rel="stylesheet" href="/static/css/style.css?v=blueprint-aprs">
|
||||
<link rel="stylesheet" href="/static/css/style.css?v=blueprint-header-fix">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<span id="mqtt-badge" class="mqtt-badge mqtt-offline">MQTT: CHK</span>
|
||||
<button class="theme-switch" id="lang-btn" onclick="toggleLang()" data-i18n-title="ttLang">ITA</button>
|
||||
<button class="theme-switch" id="push-btn" onclick="subscribeToPush()">PUSH</button>
|
||||
<div id="auth-container" style="display:flex; align-items:center; gap:8px;"></div>
|
||||
<div id="auth-container" style="display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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>
|
||||
</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>
|
||||
|
||||
<!-- COLONNA DX: SOFTWARE E LOG -->
|
||||
@@ -433,7 +440,7 @@
|
||||
|
||||
<!-- MOTORE MODULARIZZATO JS (Cache Buster aggiunto per forzare il refresh) -->
|
||||
<script src="/static/js/modals.js?v=blueprint4"></script>
|
||||
<script src="/static/js/app.js?v=blueprint-aprs-final"></script>
|
||||
<script src="/static/js/app.js?v=blueprint-modes-admin-only-final"></script>
|
||||
|
||||
<!-- SERVICE WORKER -->
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user