Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fc08f1c23 | ||
|
|
66cd63a181 |
+26
-13
@@ -15,6 +15,10 @@ from services.mqtt_service import mqtt_publish
|
|||||||
from services.push_service import node_allowed
|
from services.push_service import node_allowed
|
||||||
from routes.auth_routes import get_auth, json_body, err
|
from routes.auth_routes import get_auth, json_body, err
|
||||||
|
|
||||||
|
# --- AGGIUNTE PER GITEA BACKGROUND CHECK ---
|
||||||
|
GLOBAL_SERVER_UPDATE_AVAILABLE = False
|
||||||
|
LAST_GITEA_CHECK_TIME = 0
|
||||||
|
|
||||||
api_bp = Blueprint('api', __name__)
|
api_bp = Blueprint('api', __name__)
|
||||||
|
|
||||||
# --- REGEX & COSTANTI COMANDI ---
|
# --- REGEX & COSTANTI COMANDI ---
|
||||||
@@ -128,7 +132,7 @@ def get_stats():
|
|||||||
top_tgs = [{"target": row[0], "count": row[1]} for row in c.fetchall()]
|
top_tgs = [{"target": row[0], "count": row[1]} for row in c.fetchall()]
|
||||||
|
|
||||||
c.execute(f"""SELECT source_id, COUNT(*) as cnt FROM radio_logs
|
c.execute(f"""SELECT source_id, COUNT(*) as cnt FROM radio_logs
|
||||||
WHERE source_id NOT LIKE '🌐%'
|
WHERE source_id NOT LIKE '倹%'
|
||||||
AND timestamp >= date('now', 'localtime') AND timestamp < date('now', 'localtime', '+1 day'){node_filter}
|
AND timestamp >= date('now', 'localtime') AND timestamp < date('now', 'localtime', '+1 day'){node_filter}
|
||||||
GROUP BY source_id ORDER BY cnt DESC LIMIT 5""", params)
|
GROUP BY source_id ORDER BY cnt DESC LIMIT 5""", params)
|
||||||
top_calls = [{"call": row[0], "count": row[1]} for row in c.fetchall()]
|
top_calls = [{"call": row[0], "count": row[1]} for row in c.fetchall()]
|
||||||
@@ -182,7 +186,7 @@ def cmd():
|
|||||||
return err("Broker MQTT non raggiungibile - comando non inviato", 503)
|
return err("Broker MQTT non raggiungibile - comando non inviato", 503)
|
||||||
|
|
||||||
audit(auth['username'], cid, cmd_type)
|
audit(auth['username'], cid, cmd_type)
|
||||||
state.client_telemetry[cid] = {"ts1": "🔄 Inviato...", "ts2": "🔄 Inviato...", "alt": ""}
|
state.client_telemetry[cid] = {"ts1": "売 Inviato...", "ts2": "売 Inviato...", "alt": ""}
|
||||||
return jsonify({"success": True})
|
return jsonify({"success": True})
|
||||||
|
|
||||||
@api_bp.route('/api/global_command', methods=['POST'])
|
@api_bp.route('/api/global_command', methods=['POST'])
|
||||||
@@ -243,7 +247,7 @@ def update_nodes():
|
|||||||
return err("Non autorizzato", 403)
|
return err("Non autorizzato", 403)
|
||||||
if not mqtt_publish("devices/control/request", "update"):
|
if not mqtt_publish("devices/control/request", "update"):
|
||||||
return err("Broker MQTT non raggiungibile", 503)
|
return err("Broker MQTT non raggiungibile", 503)
|
||||||
logger.info(f"📢 REQ CONFIG inviata a tutta la flotta da {auth['username']}")
|
logger.info(f"討 REQ CONFIG inviata a tutta la flotta da {auth['username']}")
|
||||||
audit(auth['username'], '*', 'REQ_CONFIG_ALL')
|
audit(auth['username'], '*', 'REQ_CONFIG_ALL')
|
||||||
return jsonify({"success": True})
|
return jsonify({"success": True})
|
||||||
|
|
||||||
@@ -356,21 +360,30 @@ def save_config_file():
|
|||||||
|
|
||||||
# --- AGGIORNAMENTO SERVER OTA ---
|
# --- AGGIORNAMENTO SERVER OTA ---
|
||||||
|
|
||||||
@api_bp.route('/api/server_update/check', methods=['GET'])
|
def background_gitea_check():
|
||||||
def check_server_update():
|
global GLOBAL_SERVER_UPDATE_AVAILABLE, LAST_GITEA_CHECK_TIME
|
||||||
auth = get_auth()
|
|
||||||
if not auth or auth['role'] != 'admin':
|
|
||||||
return err("Non autorizzato", 403)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(['git', 'fetch'], timeout=10, cwd=BASE_DIR)
|
subprocess.run(['git', 'fetch'], timeout=10, cwd=BASE_DIR)
|
||||||
local_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=BASE_DIR).decode('utf-8').strip()
|
local_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=BASE_DIR).decode('utf-8').strip()
|
||||||
remote_hash = subprocess.check_output(['git', 'rev-parse', '@{u}'], cwd=BASE_DIR).decode('utf-8').strip()
|
remote_hash = subprocess.check_output(['git', 'rev-parse', '@{u}'], cwd=BASE_DIR).decode('utf-8').strip()
|
||||||
update_available = local_hash != remote_hash
|
GLOBAL_SERVER_UPDATE_AVAILABLE = (local_hash != remote_hash)
|
||||||
return jsonify({"success": True, "update_available": update_available})
|
LAST_GITEA_CHECK_TIME = time.time()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Errore controllo aggiornamenti server: {e}")
|
logger.error(f"Errore controllo Gitea in background: {e}")
|
||||||
return jsonify({"success": False, "error": "Impossibile verificare aggiornamenti"})
|
|
||||||
|
@api_bp.route('/api/server_update/status', methods=['GET'])
|
||||||
|
def get_server_update_status():
|
||||||
|
global LAST_GITEA_CHECK_TIME
|
||||||
|
auth = get_auth()
|
||||||
|
if not auth or auth['role'] != 'admin':
|
||||||
|
return err("Non autorizzato", 403)
|
||||||
|
|
||||||
|
# Se è passata più di un'ora (3600 secondi) dall'ultimo controllo, avvia il thread
|
||||||
|
if time.time() - LAST_GITEA_CHECK_TIME > 3600:
|
||||||
|
import threading
|
||||||
|
threading.Thread(target=background_gitea_check, daemon=True).start()
|
||||||
|
|
||||||
|
return jsonify({"success": True, "update_available": GLOBAL_SERVER_UPDATE_AVAILABLE})
|
||||||
|
|
||||||
@api_bp.route('/api/server_update/apply', methods=['POST'])
|
@api_bp.route('/api/server_update/apply', methods=['POST'])
|
||||||
def apply_server_update():
|
def apply_server_update():
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
@@ -105,6 +105,9 @@ function openNodeFocus(clientId) {
|
|||||||
document.getElementById('tab-aprs').classList.remove('active');
|
document.getElementById('tab-aprs').classList.remove('active');
|
||||||
|
|
||||||
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' });
|
||||||
|
|
||||||
const role = me.role || '';
|
const role = me.role || '';
|
||||||
|
|||||||
+36
-19
@@ -25,31 +25,45 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="top-bar-container">
|
<div id="top-bar-container" style="border-bottom: 2px solid var(--border-main); background: var(--bg-main, #04102e);">
|
||||||
<div id="top-bar">
|
<div id="top-bar" style="display: flex; justify-content: space-between; align-items: stretch; padding: 0; min-height: 90px; flex-wrap: wrap;">
|
||||||
<div class="brand-container" style="display: flex; flex-direction: column; justify-content: center; align-items: flex-start;">
|
|
||||||
<div class="title-brand" style="line-height: 1.1; padding-bottom: 2px;">SCHEMATIC // FLEET C2</div>
|
<!-- HEADER SX: BANNER CON RIEMPIMENTO ASSOLUTO A FILO -->
|
||||||
<div id="live-clock" style="font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--text-muted); letter-spacing: 1px; padding-left: 2px;">SYS_TIME: --:--:--</div>
|
<div id="master-banner-container" style="display: none; flex: 0 0 45%; max-width: 45%; border-right: 2px solid var(--border-main); background: #020b1e; align-items: stretch; justify-content: stretch; padding: 0; box-sizing: border-box; overflow: hidden;">
|
||||||
|
<img src="/static/banners/banner.png" style="width: 100%; height: 100%; object-fit: cover; object-position: center; display: block;"
|
||||||
|
onload="this.parentElement.style.display='flex';"
|
||||||
|
onerror="this.parentElement.style.display='none';">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav-tabs">
|
<!-- HEADER DX: STRUTTURA FLUIDA A 3 RIGHE -->
|
||||||
<button class="nav-tab active" onclick="switchView('home')" id="tab-home">HOME</button>
|
<div id="header-right-controls" style="flex: 1; display: flex; flex-direction: column; gap: 10px; justify-content: center; padding: 12px 20px; box-sizing: border-box; background: rgba(0, 15, 45, 0.25); min-width: 350px;">
|
||||||
<button class="nav-tab" onclick="switchView('nodes')" id="tab-nodes">NODES</button>
|
|
||||||
<button class="nav-tab" onclick="switchView('map')" id="tab-map">MAP</button>
|
<!-- RIGA 1: BRAND E OROLOGIO -->
|
||||||
<button class="nav-tab" onclick="switchView('aprs')" id="tab-aprs">APRS</button>
|
<div style="display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 10px; border-bottom: 1px dashed var(--border-light, rgba(255,255,255,0.15)); padding-bottom: 4px;">
|
||||||
|
<span class="title-brand" style="font-size: 1.15rem; font-weight: 700; letter-spacing: 2px; color: var(--text-main);">SCHEMATIC // FLEET C2</span>
|
||||||
|
<span id="live-clock" style="font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--primary); letter-spacing: 1px;">SYS_TIME: --:--:--</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="top-bar-right">
|
<!-- RIGA 2: TASTI DI NAVIGAZIONE -->
|
||||||
<span id="mqtt-badge" class="mqtt-badge mqtt-offline">MQTT: CHK</span>
|
<div class="nav-tabs" style="display: flex; flex-wrap: wrap; gap: 8px; border: none; margin: 0; padding: 0; width: 100%;">
|
||||||
<button class="theme-switch" id="layout-btn" onclick="cycleLayout()" title="Cambia Layout">[ L: BLU ]</button>
|
<button class="nav-tab active" onclick="switchView('home')" id="tab-home" style="flex: 1; min-width: 80px; padding: 6px 0; font-size: 0.85rem; font-weight: bold; letter-spacing: 1.5px; text-align: center; border-radius: 4px;">HOME</button>
|
||||||
<button class="theme-switch" id="lang-btn" onclick="toggleLang()" data-i18n-title="ttLang">ITA</button>
|
<button class="nav-tab" onclick="switchView('nodes')" id="tab-nodes" style="flex: 1; min-width: 80px; padding: 6px 0; font-size: 0.85rem; font-weight: bold; letter-spacing: 1.5px; text-align: center; border-radius: 4px;">NODES</button>
|
||||||
<button class="theme-switch" id="push-btn" onclick="subscribeToPush()">PUSH</button>
|
<button class="nav-tab" onclick="switchView('map')" id="tab-map" style="flex: 1; min-width: 80px; padding: 6px 0; font-size: 0.85rem; font-weight: bold; letter-spacing: 1.5px; text-align: center; border-radius: 4px;">MAP</button>
|
||||||
<div id="auth-container" style="display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end;"></div>
|
<button class="nav-tab" onclick="switchView('aprs')" id="tab-aprs" style="flex: 1; min-width: 80px; padding: 6px 0; font-size: 0.85rem; font-weight: bold; letter-spacing: 1.5px; text-align: center; border-radius: 4px;">APRS</button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- VISTA FLEET MAP -->
|
<!-- RIGA 3: BADGES E TASTI ADMIN -->
|
||||||
|
<div class="top-bar-right" style="display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; border: none; margin: 0; padding: 0; width: 100%;">
|
||||||
|
<span id="mqtt-badge" class="mqtt-badge mqtt-offline" style="padding: 4px 10px; font-size: 0.75rem; font-weight: bold; letter-spacing: 1px;">MQTT: CHK</span>
|
||||||
|
<button class="theme-switch" id="layout-btn" onclick="cycleLayout()" title="Cambia Layout" style="padding: 4px 10px; font-size: 0.75rem;">[ L: BLU ]</button>
|
||||||
|
<button class="theme-switch" id="lang-btn" onclick="toggleLang()" data-i18n-title="ttLang" style="padding: 4px 10px; font-size: 0.75rem;">ITA</button>
|
||||||
|
<button class="theme-switch" id="push-btn" onclick="subscribeToPush()" style="padding: 4px 10px; font-size: 0.75rem;">PUSH</button>
|
||||||
|
<div id="auth-container" style="display: flex; flex-wrap: wrap; align-items: center; gap: 6px; justify-content: flex-end;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div><!-- VISTA FLEET MAP -->
|
||||||
<div id="view-map" style="display: none; padding: 0 20px;">
|
<div id="view-map" style="display: none; padding: 0 20px;">
|
||||||
<div id="map-container"></div>
|
<div id="map-container"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,6 +105,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- BANNER PERSONALIZZATO -->
|
||||||
<div class="grid" style="grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));">
|
<div class="grid" style="grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));">
|
||||||
<!-- COLONNA SX: HARDWARE E RF -->
|
<!-- COLONNA SX: HARDWARE E RF -->
|
||||||
<div style="display: flex; flex-direction: column; gap: 20px;">
|
<div style="display: flex; flex-direction: column; gap: 20px;">
|
||||||
@@ -199,6 +214,8 @@
|
|||||||
<!-- VISTA HOME -->
|
<!-- VISTA HOME -->
|
||||||
<div id="view-home">
|
<div id="view-home">
|
||||||
<div style="max-width: 1400px; margin: 0 auto 20px auto; padding: 0 20px;">
|
<div style="max-width: 1400px; margin: 0 auto 20px auto; padding: 0 20px;">
|
||||||
|
|
||||||
|
|
||||||
<h3 style="margin: 0 0 15px 0; font-weight: 300; letter-spacing: 2px; color: var(--text-main); border-bottom: 1px dashed var(--border-main); padding-bottom: 5px;">
|
<h3 style="margin: 0 0 15px 0; font-weight: 300; letter-spacing: 2px; color: var(--text-main); border-bottom: 1px dashed var(--border-main); padding-bottom: 5px;">
|
||||||
[ FLEET_STATUS ]
|
[ FLEET_STATUS ]
|
||||||
</h3>
|
</h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user