Refactor Proxmox views for improved styling and consistency
- Updated subdomain.blade.php to enhance button styles and modal transitions. - Changed text colors for better readability and consistency across the UI. - Refactored system.blade.php to unify button components and improve layout structure. - Adjusted modal z-index values for consistent layering. - Enhanced accessibility by ensuring proper text contrast and hover states.
This commit is contained in:
@@ -43,11 +43,7 @@ class Overview extends Component
|
||||
parent::mount($server);
|
||||
|
||||
if (is_null($this->status)) {
|
||||
try {
|
||||
$this->loadVmStatus();
|
||||
} catch (\Throwable $e) {
|
||||
\Log::error('Overview: Failed to load VM status', ['error' => $e->getMessage()]);
|
||||
}
|
||||
$this->loadVmStatus();
|
||||
}
|
||||
|
||||
$this->hostname = $server->hostname ?? ($this->status->name ?? '');
|
||||
@@ -60,86 +56,13 @@ class Overview extends Component
|
||||
} catch (\Exception $e) {
|
||||
$this->notes = '';
|
||||
}
|
||||
|
||||
// Preload Statistics telemetry data in background to warm the cache
|
||||
// This ensures when user navigates to Statistics page, data is already available
|
||||
$this->preloadStatisticsData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preload statistics data to warm the cache for faster Statistics page loading.
|
||||
* Runs as a non-blocking background operation using dispatch_async if available,
|
||||
* otherwise falls back to synchronous cache warming.
|
||||
*/
|
||||
protected function preloadStatisticsData(): void
|
||||
{
|
||||
// Only preload if cache is empty (don't waste resources if already cached)
|
||||
$graphTypes = ['cpu', 'memory', 'network', 'disk'];
|
||||
$timeRange = 'hour';
|
||||
$aggregation = 'average';
|
||||
|
||||
foreach ($graphTypes as $graphType) {
|
||||
$cacheKey = 'proxmox-stats-' . $this->server->id . '-' . $graphType . '-' . $timeRange . '-' . $aggregation;
|
||||
|
||||
// Skip if already cached
|
||||
if (Cache::has($cacheKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Warm the cache in background
|
||||
try {
|
||||
Cache::remember($cacheKey, 30, function () use ($timeRange, $aggregation) {
|
||||
$proxmox = new Proxmox;
|
||||
$stats = $proxmox->request('/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/rrddata', data: [
|
||||
'timeframe' => $timeRange,
|
||||
'cf' => $aggregation === 'maximum' ? 'MAX' : 'AVERAGE',
|
||||
]);
|
||||
|
||||
$rawData = $stats->json()['data'] ?? [];
|
||||
|
||||
// Limit data points to prevent memory issues (same logic as Statistics)
|
||||
$maxPoints = 40;
|
||||
if (count($rawData) > $maxPoints) {
|
||||
$step = ceil(count($rawData) / $maxPoints);
|
||||
$sampledData = [];
|
||||
for ($i = 0; $i < count($rawData); $i += $step) {
|
||||
$sampledData[] = $rawData[$i];
|
||||
}
|
||||
if (end($rawData) !== end($sampledData)) {
|
||||
$sampledData[] = end($rawData);
|
||||
}
|
||||
return $sampledData;
|
||||
}
|
||||
|
||||
return $rawData;
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
// Silently fail - this is just a preload optimization
|
||||
\Log::debug('Overview: Stats preload failed for ' . $graphType, ['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function checkStatus()
|
||||
{
|
||||
if (!$this->status) {
|
||||
try {
|
||||
$this->loadVmStatus();
|
||||
} catch (\Throwable $e) {
|
||||
\Log::error('Overview: checkStatus failed', ['error' => $e->getMessage()]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$currentStatus = $this->status->status ?? null;
|
||||
try {
|
||||
$this->loadVmStatus();
|
||||
} catch (\Throwable $e) {
|
||||
\Log::error('Overview: checkStatus loadVmStatus failed', ['error' => $e->getMessage()]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->status && ($this->status->status ?? null) != $currentStatus) {
|
||||
$currentStatus = $this->status->status;
|
||||
$this->loadVmStatus();
|
||||
if ($this->status->status != $currentStatus) {
|
||||
$this->fastPolling = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user