From 8b817dad8729a78acbdc3f8c64e05f887a28b55c Mon Sep 17 00:00:00 2001 From: andrasbacsai Date: Tue, 6 Aug 2024 12:04:23 +0000 Subject: [PATCH] Fix styling --- app/Console/Kernel.php | 8 ++++---- app/Jobs/CheckForUpdatesJob.php | 2 +- app/Jobs/PullCoolifyImageJob.php | 2 +- app/Jobs/UpdateCoolifyJob.php | 15 +++++++++------ app/Livewire/Settings/Configuration.php | 14 ++++++++------ 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index aafda266e..8b1978d6f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,6 +2,7 @@ namespace App\Console; +use App\Jobs\CheckForUpdatesJob; use App\Jobs\CheckLogDrainContainerJob; use App\Jobs\CleanupInstanceStuffsJob; use App\Jobs\ContainerStatusJob; @@ -15,7 +16,6 @@ use App\Jobs\ScheduledTaskJob; use App\Jobs\ServerCheckJob; use App\Jobs\ServerStatusJob; use App\Jobs\UpdateCoolifyJob; -use App\Jobs\CheckForUpdatesJob; use App\Models\InstanceSettings; use App\Models\ScheduledDatabaseBackup; use App\Models\ScheduledTask; @@ -83,11 +83,11 @@ class Kernel extends ConsoleKernel $settings = InstanceSettings::get(); $updateCheckFrequency = $settings->update_check_frequency ?? '0 0 * * *'; - $schedule->job(new CheckForUpdatesJob())->cron($updateCheckFrequency)->onOneServer(); + $schedule->job(new CheckForUpdatesJob)->cron($updateCheckFrequency)->onOneServer(); if ($settings->is_auto_update_enabled) { $autoUpdateFrequency = $settings->auto_update_frequency ?? '0 11,23 * * *'; - $schedule->job(new UpdateCoolifyJob())->cron($autoUpdateFrequency)->onOneServer(); + $schedule->job(new UpdateCoolifyJob)->cron($autoUpdateFrequency)->onOneServer(); } } @@ -214,4 +214,4 @@ class Kernel extends ConsoleKernel require base_path('routes/console.php'); } -} \ No newline at end of file +} diff --git a/app/Jobs/CheckForUpdatesJob.php b/app/Jobs/CheckForUpdatesJob.php index e18e37ed6..111baba8e 100644 --- a/app/Jobs/CheckForUpdatesJob.php +++ b/app/Jobs/CheckForUpdatesJob.php @@ -41,4 +41,4 @@ class CheckForUpdatesJob implements ShouldBeEncrypted, ShouldQueue // Consider implementing a notification to administrators } } -} \ No newline at end of file +} diff --git a/app/Jobs/PullCoolifyImageJob.php b/app/Jobs/PullCoolifyImageJob.php index 624dc4414..f0912493f 100644 --- a/app/Jobs/PullCoolifyImageJob.php +++ b/app/Jobs/PullCoolifyImageJob.php @@ -47,4 +47,4 @@ class PullCoolifyImageJob implements ShouldBeEncrypted, ShouldQueue throw $e; } } -} \ No newline at end of file +} diff --git a/app/Jobs/UpdateCoolifyJob.php b/app/Jobs/UpdateCoolifyJob.php index 5c8e8e679..4da6025b4 100644 --- a/app/Jobs/UpdateCoolifyJob.php +++ b/app/Jobs/UpdateCoolifyJob.php @@ -2,6 +2,7 @@ namespace App\Jobs; +use App\Actions\Server\UpdateCoolify; use App\Models\InstanceSettings; use App\Models\Server; use Illuminate\Bus\Queueable; @@ -10,7 +11,6 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; -use App\Actions\Server\UpdateCoolify; use Illuminate\Support\Facades\Log; class UpdateCoolifyJob implements ShouldBeEncrypted, ShouldQueue @@ -23,19 +23,22 @@ class UpdateCoolifyJob implements ShouldBeEncrypted, ShouldQueue { try { $settings = InstanceSettings::get(); - if (!$settings->is_auto_update_enabled) { + if (! $settings->is_auto_update_enabled) { Log::info('Auto-update is disabled. Skipping update check.'); + return; } - if (!$settings->new_version_available) { + if (! $settings->new_version_available) { Log::info('No new version available. Skipping update.'); + return; } $server = Server::findOrFail(0); - if (!$server) { + if (! $server) { Log::error('Server not found. Cannot proceed with update.'); + return; } @@ -46,8 +49,8 @@ class UpdateCoolifyJob implements ShouldBeEncrypted, ShouldQueue Log::info('Coolify update completed successfully.'); } catch (\Throwable $e) { - Log::error('UpdateCoolifyJob failed: ' . $e->getMessage()); + Log::error('UpdateCoolifyJob failed: '.$e->getMessage()); // Consider implementing a notification to administrators } } -} \ No newline at end of file +} diff --git a/app/Livewire/Settings/Configuration.php b/app/Livewire/Settings/Configuration.php index 60cd46907..d13bd79c1 100644 --- a/app/Livewire/Settings/Configuration.php +++ b/app/Livewire/Settings/Configuration.php @@ -4,8 +4,8 @@ namespace App\Livewire\Settings; use App\Models\InstanceSettings as ModelsInstanceSettings; use App\Models\Server; -use Livewire\Component; use Cron\CronExpression; +use Livewire\Component; class Configuration extends Component { @@ -91,13 +91,15 @@ class Configuration extends Component } $this->validate(); - if ($this->is_auto_update_enabled && !$this->validateCronExpression($this->auto_update_frequency)) { + if ($this->is_auto_update_enabled && ! $this->validateCronExpression($this->auto_update_frequency)) { $this->dispatch('error', 'Invalid Cron / Human expression for Auto Update Frequency.'); + return; } - if (!$this->validateCronExpression($this->update_check_frequency)) { + if (! $this->validateCronExpression($this->update_check_frequency)) { $this->dispatch('error', 'Invalid Cron / Human expression for Update Check Frequency.'); + return; } @@ -163,15 +165,15 @@ class Configuration extends Component public function updatedAutoUpdateFrequency() { - if (!$this->validateCronExpression($this->auto_update_frequency)) { + if (! $this->validateCronExpression($this->auto_update_frequency)) { $this->dispatch('error', 'Invalid Cron / Human expression for Auto Update Frequency.'); } } public function updatedUpdateCheckFrequency() { - if (!$this->validateCronExpression($this->update_check_frequency)) { + if (! $this->validateCronExpression($this->update_check_frequency)) { $this->dispatch('error', 'Invalid Cron / Human expression for Update Check Frequency.'); } } -} \ No newline at end of file +}