feat: add location and coordinates to node cards
This commit is contained in:
@@ -302,22 +302,33 @@ def on_message(client, userdata, msg):
|
||||
except Exception as e:
|
||||
logger.error(f"Error parsing DMRGateway for {cid}: {e}")
|
||||
|
||||
# --- MMDVMHOST INFO MANAGEMENT (FREQUENZE) ---
|
||||
elif len(parts) >= 4 and parts[0] == 'data' and parts[2].lower() == 'mmdvmhost' and parts[3].lower() == 'info':
|
||||
try:
|
||||
cid = parts[1].lower()
|
||||
data = json.loads(payload)
|
||||
|
||||
# Estrazione dati
|
||||
tx = data.get("TXFrequency", "0")
|
||||
rx = data.get("RXFrequency", "0")
|
||||
lat = data.get("Latitude", "0.0")
|
||||
lon = data.get("Longitude", "0.0")
|
||||
loc = data.get("Location", "Sconosciuta")
|
||||
|
||||
# Funzione per formattare gli Hz in MHz (es. 430500000 -> 430.500 MHz)
|
||||
# Funzione per formattare gli Hz in MHz
|
||||
def format_freq(f):
|
||||
if str(f).isdigit() and int(f) > 0:
|
||||
return f"{int(f)/1000000:.3f} MHz"
|
||||
return str(f)
|
||||
|
||||
node_info[cid] = {"tx": format_freq(tx), "rx": format_freq(rx)}
|
||||
socketio.emit('dati_aggiornati') # <--- Aggiorna la UI in tempo reale
|
||||
# Salvataggio nel dizionario globale
|
||||
node_info[cid] = {
|
||||
"tx": format_freq(tx),
|
||||
"rx": format_freq(rx),
|
||||
"lat": lat,
|
||||
"lon": lon,
|
||||
"loc": loc
|
||||
}
|
||||
socketio.emit('dati_aggiornati')
|
||||
except Exception as e:
|
||||
logger.error(f"Error parsing MMDVMHost info for {cid}: {e}")
|
||||
|
||||
|
||||
+21
-1
@@ -52,6 +52,10 @@
|
||||
.freq-tx { color: #f87171; } /* Rosso per la TX */
|
||||
.freq-rx { color: #4ade80; } /* Verde per la RX */
|
||||
|
||||
/* Metadati Nodo (Location, Coordinate) */
|
||||
.node-meta { font-size: 0.75rem; color: #8b949e; text-align: center; margin-bottom: 15px; line-height: 1.4; }
|
||||
.node-meta-item { display: block; }
|
||||
|
||||
/* Display Stato */
|
||||
.status-display { text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; font-weight: 700; padding: 8px; border-radius: 3px; background: #010409; border: 1px solid var(--border-color); margin-bottom: 15px; color: var(--text-muted); }
|
||||
.card.online .status-display { color: var(--success); border-color: rgba(46, 160, 67, 0.4); }
|
||||
@@ -592,11 +596,14 @@
|
||||
<span class="client-name" title="${c.name}">${c.name}</span>
|
||||
<span class="badge-id">ID: ${c.id.toUpperCase()}</span>
|
||||
</div>
|
||||
|
||||
<div class="freq-bar" id="freq-container-${c.id}" style="display: none;">
|
||||
<span><span class="freq-tx">TX:</span> <span id="freq-tx-${c.id}">...</span></span>
|
||||
<span><span class="freq-rx">RX:</span> <span id="freq-rx-${c.id}">...</span></span>
|
||||
</div>
|
||||
<div class="node-meta" id="meta-container-${c.id}" style="display: none;">
|
||||
<span class="node-meta-item">📍 <strong id="loc-${c.id}">...</strong></span>
|
||||
<span class="node-meta-item">Lat: <span id="lat-${c.id}">...</span> | Lon: <span id="lon-${c.id}">...</span></span>
|
||||
</div>
|
||||
<div class="health-bar" id="health-${c.id}" style="display: none;">
|
||||
<span>⚡ <span id="cpu-${c.id}">--</span>%</span>
|
||||
<span>🌡️ <span id="temp-${c.id}">--</span>°C</span>
|
||||
@@ -710,10 +717,15 @@
|
||||
}
|
||||
|
||||
let healthObj = data.health && data.health[c.id.toLowerCase()];
|
||||
// --- INIZIO BLOCCO INFO AGGIUNTIVE (FREQ + LOC) ---
|
||||
let infoObj = data.info && data.info[c.id.toLowerCase()];
|
||||
const freqContainer = document.getElementById(`freq-container-${c.id}`);
|
||||
const freqTx = document.getElementById(`freq-tx-${c.id}`);
|
||||
const freqRx = document.getElementById(`freq-rx-${c.id}`);
|
||||
const metaContainer = document.getElementById(`meta-container-${c.id}`);
|
||||
const locSpan = document.getElementById(`loc-${c.id}`);
|
||||
const latSpan = document.getElementById(`lat-${c.id}`);
|
||||
const lonSpan = document.getElementById(`lon-${c.id}`);
|
||||
|
||||
if (infoObj && isOnline) {
|
||||
if (freqContainer) {
|
||||
@@ -721,9 +733,17 @@
|
||||
freqTx.innerText = infoObj.tx;
|
||||
freqRx.innerText = infoObj.rx;
|
||||
}
|
||||
if (metaContainer) {
|
||||
metaContainer.style.display = 'block';
|
||||
locSpan.innerText = infoObj.loc;
|
||||
latSpan.innerText = infoObj.lat;
|
||||
lonSpan.innerText = infoObj.lon;
|
||||
}
|
||||
} else {
|
||||
if (freqContainer) freqContainer.style.display = 'none';
|
||||
if (metaContainer) metaContainer.style.display = 'none';
|
||||
}
|
||||
// --- FINE BLOCCO INFO AGGIUNTIVE ---
|
||||
const healthContainer = document.getElementById(`health-${c.id}`); const cpuSpan = document.getElementById(`cpu-${c.id}`); const tempSpan = document.getElementById(`temp-${c.id}`); const ramSpan = document.getElementById(`ram-${c.id}`); const diskSpan = document.getElementById(`disk-${c.id}`);
|
||||
|
||||
if (healthObj && isOnline) {
|
||||
|
||||
Reference in New Issue
Block a user