feat: Add manual update check functionality to settings page

This commit is contained in:
Andras Bacsai
2024-08-07 11:42:55 +02:00
parent af41ed26ba
commit d3085e1ade
4 changed files with 48 additions and 31 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Livewire\Settings;
use App\Jobs\CheckForUpdatesJob;
use App\Models\InstanceSettings;
use App\Models\Server;
use Cron\CronExpression;
@@ -182,6 +183,18 @@ class Index extends Component
}
}
public function checkManually()
{
CheckForUpdatesJob::dispatchSync();
$this->dispatch('updateAvailable');
$settings = InstanceSettings::get();
if ($settings->new_version_available) {
$this->dispatch('success', 'New version available!');
} else {
$this->dispatch('success', 'No new version available.');
}
}
public function render()
{
return view('livewire.settings.index');

View File

@@ -3,6 +3,7 @@
namespace App\Livewire;
use App\Actions\Server\UpdateCoolify;
use App\Models\InstanceSettings;
use Livewire\Component;
class Upgrade extends Component
@@ -15,14 +16,17 @@ class Upgrade extends Component
public string $latestVersion = '';
protected $listeners = ['updateAvailable' => 'checkUpdate'];
public function checkUpdate()
{
$this->latestVersion = get_latest_version_of_coolify();
$currentVersion = config('version');
version_compare($currentVersion, $this->latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false;
if (isDev()) {
$this->isUpgradeAvailable = true;
try {
$settings = InstanceSettings::get();
$this->isUpgradeAvailable = $settings->new_version_available;
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
public function upgrade()