Fix null status handling in overview page
- Add try-catch around loadVmStatus calls in Overview.php - Add null checks in checkStatus method - Wrap entire overview content in @if(\) / @else block - Show friendly error state with retry button when status unavailable
This commit is contained in:
@@ -43,7 +43,11 @@ class Overview extends Component
|
||||
parent::mount($server);
|
||||
|
||||
if (is_null($this->status)) {
|
||||
$this->loadVmStatus();
|
||||
try {
|
||||
$this->loadVmStatus();
|
||||
} catch (\Throwable $e) {
|
||||
\Log::error('Overview: Failed to load VM status', ['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->hostname = $server->hostname ?? ($this->status->name ?? '');
|
||||
@@ -60,9 +64,24 @@ class Overview extends Component
|
||||
|
||||
public function checkStatus()
|
||||
{
|
||||
$currentStatus = $this->status->status;
|
||||
$this->loadVmStatus();
|
||||
if ($this->status->status != $currentStatus) {
|
||||
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) {
|
||||
$this->fastPolling = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user