upload-limit v0.1

This commit is contained in:
Milos Holba
2020-11-04 12:48:15 +01:00
committed by Peter Papp
parent 1c62da4e7c
commit 2b4060cb7b
9 changed files with 169 additions and 74 deletions
+25 -4
View File
@@ -10,7 +10,7 @@ const Helpers = {
Vue.prototype.$updateText = debounce(function (route, name, value) {
let enableEmptyInput = ['mimetypes_blacklist' , 'google_analytics']
let enableEmptyInput = ['mimetypes_blacklist' , 'google_analytics' , 'upload_limit']
if (value === '' && !enableEmptyInput.includes(name)) return
@@ -148,8 +148,8 @@ const Helpers = {
if (error.response.status === 500)
isNotGeneralError = false
//Break if mimetype of file is in blacklist
if(error.response.status === 415)
//Break if mimetype of file is in blacklist or file size exceed upload limit
if(error.response.status === 415 || 413)
isNotGeneralError = false
// Show Error
@@ -177,7 +177,7 @@ const Helpers = {
if (files.length == 0) return
if (!this.$checkFileMimetype(files)) return
if (!this.$checkFileMimetype(files) || !this.$checkUploadLimit(files)) return
this.$handleUploading(files, undefined)
}
@@ -307,6 +307,27 @@ const Helpers = {
}
return validated
}
Vue.prototype.$checkUploadLimit = function (files) {
let uploadLimit = store.getters.config.uploadLimit
let validate = true
for (let i = 0 ; i<files.length; i++ ) {
if(files[i].size > uploadLimit * 1000000 ) {
validate = false
events.$emit('alert:open', {
emoji: '😬😬😬',
title: i18n.t('popup_upload_limit.title'),
message: i18n.t('popup_upload_limit.message', {uploadLimit: uploadLimit}),
})
break
}else {
validate = true
}
}
return validate
}
}
}