fix: restore status dot, latency, last-ping time updates on SSE
This commit is contained in:
parent
94d24bac35
commit
1794c05b4f
|
|
@ -75,11 +75,21 @@
|
|||
} catch {}
|
||||
}, 30000);
|
||||
|
||||
// SSE: on each ping, fetch fresh sparkline for that monitor
|
||||
// SSE: on each ping, update text fields and fetch fresh sparkline
|
||||
const _fetchingSparkline = new Set();
|
||||
watchAccount(async (ping) => {
|
||||
const card = document.querySelector(`[data-monitor-id="${ping.monitor_id}"]`);
|
||||
if (!card) return;
|
||||
|
||||
// Status dot
|
||||
const dot = card.querySelector('.status-dot');
|
||||
if (dot) dot.className = `status-dot w-2.5 h-2.5 rounded-full ${ping.up ? 'bg-green-500' : 'bg-red-500'}`;
|
||||
|
||||
// Last latency + last ping time
|
||||
if (ping.latency_ms != null) card.querySelector('.stat-latency').textContent = ping.latency_ms + 'ms';
|
||||
card.querySelector('.stat-last').innerHTML = timeAgo(ping.checked_at);
|
||||
|
||||
// Sparkline
|
||||
const sparkEl = card.querySelector('.stat-sparkline');
|
||||
if (!sparkEl || _fetchingSparkline.has(ping.monitor_id)) return;
|
||||
_fetchingSparkline.add(ping.monitor_id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue