refactor: restore direct loading of firewall logs in Proxmox component, simplifying event dispatching and improving log update handling
This commit is contained in:
@@ -58,7 +58,7 @@ class Firewall extends Component
|
||||
$this->loadFirewallOptions();
|
||||
$this->loadFirewallRules();
|
||||
$this->loadNetworkAdapters();
|
||||
// Note: loadFirewallLogs() is now called only once via API on page load
|
||||
$this->loadFirewallLogs();
|
||||
}
|
||||
|
||||
protected function loadAvailableIps(): void
|
||||
@@ -797,25 +797,6 @@ class Firewall extends Component
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch firewall logs via API call - returns logs as JSON
|
||||
* This is called only once on page load via Alpine.js
|
||||
*/
|
||||
public function fetchFirewallLogs(): void
|
||||
{
|
||||
$this->loadFirewallLogs();
|
||||
$this->dispatch('firewall-logs-loaded', [
|
||||
'logs' => $this->firewallLogs,
|
||||
'error' => $this->logError,
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Livewire\Attributes\On('fetchFirewallLogsAction')]
|
||||
public function handleFetchFirewallLogs(): void
|
||||
{
|
||||
$this->loadFirewallLogs();
|
||||
}
|
||||
|
||||
public function loadFirewallLogs(): void
|
||||
{
|
||||
$this->logError = '';
|
||||
@@ -957,8 +938,8 @@ class Firewall extends Component
|
||||
$this->logError = 'No firewall logs available. Ensure firewall logging is enabled in Proxmox (Datacenter > Firewall > Options).';
|
||||
}
|
||||
|
||||
// Dispatch event to frontend with logs data
|
||||
$this->dispatch('firewall-logs-loaded', logs: $this->firewallLogs, error: '');
|
||||
// Dispatch event to update frontend without full re-render
|
||||
$this->dispatch('logs-updated', logs: $this->firewallLogs);
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
if (method_exists($e, 'response') && $e->response()) {
|
||||
@@ -979,9 +960,6 @@ class Firewall extends Component
|
||||
'vm_id' => $this->server->vm_id,
|
||||
]);
|
||||
$this->firewallLogs = [];
|
||||
|
||||
// Dispatch error event to frontend
|
||||
$this->dispatch('firewall-logs-loaded', logs: [], error: $this->logError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1260,4 +1238,3 @@ class Firewall extends Component
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user