Add alert history dashboard endpoint and UI panel
Publish Container / publish (push) Successful in 2m33s

GET /api/dashboard/alert-history?days=N reads daily .jsonl files from
data/alerts/ and returns entries newest-first. Dashboard gets a lazy-loaded
collapsible panel with a table showing time, type (NWS/threshold badge),
event name, and details, with 7d/30d/90d range selector.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Nate EmmertandClaude Sonnet 4.6 committed 2026-09-02 08:01:41 -04:00
1 parent 926f280a28
commit 97dfae86ab
2 files changed
+110

No files matched your search

+20
View File
@@ -1404,6 +1404,26 @@ app.get('/api/station/trend', requireDashboardAuth, (_req, res) => {
});
});
// Alert history log
app.get('/api/dashboard/alert-history', requireDashboardAuth, (req, res) => {
const days = Math.min(90, Math.max(1, parseInt(req.query.days) || 30));
const results = [];
const now = Date.now();
for (let i = 0; i < days; i++) {
const day = new Date(now - i * 86400000).toISOString().slice(0, 10);
const file = path.join(ALERTS_DIR, `${day}.jsonl`);
if (!fs.existsSync(file)) continue;
try {
const lines = fs.readFileSync(file, 'utf8').split('\n').filter(Boolean);
for (const line of lines) {
try { results.push(JSON.parse(line)); } catch {}
}
} catch {}
}
results.sort((a, b) => b.ts - a.ts);
res.json(results);
});
app.listen(PORT, () => {
console.log(`Weather app running on port ${PORT}`);
if (dashAuth) {