refactor
This commit is contained in:
parent
c26407fa7e
commit
662b191dfd
@ -26,7 +26,7 @@ class DatabaseController extends Controller
|
|||||||
return view('project.database.configuration', ['database' => $database]);
|
return view('project.database.configuration', ['database' => $database]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function backup_logs()
|
public function executions()
|
||||||
{
|
{
|
||||||
$backup_uuid = request()->route('backup_uuid');
|
$backup_uuid = request()->route('backup_uuid');
|
||||||
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
@ -45,8 +45,8 @@ class DatabaseController extends Controller
|
|||||||
if (!$backup) {
|
if (!$backup) {
|
||||||
return redirect()->route('dashboard');
|
return redirect()->route('dashboard');
|
||||||
}
|
}
|
||||||
$backup_executions = collect($backup->executions)->sortByDesc('created_at');
|
$executions = collect($backup->executions)->sortByDesc('created_at');
|
||||||
return view('project.database.backups.logs', ['database' => $database, 'backup' => $backup, 'backup_executions' => $backup_executions]);
|
return view('project.database.backups.executions', ['database' => $database, 'backup' => $backup, 'executions' => $executions]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function backups()
|
public function backups()
|
||||||
|
@ -12,6 +12,6 @@ class BackupExecutions extends Component
|
|||||||
|
|
||||||
public function refreshBackupExecutions(): void
|
public function refreshBackupExecutions(): void
|
||||||
{
|
{
|
||||||
$this->executions = collect($this->backup->executions)->sortByDesc('created_at');
|
$this->executions = $this->backup->executions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ class DatabaseBackupJob implements ShouldQueue
|
|||||||
$this->backup_status = 'failed';
|
$this->backup_status = 'failed';
|
||||||
$this->add_to_backup_output($th->getMessage());
|
$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());
|
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 {
|
} finally {
|
||||||
$this->backup_log->update([
|
$this->backup_log->update([
|
||||||
'status' => $this->backup_status,
|
'status' => $this->backup_status,
|
||||||
|
@ -17,9 +17,9 @@ class BackupFailed extends Notification implements ShouldQueue
|
|||||||
public string $message = 'Backup FAILED';
|
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
|
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)
|
@forelse($executions as $execution)
|
||||||
<form class="border-1 bg-coolgray-300 p-2 border-dotted flex flex-col"
|
<form class="border-1 bg-coolgray-300 p-2 border-dotted flex flex-col"
|
||||||
@class([
|
@class([
|
||||||
'border-green-500' => data_get($execution,'status') === 'success',
|
'border-green-500' => data_get($execution,'status') === 'success',
|
||||||
'border-red-500' => data_get($execution,'status') === 'failed',
|
'border-red-500' => data_get($execution,'status') === 'failed',
|
||||||
])>
|
])>
|
||||||
|
<div>Started At: {{data_get($execution,'created_at')}}</div>
|
||||||
<div>Status: {{data_get($execution,'status')}}</div>
|
<div>Status: {{data_get($execution,'status')}}</div>
|
||||||
@if(data_get($execution,'message'))
|
@if(data_get($execution,'message'))
|
||||||
<div>Message: {{data_get($execution,'message')}}</div>
|
<div>Message: {{data_get($execution,'message')}}</div>
|
||||||
@ -18,5 +19,4 @@
|
|||||||
@empty
|
@empty
|
||||||
<div>No executions found.</div>
|
<div>No executions found.</div>
|
||||||
@endforelse
|
@endforelse
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,6 +14,6 @@
|
|||||||
<div class="pt-6">
|
<div class="pt-6">
|
||||||
<livewire:project.database.backup-edit :backup="$backup"/>
|
<livewire:project.database.backup-edit :backup="$backup"/>
|
||||||
<h3 class="py-4">Executions</h3>
|
<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>
|
</div>
|
||||||
</x-layout>
|
</x-layout>
|
@ -64,7 +64,7 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
// Databases
|
// 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}', [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', [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 () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user