Graph: 1-hour view

This commit is contained in:
alex committed 2026-11-16 05:09:51 +00:00
1 parent 038d7e3229
commit 21a152ab1c
5 files changed
+9 -6

No files matched your search

+1 -1
View File
@@ -136,7 +136,7 @@ router.get('/api/site/summary', async (req, res) => {
} catch (e) { res.status(500).json({ error: 'unavailable' }); }
});
const RANGES = { '24h': [24 * 3600, 300], '7d': [7 * 86400, 1800], '30d': [30 * 86400, 7200] };
const RANGES = { '1h': [3600, 60], '24h': [24 * 3600, 300], '7d': [7 * 86400, 1800], '30d': [30 * 86400, 7200] };
router.get('/api/site/service/:id', async (req, res) => {
try {
if (!/^[0-9a-f-]{36}$/.test(req.params.id)) return res.status(404).end();
+2 -1
View File
@@ -129,5 +129,6 @@
"speedPing": "Ping",
"speedAt": "Testet",
"speedHist": "Seneste tests",
"speedNone": "Ingen resultater endnu."
"speedNone": "Ingen resultater endnu.",
"r1": "1 time"
}
+2 -1
View File
@@ -132,5 +132,6 @@
"speedPing": "Ping",
"speedAt": "Getestet",
"speedHist": "Letzte Tests",
"speedNone": "Noch keine Ergebnisse."
"speedNone": "Noch keine Ergebnisse.",
"r1": "1 Stunde"
}
+2 -1
View File
@@ -127,5 +127,6 @@
"speedPing": "Ping",
"speedAt": "Tested",
"speedHist": "Recent tests",
"speedNone": "No results yet."
"speedNone": "No results yet.",
"r1": "1 hour"
}
+2 -2
View File
@@ -208,7 +208,7 @@ async function openGraph(id, range = '24h') {
document.getElementById('gm')?.remove();
const m = document.createElement('div'); m.id = 'gm'; m.className = 'gm';
m.innerHTML = `<div class="gc" role="dialog" aria-modal="true"><div class="gh"><div class="svc">${icon(s)}<b>${esc(s.name)}</b><span class="pill ${esc(s.status)}">${s.status === 'up' ? T().up : s.status === 'down' ? T().dn : T().unk}</span></div><button class="ghost" id="gx" aria-label="${T().close}">✕</button></div>
<div class="btns" id="gr">${[['24h', T().r24], ['7d', T().r7], ['30d', T().r30]].map(([r, l]) => `<button data-r="${r}" class="${r === range ? '' : 'ghost'}">${l}</button>`).join('')}</div>
<div class="btns" id="gr">${[['1h', T().r1], ['24h', T().r24], ['7d', T().r7], ['30d', T().r30]].map(([r, l]) => `<button data-r="${r}" class="${r === range ? '' : 'ghost'}">${l}</button>`).join('')}</div>
<div id="gb"><div class="skeleton" style="height:240px"></div></div></div>`;
document.body.appendChild(m);
m.addEventListener('click', (e) => { if (e.target === m || e.target.id === 'gx') m.remove(); const r = e.target.dataset?.r; if (r) openGraph(id, r); });
@@ -234,7 +234,7 @@ function drawGraph(d, range) {
if (p.down) area += `<rect x="${(X(p.t - d.step / 2)).toFixed(1)}" y="${Tp}" width="${Math.max(2, pw * d.step / (t1 - t0)).toFixed(1)}" height="${ph}" fill="#ff5d6c" opacity=".12"/>`;
}
const grid = [0, .5, 1].map((f) => { const v = Math.round(top * f / 10) * 10, y = Y(v); return `<line x1="${L}" x2="${W - R}" y1="${y}" y2="${y}" stroke="#232836"/><text x="${L - 6}" y="${y + 4}" text-anchor="end" fill="#8a93a6" font-size="${NARROW ? 13 : 11}">${v}</text>`; }).join('');
const ticks = (NARROW ? [0, .5, 1] : [0, .25, .5, .75, 1]).map((f) => { const t = t0 + (t1 - t0) * f; return `<text x="${L + pw * f}" y="${H - 6}" text-anchor="${f === 0 ? 'start' : f === 1 ? 'end' : 'middle'}" fill="#8a93a6" font-size="${NARROW ? 13 : 11}">${new Date(t).toLocaleString(T().locale, range === '24h' ? { hour: '2-digit', minute: '2-digit' } : { day: 'numeric', month: 'short' })}</text>`; }).join('');
const ticks = (NARROW ? [0, .5, 1] : [0, .25, .5, .75, 1]).map((f) => { const t = t0 + (t1 - t0) * f; return `<text x="${L + pw * f}" y="${H - 6}" text-anchor="${f === 0 ? 'start' : f === 1 ? 'end' : 'middle'}" fill="#8a93a6" font-size="${NARROW ? 13 : 11}">${new Date(t).toLocaleString(T().locale, range === '24h' || range === '1h' ? { hour: '2-digit', minute: '2-digit' } : { day: 'numeric', month: 'short' })}</text>`; }).join('');
const thrY = Y(thr);
const tot = pts.reduce((a, p) => a + p.n, 0), ok = pts.reduce((a, p) => a + p.ok, 0), avg = rts.length ? Math.round(rts.reduce((a, b) => a + b, 0) / rts.length) : null;
d._geo = { X, Y, L, pw, pts, t0, t1, thr, W };