added pagination to audit logs

This commit is contained in:
2026-02-11 22:18:02 +11:00
parent a43c23f4b1
commit ba6929629d
5 changed files with 47 additions and 85 deletions

View File

@@ -144,7 +144,7 @@ func formatJSON(raw []byte) string {
return "No details available"
}
// Pretty print the JSON
var obj interface{}
var obj any
if err := json.Unmarshal(raw, &obj); err != nil {
return string(raw)
}

View File

@@ -184,11 +184,12 @@ templ AuditLogsResults(logs *db.List[db.AuditLog]) {
}
}}
if totalPages > 1 {
<div class="flex justify-center gap-2">
<div class="flex justify-center gap-2 mt-4">
if logs.PageOpts.Page > 1 {
<button
hx-post={ fmt.Sprintf("/admin/audit?page=%d", logs.PageOpts.Page-1) }
hx-target="#admin-content"
hx-post={ fmt.Sprintf("/admin/audit/filter?page=%d", logs.PageOpts.Page-1) }
hx-target="#audit-results"
hx-include="#audit-filters-form"
class="px-4 py-2 bg-surface1 hover:bg-surface2 text-text rounded font-medium transition hover:cursor-pointer"
>
Previous
@@ -199,8 +200,9 @@ templ AuditLogsResults(logs *db.List[db.AuditLog]) {
</span>
if logs.PageOpts.Page < totalPages {
<button
hx-post={ fmt.Sprintf("/admin/audit?page=%d", logs.PageOpts.Page+1) }
hx-target="#admin-content"
hx-post={ fmt.Sprintf("/admin/audit/filter?page=%d", logs.PageOpts.Page+1) }
hx-target="#audit-results"
hx-include="#audit-filters-form"
class="px-4 py-2 bg-surface1 hover:bg-surface2 text-text rounded font-medium transition hover:cursor-pointer"
>
Next