added pagination to audit logs
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user