Skip to content

Commit 1cdac4b

Browse files
committed
Add handler for failed export.
1 parent 52e89e7 commit 1cdac4b

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/Livewire/ExportButtonComponent.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ class ExportButtonComponent extends Component
1414

1515
public $exporting = false;
1616
public $exportFinished = false;
17+
public $exportFailed = false;
1718
public $batchJobId = null;
1819

1920
public function export($batchJobId)
2021
{
2122
$this->batchJobId = $batchJobId;
23+
$this->exportFinished = false;
24+
$this->exportFailed = false;
2225
$this->exporting = true;
2326
}
2427

@@ -34,6 +37,7 @@ public function getExportBatchProperty()
3437
public function updateExportProgress()
3538
{
3639
$this->exportFinished = $this->exportBatch->finished();
40+
$this->exportFailed = $this->exportBatch->hasFailures();
3741

3842
if ($this->exportFinished) {
3943
$this->exporting = false;
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
<div class="d-flex align-items-center" x-data>
2-
<form class="mr-2"
3-
x-on:submit.prevent="
2+
<form class="mr-2"
3+
x-on:submit.prevent="
44
$refs.exportBtn.disabled = true;
55
var url = window._buildUrl(LaravelDataTables['{{ $tableId }}'], 'exportQueue');
66
$.get(url + '&exportType={{$type}}').then(function(exportId) {
77
$wire.export(exportId)
88
});
99
"
10-
>
11-
<button type="submit"
12-
x-ref="exportBtn"
13-
:disabled="$wire.exporting"
14-
class="btn btn-primary"
15-
>Export</button>
16-
</form>
10+
>
11+
<button type="submit"
12+
x-ref="exportBtn"
13+
:disabled="$wire.exporting"
14+
class="btn btn-primary"
15+
>Export</button>
16+
</form>
1717

1818
@if($exporting && !$exportFinished)
1919
<div class="d-inline" wire:poll="updateExportProgress">Exporting...please wait.</div>
2020
@endif
2121

22-
@if($exportFinished)
22+
@if($exportFinished && !$exportFailed)
2323
<span>Done. Download file <a href="#" class="text-primary" wire:click.prevent="downloadExport">here</a></span>
2424
@endif
25+
26+
@if($exportFailed)
27+
<span>Export failed, please try again later.</span>
28+
@endif
2529
</div>

0 commit comments

Comments
 (0)