Skip to content

Commit c8ca57e

Browse files
Add chunk size input
1 parent 911773c commit c8ca57e

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

public/js/data-synchronize.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/data-synchronize.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ $(() => {
7171
dropzone.removeAllFiles()
7272
}
7373

74-
const importData = (fileName, offset, limit = $form.data('chunk-size'), total = 0) => {
74+
const importData = (fileName, offset, limit = parseInt($form.find('input[name=chunk_size]').val()), total = 0) => {
7575
formData.set('file_name', fileName)
7676
formData.set('offset', offset)
7777
formData.set('limit', limit)
@@ -92,7 +92,7 @@ $(() => {
9292
.catch(() => cleanup())
9393
}
9494

95-
const validate = (fileName, offset, limit = $form.data('chunk-size')) => {
95+
const validate = (fileName, offset, limit = parseInt($form.find('input[name=chunk_size]').val())) => {
9696
formData.set('file_name', fileName)
9797
formData.set('offset', offset)
9898
formData.set('limit', limit)

resources/lang/en/data-synchronize.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
'dropzone_message' => 'Drag and drop file here or click to upload',
1717
'allowed_extensions' => 'Choose a file with following extensions: :extensions.',
1818
'import_button' => 'Import',
19+
'chunk_size' => 'Chunk size',
20+
'chunk_size_helper' => 'The number of rows to be imported at a time is defined by the chunk size. Increase this value if you have a large file and data is imported very fast. Decrease this value if you encounter memory limits or gateway timeout issues when importing data.',
1921
],
2022

2123
'example' => [

resources/views/partials/importer.blade.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
:data-import-url="$importer->getImportUrl()"
1414
data-bb-toggle="import-form"
1515
:data-accepted-files="$acceptedFiles"
16-
:data-chunk-size="$importer->chunkSize()"
1716
:data-uploading-message="trans('packages/data-synchronize::data-synchronize.import.uploading_message')"
1817
:data-validate-failed-message="trans('packages/data-synchronize::data-synchronize.import.validating_failed_message')"
1918
class="data-synchronize-import-form"
@@ -54,7 +53,7 @@ class="data-synchronize-import-form"
5453

5554
{!! apply_filters('data_synchronize_import_form_before', null, $importer) !!}
5655

57-
<div>
56+
<div class="mb-3">
5857
<div class="dropzone">
5958
<div class="dz-message">
6059
{{ trans('packages/data-synchronize::data-synchronize.import.form.dropzone_message') }}
@@ -66,6 +65,14 @@ class="data-synchronize-import-form"
6665
</x-core::form.helper-text>
6766
</div>
6867

68+
<div class="mb-3">
69+
<x-core::form.label for="chunk-size">{{ trans('packages/data-synchronize::data-synchronize.import.form.chunk_size') }}</x-core::form.label>
70+
<x-core::form.text-input type="number" class="form-control" id="chunk-size" name="chunk_size" value="{{ $importer->chunkSize() }}" />
71+
<x-core::form.helper-text>
72+
{{ trans('packages/data-synchronize::data-synchronize.import.form.chunk_size_helper') }}
73+
</x-core::form.helper-text>
74+
</div>
75+
6976
{!! apply_filters('data_synchronize_import_form_after', null, $importer) !!}
7077

7178
<pre class="mt-3 data-synchronize-import-output" style="display: none"></pre>

0 commit comments

Comments
 (0)