From 00cc2abd23822efc89f7e573c1e1f6ea3f8d085b Mon Sep 17 00:00:00 2001 From: Pablo Revilla Date: Wed, 31 Dec 2025 11:56:18 -0800 Subject: [PATCH] Modify node.html to add statistics --- meshview/templates/node.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/meshview/templates/node.html b/meshview/templates/node.html index c7031e8..752bd70 100644 --- a/meshview/templates/node.html +++ b/meshview/templates/node.html @@ -157,6 +157,11 @@
Longitude:
Last Update:
+
+ Statistics: + +
+ @@ -426,6 +431,7 @@ async function loadNodeInfo(){ lastSeen = formatLastSeen(node.last_seen_us); } document.getElementById("info-last-update").textContent = lastSeen; + loadNodeStats(node.node_id); } catch (err) { console.error("Failed to load node info:", err); document.getElementById("node-info").style.display = "none"; @@ -1121,5 +1127,28 @@ document.addEventListener("DOMContentLoaded", async () => { }); }); +async function loadNodeStats(nodeId) { + try { + const res = await fetch( + `/api/stats/count?from_node=${nodeId}&period_type=day&length=1` + ); + + if (!res.ok) { + throw new Error(`HTTP ${res.status}`); + } + + const data = await res.json(); + + const packets = data?.total_packets ?? 0; + const seen = data?.total_seen ?? 0; + + document.getElementById("info-stats").textContent = + `24h · Packets sent: ${packets.toLocaleString()} · Times seen: ${seen.toLocaleString()}`; + } catch (err) { + console.error("Failed to load node stats:", err); + document.getElementById("info-stats").textContent = "—"; + } +} + {% endblock %}