feat: optimize Proxmox statistics loading by preloading data on mount and reducing cache TTL for faster updates

This commit is contained in:
2025-12-01 12:14:10 -05:00
parent bbe6231328
commit 0c4a8f764d
2 changed files with 24 additions and 7 deletions

View File

@@ -4341,7 +4341,8 @@
console.warn('Failed to dispatch Proxmox stats event:', e);
}
// After a short delay, check if expected charts have received any data.
// After a shorter delay, check if expected charts have received any data.
// Reduced from 3000ms to 800ms for faster loading
setTimeout(function () {
var allExpectedChartsHaveData =
(!cpuChartExpected || cpuChartHasData) &&
@@ -4362,10 +4363,10 @@
} else {
console.warn('Max stats retry attempts reached; some charts may not have data.');
}
}, 3000);
}, 800);
}
// Start the retry loop
// Start the retry loop immediately
statsRetryAttempts = 0;
requestStatsOnce();
}
@@ -4440,12 +4441,23 @@
diskChart.render();
}
// After charts are initialized, request stats with a short
// retry loop to ensure data is received even if the first
// request or event is missed.
// Request stats immediately - don't wait for charts to fully render
// This speeds up initial data loading
dispatchStatsWithRetry();
});
}
// Trigger initial stats request as soon as possible, before charts are ready
// This allows backend to start fetching data in parallel with chart initialization
if (typeof Livewire !== 'undefined') {
setTimeout(function() {
try {
Livewire.dispatch('proxmox:stats');
} catch (e) {
console.warn('Early stats dispatch failed:', e);
}
}, 100);
}
// Set up event listeners - these persist across Livewire navigation
function setupEventListeners() {