[pleroma#36] Add upload errors

This commit is contained in:
Rinpatch 2018-12-08 18:23:21 +03:00
parent fb5261b926
commit ba188eddab
5 changed files with 14 additions and 2 deletions

View file

@ -21,6 +21,10 @@ const mediaUpload = {
uploadFile (file) {
const self = this
const store = this.$store
if (file.size > store.state.instance.uploadlimit) {
self.$emit('upload-failed', 'upload_error_file_too_big')
return
}
const formData = new FormData()
formData.append('media', file)

View file

@ -262,6 +262,11 @@ const PostStatusForm = {
let index = this.newStatus.files.indexOf(fileInfo)
this.newStatus.files.splice(index, 1)
},
uploadFailed (errString) {
errString = errString || 'upload_error'
this.error = this.$t('post_status.' + errString)
this.enableSubmit()
},
disableSubmit () {
this.submitDisabled = true
},

View file

@ -64,7 +64,7 @@
</div>
</div>
<div class='form-bottom'>
<media-upload @uploading="disableSubmit" @uploaded="addMediaFile" @upload-failed="enableSubmit" :drop-files="dropFiles"></media-upload>
<media-upload @uploading="disableSubmit" @uploaded="addMediaFile" @upload-failed="uploadFailed" :drop-files="dropFiles"></media-upload>
<p v-if="isOverLengthLimit" class="error">{{ charactersLeft }}</p>
<p class="faint" v-else-if="hasStatusLengthLimit">{{ charactersLeft }}</p>