Update: cover modal toasts

This commit is contained in:
Nicholas Wallace 2024-08-28 22:23:52 -07:00
parent 10c93ed9c6
commit 74b0d145ac
4 changed files with 18 additions and 13 deletions

View file

@ -78,14 +78,14 @@ export default {
if (data.error) { if (data.error) {
this.$toast.error(data.error) this.$toast.error(data.error)
} else { } else {
this.$toast.success('Cover Uploaded') this.$toast.success(this.$strings.ToastCoverUploaded)
this.resetCoverPreview() this.resetCoverPreview()
} }
this.processingUpload = false this.processingUpload = false
}) })
.catch((error) => { .catch((error) => {
console.error('Failed', error) console.error('Failed', error)
var errorMsg = error.response && error.response.data ? error.response.data : 'Unknown Error' var errorMsg = error.response && error.response.data ? error.response.data : this.$strings.ToastUnknownError
this.$toast.error(errorMsg) this.$toast.error(errorMsg)
this.processingUpload = false this.processingUpload = false
}) })
@ -95,7 +95,7 @@ export default {
var success = await this.$axios.$post(`/api/${this.entity}/${this.entityId}/cover`, { url: this.imageUrl }).catch((error) => { var success = await this.$axios.$post(`/api/${this.entity}/${this.entityId}/cover`, { url: this.imageUrl }).catch((error) => {
console.error('Failed to download cover from url', error) console.error('Failed to download cover from url', error)
var errorMsg = error.response && error.response.data ? error.response.data : 'Unknown Error' var errorMsg = error.response && error.response.data ? error.response.data : this.$strings.ToastUnknownError
this.$toast.error(errorMsg) this.$toast.error(errorMsg)
return false return false
}) })

View file

@ -194,7 +194,7 @@ export default {
if (data.error) { if (data.error) {
this.$toast.error(data.error) this.$toast.error(data.error)
} else { } else {
this.$toast.success('Cover Uploaded') this.$toast.success(this.$strings.ToastCoverUploaded)
this.resetCoverPreview() this.resetCoverPreview()
} }
this.processingUpload = false this.processingUpload = false
@ -204,7 +204,7 @@ export default {
if (error.response && error.response.data) { if (error.response && error.response.data) {
this.$toast.error(error.response.data) this.$toast.error(error.response.data)
} else { } else {
this.$toast.error('Oops, something went wrong...') this.$toast.error(this.$strings.ToastUnknownError)
} }
this.processingUpload = false this.processingUpload = false
}) })
@ -255,7 +255,7 @@ export default {
}, },
async updateCover(cover) { async updateCover(cover) {
if (!cover.startsWith('http:') && !cover.startsWith('https:')) { if (!cover.startsWith('http:') && !cover.startsWith('https:')) {
this.$toast.error('Invalid URL') this.$toast.error(this.$strings.ToastInvalidUrl)
return return
} }
@ -264,11 +264,11 @@ export default {
.$post(`/api/items/${this.libraryItemId}/cover`, { url: cover }) .$post(`/api/items/${this.libraryItemId}/cover`, { url: cover })
.then(() => { .then(() => {
this.imageUrl = '' this.imageUrl = ''
this.$toast.success('Update Successful') this.$toast.success(this.$strings.ToastCoverUpdateSuccess)
}) })
.catch((error) => { .catch((error) => {
console.error('Failed to update cover', error) console.error('Failed to update cover', error)
this.$toast.error(error.response?.data || 'Failed to update cover') this.$toast.error(error.response?.data || this.$strings.ToastCoverUpdateFailed)
}) })
.finally(() => { .finally(() => {
this.isProcessing = false this.isProcessing = false
@ -309,11 +309,11 @@ export default {
this.$axios this.$axios
.$patch(`/api/items/${this.libraryItemId}/cover`, { cover: coverFile.metadata.path }) .$patch(`/api/items/${this.libraryItemId}/cover`, { cover: coverFile.metadata.path })
.then(() => { .then(() => {
this.$toast.success('Update Successful') this.$toast.success(this.$strings.ToastCoverUpdateSuccess)
}) })
.catch((error) => { .catch((error) => {
console.error('Failed to set local cover', error) console.error('Failed to set local cover', error)
this.$toast.error(error.response?.data || 'Failed to set cover') this.$toast.error(error.response?.data || this.$strings.ToastCoverUpdateFailed)
}) })
.finally(() => { .finally(() => {
this.isProcessing = false this.isProcessing = false

View file

@ -163,7 +163,7 @@ export default {
this.isProcessing = false this.isProcessing = false
if (updateResult) { if (updateResult) {
if (updateResult.updated) { if (updateResult.updated) {
this.$toast.success('Item details updated') this.$toast.success(this.$strings.ToastItemDetailsUpdateSuccess)
return true return true
} else { } else {
this.$toast.info(this.$strings.MessageNoUpdatesWereNecessary) this.$toast.info(this.$strings.MessageNoUpdatesWereNecessary)

View file

@ -845,6 +845,9 @@
"ToastCollectionRemoveSuccess": "Collection removed", "ToastCollectionRemoveSuccess": "Collection removed",
"ToastCollectionUpdateFailed": "Failed to update collection", "ToastCollectionUpdateFailed": "Failed to update collection",
"ToastCollectionUpdateSuccess": "Collection updated", "ToastCollectionUpdateSuccess": "Collection updated",
"ToastCoverUpdateFailed": "Cover update failed",
"ToastCoverUpdateSuccess": "Cover updated",
"ToastCoverUploaded": "Cover uploaded",
"ToastDeleteFileFailed": "Failed to delete file", "ToastDeleteFileFailed": "Failed to delete file",
"ToastDeleteFileSuccess": "File deleted", "ToastDeleteFileSuccess": "File deleted",
"ToastDeviceAddFailed": "Failed to add device", "ToastDeviceAddFailed": "Failed to add device",
@ -860,6 +863,7 @@
"ToastFailedToUpdateUser": "Failed to update user", "ToastFailedToUpdateUser": "Failed to update user",
"ToastFfprobeFailed": "FFprobe failed", "ToastFfprobeFailed": "FFprobe failed",
"ToastInvalidImageUrl": "Invalid image URL", "ToastInvalidImageUrl": "Invalid image URL",
"ToastInvalidUrl": "Invalid URL",
"ToastItemCoverUpdateFailed": "Failed to update item cover", "ToastItemCoverUpdateFailed": "Failed to update item cover",
"ToastItemCoverUpdateSuccess": "Item cover updated", "ToastItemCoverUpdateSuccess": "Item cover updated",
"ToastItemDeletedFailed": "Failed to delete item", "ToastItemDeletedFailed": "Failed to delete item",
@ -930,6 +934,7 @@
"ToastSortingPrefixesUpdateFailed": "Failed to update sorting prefixes", "ToastSortingPrefixesUpdateFailed": "Failed to update sorting prefixes",
"ToastSortingPrefixesUpdateSuccess": "Sorting prefixes updated ({0} items)", "ToastSortingPrefixesUpdateSuccess": "Sorting prefixes updated ({0} items)",
"ToastTitleRequired": "Title is required", "ToastTitleRequired": "Title is required",
"ToastUnknownError": "Unknown error",
"ToastUnlinkOpenIdFailed": "Failed to unlink user from OpenID", "ToastUnlinkOpenIdFailed": "Failed to unlink user from OpenID",
"ToastUnlinkOpenIdSuccess": "User unlinked from OpenID", "ToastUnlinkOpenIdSuccess": "User unlinked from OpenID",
"ToastUserDeleteFailed": "Failed to delete user", "ToastUserDeleteFailed": "Failed to delete user",