From 801898e295a2e187cb9c1055eeca6f01990a8bc4 Mon Sep 17 00:00:00 2001 From: "Joseph.Rawlings" Date: Wed, 17 Dec 2025 19:29:46 -0500 Subject: [PATCH] refactor: streamline data loading process in Statistics and overview views for improved performance --- .../Servers/Proxmox/Livewire/Statistics.php | 34 ++-- .../Servers/Proxmox/views/overview.blade.php | 14 +- .../Proxmox/views/statistics.blade.php | 171 +++++++----------- 3 files changed, 93 insertions(+), 126 deletions(-) diff --git a/extensions/Servers/Proxmox/Livewire/Statistics.php b/extensions/Servers/Proxmox/Livewire/Statistics.php index 9de9d690a..7842e2e52 100644 --- a/extensions/Servers/Proxmox/Livewire/Statistics.php +++ b/extensions/Servers/Proxmox/Livewire/Statistics.php @@ -152,23 +152,25 @@ class Statistics extends Component { parent::mount($server); $this->server->loadMissing('ipAddresses'); - // Network Analysis is loaded lazily via JavaScript to improve page load speed - // Initialize error state if not configured to prevent infinite loading - if (!$this->coreRouterEnabled()) { - $this->networkAnalysis['error'] = 'Core Router API is not configured.'; - $this->networkAnalysis['connections'] = []; - $this->networkAnalysis['topConnections'] = []; - $this->networkAnalysis['topPorts'] = []; - $this->networkAnalysis['security'] = []; - } - // Preload graph data on mount to speed up initial display - // Dispatch individual chart events for more reliable parallel loading - // Each chart loads independently so a failure in one doesn't block others - $this->dispatch('proxmox:stats:cpu'); - $this->dispatch('proxmox:stats:memory'); - $this->dispatch('proxmox:stats:network'); - $this->dispatch('proxmox:stats:disk'); + // Data loading is deferred to loadInitialData() which is triggered via wire:init + // This ensures JavaScript charts are fully initialized before data events are dispatched + } + + /** + * Load all initial data for the statistics page. + * Called via wire:init to ensure JavaScript is ready to receive the data. + */ + public function loadInitialData(): void + { + // Fetch graph data - each dispatch includes the actual data for JavaScript charts + $this->fetchGraphData('cpu', $this->cpuTimeRange, $this->cpuAggregation); + $this->fetchGraphData('memory', $this->memoryTimeRange, $this->memoryAggregation); + $this->fetchGraphData('network', $this->networkTimeRange, $this->networkAggregation); + $this->fetchGraphData('disk', $this->diskTimeRange, $this->diskAggregation); + + // Load Network Analysis + $this->loadNetworkAnalysis(); } #[On('proxmox:stats')] diff --git a/extensions/Servers/Proxmox/views/overview.blade.php b/extensions/Servers/Proxmox/views/overview.blade.php index 93cc48a74..1731a8a00 100644 --- a/extensions/Servers/Proxmox/views/overview.blade.php +++ b/extensions/Servers/Proxmox/views/overview.blade.php @@ -86,7 +86,7 @@ -

Server Overview

@@ -342,7 +342,7 @@ @endphp -
+
@foreach($resourceAllocations as $resource)
@@ -464,7 +464,7 @@
- +
@if($hostnameError)
{{ $hostnameError }}
@@ -635,11 +635,11 @@
- +
- +
@if($passwordError)
{{ $passwordError }}
@@ -727,7 +727,7 @@

- + Important Note

@@ -1026,7 +1026,7 @@

@if($isEditingNotes)
- @if($notesError) diff --git a/extensions/Servers/Proxmox/views/statistics.blade.php b/extensions/Servers/Proxmox/views/statistics.blade.php index 88a5d7d21..70fe8fe48 100644 --- a/extensions/Servers/Proxmox/views/statistics.blade.php +++ b/extensions/Servers/Proxmox/views/statistics.blade.php @@ -2,7 +2,7 @@ @once @endonce -
+