fix secure mode change
This commit is contained in:
+35
-2
@@ -70,16 +70,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 +246,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 +309,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;
|
||||||
|
|
||||||
@@ -1005,6 +1033,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