feat(dashboard): aggiunte colonne Source e YSF Mode, fix visibilità CQCQCQ per D-STAR e DG-ID per C4FM
This commit is contained in:
@@ -96,6 +96,14 @@ def init_db():
|
|||||||
c.execute("ALTER TABLE radio_logs ADD COLUMN rssi REAL DEFAULT 0")
|
c.execute("ALTER TABLE radio_logs ADD COLUMN rssi REAL DEFAULT 0")
|
||||||
except sqlite3.OperationalError: pass
|
except sqlite3.OperationalError: pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
c.execute("ALTER TABLE radio_logs ADD COLUMN source_conn TEXT DEFAULT ''")
|
||||||
|
except sqlite3.OperationalError: pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
c.execute("ALTER TABLE radio_logs ADD COLUMN ysf_mode TEXT DEFAULT ''")
|
||||||
|
except sqlite3.OperationalError: pass
|
||||||
|
|
||||||
c.execute('''CREATE TABLE IF NOT EXISTS users
|
c.execute('''CREATE TABLE IF NOT EXISTS users
|
||||||
(id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT UNIQUE, password_hash TEXT,
|
(id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT UNIQUE, password_hash TEXT,
|
||||||
role TEXT, allowed_nodes TEXT)''')
|
role TEXT, allowed_nodes TEXT)''')
|
||||||
@@ -190,8 +198,8 @@ def save_to_sqlite(client_id, data, protocol="DMR"):
|
|||||||
elif 'rssi' in data:
|
elif 'rssi' in data:
|
||||||
rssi_val = data['rssi']
|
rssi_val = data['rssi']
|
||||||
|
|
||||||
c.execute("INSERT INTO radio_logs (timestamp, client_id, protocol, source_id, target, slot, duration, ber, source_ext, rssi) VALUES (datetime('now', 'localtime'), ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
c.execute("INSERT INTO radio_logs (timestamp, client_id, protocol, source_id, target, slot, duration, ber, source_ext, rssi, source_conn, ysf_mode) VALUES (datetime('now', 'localtime'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
(client_id, protocol, str(data.get('src_id', '---')), str(data.get('dst_id', '---')), data.get('slot', 0), round(data.get('duration', 0), 1), round(data.get('ber', 0), 2), str(data.get('src_ext', '')), rssi_val))
|
(client_id, protocol, str(data.get('src_id', '---')), str(data.get('dst_id', '---')), data.get('slot', 0), round(data.get('duration', 0), 1), round(data.get('ber', 0), 2), str(data.get('src_ext', '')), rssi_val, str(data.get('source', '')), str(data.get('mode', ''))))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
notify_update('log_aggiornato')
|
notify_update('log_aggiornato')
|
||||||
@@ -568,28 +576,40 @@ def on_message(client, userdata, msg):
|
|||||||
else: src = str(p.get('Callsign', p.get('src_callsign', p.get('src_info', p.get('src_id', '---')))))
|
else: src = str(p.get('Callsign', p.get('src_callsign', p.get('src_info', p.get('src_id', '---')))))
|
||||||
|
|
||||||
# --- NUOVA GESTIONE TARGET VS REF/SLOT ---
|
# --- NUOVA GESTIONE TARGET VS REF/SLOT ---
|
||||||
current_target = str(p.get('dst_callsign', p.get('dst_id', ''))).strip()
|
# 1. Peschiamo il target specifico (es. ID in NXDN o chiamata YSF)
|
||||||
|
raw_target = str(p.get('dst_callsign', p.get('dst_id', ''))).strip()
|
||||||
|
|
||||||
|
# Nel D-STAR mostriamo sempre l'UR CALL (CQCQCQ o comandi), negli altri puliamo gli ALL/0 generici
|
||||||
if name == 'D-STAR':
|
if name == 'D-STAR':
|
||||||
target = current_target if current_target else "---"
|
target = raw_target if raw_target else "---"
|
||||||
ref_slot = last_seen_reflector.get(f"{cid}_{name}", "---")
|
|
||||||
else:
|
else:
|
||||||
target = current_target if current_target else "---"
|
target = raw_target if raw_target not in ['', '0', 'ALL'] else "---"
|
||||||
raw_slot = p.get('slot', '')
|
# Selezioniamo il DG-ID per l'YSF
|
||||||
ref_slot = str(raw_slot) if raw_slot != '' else "---"
|
if name == 'YSF' and 'dg-id' in p:
|
||||||
|
dg_id = str(p.get('dg-id')).strip()
|
||||||
|
if dg_id:
|
||||||
|
target = f"DG-ID {dg_id}" if target == "---" else f"{target} (DG {dg_id})"
|
||||||
|
|
||||||
active_calls[cid][k] = {'src': src, 'dst': target, 'slot': ref_slot, 'ext': str(p.get('src_ext', ''))}
|
# 2. Peschiamo il Reflector / Stanza connessa dalla memoria del Gateway
|
||||||
|
mem_ref = last_seen_reflector.get(f"{cid}_{name}", "---")
|
||||||
|
pack_ref = str(p.get('reflector', '')).strip()
|
||||||
|
|
||||||
# Aggiorniamo anche la stringa telemetrica visuale per la dashboard
|
# Diamo sempre priorità alla memoria di rete, ma usiamo il pacchetto come paracadute
|
||||||
client_telemetry[cid].update({"ts1":"","ts2":"","alt": f"{ico} {name}: {src} ➔ {target} ({ref_slot})"})
|
ref_slot = mem_ref if mem_ref != "---" else (pack_ref if pack_ref else "---")
|
||||||
|
|
||||||
|
active_calls[cid][k] = {'src': src, 'dst': target, 'slot': ref_slot, 'ext': str(p.get('src_ext', '')), 'source': str(p.get('source', '')), 'mode': str(p.get('mode', ''))}
|
||||||
|
|
||||||
|
# Aggiorniamo anche la stringa telemetrica visiva
|
||||||
|
target_str = target if target != "---" else "NET"
|
||||||
|
client_telemetry[cid].update({"ts1":"","ts2":"","alt": f"{ico} {name}: {src} ➔ {target_str} ({ref_slot})"})
|
||||||
notify_update()
|
notify_update()
|
||||||
|
|
||||||
elif act in ['end', 'lost']:
|
elif act in ['end', 'lost']:
|
||||||
# Estraiamo anche la variabile 'slot' memorizzata prima
|
# Estraiamo anche la variabile 'slot' memorizzata prima
|
||||||
info = active_calls[cid].get(k, {'src': '---', 'dst': '---', 'slot': '---', 'ext': ''})
|
info = active_calls[cid].get(k, {'src': '---', 'dst': '---', 'slot': '---', 'ext': '', 'source': '', 'mode': ''})
|
||||||
|
|
||||||
# Forziamo l'inserimento dello slot nel dizionario 'p' che verrà salvato nel DB
|
# Forziamo l'inserimento dello slot nel dizionario 'p' che verrà salvato nel DB
|
||||||
p.update({'src_id': info['src'], 'dst_id': info['dst'], 'slot': info['slot'], 'src_ext': info['ext']})
|
p.update({'src_id': info['src'], 'dst_id': info['dst'], 'slot': info['slot'], 'src_ext': info['ext'], 'source': info['source'], 'mode': info['mode']})
|
||||||
|
|
||||||
save_to_sqlite(cid, p, protocol=name)
|
save_to_sqlite(cid, p, protocol=name)
|
||||||
client_telemetry[cid]["alt"] = f"{'✅' if act=='end' else '⚠️'} {name}: {info['src']}"
|
client_telemetry[cid]["alt"] = f"{'✅' if act=='end' else '⚠️'} {name}: {info['src']}"
|
||||||
@@ -647,7 +667,7 @@ def get_clients():
|
|||||||
def get_logs():
|
def get_logs():
|
||||||
conn = sqlite3.connect(DB_PATH, timeout=10)
|
conn = sqlite3.connect(DB_PATH, timeout=10)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute("SELECT timestamp, client_id, protocol, source_id, target, slot, duration, ber, source_ext, rssi FROM radio_logs ORDER BY id DESC LIMIT 60")
|
c.execute("SELECT timestamp, client_id, protocol, source_id, target, slot, duration, ber, source_ext, rssi, source_conn, ysf_mode FROM radio_logs ORDER BY id DESC LIMIT 60")
|
||||||
logs = c.fetchall()
|
logs = c.fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
return jsonify(logs)
|
return jsonify(logs)
|
||||||
|
|||||||
+19
-1
@@ -236,6 +236,8 @@
|
|||||||
<th data-i18n="thTime">Time</th>
|
<th data-i18n="thTime">Time</th>
|
||||||
<th data-i18n="thRep">Repeater</th>
|
<th data-i18n="thRep">Repeater</th>
|
||||||
<th data-i18n="thMode">Mode</th>
|
<th data-i18n="thMode">Mode</th>
|
||||||
|
<th style="text-align: center;">YSF Mode</th>
|
||||||
|
<th style="text-align: center;">Source</th>
|
||||||
<th style="text-align: center;">REF / SLOT</th>
|
<th style="text-align: center;">REF / SLOT</th>
|
||||||
<th data-i18n="thCall">Callsign</th>
|
<th data-i18n="thCall">Callsign</th>
|
||||||
<th>Target / TG</th>
|
<th>Target / TG</th>
|
||||||
@@ -1017,6 +1019,8 @@
|
|||||||
const clientId = row[1]; const protocol = row[2] || "DMR"; let source = row[3] || "---"; const target = row[4] || "---";
|
const clientId = row[1]; const protocol = row[2] || "DMR"; let source = row[3] || "---"; const target = row[4] || "---";
|
||||||
const rawSlot = row[5]; const source_ext = row[8];
|
const rawSlot = row[5]; const source_ext = row[8];
|
||||||
const rawRssi = row[9];
|
const rawRssi = row[9];
|
||||||
|
const sourceConn = row[10];
|
||||||
|
const ysfMode = row[11];
|
||||||
|
|
||||||
let sourceHtml = esc(source);
|
let sourceHtml = esc(source);
|
||||||
if (source_ext && source_ext.trim() !== "") { sourceHtml += ` <span style="font-size:0.8em; color:#94a3b8; font-family:'JetBrains Mono', monospace;">/${esc(source_ext)}</span>`; }
|
if (source_ext && source_ext.trim() !== "") { sourceHtml += ` <span style="font-size:0.8em; color:#94a3b8; font-family:'JetBrains Mono', monospace;">/${esc(source_ext)}</span>`; }
|
||||||
@@ -1031,6 +1035,20 @@
|
|||||||
}
|
}
|
||||||
let protoColor = "#3b82f6"; if (protocol === "NXDN") protoColor = "#10b981"; else if (protocol === "YSF") protoColor = "#8b5cf6"; else if (protocol === "D-STAR") protoColor = "#06b6d4"; else if (protocol === "P25") protoColor = "#f59e0b";
|
let protoColor = "#3b82f6"; if (protocol === "NXDN") protoColor = "#10b981"; else if (protocol === "YSF") protoColor = "#8b5cf6"; else if (protocol === "D-STAR") protoColor = "#06b6d4"; else if (protocol === "P25") protoColor = "#f59e0b";
|
||||||
|
|
||||||
|
// Formatta il Source (RF o NET)
|
||||||
|
let sourceBadge = "---";
|
||||||
|
if (sourceConn) {
|
||||||
|
if (sourceConn.toLowerCase() === 'rf') sourceBadge = '<span style="color:#f87171; font-weight:800;">RF</span>';
|
||||||
|
else if (sourceConn.toLowerCase() === 'network') sourceBadge = '<span style="color:#38bdf8; font-weight:800;">NET</span>';
|
||||||
|
else sourceBadge = `<span style="font-weight:800; color:var(--text-muted);">${esc(sourceConn).toUpperCase()}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formatta l'YSF Mode
|
||||||
|
let modeDisplay = "---";
|
||||||
|
if (ysfMode && ysfMode.trim() !== "") {
|
||||||
|
modeDisplay = `<span style="font-size:0.7rem; color:#a78bfa; border: 1px solid #a78bfa; padding: 2px 4px; border-radius: 4px;">${esc(ysfMode).toUpperCase()}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
// Formatta l'RSSI con S-Meter grafico a segmenti
|
// Formatta l'RSSI con S-Meter grafico a segmenti
|
||||||
let rssiDisplay = '---';
|
let rssiDisplay = '---';
|
||||||
if (rawRssi && rawRssi !== 0) {
|
if (rawRssi && rawRssi !== 0) {
|
||||||
@@ -1082,7 +1100,7 @@
|
|||||||
if (!networkLogs[clientId]) networkLogs[clientId] = "";
|
if (!networkLogs[clientId]) networkLogs[clientId] = "";
|
||||||
networkLogs[clientId] += `<div style="border-bottom:1px solid rgba(255,255,255,0.1); padding:4px 0;"><span style="color:#64748b;">[${esc(time)}]</span> <span style="color:${protoColor}; font-weight:bold;">[${esc(protocol)}]</span> <span style="color:#cbd5e1;">${esc(source.replace("🌐", "").trim())}</span></div>`;
|
networkLogs[clientId] += `<div style="border-bottom:1px solid rgba(255,255,255,0.1); padding:4px 0;"><span style="color:#64748b;">[${esc(time)}]</span> <span style="color:${protoColor}; font-weight:bold;">[${esc(protocol)}]</span> <span style="color:#cbd5e1;">${esc(source.replace("🌐", "").trim())}</span></div>`;
|
||||||
} else {
|
} else {
|
||||||
tableHTML += `<tr><td>${esc(time)}</td><td><b style="color:var(--text-main);">${esc(String(clientId).toUpperCase())}</b></td><td><span style="background:${protoColor}; color:white; padding:3px 8px; border-radius:8px; font-size:0.7rem; font-weight:800;">${esc(protocol)}</span></td><td style="font-family:'JetBrains Mono', monospace; font-weight:bold; text-align:center;">${esc(slotDisplay)}</td><td style="color:var(--accent); font-weight:800;">${sourceHtml}</td><td style="font-family:'JetBrains Mono', monospace;">${esc(target.trim())}</td><td>${esc(row[6])}s</td><td>${esc(row[7])}%</td><td style="font-family:'JetBrains Mono', monospace;">${rssiDisplay}</td></tr>`;
|
tableHTML += `<tr><td>${esc(time)}</td><td><b style="color:var(--text-main);">${esc(String(clientId).toUpperCase())}</b></td><td><span style="background:${protoColor}; color:white; padding:3px 8px; border-radius:8px; font-size:0.7rem; font-weight:800;">${esc(protocol)}</span></td><td style="text-align:center;">${modeDisplay}</td><td style="text-align:center; font-family:'JetBrains Mono', monospace;">${sourceBadge}</td><td style="font-family:'JetBrains Mono', monospace; font-weight:bold; text-align:center;">${esc(slotDisplay)}</td><td style="color:var(--accent); font-weight:800;">${sourceHtml}</td><td style="font-family:'JetBrains Mono', monospace;">${esc(target.trim())}</td><td>${esc(row[6])}s</td><td>${esc(row[7])}%</td><td style="font-family:'JetBrains Mono', monospace;">${rssiDisplay}</td></tr>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tbody.innerHTML = tableHTML;
|
tbody.innerHTML = tableHTML;
|
||||||
|
|||||||
Reference in New Issue
Block a user