diff --git a/web/app/Filament/Resources/BackupResource.php b/web/app/Filament/Resources/BackupResource.php index ef35e2f..020a2a2 100644 --- a/web/app/Filament/Resources/BackupResource.php +++ b/web/app/Filament/Resources/BackupResource.php @@ -118,9 +118,9 @@ class BackupResource extends Resource ->label('View Log') ->icon('heroicon-o-document') ->hidden(function (Backup $backup) { - $hide = false; - if ($backup->status === BackupStatus::Completed) { - $hide = true; + $hide = true; + if ($backup->status === BackupStatus::Processing || $backup->status === BackupStatus::Failed) { + $hide = false; } return $hide; }) diff --git a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionBackups.php b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionBackups.php index 77eca05..1d82d09 100644 --- a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionBackups.php +++ b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptionBackups.php @@ -91,16 +91,6 @@ class ManageHostingSubscriptionBackups extends ManageRelatedRecords public function table(Table $table): Table { - - $findHostingSubscription = HostingSubscriptionBackup::where('hosting_subscription_id', $this->record->id) - ->where('status', 'processing') - ->get(); - if ($findHostingSubscription->count() > 0) { - foreach ($findHostingSubscription as $backup) { - $backup->checkBackup(); - } - } - return $table ->recordTitleAttribute('file_name') ->columns([ @@ -145,13 +135,14 @@ class ManageHostingSubscriptionBackups extends ManageRelatedRecords return redirect($tempUrl); }), + Tables\Actions\Action::make('viewLog') ->label('View Log') ->icon('heroicon-o-document') ->hidden(function (HostingSubscriptionBackup $backup) { - $hide = false; - if ($backup->status === BackupStatus::Completed) { - $hide = true; + $hide = true; + if ($backup->status === BackupStatus::Processing || $backup->status === BackupStatus::Failed) { + $hide = false; } return $hide; }) diff --git a/web/app/Models/HostingSubscriptionBackup.php b/web/app/Models/HostingSubscriptionBackup.php index 524922c..1e2bffe 100644 --- a/web/app/Models/HostingSubscriptionBackup.php +++ b/web/app/Models/HostingSubscriptionBackup.php @@ -126,6 +126,7 @@ class HostingSubscriptionBackup extends Model if (Str::contains($checkProcess, $this->process_id)) { $this->size = 0; + $this->backup_log = "Backup is started with process id: $this->process_id"; $this->save(); return [ @@ -134,6 +135,7 @@ class HostingSubscriptionBackup extends Model ]; } else { $this->status = 'failed'; + $this->backup_log = "Backup failed. Process not found"; $this->save(); return [ 'status' => 'failed', @@ -155,12 +157,13 @@ class HostingSubscriptionBackup extends Model ]; } - if ($this->status == BackupStatus::Processing) { + if ($this->status !== BackupStatus::Pending) { return [ - 'status' => 'processing', - 'message' => 'Backup is already processing' + 'status' => 'failed', + 'message' => 'Backup already started' ]; } + $findMainDomain = Domain::where('hosting_subscription_id', $findHostingSubscription->id) ->where('is_main', 1) ->first();