Files
coolify/app/Livewire/Storage/Show.php
T
6b07f03107 feat(terminal): interactive console mode for containers (docker attach) (#11538)
Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Co-authored-by: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: rosslh <ross@rosshill.ca>
2026-10-14 14:32:02 +02:00

65 lines
1.7 KiB
PHP

<?php
namespace App\Livewire\Storage;
use App\Models\S3Storage;
use App\Models\ScheduledDatabaseBackup;
use App\Models\ScheduledVolumeBackup;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Livewire\Attributes\On;
use Livewire\Component;
class Show extends Component
{
use AuthorizesRequests;
public $storage = null;
public string $currentRoute = '';
public int $backupCount = 0;
public function mount()
{
$this->storage = S3Storage::ownedByCurrentTeam()->whereUuid(request()->storage_uuid)->first();
if (! $this->storage) {
abort(404);
}
try {
$this->authorize('view', $this->storage);
} catch (AuthorizationException) {
return $this->redirectRoute('storage.index', navigate: true);
}
$this->currentRoute = request()->route()->getName();
$this->backupCount = collect([ScheduledDatabaseBackup::class, ScheduledVolumeBackup::class])
->sum(fn (string $backupModel): int => $backupModel::query()
->usingS3Storage($this->storage->id)
->count());
}
public function delete()
{
try {
$this->authorize('delete', $this->storage);
$this->storage->delete();
return redirectRoute($this, 'storage.index');
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
#[On('storage-status-changed')]
public function refreshStorageStatus(bool $isUsable): void
{
$this->storage->refresh();
}
public function render()
{
return view('livewire.storage.show');
}
}