diff --git a/client/components/app/BookShelfToolbar.vue b/client/components/app/BookShelfToolbar.vue index af0713f5..591a0c31 100644 --- a/client/components/app/BookShelfToolbar.vue +++ b/client/components/app/BookShelfToolbar.vue @@ -61,6 +61,10 @@

Search results for "{{ searchQuery }}"

+
@@ -75,7 +79,11 @@ export default { default: () => null }, searchQuery: String, - viewMode: String + viewMode: String, + authors: { + type: Array, + default: () => [] + } }, data() { return { @@ -85,13 +93,17 @@ export default { keywordFilter: null, keywordTimeout: null, processingSeries: false, - processingIssues: false + processingIssues: false, + processingAuthors: false } }, computed: { userCanDelete() { return this.$store.getters['user/getUserCanDelete'] }, + userCanUpdate() { + return this.$store.getters['user/getUserCanUpdate'] + }, isPodcast() { return this.$store.getters['libraries/getCurrentLibraryMediaType'] == 'podcast' }, @@ -147,6 +159,35 @@ export default { } }, methods: { + async matchAllAuthors() { + this.processingAuthors = true + + for (const author of this.authors) { + const payload = {} + if (author.asin) payload.asin = author.asin + else payload.q = author.name + console.log('Payload', payload, 'author', author) + + this.$eventBus.$emit(`searching-author-${author.id}`, true) + + var response = await this.$axios.$post(`/api/authors/${author.id}/match`, payload).catch((error) => { + console.error('Failed', error) + return null + }) + if (!response) { + console.error(`Author ${author.name} not found`) + this.$toast.error(`Author ${author.name} not found`) + } else if (response.updated) { + if (response.author.imagePath) console.log(`Author ${response.author.name} was updated`) + else console.log(`Author ${response.author.name} was updated (no image found)`) + } else { + console.log(`No updates were made for Author ${response.author.name}`) + } + + this.$eventBus.$emit(`searching-author-${author.id}`, false) + } + this.processingAuthors = false + }, removeAllIssues() { if (confirm(`Are you sure you want to remove all library items with issues?\n\nNote: This will not delete any files`)) { this.processingIssues = true diff --git a/client/components/cards/AuthorCard.vue b/client/components/cards/AuthorCard.vue index 9f5803ed..c8e68a29 100644 --- a/client/components/cards/AuthorCard.vue +++ b/client/components/cards/AuthorCard.vue @@ -101,8 +101,16 @@ export default { this.$toast.info('No updates were made for Author') } this.searching = false + }, + setSearching(isSearching) { + this.searching = isSearching } }, - mounted() {} + mounted() { + this.$eventBus.$on(`searching-author-${this.authorId}`, this.setSearching) + }, + beforeDestroy() { + this.$eventBus.$off(`searching-author-${this.authorId}`, this.setSearching) + } } \ No newline at end of file diff --git a/client/pages/library/_library/authors/index.vue b/client/pages/library/_library/authors/index.vue index ba8ac661..beb36c3f 100644 --- a/client/pages/library/_library/authors/index.vue +++ b/client/pages/library/_library/authors/index.vue @@ -1,6 +1,6 @@