diff --git a/app/Events/S3DownloadFinished.php b/app/Events/S3DownloadFinished.php index ddc2ead30..32744cfa6 100644 --- a/app/Events/S3DownloadFinished.php +++ b/app/Events/S3DownloadFinished.php @@ -15,6 +15,8 @@ class S3DownloadFinished implements ShouldBroadcast public int|string|null $userId = null; + public ?string $downloadPath = null; + public function __construct($teamId, $data = null) { if (is_null($data)) { @@ -23,6 +25,7 @@ public function __construct($teamId, $data = null) // Get userId from event data (the user who triggered the download) $this->userId = data_get($data, 'userId'); + $this->downloadPath = data_get($data, 'downloadPath'); $containerName = data_get($data, 'containerName'); $serverId = data_get($data, 'serverId'); @@ -46,4 +49,11 @@ public function broadcastOn(): ?array new PrivateChannel("user.{$this->userId}"), ]; } + + public function broadcastWith(): array + { + return [ + 'downloadPath' => $this->downloadPath, + ]; + } } diff --git a/app/Livewire/Project/Database/Import.php b/app/Livewire/Project/Database/Import.php index 9cf11c26c..ad018a1eb 100644 --- a/app/Livewire/Project/Database/Import.php +++ b/app/Livewire/Project/Database/Import.php @@ -78,9 +78,16 @@ public function getListeners() ]; } - public function handleS3DownloadFinished(): void + public function handleS3DownloadFinished($data): void { $this->s3DownloadInProgress = false; + + // Set the downloaded file path from the event data + $downloadPath = data_get($data, 'downloadPath'); + if (filled($downloadPath)) { + $this->s3DownloadedFile = $downloadPath; + $this->filename = $downloadPath; + } } public function mount() @@ -408,9 +415,6 @@ public function downloadFromS3() 'resourceUuid' => $this->resource->uuid, ]); - $this->s3DownloadedFile = $downloadPath; - $this->filename = $downloadPath; - $this->dispatch('activityMonitor', $activity->id); $this->dispatch('info', 'Downloading file from S3. This may take a few minutes for large backups...'); } catch (\Throwable $e) { diff --git a/resources/views/livewire/project/database/import.blade.php b/resources/views/livewire/project/database/import.blade.php index 2cbfc6943..b8bed1d44 100644 --- a/resources/views/livewire/project/database/import.blade.php +++ b/resources/views/livewire/project/database/import.blade.php @@ -151,7 +151,8 @@
Downloading from S3... This may take a few minutes for large backups.
@if ($s3DownloadInProgress) - + @endif @@ -176,7 +177,8 @@ @if ($importRunning)
- +
@endif @else