From 49905aa97e497c56a6dc96faa82695e273cb93c3 Mon Sep 17 00:00:00 2001 From: duffyduck Date: Fri, 1 May 2026 09:36:40 +0200 Subject: [PATCH] Monitoring: Pagination mit Seitenzahlen + Anfang/Ende-Buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vorher: nur "Zurück / Weiter". Jetzt: [«] [‹] [1] [2] [3] [4] [5*] [6] [7] [8] [9] [10] [›] [»] 10 Seitenzahlen-Buttons, current centered (clamped an Anfang/Ende). Zusätzlich Doppelpfeile für erste/letzte Seite. Kompakt + verständlich auch bei 50+ Seiten. Helper paginationWindow() rechnet das Fenster aus, sodass bei totalPages <= 10 alle gezeigt werden, sonst current ungefähr mittig mit Clamp an die Ränder. Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/src/pages/settings/Monitoring.tsx | 76 +++++++++++++++++++--- 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/settings/Monitoring.tsx b/frontend/src/pages/settings/Monitoring.tsx index e84d59d4..34ea3bf0 100644 --- a/frontend/src/pages/settings/Monitoring.tsx +++ b/frontend/src/pages/settings/Monitoring.tsx @@ -8,7 +8,22 @@ import Button from '../../components/ui/Button'; import Input from '../../components/ui/Input'; import Select from '../../components/ui/Select'; import Modal from '../../components/ui/Modal'; -import { ArrowLeft, Send, RefreshCw, Mail, ShieldAlert, ChevronLeft, ChevronRight, Trash2 } from 'lucide-react'; +import { ArrowLeft, Send, RefreshCw, Mail, ShieldAlert, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, Trash2 } from 'lucide-react'; + +/** + * Liefert die anzuzeigenden Seitenzahlen für die Pagination. + * Bis zu 10 Seitenzahlen, current möglichst mittig. + */ +function paginationWindow(current: number, total: number, size = 10): number[] { + if (total <= size) return Array.from({ length: total }, (_, i) => i + 1); + let start = Math.max(1, current - Math.floor(size / 2)); + let end = start + size - 1; + if (end > total) { + end = total; + start = end - size + 1; + } + return Array.from({ length: end - start + 1 }, (_, i) => start + i); +} const TYPE_OPTIONS: { value: SecurityEventType | ''; label: string }[] = [ { value: '', label: 'Alle Typen' }, @@ -305,15 +320,56 @@ export default function Monitoring() { )} {pagination && pagination.totalPages > 1 && ( -
- Seite {pagination.page} von {pagination.totalPages} ({pagination.total} Einträge) -
- - +
+ + Seite {pagination.page} von {pagination.totalPages} ({pagination.total} Einträge) + +
+ + + {paginationWindow(page, pagination.totalPages, 10).map((p) => ( + + ))} + +
)}