mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-22 08:04:19 +02:00
feat: Add manual update check functionality to settings page
This commit is contained in:
parent
af41ed26ba
commit
d3085e1ade
@ -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 @@ public function updatedUpdateCheckFrequency()
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
|
@ -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()
|
||||
|
@ -13,7 +13,7 @@ public function up(): void
|
||||
{
|
||||
Schema::table('instance_settings', function (Blueprint $table) {
|
||||
$table->string('auto_update_frequency')->default('0 0 * * *')->nullable();
|
||||
$table->string('update_check_frequency')->default('0 */11 * * *')->nullable();
|
||||
$table->string('update_check_frequency')->default('0 * * * *')->nullable();
|
||||
$table->boolean('new_version_available')->default(false);
|
||||
});
|
||||
}
|
||||
|
@ -18,8 +18,8 @@
|
||||
<x-forms.input id="settings.fqdn" label="Instance's Domain" placeholder="https://coolify.io" />
|
||||
<x-forms.input id="settings.instance_name" label="Instance's Name" placeholder="Coolify" />
|
||||
<h4 class="w-full pt-6">DNS Validation</h4>
|
||||
<div class="flex flex-wrap items-end gap-2 md:w-96">
|
||||
<x-forms.checkbox instantSave id="is_dns_validation_enabled" label="Enable DNS validation" />
|
||||
<div class="md:w-96">
|
||||
<x-forms.checkbox instantSave id="is_dns_validation_enabled" label="Enabled" />
|
||||
</div>
|
||||
<x-forms.input id="settings.custom_dns_servers" label="DNS Servers"
|
||||
helper="DNS servers for validation FQDNs againts. A comma separated list of DNS servers."
|
||||
@ -42,31 +42,31 @@
|
||||
</form>
|
||||
|
||||
<h4 class="pt-6">Advanced</h4>
|
||||
|
||||
|
||||
<h5 class="pt-4 font-bold text-white">Auto Update</h5>
|
||||
@if (!is_null(env('AUTOUPDATE', null)))
|
||||
<div class="text-right md:w-96">
|
||||
<x-forms.checkbox instantSave helper="AUTOUPDATE is set in .env file, you need to modify it there." disabled
|
||||
id="is_auto_update_enabled" label="Enabled" />
|
||||
</div>
|
||||
@else
|
||||
<div class="text-right md:w-96">
|
||||
<x-forms.checkbox instantSave id="is_auto_update_enabled" label="Enabled" />
|
||||
</div>
|
||||
<div class="flex gap-2 ">
|
||||
@if ($is_auto_update_enabled)
|
||||
<x-forms.input id="auto_update_frequency" label="Auto Update Frequency" placeholder="0 0 * * *"
|
||||
helper="Cron expression for auto update frequency (automatically update coolify). Default is every day at 00:00" />
|
||||
@endif
|
||||
<x-forms.input id="update_check_frequency" label="Update Check Frequency" placeholder="0 */11 * * *"
|
||||
helper="Cron expression for update check frequency (check for new Coolify versions and pull new Service Templates from CDN). Default is every 12 hours at 11:00 and 23:00" />
|
||||
</div>
|
||||
@endif
|
||||
<h5 class="pt-4 font-bold text-white">Others</h5>
|
||||
<div class="text-right md:w-96">
|
||||
<x-forms.checkbox instantSave id="is_registration_enabled" label="Registration Allowed" />
|
||||
<x-forms.checkbox instantSave id="do_not_track" label="Do Not Track" />
|
||||
</div>
|
||||
</div>
|
||||
<h5 class="pt-4 font-bold text-white">Update</h5>
|
||||
<div class="text-right md:w-96">
|
||||
@if (!is_null(env('AUTOUPDATE', null)))
|
||||
<div class="text-right md:w-96">
|
||||
<x-forms.checkbox instantSave helper="AUTOUPDATE is set in .env file, you need to modify it there."
|
||||
disabled id="is_auto_update_enabled" label="Enabled" />
|
||||
</div>
|
||||
@else
|
||||
<x-forms.checkbox instantSave id="is_auto_update_enabled" label="Auto Update Enabled" />
|
||||
@endif
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex items-end gap-2">
|
||||
<x-forms.input id="update_check_frequency" label="Update Check Frequency" placeholder="0 * * * *"
|
||||
helper="Cron expression for update check frequency (check for new Coolify versions and pull new Service Templates from CDN). Default is every hour." />
|
||||
<x-forms.button wire:click='checkManually'>Check Manually</x-forms.button>
|
||||
</div>
|
||||
|
||||
@if (is_null(env('AUTOUPDATE', null)) && $is_auto_update_enabled)
|
||||
<x-forms.input id="auto_update_frequency" label="Auto Update Frequency" placeholder="0 0 * * *"
|
||||
helper="Cron expression for auto update frequency (automatically update coolify). Default is every day at 00:00" />
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user