Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions app/Livewire/Dashboard/DashboardConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

use App\Actions\Conversions\CreateConversionJobAction;
use App\Actions\Files\StoreUploadedFileAction;
use App\Enums\ConversionStatus;
use App\Exceptions\Files\FileStorageException;
use App\Exceptions\Files\UnsupportedFileFormatException;
use App\Models\ConversionJob;
use App\Models\FileRecord;
use App\Support\Converters\ConverterRegistry;
use App\Support\Converters\DTO\ConverterTarget;
Expand Down Expand Up @@ -309,6 +311,43 @@ private function resetTargetSelection(): void
$this->optionsByTarget = [];
}

public function getCurrentJobProperty(): ?ConversionJob
{
if ($this->currentConversionJobId === null) {
return null;
}

return ConversionJob::query()
->with(['sourceFile', 'resultFile'])
->where('user_id', auth()->id())
->find($this->currentConversionJobId);
}

public function refreshConversionStatus(): void
{
if ($this->currentConversionJobId === null) {
return;
}

$job = ConversionJob::query()
->where('user_id', auth()->id())
->find($this->currentConversionJobId);

if (! $job) {
return;
}

if ($job->status === ConversionStatus::Completed) {
$this->step = 'completed';

return;
}

if ($job->status === ConversionStatus::Failed) {
$this->step = 'failed';
}
}

public function getCurrentFileProperty(): ?FileRecord
{
return $this->currentFileId
Expand Down
19 changes: 19 additions & 0 deletions resources/views/livewire/dashboard/dashboard-converter.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,25 @@ class="flex items-center justify-between gap-4 rounded-[var(--ca-radius-md)] bor
</div>
@endif

@if ($step === 'converting')
<div wire:poll.2s="refreshConversionStatus">
<div class="flex flex-col items-center gap-4 py-8 text-center">
<div class="h-12 w-12 animate-spin rounded-full border-4 border-[var(--ca-border)] border-t-[var(--ca-primary)]"></div>

<div>
<p class="text-base font-semibold text-[var(--ca-text)]">Converting your file</p>
@if ($this->currentJob)
<p class="mt-1 text-sm text-[var(--ca-muted)]">
{{ strtoupper($this->currentJob->source_format) }} → {{ strtoupper($this->currentJob->target_format) }}
</p>
@endif
</div>

<p class="text-xs text-[var(--ca-muted)]">Please keep this page open while we prepare your file.</p>
</div>
</div>
@endif

@if ($step === 'convert' && $this->currentFile)
@php($file = $this->currentFile)
<div class="flex flex-col gap-4">
Expand Down