diff --git a/frontend/components/organisms/documents/DocumentUploadForm.vue b/frontend/components/organisms/documents/DocumentUploadForm.vue index 623ae1d3..6159728a 100644 --- a/frontend/components/organisms/documents/DocumentUploadForm.vue +++ b/frontend/components/organisms/documents/DocumentUploadForm.vue @@ -18,7 +18,7 @@ type="error" dismissible > - {{ $t('errors.fileCannotUpload') }} + {{ $t('errors.fileCannotUpload') + errorMsg }}

{{ $t('dataset.importDataMessage1') }}

{{ $t('dataset.importDataMessage2') }} { - this.reset() - this.cancel() + this.errors = [] + const promises = [] + const id = this.$route.params.id + const type = this.selectedFormat.type + this.file.forEach((item) => { + promises.push({ + projectId: id, + format: type, + file: item }) - .catch(() => { + }) + let p = Promise.resolve() + promises.forEach((item) => { + p = p.then(() => this.uploadDocument(item)).catch(() => { + this.errors.push(item.file.name) this.showError = true }) + }) + p.finally(() => { + if (!this.errors.length) { + this.reset() + this.cancel() + } else { + this.errorMsg = this.errors.join(', ') + } + }) } } } diff --git a/frontend/i18n/en/projects/dataset.js b/frontend/i18n/en/projects/dataset.js index ac8cccd1..d645083b 100644 --- a/frontend/i18n/en/projects/dataset.js +++ b/frontend/i18n/en/projects/dataset.js @@ -9,7 +9,7 @@ export default { annotate: 'Annotate', importDataTitle: 'Upload Data', importDataMessage1: 'Select a file format', - importDataMessage2: 'Select a file', + importDataMessage2: 'Select file(s)', importDataPlaceholder: 'File input', exportDataTitle: 'Export Data', exportDataMessage: 'Select a file format', diff --git a/frontend/i18n/en/projects/errors.js b/frontend/i18n/en/projects/errors.js index f84d04a9..fcb93846 100644 --- a/frontend/i18n/en/projects/errors.js +++ b/frontend/i18n/en/projects/errors.js @@ -1,5 +1,5 @@ export default { - fileCannotUpload: 'The file could not be uploaded. Maybe invalid format.\n Please check available formats carefully.', + fileCannotUpload: 'The file(s) could not be uploaded. Maybe invalid format.\n Please check available formats and the following file(s): ', labelCannotCreate: 'The label could not be created.\n You cannot use the same label name or shortcut key.', invalidUserOrPass: 'Incorrect username or password, or something went wrong.' } diff --git a/frontend/rules/index.js b/frontend/rules/index.js index 3f5219b3..51224440 100644 --- a/frontend/rules/index.js +++ b/frontend/rules/index.js @@ -57,7 +57,7 @@ export const fileFormatRules = (msg) => { export const uploadFileRules = (msg) => { return [ v => !!v || msg.fileRequired, - v => !v || v.size < 1000000 || msg.fileLessThan1MB + v => !v || v.some(file => file.size < 1000000) || msg.fileLessThan1MB ] }