From 4df0149f8bd5ef5d6a2928bce103c0bc966326b8 Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Fri, 18 Sep 2026 12:59:01 +0200 Subject: [PATCH] Add active/archived/all filter tabs to the Raids page Uses the bot's new ?status= query param on /api/raids. fetch_raids() takes a status argument (whitelisted against active/archived/all, falls back to active on anything else) and appends it to the request URL. Archived raids get a dimmed card style and an "Archiviert" badge using the new archived/archived_at fields. Verified all three filters end-to-end against the live API. Co-Authored-By: Claude Sonnet 5 --- assets/css/style.css | 27 +++++++++++++++++++++++++++ includes/raids_api.php | 13 +++++++++++-- raids.php | 38 +++++++++++++++++++++++++++++++++----- 3 files changed, 71 insertions(+), 7 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index 8cd1384..8fb584b 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -389,6 +389,33 @@ input:focus, select:focus, textarea:focus { .raid-group ul { margin: 0; padding-left: 1.1rem; } .raid-group li { margin-bottom: 0.25rem; } +.panel-archived { opacity: 0.7; } + +.filter-tabs { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; + margin-top: 1rem; +} + +.filter-tab { + padding: 0.4rem 0.9rem; + border-radius: 999px; + border: 1px solid var(--border); + background: var(--bg-panel-alt); + color: var(--text-muted); + font-size: 0.85rem; + font-weight: 600; +} + +.filter-tab:hover { color: var(--text); text-decoration: none; } + +.filter-tab.active { + background: rgba(201, 162, 39, 0.15); + border-color: var(--gold); + color: var(--gold); +} + @media (max-width: 860px) { .app-shell { flex-direction: column; diff --git a/includes/raids_api.php b/includes/raids_api.php index c236464..51141e8 100644 --- a/includes/raids_api.php +++ b/includes/raids_api.php @@ -1,12 +1,18 @@ > * @throws RuntimeException */ -function fetch_raids(): array +function fetch_raids(string $status = 'active'): array { + if (!in_array($status, RAID_STATUSES, true)) { + $status = 'active'; + } + $configPath = __DIR__ . '/../config.php'; if (!file_exists($configPath)) { throw new RuntimeException('Konfigurationsdatei fehlt.'); @@ -24,7 +30,10 @@ function fetch_raids(): array throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.'); } - $ch = curl_init($apiUrl); + $separator = str_contains($apiUrl, '?') ? '&' : '?'; + $requestUrl = $apiUrl . $separator . 'status=' . urlencode($status); + + $ch = curl_init($requestUrl); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['X-API-Key: ' . $apiKey], diff --git a/raids.php b/raids.php index 50d7f37..d31fe00 100644 --- a/raids.php +++ b/raids.php @@ -3,21 +3,42 @@ require_once __DIR__ . '/includes/bootstrap.php'; require_once __DIR__ . '/includes/raids_api.php'; require_permission('raids.view'); +$status = (string) ($_GET['status'] ?? 'active'); +if (!in_array($status, RAID_STATUSES, true)) { + $status = 'active'; +} + $raids = []; $apiError = null; try { - $raids = fetch_raids(); + $raids = fetch_raids($status); } catch (Throwable $e) { $apiError = $e->getMessage(); } +$statusLabels = [ + 'active' => 'Aktiv', + 'archived' => 'Archiviert', + 'all' => 'Alle', +]; +$emptyLabels = [ + 'active' => 'Aktuell sind keine aktiven Raids geplant.', + 'archived' => 'Es sind keine archivierten Raids vorhanden.', + 'all' => 'Aktuell sind keine Raids vorhanden.', +]; + $pageTitle = 'Raids'; include __DIR__ . '/includes/header.php'; ?>

Raids

-

Anstehende Raid-Termine deiner Gilde.

+

Raid-Termine deiner Gilde.

+
+ $label): ?> + + +
@@ -26,7 +47,7 @@ include __DIR__ . '/includes/header.php';
-

Aktuell sind keine Raids geplant.

+

@@ -40,6 +61,8 @@ include __DIR__ . '/includes/header.php'; $gearscore = trim((string) ($raid['gearscore'] ?? '')); $maxSlots = (int) ($raid['max_slots'] ?? 0); $signups = is_array($raid['signups'] ?? null) ? $raid['signups'] : []; + $isArchived = !empty($raid['archived']) || !empty($raid['archived_at']); + $archivedAt = $raid['archived_at'] ?? null; $groupNames = array_values(array_filter(array_map('trim', explode(',', (string) ($raid['groups'] ?? ''))))); @@ -49,10 +72,15 @@ include __DIR__ . '/includes/header.php'; $signupsByGroup[$groupNumber][] = $signup; } ?> -
+

- / angemeldet +
+ + Archiviert + + / angemeldet +