feat: add pagination for firewall logs in Proxmox component, enhancing log management and user experience with navigation controls
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
Reference in New Issue
Block a user