Compare commits
2
Commits
34180df506
...
v5.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e92a37f02a | ||
|
|
2456f462fe |
+88
-28
@@ -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;
|
||||||
@@ -70,16 +69,29 @@ 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' });
|
||||||
|
|
||||||
document.getElementById('focus-modes-toggles').innerHTML = '<span style="color:var(--text-muted); font-size: 0.9rem;" class="blink">FETCHING CONFIG...</span>';
|
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();
|
||||||
fetchNodeConfigForModes(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');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +245,16 @@ function sendTgCommand(clientId, comando) {
|
|||||||
|
|
||||||
// --- LOGICA MODI OPERATIVI E GATEWAYS ---
|
// --- LOGICA MODI OPERATIVI E GATEWAYS ---
|
||||||
async function fetchNodeConfigForModes(clientId) {
|
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 {
|
try {
|
||||||
const healthObj = globalHealthData[clientId.toLowerCase()];
|
const healthObj = globalHealthData[clientId.toLowerCase()];
|
||||||
if (!healthObj) {
|
if (!healthObj) {
|
||||||
@@ -286,6 +308,11 @@ function renderModeToggles(clientId, statusMsg = "") {
|
|||||||
const allowedList = String(me.allowed_nodes || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
|
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()));
|
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');
|
let container = document.getElementById('focus-modes-toggles');
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
||||||
@@ -864,14 +891,18 @@ async function refreshStates() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let timeSinceTx = 0;
|
// --- NESSUN TIMER LOCALE: COMANDA MQTT ---
|
||||||
if (isTx && isOnline && !isIdle) {
|
// Memorizza l'ultimo modo in trasmissione per usarlo durante l'Hangtime
|
||||||
cardDiv.dataset.lastTx = Date.now();
|
if (isTx && isOnline) {
|
||||||
} else {
|
cardDiv.dataset.lastMode = txModeStr.replace("TX ", "").trim();
|
||||||
timeSinceTx = Date.now() - (parseInt(cardDiv.dataset.lastTx) || 0);
|
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 displayState = stateValue;
|
||||||
let statusColor = "";
|
let statusColor = "";
|
||||||
@@ -881,21 +912,38 @@ async function refreshStates() {
|
|||||||
if (!isOnline) {
|
if (!isOnline) {
|
||||||
displayState = stateValue;
|
displayState = stateValue;
|
||||||
cBorder = "var(--border-light)";
|
cBorder = "var(--border-light)";
|
||||||
} else if (isTx && !isIdle) {
|
} else if (isTx) {
|
||||||
displayState = `( ${txModeStr} )`;
|
displayState = `( ${txModeStr} )`;
|
||||||
statusColor = activeModeColor;
|
statusColor = activeModeColor;
|
||||||
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;
|
||||||
|
cBorder = holdColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -907,15 +955,19 @@ async function refreshStates() {
|
|||||||
|
|
||||||
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";
|
||||||
@@ -928,15 +980,16 @@ async function refreshStates() {
|
|||||||
let mColor = "var(--success)";
|
let mColor = "var(--success)";
|
||||||
let mBorderColor = "var(--border-light)";
|
let mBorderColor = "var(--border-light)";
|
||||||
|
|
||||||
if (isTx && !isIdle) {
|
if (isTx) {
|
||||||
mcBorder = activeModeColor;
|
mcBorder = activeModeColor;
|
||||||
mStatus = `( ${txModeStr} )`;
|
mStatus = `( ${txModeStr} )`;
|
||||||
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;
|
||||||
@@ -946,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";
|
||||||
@@ -961,20 +1016,20 @@ async function refreshStates() {
|
|||||||
let fsColor = isOnline ? 'var(--success)' : 'var(--danger)';
|
let fsColor = isOnline ? 'var(--success)' : 'var(--danger)';
|
||||||
|
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
if (isTx && !isIdle) {
|
if (isTx) {
|
||||||
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 && !isIdle ? activeModeColor : 'var(--success)') : 'var(--border-light)';
|
let focusLedColor = isOnline ? (isTx ? activeModeColor : (isHold ? holdColor : 'var(--success)')) : 'var(--border-light)';
|
||||||
let focusLedBg = (isOnline && isTx && !isIdle) ? 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)}`;
|
||||||
|
|
||||||
document.getElementById('focus-id').innerText = `NET-ID: ${genObj ? genObj.radio_id : c.id.toUpperCase()}`;
|
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 || "--";
|
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';
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
<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;">
|
<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>
|
<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) -->
|
<!-- 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-mode-toggles-2"></script>
|
<script src="/static/js/app.js?v=blueprint-modes-admin-only-final"></script>
|
||||||
|
|
||||||
<!-- SERVICE WORKER -->
|
<!-- SERVICE WORKER -->
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Reference in New Issue
Block a user