added admin page and audit log viewing

This commit is contained in:
2026-02-11 19:07:40 +11:00
parent c05ecb66fe
commit 000eac44bb
22 changed files with 1298 additions and 155 deletions

View File

@@ -171,17 +171,65 @@ func addRoutes(
// Admin routes
adminRoutes := []hws.Route{
// Full page routes (for direct navigation and refreshes)
{
// TODO: on page load, redirect to /admin/users
Path: "/admin",
Method: hws.MethodGET,
Handler: perms.RequireAdmin(s)(handlers.AdminDashboard(s, conn)),
},
{
Path: "/admin/users",
Method: hws.MethodGET,
Handler: perms.RequireAdmin(s)(handlers.AdminUsersPage(s, conn)),
},
{
Path: "/admin/roles",
Method: hws.MethodGET,
Handler: perms.RequireAdmin(s)(handlers.AdminRolesPage(s, conn)),
},
{
Path: "/admin/permissions",
Method: hws.MethodGET,
Handler: perms.RequireAdmin(s)(handlers.AdminPermissionsPage(s, conn)),
},
{
Path: "/admin/audit",
Method: hws.MethodGET,
Handler: perms.RequireAdmin(s)(handlers.AdminAuditLogsPage(s, conn)),
},
// HTMX content fragment routes (for section swapping)
{
Path: "/admin/users",
Method: hws.MethodPOST,
Handler: perms.RequireAdmin(s)(handlers.AdminUsersList(s, conn)),
},
{
Path: "/admin/roles",
Method: hws.MethodPOST,
Handler: perms.RequireAdmin(s)(handlers.AdminRolesList(s, conn)),
},
{
Path: "/admin/permissions",
Method: hws.MethodPOST,
Handler: perms.RequireAdmin(s)(handlers.AdminPermissionsList(s, conn)),
},
{
Path: "/admin/audit",
Method: hws.MethodPOST,
Handler: perms.RequireAdmin(s)(handlers.AdminAuditLogsList(s, conn)),
},
// Audit log filtering (returns only results table, no URL push)
{
Path: "/admin/audit/filter",
Method: hws.MethodPOST,
Handler: perms.RequireAdmin(s)(handlers.AdminAuditLogsFilter(s, conn)),
},
// Audit log detail modal
{
Path: "/admin/audit/{id}",
Method: hws.MethodGET,
Handler: perms.RequireAdmin(s)(handlers.AdminAuditLogDetail(s, conn)),
},
}
routes := append(pageroutes, htmxRoutes...)