diff --git a/extensions/Servers/Proxmox/Livewire/Firewall.php b/extensions/Servers/Proxmox/Livewire/Firewall.php index dcbd38723..2321c0669 100644 --- a/extensions/Servers/Proxmox/Livewire/Firewall.php +++ b/extensions/Servers/Proxmox/Livewire/Firewall.php @@ -157,6 +157,10 @@ class Firewall extends Component public array $firewallLogs = []; public int $logLimit = 1000; public string $logError = ''; + + // Pagination for logs + public int $currentPage = 1; + public int $perPage = 50; // Available IPs for rules public array $availableIps = []; @@ -1239,6 +1243,50 @@ class Firewall extends Component } } + // ==================== LOG PAGINATION ==================== + + public function getPaginatedLogsProperty(): array + { + $reversedLogs = array_reverse($this->firewallLogs); + $offset = ($this->currentPage - 1) * $this->perPage; + return array_slice($reversedLogs, $offset, $this->perPage); + } + + public function getTotalPagesProperty(): int + { + return (int)ceil(count($this->firewallLogs) / $this->perPage); + } + + public function goToPage(int $page): void + { + $totalPages = $this->getTotalPagesProperty(); + if ($page >= 1 && $page <= $totalPages) { + $this->currentPage = $page; + } + } + + public function previousPage(): void + { + if ($this->currentPage > 1) { + $this->currentPage--; + } + } + + public function nextPage(): void + { + if ($this->currentPage < $this->getTotalPagesProperty()) { + $this->currentPage++; + } + } + + public function updatedPerPage(): void + { + // Reset to page 1 when changing per-page value + $this->currentPage = 1; + } + + // ==================== LOG PARSING ==================== + protected function parseFirewallLogs(array $rawLogs): array { $parsed = []; diff --git a/extensions/Servers/Proxmox/views/firewall.blade.php b/extensions/Servers/Proxmox/views/firewall.blade.php index 545e2a690..fea4839ad 100644 --- a/extensions/Servers/Proxmox/views/firewall.blade.php +++ b/extensions/Servers/Proxmox/views/firewall.blade.php @@ -730,7 +730,36 @@