diff --git a/app/Livewire/Project/Database/BackupExecutions.php b/app/Livewire/Project/Database/BackupExecutions.php index 101bb4593..18ec9cd96 100644 --- a/app/Livewire/Project/Database/BackupExecutions.php +++ b/app/Livewire/Project/Database/BackupExecutions.php @@ -2,11 +2,12 @@ namespace App\Livewire\Project\Database; +use App\Models\ScheduledDatabaseBackup; use Livewire\Component; class BackupExecutions extends Component { - public $backup; + public ?ScheduledDatabaseBackup $backup = null; public $executions = []; public $setDeletableBackup; public function getListeners() @@ -20,8 +21,11 @@ public function getListeners() public function cleanupFailed() { - $this->backup?->executions()->where('status', 'failed')->delete(); - $this->refreshBackupExecutions(); + if ($this->backup) { + $this->backup?->executions()->where('status', 'failed')->delete(); + $this->refreshBackupExecutions(); + $this->dispatch('success', 'Failed backups cleaned up.'); + } } public function deleteBackup($exeuctionId) { @@ -45,6 +49,6 @@ public function download_file($exeuctionId) } public function refreshBackupExecutions(): void { - $this->executions = $this->backup->executions()->get()->sortByDesc('created_at'); + $this->executions = $this->backup?->executions()->get()->sortByDesc('created_at'); } } diff --git a/app/Livewire/Settings/Backup.php b/app/Livewire/Settings/Backup.php index 121b73af8..82b3075c0 100644 --- a/app/Livewire/Settings/Backup.php +++ b/app/Livewire/Settings/Backup.php @@ -36,7 +36,7 @@ class Backup extends Component public function mount() { - $this->backup = $this->database?->scheduledBackups->first() ?? []; + $this->backup = $this->database?->scheduledBackups->first() ?? null; $this->executions = $this->backup?->executions ?? []; } public function add_coolify_database() diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.php index 34e2b965d..dd96e13a9 100644 --- a/resources/views/livewire/project/database/backup-executions.blade.php +++ b/resources/views/livewire/project/database/backup-executions.blade.php @@ -1,54 +1,57 @@
-
-

Executions

- Cleanup Failed Backups -
-
- @forelse($executions as $execution) -
data_get($execution, 'status') === 'success', - 'border-red-500' => data_get($execution, 'status') === 'failed', - ])> - @if (data_get($execution, 'status') === 'running') -
- -
- @endif -
Database: {{ data_get($execution, 'database_name', 'N/A') }}
-
Status: {{ data_get($execution, 'status') }}
-
Started At: {{ data_get($execution, 'created_at') }}
- @if (data_get($execution, 'message')) -
Message: {{ data_get($execution, 'message') }}
- @endif -
Size: {{ data_get($execution, 'size') }} B / - {{ round((int) data_get($execution, 'size') / 1024, 2) }} - kB / {{ round((int) data_get($execution, 'size') / 1024 / 1024, 3) }} MB -
-
Location: {{ data_get($execution, 'filename', 'N/A') }}
-
-
- @if (data_get($execution, 'status') === 'success') - Download + @isset($backup) +
+

Executions

+ Cleanup Failed Backups +
+
+ @forelse($executions as $execution) + data_get($execution, 'status') === 'success', + 'border-red-500' => data_get($execution, 'status') === 'failed', + ])> + @if (data_get($execution, 'status') === 'running') +
+ +
@endif - - - Delete - - This will delete this backup. It is not reversible.
Please think again. -
-
- +
Database: {{ data_get($execution, 'database_name', 'N/A') }}
+
Status: {{ data_get($execution, 'status') }}
+
Started At: {{ data_get($execution, 'created_at') }}
+ @if (data_get($execution, 'message')) +
Message: {{ data_get($execution, 'message') }}
+ @endif +
Size: {{ data_get($execution, 'size') }} B / + {{ round((int) data_get($execution, 'size') / 1024, 2) }} + kB / {{ round((int) data_get($execution, 'size') / 1024 / 1024, 3) }} MB +
+
Location: {{ data_get($execution, 'filename', 'N/A') }}
+
+
+ @if (data_get($execution, 'status') === 'success') + Download + @endif + + + Delete + + This will delete this backup. It is not reversible.
Please think again. +
+
+ + + @empty +
No executions found.
+ @endforelse +
+ + @endisset - @empty -
No executions found.
- @endforelse -
-
diff --git a/resources/views/livewire/settings/backup.blade.php b/resources/views/livewire/settings/backup.blade.php index 7dc1dadd3..cd1d1f428 100644 --- a/resources/views/livewire/settings/backup.blade.php +++ b/resources/views/livewire/settings/backup.blade.php @@ -30,7 +30,6 @@ @endif
-

Executions