fix secure mode change

This commit is contained in:
2026-10-31 20:49:05 +01:00
parent 34180df506
commit 2f97464c6e
2 changed files with 37 additions and 4 deletions
+34 -1
View File
@@ -70,16 +70,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 +246,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 +309,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;
@@ -1005,6 +1033,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';
+2 -2
View File
@@ -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>