Private
Public Access
1
0

feat: add pagination for firewall logs in Proxmox component, enhancing log management and user experience with navigation controls

This commit is contained in:
2025-12-04 19:47:51 -05:00
parent 42fcad4854
commit 0adfdb3741
2 changed files with 170 additions and 8 deletions

View File

@@ -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 = [];