Add per-column filters, smart pagination (25/page), and date range filter to audit logs

This commit is contained in:
2026-06-07 12:43:50 -04:00
parent 4448dec60d
commit cd24cc53a0
4 changed files with 278 additions and 33 deletions

View File

@@ -168,19 +168,34 @@ class AdminController
$page = (int) ($_GET['page'] ?? 1);
$action = $_GET['action'] ?? '';
$userId = $_GET['user_id'] ?? '';
$username = $_GET['username'] ?? '';
$ipAddress = $_GET['ip_address'] ?? '';
$entityType = $_GET['entity_type'] ?? '';
$details = $_GET['details'] ?? '';
$dateFrom = $_GET['date_from'] ?? '';
$dateTo = $_GET['date_to'] ?? '';
$filters = [];
if ($action) $filters['action'] = $action;
if ($userId) $filters['user_id'] = (int) $userId;
if ($action !== '') $filters['action'] = $action;
if ($username !== '') $filters['username'] = $username;
if ($ipAddress !== '') $filters['ip_address'] = $ipAddress;
if ($entityType !== '') $filters['entity_type'] = $entityType;
if ($details !== '') $filters['details'] = $details;
if ($dateFrom !== '') $filters['date_from'] = $dateFrom;
if ($dateTo !== '') $filters['date_to'] = $dateTo;
$logs = $this->auditService->getAuditLogs($page, 50, $filters);
$logs = $this->auditService->getAuditLogs($page, 25, $filters);
$this->view->display('admin.audit', [
'title' => 'Audit Logs - ServerManager',
'logs' => $logs,
'action' => $action,
'userId' => $userId,
'username' => $username,
'ipAddress' => $ipAddress,
'entityType' => $entityType,
'details' => $details,
'dateFrom' => $dateFrom,
'dateTo' => $dateTo,
]);
}