Refactor upgrade status to use Livewire instead of API endpoint

- Remove /api/upgrade-status endpoint and route
- Add getUpgradeStatus() method to Upgrade Livewire component
- Update frontend to call Livewire method via $wire.getUpgradeStatus()
- Simpler approach: no separate API, auth handled by Livewire

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-12-12 21:37:32 +01:00
parent d111f448f5
commit deb9a7dab0
4 changed files with 92 additions and 153 deletions
+24 -37
View File
@@ -284,45 +284,32 @@
this.currentStatus = 'Starting upgrade...';
this.serviceDown = false;
// Poll upgrade status API for real progress
this.checkUpgradeStatusInterval = setInterval(() => {
fetch('/api/upgrade-status', {
credentials: 'same-origin',
headers: {
'Accept': 'application/json',
// Poll upgrade status via Livewire
this.checkUpgradeStatusInterval = setInterval(async () => {
try {
const data = await this.$wire.getUpgradeStatus();
if (data.status === 'in_progress') {
this.currentStep = this.mapStepToUI(data.step);
this.currentStatus = data.message;
} else if (data.status === 'complete') {
this.showSuccess();
} else if (data.status === 'error') {
this.currentStatus = `Error: ${data.message}`;
}
})
.then(response => {
if (response.ok) {
return response.json();
} catch (error) {
// Service is down - switch to health check mode
console.log('Livewire unavailable, switching to health check mode');
if (!this.serviceDown) {
this.serviceDown = true;
this.currentStep = 4;
this.currentStatus = 'Coolify is restarting with the new version...';
if (this.checkUpgradeStatusInterval) {
clearInterval(this.checkUpgradeStatusInterval);
this.checkUpgradeStatusInterval = null;
}
// Auth errors (401/403) or service down - switch to health check
throw new Error('Service unavailable');
})
.then(data => {
if (data.status === 'in_progress') {
this.currentStep = this.mapStepToUI(data.step);
this.currentStatus = data.message;
} else if (data.status === 'complete') {
this.showSuccess();
} else if (data.status === 'error') {
this.currentStatus = `Error: ${data.message}`;
}
})
.catch(error => {
// Service is down - switch to health check mode
console.log('Upgrade status API unavailable, switching to health check mode');
if (!this.serviceDown) {
this.serviceDown = true;
this.currentStep = 4;
this.currentStatus = 'Coolify is restarting with the new version...';
if (this.checkUpgradeStatusInterval) {
clearInterval(this.checkUpgradeStatusInterval);
this.checkUpgradeStatusInterval = null;
}
this.revive();
}
});
this.revive();
}
}
}, 2000);
}
}))