refactor
This commit is contained in:
parent
c26407fa7e
commit
662b191dfd
@ -26,7 +26,7 @@ public function configuration()
|
||||
return view('project.database.configuration', ['database' => $database]);
|
||||
}
|
||||
|
||||
public function backup_logs()
|
||||
public function executions()
|
||||
{
|
||||
$backup_uuid = request()->route('backup_uuid');
|
||||
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||
@ -45,8 +45,8 @@ public function backup_logs()
|
||||
if (!$backup) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
$backup_executions = collect($backup->executions)->sortByDesc('created_at');
|
||||
return view('project.database.backups.logs', ['database' => $database, 'backup' => $backup, 'backup_executions' => $backup_executions]);
|
||||
$executions = collect($backup->executions)->sortByDesc('created_at');
|
||||
return view('project.database.backups.executions', ['database' => $database, 'backup' => $backup, 'executions' => $executions]);
|
||||
}
|
||||
|
||||
public function backups()
|
||||
|
@ -12,6 +12,6 @@ class BackupExecutions extends Component
|
||||
|
||||
public function refreshBackupExecutions(): void
|
||||
{
|
||||
$this->executions = collect($this->backup->executions)->sortByDesc('created_at');
|
||||
$this->executions = $this->backup->executions;
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ private function backup_standalone_postgresql()
|
||||
$this->backup_status = 'failed';
|
||||
$this->add_to_backup_output($th->getMessage());
|
||||
ray('Backup failed for ' . $this->database->uuid . ' at ' . $this->server->name . ':' . $this->backup_filename . '\n\nError:' . $th->getMessage());
|
||||
$this->team->notify(new BackupFailed($this->backup, $this->database));
|
||||
$this->team->notify(new BackupFailed($this->backup, $this->database, $this->backup_output));
|
||||
} finally {
|
||||
$this->backup_log->update([
|
||||
'status' => $this->backup_status,
|
||||
|
@ -17,9 +17,9 @@ class BackupFailed extends Notification implements ShouldQueue
|
||||
public string $message = 'Backup FAILED';
|
||||
|
||||
|
||||
public function __construct(ScheduledDatabaseBackup $backup, public $database)
|
||||
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $output)
|
||||
{
|
||||
$this->message = "❌ Database backup for {$database->name} with frequency of $backup->frequency was FAILED.";
|
||||
$this->message = "❌ Database backup for {$database->name} with frequency of $backup->frequency was FAILED.\n\nReason: $output";
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
|
@ -1,10 +1,11 @@
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex flex-col gap-2 flex-col-reverse">
|
||||
@forelse($executions as $execution)
|
||||
<form class="border-1 bg-coolgray-300 p-2 border-dotted flex flex-col"
|
||||
@class([
|
||||
'border-green-500' => data_get($execution,'status') === 'success',
|
||||
'border-red-500' => data_get($execution,'status') === 'failed',
|
||||
])>
|
||||
<div>Started At: {{data_get($execution,'created_at')}}</div>
|
||||
<div>Status: {{data_get($execution,'status')}}</div>
|
||||
@if(data_get($execution,'message'))
|
||||
<div>Message: {{data_get($execution,'message')}}</div>
|
||||
@ -18,5 +19,4 @@
|
||||
@empty
|
||||
<div>No executions found.</div>
|
||||
@endforelse
|
||||
|
||||
</div>
|
||||
|
@ -14,6 +14,6 @@
|
||||
<div class="pt-6">
|
||||
<livewire:project.database.backup-edit :backup="$backup"/>
|
||||
<h3 class="py-4">Executions</h3>
|
||||
<livewire:project.database.backup-executions :backup="$backup" :executions="$backup_executions"/>
|
||||
<livewire:project.database.backup-executions :backup="$backup" :executions="$executions"/>
|
||||
</div>
|
||||
</x-layout>
|
@ -64,7 +64,7 @@
|
||||
// Databases
|
||||
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}', [DatabaseController::class, 'configuration'])->name('project.database.configuration');
|
||||
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}/backups', [DatabaseController::class, 'backups'])->name('project.database.backups.all');
|
||||
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}/backups/{backup_uuid}', [DatabaseController::class, 'backup_logs'])->name('project.database.backups.logs');
|
||||
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}/backups/{backup_uuid}', [DatabaseController::class, 'executions'])->name('project.database.backups.executions');
|
||||
});
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user