From e17ff99c5b79c3f8b030168e3cc6cbbf4bdd8176 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 15 Sep 2023 15:50:37 +0200 Subject: [PATCH] fix: missing upgrade js --- app/Http/Livewire/Upgrade.php | 2 +- resources/views/layouts/base.blade.php | 36 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/Http/Livewire/Upgrade.php b/app/Http/Livewire/Upgrade.php index 46f97027a..d5ff62a64 100644 --- a/app/Http/Livewire/Upgrade.php +++ b/app/Http/Livewire/Upgrade.php @@ -36,7 +36,7 @@ public function upgrade() } $this->showProgress = true; resolve(UpdateCoolify::class)(true); - Toaster::success("Upgrading to {$this->latestVersion} version..."); + $this->emit('success', "Upgrading to {$this->latestVersion} version..."); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php index 4e6ed3cdf..b3376ca14 100644 --- a/resources/views/layouts/base.blade.php +++ b/resources/views/layouts/base.blade.php @@ -58,6 +58,42 @@ function changePasswordFieldType(event) { } } + function revive() { + if (checkHealthInterval) return true; + console.log('Checking server\'s health...') + checkHealthInterval = setInterval(() => { + fetch('/api/health') + .then(response => { + if (response.ok) { + Toaster.success('Coolify is back online. Reloading...') + if (checkHealthInterval) clearInterval(checkHealthInterval); + setTimeout(() => { + window.location.reload(); + }, 5000) + } else { + console.log('Waiting for server to come back from dead...'); + } + }) + }, 2000); + } + + function upgrade() { + if (checkIfIamDeadInterval) return true; + console.log('Update initiated.') + checkIfIamDeadInterval = setInterval(() => { + fetch('/api/health') + .then(response => { + if (response.ok) { + console.log('It\'s alive. Waiting for server to be dead...'); + } else { + Toaster.success('Update done, restarting Coolify!') + console.log('It\'s dead. Reviving... Standby... Bzz... Bzz...') + if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval); + revive(); + } + }) + }, 2000); + } function copyToClipboard(text) { navigator.clipboard.writeText(text); Livewire.emit('success', 'Copied to clipboard.');