adding search
Deploy / deploy (push) Successful in 9s

This commit is contained in:
2026-05-06 12:30:13 +02:00
parent ddcd7b0a5e
commit 556ac06413
4 changed files with 106 additions and 6 deletions
+11
View File
@@ -67,6 +67,7 @@ class Router
=> $this->deleteEntity('rule', (int) $m[1]),
$path === '/alerts' && $method === 'GET' => $this->getAlerts(),
$path === '/alerts/search' && $method === 'GET' => $this->searchAlerts(),
preg_match('#^/alerts/(\d+)/ack$#', $path, $m) && $method === 'POST'
=> $this->ackAlert((int) $m[1]),
preg_match('#^/alerts/counts$#', $path) && $method === 'GET'
@@ -193,6 +194,16 @@ class Router
return ['status' => 'acknowledged', 'id' => $id];
}
private function searchAlerts(): array
{
$query = $_GET['q'] ?? '';
if (empty($query)) {
return [];
}
$limit = (int) ($_GET['limit'] ?? 100);
return $this->repo->searchAlerts($query, $limit);
}
private function updateAllowedTokens(): array
{
$body = json_decode(file_get_contents('php://input'), true);