fix
This commit is contained in:
parent
766a3d490a
commit
cdf6e600bd
@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Livewire;
|
|
||||||
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class CheckUpdate extends Component
|
|
||||||
{
|
|
||||||
public $updateAvailable = false;
|
|
||||||
public $latestVersion = 'latest';
|
|
||||||
protected $currentVersion;
|
|
||||||
protected $image = 'ghcr.io/coollabsio/coolify';
|
|
||||||
|
|
||||||
public function checkUpdate()
|
|
||||||
{
|
|
||||||
$this->latestVersion = get_latest_version_of_coolify();
|
|
||||||
$this->currentVersion = config('version');
|
|
||||||
if ($this->latestVersion === 'latest') {
|
|
||||||
$this->updateAvailable = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
version_compare($this->currentVersion, $this->latestVersion, '<') ? $this->updateAvailable = true : $this->updateAvailable = false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,6 +9,18 @@ use Livewire\Component;
|
|||||||
class Upgrade extends Component
|
class Upgrade extends Component
|
||||||
{
|
{
|
||||||
public bool $showProgress = false;
|
public bool $showProgress = false;
|
||||||
|
public bool $isUpgradeAvailable = false;
|
||||||
|
|
||||||
|
public function checkUpdate()
|
||||||
|
{
|
||||||
|
$latestVersion = get_latest_version_of_coolify();
|
||||||
|
$currentVersion = config('version');
|
||||||
|
version_compare($currentVersion, $latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false;
|
||||||
|
if (config('app.env') === 'local') {
|
||||||
|
$this->isUpgradeAvailable = true;
|
||||||
|
}
|
||||||
|
ray($this->isUpgradeAvailable);
|
||||||
|
}
|
||||||
public function upgrade()
|
public function upgrade()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -67,9 +67,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li title="New version available">
|
<livewire:upgrade />
|
||||||
<livewire:upgrade />
|
|
||||||
</li>
|
|
||||||
@endif
|
@endif
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<div>
|
|
||||||
<x-forms.button wire:click='checkUpdate' type="submit">
|
|
||||||
Check Update</x-forms.button>
|
|
||||||
@if ($updateAvailable)
|
|
||||||
Update available
|
|
||||||
@endif
|
|
||||||
</div>
|
|
@ -1,64 +1,69 @@
|
|||||||
<div x-data wire:click='upgrade' x-on:click="upgrade" @class([
|
<li title="New version available" x-init="$wire.checkUpdate">
|
||||||
'bg-gradient-to-r from-purple-500 via-pink-500 to-red-500' => !$showProgress,
|
@if ($isUpgradeAvailable)
|
||||||
'hover:bg-transparent focus:bg-transparent' => $showProgress,
|
<div x-data wire:click='upgrade' class=" hover:bg-transparent focus:bg-transparent" x-on:click="upgrade" <button>
|
||||||
])>
|
@if ($showProgress)
|
||||||
<button>
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
@if ($showProgress)
|
class="w-6 h-6 text-pink-500 transition-colors hover:text-pink-300 lds-heart" viewBox="0 0 24 24"
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 text-pink-500 lds-heart" viewBox="0 0 24 24"
|
stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
|
||||||
stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
stroke-linejoin="round">
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
<path d="M19.5 13.572l-7.5 7.428l-7.5 -7.428m0 0a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572" />
|
<path d="M19.5 13.572l-7.5 7.428l-7.5 -7.428m0 0a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572" />
|
||||||
</svg>
|
</svg>
|
||||||
@else
|
@else
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 text-white " viewBox="0 0 24 24" stroke-width="1.5"
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
class="w-6 h-6 text-pink-500 transition-colors hover:text-pink-300" viewBox="0 0 24 24"
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
|
||||||
<path
|
stroke-linejoin="round">
|
||||||
d="M9 12h-3.586a1 1 0 0 1 -.707 -1.707l6.586 -6.586a1 1 0 0 1 1.414 0l6.586 6.586a1 1 0 0 1 -.707 1.707h-3.586v3h-6v-3z" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
<path d="M9 21h6" />
|
<path
|
||||||
<path d="M9 18h6" />
|
d="M9 12h-3.586a1 1 0 0 1 -.707 -1.707l6.586 -6.586a1 1 0 0 1 1.414 0l6.586 6.586a1 1 0 0 1 -.707 1.707h-3.586v3h-6v-3z" />
|
||||||
</svg>
|
<path d="M9 21h6" />
|
||||||
@endif
|
<path d="M9 18h6" />
|
||||||
</button>
|
</svg>
|
||||||
<script>
|
@endif
|
||||||
let checkHealthInterval = null;
|
</button>
|
||||||
let checkIfIamDeadInterval = null;
|
|
||||||
|
|
||||||
function revive() {
|
<script>
|
||||||
console.log('Checking server\'s health...')
|
let checkHealthInterval = null;
|
||||||
checkHealthInterval = setInterval(() => {
|
let checkIfIamDeadInterval = null;
|
||||||
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...');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return;
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function upgrade() {
|
function revive() {
|
||||||
console.log('Update initiated.')
|
console.log('Checking server\'s health...')
|
||||||
checkIfIamDeadInterval = setInterval(() => {
|
checkHealthInterval = setInterval(() => {
|
||||||
fetch('/api/health')
|
fetch('/api/health')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
console.log('It\'s alive. Waiting for server to be dead...');
|
Toaster.success('Coolify is back online. Reloading...')
|
||||||
} else {
|
if (checkHealthInterval) clearInterval(checkHealthInterval);
|
||||||
Toaster.success('Update done, restarting Coolify!')
|
setTimeout(() => {
|
||||||
console.log('It\'s dead. Reviving... Standby... Bzz... Bzz...')
|
window.location.reload();
|
||||||
if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval);
|
}, 5000)
|
||||||
revive();
|
} else {
|
||||||
}
|
console.log('Waiting for server to come back from dead...');
|
||||||
})
|
}
|
||||||
return;
|
})
|
||||||
}, 2000);
|
return;
|
||||||
}
|
}, 2000);
|
||||||
</script>
|
}
|
||||||
</div>
|
|
||||||
|
function upgrade() {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user