{{-- Import rows of Importer (#2957 slice 4d, card #3018). Included by import/index only. Expects: $data (collection of grouped imports from Company::imports(), with jobs_left, running_jobs and package_limit_reached). Same status words, links and conditions as the old table: - Status: Pågår while a sub job runs; Väntar på dig (package limit or waiting for columns) or I kö while jobs are left; otherwise the word of the stored status. - Väntar på dig (waiting): Fortsätt goes to the column mapping (imports.edit). - Klar with no jobs left: the file name and "Visa resultat" open imports.show. - Running: a progress bar; with the package limit reached, a link to imports.show. - Ta bort rapport (DELETE imports.destroy) for every import that is not working, in "Mer", confirmed in the native dialog below (without dialog support it submits directly). --}} @php $pageRows = \App\Support\TablePagination::rows($data); $types = Import::_get('statusTypes'); $shortDate = fn ($date) => \App\Support\DisplayDate::timestamp($date); @endphp {{ __('import.nh.columnFile') }}{{ __('import.nh.columnCreated') }}{{ __('import.nh.columnActions') }} @foreach ($pageRows as $import) @php $json = json_decode($import->json, true); $filename = is_array($json) && isset($json['filename']) ? $json['filename'] : null; $label = $filename === 'TextAreaImport.csv' ? __('import.textImport') : $filename; $packageLimit = $import->package_limit_reached == 1; if ($import->jobs_left > 0 && $import->running_jobs > 0) { [$word, $pill] = [$types['working'], 'running']; } elseif ($import->jobs_left > 0) { [$word, $pill] = $packageLimit || $import->status == $types['waiting'] ? [$types['waiting'], $packageLimit ? 'stopped' : 'neutral'] : [$types['queue'], 'planned']; } else { [$word, $pill] = [$import->status, [$types['done'] => 'done', $types['failed'] => 'stopped', $types['packageLimitReached'] => 'stopped'][$import->status] ?? 'neutral']; } $waiting = $import->status == $types['waiting']; $finished = $import->status == $types['done'] && $import->jobs_left == 0; $queued = $import->status == $types['queue']; $running = ! $waiting && ! $finished && ! $queued && isset($import->total, $import->current_count); if ($running) { $total = $import->total == 0 ? 1 : $import->total; $percent = 100 - (($import->current_count / $total) * 100); $percent = $percent == 100 ? 99 : $percent; } @endphp @if ($finished && $label !== null) {{ $label }} @elseif ($finished) {{ __('import.nh.somethingWrong') }} @elseif ($label !== null) {{ $label }} @endif {{ __('import.statusText.'.$word) }} @if ($running) {{ __('import.nh.progress', ['percent' => (int) ceil($percent)]) }} @if ($packageLimit) {{ __('import.index.packageLimitReached') }} @endif @endif @if ($waiting) {{ __('import.editBtn') }} @elseif ($finished && $label !== null) {{ __('import.nh.openResult') }} @endif @if ($import->status != $types['working'])
@csrf @method('DELETE')
@endif
@endforeach {{ trans_choice('import.nh.count', $data->count(), ['count' => formatNumber($data->count())]) }}

{{ __('import.nh.deleteTitle') }}

{{ __('import.nh.deleteText') }}

@push('scripts') @endpush