Fix Overview layout: stats panel, filter panel, then tables (in that order)

Placing the filter form outside the polled div (so the poll can't wipe out
typed/selected values) put it before the stat-grid, since both used to
live inside that same polled block — stats ended up after the filter
instead of before it, as it always was.

Splits the stat-grid out into its own #overview-stats div, positioned
before the filter form; the actual poll target is now #overview-tables
(just the two tables). Since #overview-stats no longer polls directly,
/overview/fragment now also renders it as an out-of-band swap alongside
the main #overview-tables response — the same hx-swap-oob idiom already
used for the shared error banner — so the stat counts still refresh every
tick even though they're outside the polled element.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5 committed 2026-09-23 12:13:23 +03:00
1 parent 281c9188a2
commit 3e33841ada
9 files changed
+72 -15

No files matched your search

+34 -1
View File
@@ -36,11 +36,44 @@ func TestOverviewFragment(t *testing.T) {
}
}
// TestOverviewFragmentUpdatesStatsOutOfBand proves /overview/fragment keeps
// refreshing the stat-grid even though #overview-stats lives outside the
// polled #overview-tables div (see overview.html — the stat panel sits
// above the filter form, which must survive polling, so it can't be part
// of the swapped tables block). This guards the DOM layout fix: stats,
// then a gap, then the filter panel, then everything else.
func TestOverviewFragmentUpdatesStatsOutOfBand(t *testing.T) {
fake, caURL := newFakeControlAPI(t)
fake.validators = []validatorDTO{{ValidatorID: "v1", State: "idle"}}
fake.ips = []ipQueueItem{{IPAddress: "1.1.1.1", State: "queued"}}
ts := newTestServer(t, caURL)
body := get(t, ts, "/overview/fragment")
if !strings.Contains(body, `id="overview-stats" hx-swap-oob="true"`) {
t.Fatalf("expected an out-of-band update for #overview-stats, got:\n%s", body)
}
if !strings.Contains(body, "всего IP") {
t.Fatalf("expected the stat-grid labels in the OOB block, got:\n%s", body)
}
page := get(t, ts, "/overview")
statsIdx := strings.Index(page, `id="overview-stats"`)
filterIdx := strings.Index(page, `id="overview-filter"`)
tablesIdx := strings.Index(page, `id="overview-tables"`)
if statsIdx < 0 || filterIdx < 0 || tablesIdx < 0 {
t.Fatalf("expected all three sections present, got:\n%s", page)
}
if !(statsIdx < filterIdx && filterIdx < tablesIdx) {
t.Fatalf("expected DOM order stats -> filter -> tables, got indices stats=%d filter=%d tables=%d",
statsIdx, filterIdx, tablesIdx)
}
}
// TestOverviewFilterByQueryAndStatus proves the ?q=&status= params on both
// /overview and /overview/fragment narrow the current-checking and
// last-completed tables to matching rows only, and that the filter form
// echoes the applied values back (so they survive the recurring poll,
// which only re-renders overview_fragment, not the form around it).
// which only re-renders #overview-tables, not the form around it).
func TestOverviewFilterByQueryAndStatus(t *testing.T) {
fake, caURL := newFakeControlAPI(t)
now := time.Now()