Files
coolify/app/Livewire/Project/Database/Backup/Execution.php
T
Andras Bacsai fa1895c99a feat(dashboard): add canvas view with active deployment overlay
Add a /dashboard/canvas page that renders every team server with its
resources and their running or queued deployments, backed by a new
ServerCanvasController::dashboard endpoint and a per-server usage
endpoint for zone headers. The dashboard remembers the list/canvas
choice and each section (projects, servers) its own table/grid view.

- Show Deploying/Queued pills on canvas cards and a foldable recent
  deployments panel; add shared CanvasControls component
- Allow backup downloads from the server host via the S3 download
  storage (PrepareFileDownloadJob accepts a null container)
- Extract backup toggle/run actions into ManagesDatabaseBackup and
  surface them in backup execution headers; merge S3 and retention
  sections into the general backup settings
- Move deployments indicator to the top bar and add a main nav
  resource menu with submenus; simplify breadcrumbs and settings
  layouts
- Add shared variables overview canvas and scheduled task modals
- Add feature tests for dashboard canvas, view modes, navbar
  submenus, backup S3 downloads and scheduled task modals
2026-10-14 23:55:28 +02:00

115 lines
3.4 KiB
PHP

<?php
namespace App\Livewire\Project\Database\Backup;
use App\Livewire\Concerns\ManagesDatabaseBackup;
use App\Livewire\Project\Database\BackupEdit;
use App\Models\S3Storage;
use App\Models\ScheduledDatabaseBackup;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
use Livewire\Features\SupportRedirects\Redirector;
class Execution extends Component
{
use AuthorizesRequests;
use ManagesDatabaseBackup;
public $database;
public ?ScheduledDatabaseBackup $backup;
public $executions;
public $s3s;
public array $parameters = [];
public string $section = 'general';
public function getListeners(): array
{
// Keep the header backup actions in sync when the database starts/stops.
$listeners = [
'databaseUpdated' => '$refresh',
'backupEnabledChanged' => 'syncBackupEnabled',
];
$user = Auth::user();
if ($user) {
$listeners["echo-private:user.{$user->id},DatabaseStatusChanged"] = '$refresh';
}
return $listeners;
}
public function mount()
{
$backup_uuid = request()->route('backup_uuid');
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
if (! $project) {
return redirect()->route('dashboard');
}
$environment = $project->load(['environments'])->environments->where('uuid', request()->route('environment_uuid'))->first();
if (! $environment) {
abort(404);
}
$environment->load(['applications']);
$database = $environment->databases()->where('uuid', request()->route('database_uuid'))->first();
if (! $database) {
return redirect()->route('dashboard');
}
$backup = $database->scheduledBackups->where('uuid', $backup_uuid)->first();
if (! $backup) {
return redirect()->route('dashboard');
}
$executions = collect($backup->executions)->sortByDesc('created_at');
$this->database = $database;
$this->backup = $backup;
$this->executions = $executions;
$this->s3s = S3Storage::query()
->where('team_id', $database->team()->id)
->where('is_usable', true)
->get();
$this->parameters = get_route_parameters();
$this->section = match (request()->route()?->getName()) {
'project.database.backup.executions' => 'executions',
'project.database.backup.danger' => 'danger',
default => 'general',
};
}
public function backupNow(): Redirector|RedirectResponse|null
{
try {
return $this->queueDatabaseBackup($this->backup);
} catch (\Throwable $e) {
handleError($e, $this);
return null;
}
}
public function toggleEnabled(): void
{
try {
$this->toggleDatabaseBackup($this->backup);
$this->dispatch('backupEnabledChanged')->to(BackupEdit::class);
} catch (\Throwable $e) {
$this->dispatch('error', $e->getMessage());
}
}
public function syncBackupEnabled(): void
{
$this->backup->refresh();
}
public function render()
{
return view('livewire.project.database.backup.execution');
}
}