Browse Source
Merge pull request #1163 from MrChrissie/feature/bulkimport
Feature: bulkimport for same filetype.
pull/1177/head
Hiroki Nakayama
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
31 additions and
14 deletions
-
frontend/components/organisms/documents/DocumentUploadForm.vue
-
frontend/i18n/en/projects/dataset.js
-
frontend/i18n/en/projects/errors.js
-
frontend/rules/index.js
|
|
@ -18,7 +18,7 @@ |
|
|
|
type="error" |
|
|
|
dismissible |
|
|
|
> |
|
|
|
{{ $t('errors.fileCannotUpload') }} |
|
|
|
{{ $t('errors.fileCannotUpload') + errorMsg }} |
|
|
|
</v-alert> |
|
|
|
<h2>{{ $t('dataset.importDataMessage1') }}</h2> |
|
|
|
<v-radio-group |
|
|
@ -45,6 +45,7 @@ |
|
|
|
<h2>{{ $t('dataset.importDataMessage2') }}</h2> |
|
|
|
<v-file-input |
|
|
|
v-model="file" |
|
|
|
multiple |
|
|
|
:accept="acceptType" |
|
|
|
:rules="uploadFileRules($t('rules.uploadFileRules'))" |
|
|
|
:label="$t('labels.filePlaceholder')" |
|
|
@ -81,7 +82,9 @@ export default { |
|
|
|
selectedFormat: null, |
|
|
|
fileFormatRules, |
|
|
|
uploadFileRules, |
|
|
|
showError: false |
|
|
|
showError: false, |
|
|
|
errors: [], |
|
|
|
errorMsg: '' |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
@ -107,18 +110,32 @@ export default { |
|
|
|
}, |
|
|
|
create() { |
|
|
|
if (this.validate()) { |
|
|
|
this.uploadDocument({ |
|
|
|
projectId: this.$route.params.id, |
|
|
|
format: this.selectedFormat.type, |
|
|
|
file: this.file |
|
|
|
}) |
|
|
|
.then((response) => { |
|
|
|
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(', ') |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
@ -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', |
|
|
|
|
|
@ -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.' |
|
|
|
} |
|
|
@ -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 |
|
|
|
] |
|
|
|
} |
|
|
|
|
|
|
|