|
|
@ -45,9 +45,7 @@ const ProfileTab = {
|
|
|
|
banner: null,
|
|
|
|
banner: null,
|
|
|
|
bannerPreview: null,
|
|
|
|
bannerPreview: null,
|
|
|
|
background: null,
|
|
|
|
background: null,
|
|
|
|
backgroundPreview: null,
|
|
|
|
backgroundPreview: null
|
|
|
|
bannerUploadError: null,
|
|
|
|
|
|
|
|
backgroundUploadError: null
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
components: {
|
|
|
@ -162,18 +160,18 @@ const ProfileTab = {
|
|
|
|
if (file.size > this.$store.state.instance[slot + 'limit']) {
|
|
|
|
if (file.size > this.$store.state.instance[slot + 'limit']) {
|
|
|
|
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
|
|
|
|
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
|
|
|
|
const allowedsize = fileSizeFormatService.fileSizeFormat(this.$store.state.instance[slot + 'limit'])
|
|
|
|
const allowedsize = fileSizeFormatService.fileSizeFormat(this.$store.state.instance[slot + 'limit'])
|
|
|
|
this[slot + 'UploadError'] = [
|
|
|
|
this.$store.dispatch('pushGlobalNotice', {
|
|
|
|
this.$t('upload.error.base'),
|
|
|
|
messageKey: 'upload.error.message',
|
|
|
|
this.$t(
|
|
|
|
messageArgs: [
|
|
|
|
'upload.error.file_too_big',
|
|
|
|
this.$t('upload.error.file_too_big', {
|
|
|
|
{
|
|
|
|
|
|
|
|
filesize: filesize.num,
|
|
|
|
filesize: filesize.num,
|
|
|
|
filesizeunit: filesize.unit,
|
|
|
|
filesizeunit: filesize.unit,
|
|
|
|
allowedsize: allowedsize.num,
|
|
|
|
allowedsize: allowedsize.num,
|
|
|
|
allowedsizeunit: allowedsize.unit
|
|
|
|
allowedsizeunit: allowedsize.unit
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
],
|
|
|
|
].join(' ')
|
|
|
|
level: 'error'
|
|
|
|
|
|
|
|
})
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
@ -213,8 +211,9 @@ const ProfileTab = {
|
|
|
|
that.$store.commit('setCurrentUser', user)
|
|
|
|
that.$store.commit('setCurrentUser', user)
|
|
|
|
resolve()
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
.catch((error) => {
|
|
|
|
reject(new Error(that.$t('upload.error.base') + ' ' + err.message))
|
|
|
|
that.displayUploadError(error)
|
|
|
|
|
|
|
|
reject(error)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -235,24 +234,27 @@ const ProfileTab = {
|
|
|
|
this.$store.commit('setCurrentUser', user)
|
|
|
|
this.$store.commit('setCurrentUser', user)
|
|
|
|
this.bannerPreview = null
|
|
|
|
this.bannerPreview = null
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
.catch(this.displayUploadError)
|
|
|
|
this.bannerUploadError = this.$t('upload.error.base') + ' ' + err.message
|
|
|
|
.finally(() => { this.bannerUploading = false })
|
|
|
|
})
|
|
|
|
|
|
|
|
.then(() => { this.bannerUploading = false })
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
submitBackground (background) {
|
|
|
|
submitBackground (background) {
|
|
|
|
if (!this.backgroundPreview && background !== '') { return }
|
|
|
|
if (!this.backgroundPreview && background !== '') { return }
|
|
|
|
|
|
|
|
|
|
|
|
this.backgroundUploading = true
|
|
|
|
this.backgroundUploading = true
|
|
|
|
this.$store.state.api.backendInteractor.updateProfileImages({ background }).then((data) => {
|
|
|
|
this.$store.state.api.backendInteractor.updateProfileImages({ background })
|
|
|
|
if (!data.error) {
|
|
|
|
.then((data) => {
|
|
|
|
this.$store.commit('addNewUsers', [data])
|
|
|
|
this.$store.commit('addNewUsers', [data])
|
|
|
|
this.$store.commit('setCurrentUser', data)
|
|
|
|
this.$store.commit('setCurrentUser', data)
|
|
|
|
this.backgroundPreview = null
|
|
|
|
this.backgroundPreview = null
|
|
|
|
} else {
|
|
|
|
})
|
|
|
|
this.backgroundUploadError = this.$t('upload.error.base') + data.error
|
|
|
|
.catch(this.displayUploadError)
|
|
|
|
}
|
|
|
|
.finally(() => { this.backgroundUploading = false })
|
|
|
|
this.backgroundUploading = false
|
|
|
|
},
|
|
|
|
|
|
|
|
displayUploadError (error) {
|
|
|
|
|
|
|
|
this.$store.dispatch('pushGlobalNotice', {
|
|
|
|
|
|
|
|
messageKey: 'upload.error.message',
|
|
|
|
|
|
|
|
messageArgs: [error.message],
|
|
|
|
|
|
|
|
level: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|