diff --git a/src/main.js b/src/main.js index 926e89a..ea9632f 100644 --- a/src/main.js +++ b/src/main.js @@ -148,12 +148,13 @@ async function detectGateway() { // --- App State --------------------------------------------------------------- class HostState { - constructor(host) { + constructor(host, pinned = false) { this.name = host.name; this.url = host.url; this.history = []; // { timestamp, latency, paused } this.lastLatency = null; this.status = "pending"; // 'online' | 'offline' | 'error' | 'pending' + this.pinned = pinned; } pushSample(timestamp, result) { @@ -190,7 +191,9 @@ class HostState { class AppState { constructor(localHosts) { - this.wan = WAN_HOSTS.map((h) => new HostState(h)); + this.wan = WAN_HOSTS.map( + (h) => new HostState(h, h.name === "datavi.be"), + ); this.local = localHosts.map((h) => new HostState(h)); this.paused = false; this.tickCount = 0; @@ -218,6 +221,22 @@ class AppState { }; } + /** Min/max across all WAN host history (the full 300s window) */ + wanHistoryStats() { + let min = Infinity; + let max = -Infinity; + for (const host of this.wan) { + for (const p of host.history) { + if (p.latency !== null) { + if (p.latency < min) min = p.latency; + if (p.latency > max) max = p.latency; + } + } + } + if (min === Infinity) return { min: null, max: null }; + return { min, max }; + } + /** Overall health: true = healthy (more than half WAN reachable) */ isHealthy() { const reachable = this.wan.filter((h) => h.lastLatency !== null).length; @@ -412,9 +431,17 @@ class SparklineRenderer { // --- UI Renderer ------------------------------------------------------------- function hostRowHTML(host, index) { + const pinColor = host.pinned + ? "text-blue-400" + : "text-gray-600 hover:text-gray-400"; return `