refactor: full SSR dashboard, minimal SSE DOM patches, poll-based refresh

This commit is contained in:
M1
2026-03-16 21:14:45 +04:00
parent 878829111f
commit 2f7273604b
6 changed files with 299 additions and 376 deletions
-22
View File
@@ -52,28 +52,6 @@ setInterval(() => {
});
}, 1000);
// Render a tiny sparkline SVG from latency values
function sparkline(values, width = 120, height = 32) {
if (!values.length) return '';
const max = Math.max(...values, 1);
const min = Math.min(...values, 0);
const range = max - min || 1;
const step = width / Math.max(values.length - 1, 1);
const points = values.map((v, i) => {
const x = i * step;
const y = height - ((v - min) / range) * (height - 4) - 2;
return `${x},${y}`;
}).join(' ');
return `<svg width="${width}" height="${height}" class="inline-block"><polyline points="${points}" fill="none" stroke="#60a5fa" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
}
// Status badge
function statusBadge(up) {
if (up === true) return '<span class="inline-block w-2.5 h-2.5 rounded-full bg-green-400 mr-2" title="Up"></span>';
if (up === false) return '<span class="inline-block w-2.5 h-2.5 rounded-full bg-red-400 mr-2" title="Down"></span>';
return '<span class="inline-block w-2.5 h-2.5 rounded-full bg-gray-600 mr-2" title="Unknown"></span>';
}
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;