Compare commits
2
Commits
34180df506
..
v5.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e92a37f02a | ||
|
|
2456f462fe |
+83
-23
@@ -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;
|
||||
@@ -70,16 +69,29 @@ 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();
|
||||
fetchNodeConfigForModes(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');
|
||||
}
|
||||
|
||||
@@ -233,6 +245,16 @@ 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) {
|
||||
@@ -286,6 +308,11 @@ function renderModeToggles(clientId, statusMsg = "") {
|
||||
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;
|
||||
|
||||
@@ -864,14 +891,18 @@ async function refreshStates() {
|
||||
}
|
||||
}
|
||||
|
||||
let timeSinceTx = 0;
|
||||
if (isTx && isOnline && !isIdle) {
|
||||
cardDiv.dataset.lastTx = Date.now();
|
||||
} else {
|
||||
timeSinceTx = Date.now() - (parseInt(cardDiv.dataset.lastTx) || 0);
|
||||
// --- 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;
|
||||
}
|
||||
|
||||
let isHold = (!isTx && !isIdle && timeSinceTx < 6000);
|
||||
// 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 = "";
|
||||
@@ -881,21 +912,38 @@ async function refreshStates() {
|
||||
if (!isOnline) {
|
||||
displayState = stateValue;
|
||||
cBorder = "var(--border-light)";
|
||||
} else if (isTx && !isIdle) {
|
||||
} else if (isTx) {
|
||||
displayState = `( ${txModeStr} )`;
|
||||
statusColor = activeModeColor;
|
||||
statusBorder = activeModeColor;
|
||||
cBorder = activeModeColor;
|
||||
} else if (isHold) {
|
||||
displayState = `[ ${txModeStr.replace("TX ", "")} ]`;
|
||||
statusColor = activeModeColor;
|
||||
statusBorder = activeModeColor;
|
||||
displayState = `[ ${holdMode} ]`;
|
||||
statusColor = holdColor;
|
||||
statusBorder = holdColor;
|
||||
cBorder = holdColor;
|
||||
}
|
||||
|
||||
if (isOnline) {
|
||||
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 {
|
||||
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;
|
||||
@@ -907,15 +955,19 @@ async function refreshStates() {
|
||||
|
||||
const miniCard = document.getElementById(`mini-card-${c.id}`);
|
||||
const miniStatus = document.getElementById(`mini-status-${c.id}`);
|
||||
if (miniCard && miniStatus) {
|
||||
if (genObj && isOnline) {
|
||||
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}`;
|
||||
}
|
||||
|
||||
if (isOnline) {
|
||||
miniCard.style.opacity = "1";
|
||||
miniCard.style.filter = "none";
|
||||
|
||||
if (warns.length > 0 && !isTx && !isHold) {
|
||||
miniCard.style.borderColor = "var(--accent)";
|
||||
miniStatus.innerText = "(!) ALERT";
|
||||
@@ -928,15 +980,16 @@ async function refreshStates() {
|
||||
let mColor = "var(--success)";
|
||||
let mBorderColor = "var(--border-light)";
|
||||
|
||||
if (isTx && !isIdle) {
|
||||
if (isTx) {
|
||||
mcBorder = activeModeColor;
|
||||
mStatus = `( ${txModeStr} )`;
|
||||
mColor = activeModeColor;
|
||||
mBorderColor = activeModeColor;
|
||||
} else if (isHold) {
|
||||
mStatus = `[ ${txModeStr.replace("TX ", "")} ]`;
|
||||
mColor = activeModeColor;
|
||||
mBorderColor = activeModeColor;
|
||||
mcBorder = holdColor;
|
||||
mStatus = `[ ${holdMode} ]`;
|
||||
mColor = holdColor;
|
||||
mBorderColor = holdColor;
|
||||
}
|
||||
|
||||
miniCard.style.borderColor = mcBorder;
|
||||
@@ -946,6 +999,8 @@ async function refreshStates() {
|
||||
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";
|
||||
@@ -961,20 +1016,20 @@ async function refreshStates() {
|
||||
let fsColor = isOnline ? 'var(--success)' : 'var(--danger)';
|
||||
|
||||
if (isOnline) {
|
||||
if (isTx && !isIdle) {
|
||||
if (isTx) {
|
||||
fsState = `( ${txModeStr} )`;
|
||||
fsColor = activeModeColor;
|
||||
} else if (isHold) {
|
||||
fsState = `[ ${txModeStr.replace("TX ", "")} ]`;
|
||||
fsColor = activeModeColor;
|
||||
fsState = `[ ${holdMode} ]`;
|
||||
fsColor = holdColor;
|
||||
}
|
||||
}
|
||||
|
||||
focusStatus.innerText = fsState;
|
||||
focusStatus.style.color = fsColor;
|
||||
|
||||
let focusLedColor = isOnline ? (isTx && !isIdle ? activeModeColor : 'var(--success)') : 'var(--border-light)';
|
||||
let focusLedBg = (isOnline && isTx && !isIdle) ? activeModeColor : 'transparent';
|
||||
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()}`;
|
||||
@@ -1005,6 +1060,11 @@ async function refreshStates() {
|
||||
}
|
||||
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');
|
||||
if (canControl || showReboot) {
|
||||
focusControls.style.display = 'block';
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" style="border-width: 1px !important;">
|
||||
<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>
|
||||
@@ -440,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-mode-toggles-2"></script>
|
||||
<script src="/static/js/app.js?v=blueprint-modes-admin-only-final"></script>
|
||||
|
||||
<!-- SERVICE WORKER -->
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user