diff --git a/app.py b/app.py index 6ab5bbf..dc5d207 100644 --- a/app.py +++ b/app.py @@ -1,3 +1,6 @@ +import gevent.monkey +gevent.monkey.patch_all() + from flask import Flask, render_template, request, session, jsonify, send_from_directory from paho.mqtt import client as mqtt_client from werkzeug.security import generate_password_hash, check_password_hash diff --git a/sw.js b/sw.js index 59e93d1..dc539ac 100644 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = 'fleet-c2-v3'; // incrementare a ogni modifica degli asset precaricati +const CACHE_NAME = 'fleet-c2-v5'; const PRECACHE_URLS = [ '/', '/manifest.json', @@ -6,8 +6,6 @@ const PRECACHE_URLS = [ ]; // --- 1. INSTALL: precache "best effort" ------------------------------------- -// Se un file manca (es. icona non ancora caricata) l'installazione NON fallisce: -// un SW che non si installa significa niente notifiche push. self.addEventListener('install', event => { event.waitUntil( caches.open(CACHE_NAME) @@ -26,8 +24,6 @@ self.addEventListener('activate', event => { }); // --- 3. FETCH: network-first, cache come ripiego offline --------------------- -// Gestiamo solo le GET della nostra origine. API e WebSocket (socket.io) passano -// sempre direttamente dalla rete: i dati della flotta non vanno mai serviti "vecchi". self.addEventListener('fetch', event => { const req = event.request; if (req.method !== 'GET') return; @@ -80,8 +76,6 @@ self.addEventListener('push', event => { icon: '/icon-512.png', badge: '/icon-512.png', vibrate: [200, 100, 200], - // Stesso tag = la nuova notifica dello stesso nodo sostituisce la precedente - // (invece di accumulare 10 notifiche) e rifΓ vibrare/suonare. tag: data.tag || 'fleet-alert', renotify: true, data: { @@ -100,8 +94,6 @@ self.addEventListener('push', event => { }); // --- 5. CLICK SULLA NOTIFICA ------------------------------------------------- -// Click sul corpo O su "Apri Dashboard": porta in primo piano la finestra giΓ aperta, -// altrimenti ne apre una nuova. "Chiudi" chiude soltanto. self.addEventListener('notificationclick', event => { event.notification.close(); if (event.action === 'close') return; diff --git a/templates/index.html b/templates/index.html index 55e73ed..fbe4973 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,154 +13,170 @@ @@ -170,7 +186,6 @@
No profiles configured on the network.
`; - } - - container.innerHTML = html; - document.getElementById('override-desc').innerText = t('msgOvrSel'); - document.getElementById('override-modal').style.display = 'flex'; + if (Object.keys(uniqueProfiles).length === 0) { html = `No profiles configured on the network.
`; } + container.innerHTML = html; document.getElementById('override-desc').innerText = t('msgOvrSel'); document.getElementById('override-modal').style.display = 'flex'; } function sendGlobalAction(action) { @@ -1256,20 +1222,15 @@ } catch (e) { console.error(e); } } - // --- SERVICES & CONFIGS --- function fileLabel(stem, names) { - const key = String(stem).toLowerCase(); - const full = (names || []).find(n => String(n).replace(/\.[^.]*$/, '').toLowerCase() === key); - if (full) { - const m = String(full).match(/^(.*?)(\.[^.]*)?$/); - return String(m[1]).toUpperCase() + (m[2] || ''); - } + const key = String(stem).toLowerCase(); const full = (names || []).find(n => String(n).replace(/\.[^.]*$/, '').toLowerCase() === key); + if (full) { const m = String(full).match(/^(.*?)(\.[^.]*)?$/); return String(m[1]).toUpperCase() + (m[2] || ''); } return String(stem).toUpperCase() + '.ini'; } function openConfigsModal(clientId) { const data = globalHealthData[clientId.toLowerCase()]; const listDiv = document.getElementById('configs-list'); let listaFile = data ? (data.config_files || data.files || []) : []; const fileNames = (data && data.file_names) || []; if (listaFile.length === 0) listDiv.innerHTML = `${t('waitData')}