diff --git a/client/components/app/LazyBookshelf.vue b/client/components/app/LazyBookshelf.vue index ea692428..2985ffc3 100644 --- a/client/components/app/LazyBookshelf.vue +++ b/client/components/app/LazyBookshelf.vue @@ -425,42 +425,42 @@ export default { this.handleScroll(scrollTop) // }, 250) }, - audiobookAdded(audiobook) { - console.log('Audiobook added', audiobook) + libraryItemAdded(libraryItem) { + console.log('libraryItem added', libraryItem) // TODO: Check if audiobook would be on this shelf this.resetEntities() }, - audiobookUpdated(audiobook) { - console.log('Audiobook updated', audiobook) + libraryItemUpdated(libraryItem) { + console.log('Item updated', libraryItem) if (this.entityName === 'books' || this.entityName === 'series-books') { - var indexOf = this.entities.findIndex((ent) => ent && ent.id === audiobook.id) + var indexOf = this.entities.findIndex((ent) => ent && ent.id === libraryItem.id) if (indexOf >= 0) { - this.entities[indexOf] = audiobook + this.entities[indexOf] = libraryItem if (this.entityComponentRefs[indexOf]) { - this.entityComponentRefs[indexOf].setEntity(audiobook) + this.entityComponentRefs[indexOf].setEntity(libraryItem) } } } }, - audiobookRemoved(audiobook) { + libraryItemRemoved(libraryItem) { if (this.entityName === 'books' || this.entityName === 'series-books') { - var indexOf = this.entities.findIndex((ent) => ent && ent.id === audiobook.id) + var indexOf = this.entities.findIndex((ent) => ent && ent.id === libraryItem.id) if (indexOf >= 0) { - this.entities = this.entities.filter((ent) => ent.id !== audiobook.id) + this.entities = this.entities.filter((ent) => ent.id !== libraryItem.id) this.totalEntities = this.entities.length this.$eventBus.$emit('bookshelf-total-entities', this.totalEntities) - this.remountEntities() + this.executeRebuild() } } }, - audiobooksAdded(audiobooks) { - console.log('audiobooks added', audiobooks) + libraryItemsAdded(libraryItems) { + console.log('items added', libraryItems) // TODO: Check if audiobook would be on this shelf this.resetEntities() }, - audiobooksUpdated(audiobooks) { - audiobooks.forEach((ab) => { - this.audiobookUpdated(ab) + libraryItemsUpdated(libraryItems) { + libraryItems.forEach((ab) => { + this.libraryItemUpdated(ab) }) }, initSizeData(_bookshelf) { @@ -525,11 +525,11 @@ export default { this.$store.commit('user/addSettingsListener', { id: 'lazy-bookshelf', meth: this.settingsUpdated }) if (this.$root.socket) { - this.$root.socket.on('audiobook_updated', this.audiobookUpdated) - this.$root.socket.on('audiobook_added', this.audiobookAdded) - this.$root.socket.on('audiobook_removed', this.audiobookRemoved) - this.$root.socket.on('audiobooks_updated', this.audiobooksUpdated) - this.$root.socket.on('audiobooks_added', this.audiobooksAdded) + this.$root.socket.on('item_updated', this.libraryItemUpdated) + this.$root.socket.on('item_added', this.libraryItemAdded) + this.$root.socket.on('item_removed', this.libraryItemRemoved) + this.$root.socket.on('items_updated', this.libraryItemsUpdated) + this.$root.socket.on('items_added', this.libraryItemsAdded) } else { console.error('Bookshelf - Socket not initialized') } @@ -546,11 +546,11 @@ export default { this.$store.commit('user/removeSettingsListener', 'lazy-bookshelf') if (this.$root.socket) { - this.$root.socket.off('audiobook_updated', this.audiobookUpdated) - this.$root.socket.off('audiobook_added', this.audiobookAdded) - this.$root.socket.off('audiobook_removed', this.audiobookRemoved) - this.$root.socket.off('audiobooks_updated', this.audiobooksUpdated) - this.$root.socket.off('audiobooks_added', this.audiobooksAdded) + this.$root.socket.off('item_updated', this.libraryItemUpdated) + this.$root.socket.off('item_added', this.libraryItemAdded) + this.$root.socket.off('item_removed', this.libraryItemRemoved) + this.$root.socket.off('items_updated', this.libraryItemsUpdated) + this.$root.socket.off('items_added', this.libraryItemsAdded) } else { console.error('Bookshelf - Socket not initialized') } diff --git a/client/components/cards/LazyBookCard.vue b/client/components/cards/LazyBookCard.vue index 2a9cd2c0..2422479e 100644 --- a/client/components/cards/LazyBookCard.vue +++ b/client/components/cards/LazyBookCard.vue @@ -379,8 +379,8 @@ export default { this.isSelectionMode = val if (!val) this.selected = false }, - setEntity(audiobook) { - this.audiobook = audiobook + setEntity(libraryItem) { + this.audiobook = libraryItem }, clickCard(e) { if (this.isSelectionMode) { diff --git a/client/components/modals/edit-tabs/Cover.vue b/client/components/modals/edit-tabs/Cover.vue index 70eedeab..1caac83a 100644 --- a/client/components/modals/edit-tabs/Cover.vue +++ b/client/components/modals/edit-tabs/Cover.vue @@ -157,7 +157,7 @@ export default { .filter((f) => f.fileType === 'image') .map((file) => { var _file = { ...file } - _file.localPath = `/s/item/${this.libraryItemId}/${this.$encodeUriPath(file.metadata.relPath)}` + _file.localPath = `/s/item/${this.libraryItemId}/${this.$encodeUriPath(file.metadata.relPath).replace(/^\//, '')}` return _file }) } @@ -169,7 +169,7 @@ export default { form.set('cover', this.selectedFile) this.$axios - .$post(`/api/books/${this.libraryItemId}/cover`, form) + .$post(`/api/items/${this.libraryItemId}/cover`, form) .then((data) => { if (data.error) { this.$toast.error(data.error) @@ -230,8 +230,20 @@ export default { this.isProcessing = true var success = false - // Download cover from url and use - if (cover.startsWith('http:') || cover.startsWith('https:')) { + if (!cover) { + // Remove cover + success = await this.$axios + .$delete(`/api/items/${this.libraryItemId}/cover`) + .then(() => true) + .catch((error) => { + console.error('Failed to remove cover', error) + if (error.response && error.response.data) { + this.$toast.error(error.response.data) + } + return false + }) + } else if (cover.startsWith('http:') || cover.startsWith('https:')) { + // Download cover from url and use success = await this.$axios.$post(`/api/items/${this.libraryItemId}/cover`, { url: cover }).catch((error) => { console.error('Failed to download cover from url', error) if (error.response && error.response.data) { @@ -242,11 +254,9 @@ export default { } else { // Update local cover url const updatePayload = { - book: { - cover: cover - } + cover } - success = await this.$axios.$patch(`/api/books/${this.libraryItemId}`, updatePayload).catch((error) => { + success = await this.$axios.$patch(`/api/items/${this.libraryItemId}/cover`, updatePayload).catch((error) => { console.error('Failed to update', error) if (error.response && error.response.data) { this.$toast.error(error.response.data) @@ -256,7 +266,7 @@ export default { } if (success) { this.$toast.success('Update Successful') - this.$emit('close') + // this.$emit('close') } else { this.imageUrl = this.media.coverPath || '' } diff --git a/client/components/modals/edit-tabs/Details.vue b/client/components/modals/edit-tabs/Details.vue index 35a7bd0a..7643b0a5 100644 --- a/client/components/modals/edit-tabs/Details.vue +++ b/client/components/modals/edit-tabs/Details.vue @@ -287,22 +287,22 @@ export default { this.quickMatching = false }) }, - audiobookScanComplete(result) { + libraryScanComplete(result) { this.rescanning = false if (!result) { this.$toast.error(`Re-Scan Failed for "${this.title}"`) } else if (result === 'UPDATED') { - this.$toast.success(`Re-Scan complete audiobook was updated`) + this.$toast.success(`Re-Scan complete item was updated`) } else if (result === 'UPTODATE') { - this.$toast.success(`Re-Scan complete audiobook was up to date`) + this.$toast.success(`Re-Scan complete item was up to date`) } else if (result === 'REMOVED') { - this.$toast.error(`Re-Scan complete audiobook was removed`) + this.$toast.error(`Re-Scan complete item was removed`) } }, rescan() { this.rescanning = true - this.$root.socket.once('audiobook_scan_complete', this.audiobookScanComplete) - this.$root.socket.emit('scan_audiobook', this.audiobookId) + this.$root.socket.once('item_scan_complete', this.libraryScanComplete) + this.$root.socket.emit('scan_item', this.libraryItemId) }, saveMetadataComplete(result) { this.savingMetadata = false @@ -381,7 +381,7 @@ export default { if (confirm(`Are you sure you want to remove this item?\n\n*Does not delete your files, only removes the item from audiobookshelf`)) { this.isProcessing = true this.$axios - .$delete(`/api/books/${this.libraryItemId}`) + .$delete(`/api/items/${this.libraryItemId}`) .then(() => { console.log('Item removed') this.$toast.success('Item Removed') diff --git a/client/components/modals/edit-tabs/Files.vue b/client/components/modals/edit-tabs/Files.vue index 4644b2c4..df17b441 100644 --- a/client/components/modals/edit-tabs/Files.vue +++ b/client/components/modals/edit-tabs/Files.vue @@ -13,20 +13,20 @@ Manage Tracks - +
- + - - - + + +
## FilenameSizeDurationDownloadSizeDurationDownload