2

Improve requests log filters and sorting

This commit is contained in:
2026-03-12 18:42:12 +01:00
parent 200fc83831
commit fef2237c49
7 changed files with 589 additions and 89 deletions

View File

@@ -57,7 +57,7 @@ func TestHandlerServesOverviewAndManualActions(t *testing.T) {
}
recorder = httptest.NewRecorder()
request = httptest.NewRequest(http.MethodGet, "/api/events?hours=24&limit=250&page=2&show_known_bots=false&show_allowed=false&review_only=true", nil)
request = httptest.NewRequest(http.MethodGet, "/api/events?hours=24&limit=250&page=2&source=main&method=GET&status=4xx&state=review&bot_filter=known&sort_by=status&sort_dir=asc", nil)
handler.ServeHTTP(recorder, request)
if recorder.Code != http.StatusOK {
t.Fatalf("unexpected filtered events status: %d", recorder.Code)
@@ -69,7 +69,15 @@ func TestHandlerServesOverviewAndManualActions(t *testing.T) {
if eventPage.Page != 2 || !eventPage.HasPrev {
t.Fatalf("unexpected event page payload: %+v", eventPage)
}
if app.lastEventOptions.ShowKnownBots || app.lastEventOptions.ShowAllowed || !app.lastEventOptions.ReviewOnly || app.lastEventOptions.Offset != 250 {
if app.lastEventOptions.Offset != 250 ||
app.lastEventOptions.Source != "main" ||
app.lastEventOptions.Method != "GET" ||
app.lastEventOptions.StatusFilter != "4xx" ||
app.lastEventOptions.State != string(model.IPStateReview) ||
app.lastEventOptions.BotFilter != "known" ||
app.lastEventOptions.SortBy != "status" ||
app.lastEventOptions.SortDesc ||
app.lastEventOptions.ReviewOnly {
t.Fatalf("event filter options were not forwarded correctly: %+v", app.lastEventOptions)
}
@@ -158,11 +166,11 @@ func TestHandlerServesOverviewAndManualActions(t *testing.T) {
t.Fatalf("unexpected requests log page status: %d", recorder.Code)
}
queryLogBody := recorder.Body.String()
if !strings.Contains(queryLogBody, "Review only") {
t.Fatalf("requests log page should expose the review-only toggle")
if !strings.Contains(queryLogBody, "Filters, sorting, and pagination") {
t.Fatalf("requests log page should expose the collapsible controls panel")
}
if !strings.Contains(queryLogBody, "These filters affect the full Requests Log") {
t.Fatalf("requests log page should explain its filters")
if !strings.Contains(queryLogBody, "Rows per page") {
t.Fatalf("requests log page should expose pagination settings")
}
if !strings.Contains(queryLogBody, "Request") {
t.Fatalf("requests log page should render the request table")
@@ -170,6 +178,12 @@ func TestHandlerServesOverviewAndManualActions(t *testing.T) {
if !strings.Contains(queryLogBody, "Auto refresh") {
t.Fatalf("requests log page should expose the auto refresh toggle")
}
if !strings.Contains(queryLogBody, "onclick=\"applySort('status')\"") {
t.Fatalf("requests log page should expose clickable sortable columns")
}
if !strings.Contains(queryLogBody, "Source") || !strings.Contains(queryLogBody, "Bots") || !strings.Contains(queryLogBody, "HTTP status") {
t.Fatalf("requests log page should expose source, bot, and status filters")
}
if !strings.Contains(queryLogBody, "Previous") || !strings.Contains(queryLogBody, "Next") {
t.Fatalf("requests log page should expose pagination controls")
}