Add pagination to event queries, input validation, daily event purge
- get_active_events() now takes limit/offset (default 200) to cap unbounded queries - count_active_events() added to return total for pagination display - /api/events supports ?limit=, ?offset=, ?status= query params (max 1000) - /api/status includes total_active count alongside paginated events list - index() route passes total_active to template for server-side truncation notice - Show "Showing X of Y" notice in dashboard when events are truncated - Suppression POST validates: reason ≤500 chars, target_name/detail ≤255 chars - _purge_old_jobs_loop runs purge_old_resolved_events(90d) once per day Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,7 @@ async function refreshAll() {
|
||||
|
||||
updateHostGrid(net.hosts || {});
|
||||
updateUnifiTable(net.unifi || []);
|
||||
updateEventsTable(status.events || []);
|
||||
updateEventsTable(status.events || [], status.total_active);
|
||||
updateStatusBar(status.summary || {}, status.last_check || '');
|
||||
updateTopology(net.hosts || {});
|
||||
|
||||
@@ -147,7 +147,7 @@ function updateUnifiTable(devices) {
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function updateEventsTable(events) {
|
||||
function updateEventsTable(events, totalActive) {
|
||||
const wrap = document.getElementById('events-table-wrap');
|
||||
if (!wrap) return;
|
||||
|
||||
@@ -157,6 +157,11 @@ function updateEventsTable(events) {
|
||||
return;
|
||||
}
|
||||
|
||||
const truncated = totalActive != null && totalActive > active.length;
|
||||
const countNotice = truncated
|
||||
? `<div class="pagination-notice">Showing ${active.length} of ${totalActive} active alerts — <a href="/api/events?limit=1000">view all via API</a></div>`
|
||||
: '';
|
||||
|
||||
const rows = active.map(e => {
|
||||
const supType = e.event_type === 'unifi_device_offline' ? 'unifi_device'
|
||||
: e.event_type === 'interface_down' ? 'interface'
|
||||
@@ -188,6 +193,7 @@ function updateEventsTable(events) {
|
||||
}).join('');
|
||||
|
||||
wrap.innerHTML = `
|
||||
${countNotice}
|
||||
<div class="table-wrap">
|
||||
<table class="data-table" id="events-table">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user