Update index.html
This commit is contained in:
+52
-1
@@ -238,6 +238,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="override-modal" class="modal-overlay" style="z-index: 3000;">
|
||||||
|
<div class="modal-content" style="width:90%; max-width:400px; text-align:center;">
|
||||||
|
<h2 style="margin-top:0; color:var(--danger);">🚨 <span data-i18n="btnGlobal">OVERRIDE GLOBALE</span> 🚨</h2>
|
||||||
|
<p style="margin-bottom:25px; color:var(--text-muted); font-weight: 600;" id="override-desc">Seleziona il profilo da inviare a TUTTA la rete:</p>
|
||||||
|
<div style="display:flex; flex-direction:column; gap:15px;">
|
||||||
|
<button id="btn-global-A" onclick="sendGlobalAction('A')" class="btn-cmd" style="background:var(--accent); padding:15px; font-size:1.1rem;">PROFILO A</button>
|
||||||
|
<button id="btn-global-B" onclick="sendGlobalAction('B')" class="btn-cmd" style="background:#eab308; padding:15px; font-size:1.1rem;">PROFILO B</button>
|
||||||
|
<button onclick="document.getElementById('override-modal').style.display='none'" class="btn-cmd" style="background:var(--text-muted); padding:12px; margin-top:10px;">ANNULLA</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// --- 1. TRANSLATION SYSTEM (i18n) ---
|
// --- 1. TRANSLATION SYSTEM (i18n) ---
|
||||||
const i18n = {
|
const i18n = {
|
||||||
@@ -641,7 +653,46 @@
|
|||||||
async function deleteUser(id) { if (confirm("Delete user?")) { await fetch(`/api/users/${id}`, {method: 'DELETE'}); loadUsers(); cancelEdit(); } }
|
async function deleteUser(id) { if (confirm("Delete user?")) { await fetch(`/api/users/${id}`, {method: 'DELETE'}); loadUsers(); cancelEdit(); } }
|
||||||
|
|
||||||
// --- EMERGENCY & SETTINGS ---
|
// --- EMERGENCY & SETTINGS ---
|
||||||
async function triggerGlobalEmergency() { let action = prompt(`${t('promptOvr')}`); if (action && confirm(t('promptOvrConfirm'))) { const res = await fetch('/api/global_command', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({type: action.toUpperCase()}) }); const d = await res.json(); if(d.success) alert("Command sent!"); else alert(d.error); } }
|
function triggerGlobalEmergency() {
|
||||||
|
// Recupera i nomi dinamici dei profili dal primo nodo disponibile online
|
||||||
|
let nameA = "PROFILO A";
|
||||||
|
let nameB = "PROFILO B";
|
||||||
|
for (const id in globalHealthData) {
|
||||||
|
if (globalHealthData[id] && globalHealthData[id].profiles) {
|
||||||
|
nameA = globalHealthData[id].profiles.A || nameA;
|
||||||
|
nameB = globalHealthData[id].profiles.B || nameB;
|
||||||
|
break; // Ne basta uno, la rete condivide i nomi dei profili
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiorna dinamicamente i testi dei pulsanti del popup
|
||||||
|
document.getElementById('btn-global-A').innerText = nameA;
|
||||||
|
document.getElementById('btn-global-B').innerText = nameB;
|
||||||
|
document.getElementById('override-desc').innerText = currentLang === 'it'
|
||||||
|
? "Seleziona il profilo da inviare a TUTTA la rete:"
|
||||||
|
: "Select the profile to send to the ENTIRE network:";
|
||||||
|
|
||||||
|
// Mostra il popup
|
||||||
|
document.getElementById('override-modal').style.display = 'flex';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendGlobalAction(action) {
|
||||||
|
document.getElementById('override-modal').style.display = 'none'; // Chiudi il modal
|
||||||
|
|
||||||
|
// Chiede l'ultima conferma di sicurezza prima di sparare il comando a tutti
|
||||||
|
if (confirm(t('promptOvrConfirm'))) {
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/global_command', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({type: action}) });
|
||||||
|
const d = await res.json();
|
||||||
|
if(d.success) {
|
||||||
|
alert(currentLang === 'it' ? "Comando inviato con successo a tutta la rete!" : "Command successfully sent to the network!");
|
||||||
|
} else {
|
||||||
|
alert(d.error);
|
||||||
|
}
|
||||||
|
refreshStates();
|
||||||
|
} catch(e) { console.error(e); }
|
||||||
|
}
|
||||||
|
}
|
||||||
async function changeMyPassword() { const p = prompt("New password:"); if (p) { const res = await fetch('/api/change_password', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({username: sessionStorage.getItem('user_name'), new_password: p}) }); if ((await res.json()).success) { alert("Password updated!"); logout(); } } }
|
async function changeMyPassword() { const p = prompt("New password:"); if (p) { const res = await fetch('/api/change_password', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({username: sessionStorage.getItem('user_name'), new_password: p}) }); if ((await res.json()).success) { alert("Password updated!"); logout(); } } }
|
||||||
async function loadSettings() { try { const res = await fetch('/api/config'); const data = await res.json(); document.getElementById('update-time-input').value = data.update_schedule; document.getElementById('url-dmr-input').value = data.url_dmr; document.getElementById('url-nxdn-input').value = data.url_nxdn; } catch (e) { console.error(e); } }
|
async function loadSettings() { try { const res = await fetch('/api/config'); const data = await res.json(); document.getElementById('update-time-input').value = data.update_schedule; document.getElementById('url-dmr-input').value = data.url_dmr; document.getElementById('url-nxdn-input').value = data.url_nxdn; } catch (e) { console.error(e); } }
|
||||||
async function saveSettings() { const payload = { update_schedule: document.getElementById('update-time-input').value, url_dmr: document.getElementById('url-dmr-input').value, url_nxdn: document.getElementById('url-nxdn-input').value }; try { const res = await fetch('/api/config', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(payload) }); const data = await res.json(); if (data.success) alert("Configuration saved!"); else alert("Error saving"); } catch (e) { console.error(e); } }
|
async function saveSettings() { const payload = { update_schedule: document.getElementById('update-time-input').value, url_dmr: document.getElementById('url-dmr-input').value, url_nxdn: document.getElementById('url-nxdn-input').value }; try { const res = await fetch('/api/config', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(payload) }); const data = await res.json(); if (data.success) alert("Configuration saved!"); else alert("Error saving"); } catch (e) { console.error(e); } }
|
||||||
|
|||||||
Reference in New Issue
Block a user