From 7d4e7ce2c056353e4c1708d38c1fa08058a140c8 Mon Sep 17 00:00:00 2001 From: Nick Thomson Date: Mon, 19 Sep 2022 16:29:24 +0100 Subject: [PATCH 01/18] Initial commit --- client/components/app/Appbar.vue | 8 ++- .../modals/BatchQuickMatchModel.vue | 70 +++++++++++++++++++ client/store/globals.js | 5 ++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 client/components/modals/BatchQuickMatchModel.vue diff --git a/client/components/app/Appbar.vue b/client/components/app/Appbar.vue index cc417739..842d559f 100644 --- a/client/components/app/Appbar.vue +++ b/client/components/app/Appbar.vue @@ -49,6 +49,9 @@

{{ numLibraryItemsSelected }} Selected

+ + + @@ -210,7 +213,10 @@ export default { }, setBookshelfTotalEntities(totalEntities) { this.totalEntities = totalEntities - } + }, + batchAutoMatchClick() { + this.$store.commit('globals/setShowBatchQuickMatchModal', true) + }, }, mounted() { this.$eventBus.$on('bookshelf-total-entities', this.setBookshelfTotalEntities) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue new file mode 100644 index 00000000..d02c39f4 --- /dev/null +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -0,0 +1,70 @@ + + + + + \ No newline at end of file diff --git a/client/store/globals.js b/client/store/globals.js index 21a31d5a..8625b22e 100644 --- a/client/store/globals.js +++ b/client/store/globals.js @@ -14,6 +14,7 @@ export const state = () => ({ selectedAuthor: null, isCasting: false, // Actively casting isChromecastInitialized: false, // Script loaded + showBatchQuickMatchModal: false, dateFormats: [ { text: 'MM/DD/YYYY', @@ -108,5 +109,9 @@ export const mutations = { }, setCasting(state, val) { state.isCasting = val + }, + setShowBatchQuickMatchModal(state, val) { + console.log("setShowBatchQuickMatchModal: " + val) + state.showBatchQuickMatchModal = val } } \ No newline at end of file From dbb62069ef2c985e55afd9a4be68a3c4bceafbce Mon Sep 17 00:00:00 2001 From: Nick Thomson Date: Fri, 23 Sep 2022 17:51:34 +0100 Subject: [PATCH 02/18] Implementation of batch quick match API and related options dialog --- .../modals/BatchQuickMatchModel.vue | 89 +++++++++++++++---- client/layouts/default.vue | 1 + server/controllers/LibraryItemController.js | 25 ++++++ server/routers/ApiRouter.js | 1 + 4 files changed, 99 insertions(+), 17 deletions(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index d02c39f4..c424baaa 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -10,7 +10,39 @@

Quick Match {{ selectedBookIds.length }} Books

-
+
+ +
+
+

Provider

+ +
+
+ + +

+ Update Covers + info_outlined +

+
+
+
+ + +

+ Update Details + info_outlined +

+
+
+
+
+ Cancel +
+ Continue +
+
+
@@ -20,7 +52,16 @@ export default { data() { return { - processing: false + processing: false, + options: { + provider: 'google', + overrideDetails: true, + overrideCover: true + }, + tooltips: { + updateCovers: 'Update the selected book covers when a match is located.', + updateDetails: 'Update the selected book details when a match is located.' + } } }, computed: { @@ -45,26 +86,40 @@ export default { }, currentLibraryId() { return this.$store.state.libraries.currentLibraryId + }, + providers() { + if (this.isPodcast) return this.$store.state.scanners.podcastProviders + return this.$store.state.scanners.providers } }, methods: { + doBatchQuickMatch() { + if (!this.selectedBookIds.length) return + if (this.processing) return + + this.processing = true + this.$store.commit('setProcessingBatch', true) + this.$axios + .$post(`/api/items/batch/quickmatch`, { + options: this.options, + libraryItemIds: this.selectedBookIds + }) + .then(() => { + this.$toast.success('Batch quick match success!') + this.processing = false + this.$store.commit('setProcessingBatch', false) + this.show = false + }) + .catch((error) => { + this.$toast.error('Batch quick match failed') + console.error('Failed to batch quick match', error) + this.processing = false + this.$store.commit('setProcessingBatch', false) + this.show = false + }) + } }, mounted() {} } - \ No newline at end of file diff --git a/client/layouts/default.vue b/client/layouts/default.vue index 3e4202f2..89be096e 100644 --- a/client/layouts/default.vue +++ b/client/layouts/default.vue @@ -15,6 +15,7 @@ +
diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 328e75a5..9eba9cc6 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -305,6 +305,31 @@ class LibraryItemController { res.json(libraryItems) } + // POST: api/items/batch/quickmatch + async batchQuickMatch(req, res) { + var itemsUpdated = 0 + + var matchData = req.body + var options = matchData.options || {} + var items = matchData.libraryItemIds + if (!items || !items.length) { + return res.sendStatus(500) + } + + for (let i = 0; i < items.length; i++) { + var libraryItem = this.db.libraryItems.find(_li => _li.id === items[i]) + var matchResult = await this.scanner.quickMatchLibraryItem(libraryItem, options) + if (matchResult.updated) { + itemsUpdated++ + } + } + + res.json({ + success: itemsUpdated > 0, + updates: itemsUpdated + }) + } + // DELETE: api/items/all async deleteAll(req, res) { if (!req.user.isAdminOrUp) { diff --git a/server/routers/ApiRouter.js b/server/routers/ApiRouter.js index edb293df..27b8233c 100644 --- a/server/routers/ApiRouter.js +++ b/server/routers/ApiRouter.js @@ -101,6 +101,7 @@ class ApiRouter { this.router.post('/items/batch/delete', LibraryItemController.batchDelete.bind(this)) this.router.post('/items/batch/update', LibraryItemController.batchUpdate.bind(this)) this.router.post('/items/batch/get', LibraryItemController.batchGet.bind(this)) + this.router.post('/items/batch/quickmatch', LibraryItemController.batchQuickMatch.bind(this)) // // User Routes From c3f2e606dd9e35cc9b311d462738c52f5f6f6dea Mon Sep 17 00:00:00 2001 From: Nick Thomson Date: Fri, 23 Sep 2022 18:53:30 +0100 Subject: [PATCH 03/18] Clarified behaviour of Update options in batch quick match dialog and added flag in quickMatchLibraryItem to override the default system settings --- client/components/modals/BatchQuickMatchModel.vue | 8 +++++--- server/scanner/Scanner.js | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index c424baaa..40a3cf25 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -17,6 +17,7 @@

Provider

+

Quick Match will attempt to add missing covers and metadata for the selected books. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.

@@ -56,11 +57,12 @@ export default { options: { provider: 'google', overrideDetails: true, - overrideCover: true + overrideCover: true, + overrideDefaults: true }, tooltips: { - updateCovers: 'Update the selected book covers when a match is located.', - updateDetails: 'Update the selected book details when a match is located.' + updateCovers: 'Allow overwriting of existing covers for the selected books when a match is located.', + updateDetails: 'Allow overwriting of existing details for the selected books when a match is located.' } } }, diff --git a/server/scanner/Scanner.js b/server/scanner/Scanner.js index acfcdd9e..87c57351 100644 --- a/server/scanner/Scanner.js +++ b/server/scanner/Scanner.js @@ -675,9 +675,11 @@ class Scanner { var provider = options.provider || 'google' var searchTitle = options.title || libraryItem.media.metadata.title var searchAuthor = options.author || libraryItem.media.metadata.authorName + var overrideDefaults = options.overrideDefaults || false - // Set to override existing metadata if scannerPreferMatchedMetadata setting is true - if (this.db.serverSettings.scannerPreferMatchedMetadata) { + // Set to override existing metadata if scannerPreferMatchedMetadata setting is true and + // the overrideDefaults option is not set or set to false. + if ((overrideDefaults == false) && (this.db.serverSettings.scannerPreferMatchedMetadata)) { options.overrideCover = true options.overrideDetails = true } From 731cf8e4ed1f1ae688ff3ba869512130a0fa4a9f Mon Sep 17 00:00:00 2001 From: Nick Thomson Date: Fri, 23 Sep 2022 19:37:30 +0100 Subject: [PATCH 04/18] Fix whitespace issues --- .../modals/BatchQuickMatchModel.vue | 62 +++++++++---------- client/layouts/default.vue | 2 +- client/store/globals.js | 1 - server/controllers/LibraryItemController.js | 30 ++++----- server/routers/ApiRouter.js | 2 +- 5 files changed, 47 insertions(+), 50 deletions(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index 40a3cf25..fd30d9e9 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -10,19 +10,19 @@

Quick Match {{ selectedBookIds.length }} Books

-
- -
+
+ +
-

Provider

- -
-

Quick Match will attempt to add missing covers and metadata for the selected books. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.

+

Provider

+ +
+

Quick Match will attempt to add missing covers and metadata for the selected books. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.

- Update Covers + Update Covers info_outlined

@@ -43,7 +43,7 @@ Continue
-
+ @@ -54,26 +54,24 @@ export default { data() { return { processing: false, - options: { - provider: 'google', - overrideDetails: true, - overrideCover: true, - overrideDefaults: true - }, - tooltips: { - updateCovers: 'Allow overwriting of existing covers for the selected books when a match is located.', - updateDetails: 'Allow overwriting of existing details for the selected books when a match is located.' - } + options: { + provider: 'google', + overrideDetails: true, + overrideCover: true, + overrideDefaults: true + }, + tooltips: { + updateCovers: 'Allow overwriting of existing covers for the selected books when a match is located.', + updateDetails: 'Allow overwriting of existing details for the selected books when a match is located.' + } } }, computed: { show: { get() { - console.log("Getter") return this.$store.state.globals.showBatchQuickMatchModal }, set(val) { - console.log("Setter") this.$store.commit('globals/setShowBatchQuickMatchModal', val) } }, @@ -95,31 +93,31 @@ export default { } }, methods: { - doBatchQuickMatch() { - if (!this.selectedBookIds.length) return - if (this.processing) return - - this.processing = true - this.$store.commit('setProcessingBatch', true) - this.$axios + doBatchQuickMatch() { + if (!this.selectedBookIds.length) return + if (this.processing) return + + this.processing = true + this.$store.commit('setProcessingBatch', true) + this.$axios .$post(`/api/items/batch/quickmatch`, { - options: this.options, + options: this.options, libraryItemIds: this.selectedBookIds }) .then(() => { this.$toast.success('Batch quick match success!') this.processing = false this.$store.commit('setProcessingBatch', false) - this.show = false + this.show = false }) .catch((error) => { this.$toast.error('Batch quick match failed') console.error('Failed to batch quick match', error) this.processing = false this.$store.commit('setProcessingBatch', false) - this.show = false + this.show = false }) - } + } }, mounted() {} } diff --git a/client/layouts/default.vue b/client/layouts/default.vue index 89be096e..8998a92c 100644 --- a/client/layouts/default.vue +++ b/client/layouts/default.vue @@ -15,7 +15,7 @@ - + diff --git a/client/store/globals.js b/client/store/globals.js index 8625b22e..9e837f00 100644 --- a/client/store/globals.js +++ b/client/store/globals.js @@ -111,7 +111,6 @@ export const mutations = { state.isCasting = val }, setShowBatchQuickMatchModal(state, val) { - console.log("setShowBatchQuickMatchModal: " + val) state.showBatchQuickMatchModal = val } } \ No newline at end of file diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 9eba9cc6..9544f299 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -307,26 +307,26 @@ class LibraryItemController { // POST: api/items/batch/quickmatch async batchQuickMatch(req, res) { - var itemsUpdated = 0 + var itemsUpdated = 0 - var matchData = req.body - var options = matchData.options || {} - var items = matchData.libraryItemIds + var matchData = req.body + var options = matchData.options || {} + var items = matchData.libraryItemIds if (!items || !items.length) { return res.sendStatus(500) } - + for (let i = 0; i < items.length; i++) { - var libraryItem = this.db.libraryItems.find(_li => _li.id === items[i]) - var matchResult = await this.scanner.quickMatchLibraryItem(libraryItem, options) - if (matchResult.updated) { - itemsUpdated++ - } - } - - res.json({ - success: itemsUpdated > 0, - updates: itemsUpdated + var libraryItem = this.db.libraryItems.find(_li => _li.id === items[i]) + var matchResult = await this.scanner.quickMatchLibraryItem(libraryItem, options) + if (matchResult.updated) { + itemsUpdated++ + } + } + + res.json({ + success: itemsUpdated > 0, + updates: itemsUpdated }) } diff --git a/server/routers/ApiRouter.js b/server/routers/ApiRouter.js index 27b8233c..241acc22 100644 --- a/server/routers/ApiRouter.js +++ b/server/routers/ApiRouter.js @@ -101,7 +101,7 @@ class ApiRouter { this.router.post('/items/batch/delete', LibraryItemController.batchDelete.bind(this)) this.router.post('/items/batch/update', LibraryItemController.batchUpdate.bind(this)) this.router.post('/items/batch/get', LibraryItemController.batchGet.bind(this)) - this.router.post('/items/batch/quickmatch', LibraryItemController.batchQuickMatch.bind(this)) + this.router.post('/items/batch/quickmatch', LibraryItemController.batchQuickMatch.bind(this)) // // User Routes From 9983fe7d66166f73e03ae6c2a29732ff0039ff10 Mon Sep 17 00:00:00 2001 From: Nick Thomson Date: Fri, 23 Sep 2022 19:39:20 +0100 Subject: [PATCH 05/18] Fix another whitespace issue --- server/scanner/Scanner.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/scanner/Scanner.js b/server/scanner/Scanner.js index 87c57351..21d95058 100644 --- a/server/scanner/Scanner.js +++ b/server/scanner/Scanner.js @@ -675,10 +675,10 @@ class Scanner { var provider = options.provider || 'google' var searchTitle = options.title || libraryItem.media.metadata.title var searchAuthor = options.author || libraryItem.media.metadata.authorName - var overrideDefaults = options.overrideDefaults || false + var overrideDefaults = options.overrideDefaults || false // Set to override existing metadata if scannerPreferMatchedMetadata setting is true and - // the overrideDefaults option is not set or set to false. + // the overrideDefaults option is not set or set to false. if ((overrideDefaults == false) && (this.db.serverSettings.scannerPreferMatchedMetadata)) { options.overrideCover = true options.overrideDetails = true From 11e3cf4f191570d61a4ef17b65fcdd66a1c322ca Mon Sep 17 00:00:00 2001 From: Nick Thomson Date: Sat, 24 Sep 2022 18:23:33 +0100 Subject: [PATCH 06/18] Initialise the selected provider to the default for the library when the batch quick match is first opened or if the user has switched libraries. --- .../modals/BatchQuickMatchModel.vue | 72 ++++++++++++------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index fd30d9e9..9c4115cd 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -54,8 +54,10 @@ export default { data() { return { processing: false, + isScrollable: false, + lastUsedLibrary: undefined, options: { - provider: 'google', + provider: undefined, overrideDetails: true, overrideCover: true, overrideDefaults: true @@ -66,6 +68,13 @@ export default { } } }, + watch: { + show: { + handler(newVal) { + this.init() + } + } + }, computed: { show: { get() { @@ -90,34 +99,45 @@ export default { providers() { if (this.isPodcast) return this.$store.state.scanners.podcastProviders return this.$store.state.scanners.providers - } + }, + libraryProvider() { + return this.$store.getters['libraries/getLibraryProvider'](this.currentLibraryId) || 'google' + }, }, methods: { - doBatchQuickMatch() { - if (!this.selectedBookIds.length) return - if (this.processing) return - - this.processing = true - this.$store.commit('setProcessingBatch', true) - this.$axios - .$post(`/api/items/batch/quickmatch`, { - options: this.options, - libraryItemIds: this.selectedBookIds - }) - .then(() => { - this.$toast.success('Batch quick match success!') - this.processing = false - this.$store.commit('setProcessingBatch', false) - this.show = false - }) - .catch((error) => { - this.$toast.error('Batch quick match failed') - console.error('Failed to batch quick match', error) - this.processing = false - this.$store.commit('setProcessingBatch', false) - this.show = false - }) + init() { + // If we don't have a set provider (first open of dialog) or we've switched library, set + // the selected provider to the current library default provider + if (!this.options.provider || (this.options.lastUsedLibrary != this.currentLibraryId)) { + this.options.lastUsedLibrary = this.currentLibraryId + this.options.provider = this.libraryProvider; } + }, + doBatchQuickMatch() { + if (!this.selectedBookIds.length) return + if (this.processing) return + + this.processing = true + this.$store.commit('setProcessingBatch', true) + this.$axios + .$post(`/api/items/batch/quickmatch`, { + options: this.options, + libraryItemIds: this.selectedBookIds + }) + .then(() => { + this.$toast.success('Batch quick match success!') + this.processing = false + this.$store.commit('setProcessingBatch', false) + this.show = false + }) + .catch((error) => { + this.$toast.error('Batch quick match failed') + console.error('Failed to batch quick match', error) + this.processing = false + this.$store.commit('setProcessingBatch', false) + this.show = false + }) + } }, mounted() {} } From 2d6f9bab8b850b99a47acd01a4d57c077e376a0e Mon Sep 17 00:00:00 2001 From: Nick Thomson Date: Sat, 24 Sep 2022 18:57:09 +0100 Subject: [PATCH 07/18] Added totals of updated and unmatched books to toast shown at completion of batch quick match. --- client/components/modals/BatchQuickMatchModel.vue | 13 +++++++++++-- server/controllers/LibraryItemController.js | 8 ++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index 9c4115cd..77eb851e 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -124,8 +124,17 @@ export default { options: this.options, libraryItemIds: this.selectedBookIds }) - .then(() => { - this.$toast.success('Batch quick match success!') + .then((result) => { + var success = result.success || false + var toast = 'Batch quick match complete!\n' + result.updates + ' Updated' + if (result.unmatched && (result.unmatched > 0)) { + toast += '\n' + result.unmatched + ' with no matches' + } + if (success) { + this.$toast.success(toast) + } else { + this.$toast.info(toast) + } this.processing = false this.$store.commit('setProcessingBatch', false) this.show = false diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 9544f299..79e9c673 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -308,6 +308,7 @@ class LibraryItemController { // POST: api/items/batch/quickmatch async batchQuickMatch(req, res) { var itemsUpdated = 0 + var itemsUnmatched = 0 var matchData = req.body var options = matchData.options || {} @@ -321,12 +322,15 @@ class LibraryItemController { var matchResult = await this.scanner.quickMatchLibraryItem(libraryItem, options) if (matchResult.updated) { itemsUpdated++ - } + } else if (matchResult.warning) { + itemsUnmatched++ + } } res.json({ success: itemsUpdated > 0, - updates: itemsUpdated + updates: itemsUpdated, + unmatched: itemsUnmatched }) } From 3e7a76574b3178f3f697979fcdf63392a9624545 Mon Sep 17 00:00:00 2001 From: Nick Thomson Date: Sat, 24 Sep 2022 22:17:36 +0100 Subject: [PATCH 08/18] Switch to using the websocket for confirmation of batch updates, allowing the main request to be done asynchronously --- client/components/modals/BatchQuickMatchModel.vue | 13 ++----------- client/layouts/default.vue | 14 ++++++++++++++ server/controllers/LibraryItemController.js | 13 ++++++++++--- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index 77eb851e..0df66dfd 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -124,17 +124,8 @@ export default { options: this.options, libraryItemIds: this.selectedBookIds }) - .then((result) => { - var success = result.success || false - var toast = 'Batch quick match complete!\n' + result.updates + ' Updated' - if (result.unmatched && (result.unmatched > 0)) { - toast += '\n' + result.unmatched + ' with no matches' - } - if (success) { - this.$toast.success(toast) - } else { - this.$toast.info(toast) - } + .then(() => { + this.$toast.info('Batch quick match of ' + this.selectedBookIds.length + ' books started!') this.processing = false this.$store.commit('setProcessingBatch', false) this.show = false diff --git a/client/layouts/default.vue b/client/layouts/default.vue index 8998a92c..1a23cde7 100644 --- a/client/layouts/default.vue +++ b/client/layouts/default.vue @@ -359,6 +359,18 @@ export default { // Force refresh location.reload() }, + batchQuickMatchComplete(result) { + var success = result.success || false + var toast = 'Batch quick match complete!\n' + result.updates + ' Updated' + if (result.unmatched && (result.unmatched > 0)) { + toast += '\n' + result.unmatched + ' with no matches' + } + if (success) { + this.$toast.success(toast) + } else { + this.$toast.info(toast) + } + }, initializeSocket() { this.socket = this.$nuxtSocket({ name: process.env.NODE_ENV === 'development' ? 'dev' : 'prod', @@ -430,6 +442,8 @@ export default { this.socket.on('rss_feed_closed', this.rssFeedClosed) this.socket.on('backup_applied', this.backupApplied) + + this.socket.on('batch_quickmatch_complete', this.batchQuickMatchComplete) }, showUpdateToast(versionData) { var ignoreVersion = localStorage.getItem('ignoreVersion') diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 79e9c673..32c297ec 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -307,6 +307,11 @@ class LibraryItemController { // POST: api/items/batch/quickmatch async batchQuickMatch(req, res) { + if (!req.user.isAdminOrUp) { + Logger.warn('User other than admin attempted to batch quick match library items', req.user) + return res.sendStatus(403) + } + var itemsUpdated = 0 var itemsUnmatched = 0 @@ -316,6 +321,7 @@ class LibraryItemController { if (!items || !items.length) { return res.sendStatus(500) } + res.sendStatus(200); for (let i = 0; i < items.length; i++) { var libraryItem = this.db.libraryItems.find(_li => _li.id === items[i]) @@ -327,11 +333,12 @@ class LibraryItemController { } } - res.json({ + var result = { success: itemsUpdated > 0, updates: itemsUpdated, - unmatched: itemsUnmatched - }) + unmatched: itemsUnmatched + }; + this.clientEmitter(req.user.id, 'batch_quickmatch_complete', result) } // DELETE: api/items/all From dd8577354b8024a3e561f1685801e07c9c29ee09 Mon Sep 17 00:00:00 2001 From: Nick Thomson Date: Sat, 24 Sep 2022 22:20:49 +0100 Subject: [PATCH 09/18] Fixing tabs again. --- server/controllers/LibraryItemController.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 32c297ec..4b638746 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -311,9 +311,9 @@ class LibraryItemController { Logger.warn('User other than admin attempted to batch quick match library items', req.user) return res.sendStatus(403) } - + var itemsUpdated = 0 - var itemsUnmatched = 0 + var itemsUnmatched = 0 var matchData = req.body var options = matchData.options || {} @@ -321,7 +321,7 @@ class LibraryItemController { if (!items || !items.length) { return res.sendStatus(500) } - res.sendStatus(200); + res.sendStatus(200); for (let i = 0; i < items.length; i++) { var libraryItem = this.db.libraryItems.find(_li => _li.id === items[i]) @@ -329,16 +329,16 @@ class LibraryItemController { if (matchResult.updated) { itemsUpdated++ } else if (matchResult.warning) { - itemsUnmatched++ - } + itemsUnmatched++ + } } - var result = { + var result = { success: itemsUpdated > 0, updates: itemsUpdated, unmatched: itemsUnmatched }; - this.clientEmitter(req.user.id, 'batch_quickmatch_complete', result) + this.clientEmitter(req.user.id, 'batch_quickmatch_complete', result) } // DELETE: api/items/all From 46a3974b79ba81f590817dfdcf149869af76c294 Mon Sep 17 00:00:00 2001 From: Undergrid Date: Sat, 24 Sep 2022 23:37:43 +0100 Subject: [PATCH 10/18] Update client/components/modals/BatchQuickMatchModel.vue Co-authored-by: advplyr <67830747+advplyr@users.noreply.github.com> --- client/components/modals/BatchQuickMatchModel.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index 0df66dfd..c14ca1f8 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -54,7 +54,6 @@ export default { data() { return { processing: false, - isScrollable: false, lastUsedLibrary: undefined, options: { provider: undefined, From 7fd70c1c86b7f1dbf37a3d0d9e267c5d562bdad3 Mon Sep 17 00:00:00 2001 From: Undergrid Date: Sat, 24 Sep 2022 23:37:54 +0100 Subject: [PATCH 11/18] Update client/components/modals/BatchQuickMatchModel.vue Co-authored-by: advplyr <67830747+advplyr@users.noreply.github.com> --- client/components/modals/BatchQuickMatchModel.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index c14ca1f8..09b8b9cc 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -36,7 +36,7 @@

-
+
Cancel
From f3f2d614b1b886790edc101683fad1d46f8f57a2 Mon Sep 17 00:00:00 2001 From: Undergrid Date: Sat, 24 Sep 2022 23:37:59 +0100 Subject: [PATCH 12/18] Update client/components/modals/BatchQuickMatchModel.vue Co-authored-by: advplyr <67830747+advplyr@users.noreply.github.com> --- client/components/modals/BatchQuickMatchModel.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index 09b8b9cc..7fc7effa 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -109,7 +109,7 @@ export default { // the selected provider to the current library default provider if (!this.options.provider || (this.options.lastUsedLibrary != this.currentLibraryId)) { this.options.lastUsedLibrary = this.currentLibraryId - this.options.provider = this.libraryProvider; + this.options.provider = this.libraryProvider } }, doBatchQuickMatch() { From 62c59c634cb8afd93b210fd20e0fe6902702c801 Mon Sep 17 00:00:00 2001 From: Undergrid Date: Sat, 24 Sep 2022 23:38:18 +0100 Subject: [PATCH 13/18] Update server/controllers/LibraryItemController.js Co-authored-by: advplyr <67830747+advplyr@users.noreply.github.com> --- server/controllers/LibraryItemController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 4b638746..90b1ec1d 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -321,7 +321,7 @@ class LibraryItemController { if (!items || !items.length) { return res.sendStatus(500) } - res.sendStatus(200); + res.sendStatus(200) for (let i = 0; i < items.length; i++) { var libraryItem = this.db.libraryItems.find(_li => _li.id === items[i]) From 014ad668a54a0fceb86e95cbf4bdb367dcc3131c Mon Sep 17 00:00:00 2001 From: Undergrid Date: Sat, 24 Sep 2022 23:38:44 +0100 Subject: [PATCH 14/18] Update server/controllers/LibraryItemController.js Co-authored-by: advplyr <67830747+advplyr@users.noreply.github.com> --- server/controllers/LibraryItemController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 90b1ec1d..acbc6926 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -337,7 +337,7 @@ class LibraryItemController { success: itemsUpdated > 0, updates: itemsUpdated, unmatched: itemsUnmatched - }; + } this.clientEmitter(req.user.id, 'batch_quickmatch_complete', result) } From 066b6c13c6aff8caa5bf008871f943662c6dd937 Mon Sep 17 00:00:00 2001 From: Undergrid Date: Sat, 24 Sep 2022 23:38:51 +0100 Subject: [PATCH 15/18] Update client/components/modals/BatchQuickMatchModel.vue Co-authored-by: advplyr <67830747+advplyr@users.noreply.github.com> --- client/components/modals/BatchQuickMatchModel.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index 7fc7effa..8d82a34c 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -62,8 +62,8 @@ export default { overrideDefaults: true }, tooltips: { - updateCovers: 'Allow overwriting of existing covers for the selected books when a match is located.', - updateDetails: 'Allow overwriting of existing details for the selected books when a match is located.' + updateCovers: 'Allow overwriting of existing covers for the selected books when a match is located.', + updateDetails: 'Allow overwriting of existing details for the selected books when a match is located.' } } }, From eb0ef8c696830a47f8c26393dec941ff5092b8a8 Mon Sep 17 00:00:00 2001 From: Undergrid Date: Sat, 24 Sep 2022 23:38:58 +0100 Subject: [PATCH 16/18] Update client/components/modals/BatchQuickMatchModel.vue Co-authored-by: advplyr <67830747+advplyr@users.noreply.github.com> --- client/components/modals/BatchQuickMatchModel.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index 8d82a34c..91be72cf 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -101,7 +101,7 @@ export default { }, libraryProvider() { return this.$store.getters['libraries/getLibraryProvider'](this.currentLibraryId) || 'google' - }, + } }, methods: { init() { From 5e8979876fe635dd6473ab28dff2521485883de5 Mon Sep 17 00:00:00 2001 From: Undergrid Date: Sat, 24 Sep 2022 23:39:37 +0100 Subject: [PATCH 17/18] Update client/components/modals/BatchQuickMatchModel.vue Co-authored-by: advplyr <67830747+advplyr@users.noreply.github.com> --- client/components/modals/BatchQuickMatchModel.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index 91be72cf..233b0134 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -17,7 +17,7 @@

Provider

-

Quick Match will attempt to add missing covers and metadata for the selected books. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.

+

Quick Match will attempt to add missing covers and metadata for the selected books. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.

From 951afaa568071511c5494f4d0777f0072bc3de64 Mon Sep 17 00:00:00 2001 From: Undergrid Date: Sat, 24 Sep 2022 23:40:07 +0100 Subject: [PATCH 18/18] Update client/components/modals/BatchQuickMatchModel.vue Co-authored-by: advplyr <67830747+advplyr@users.noreply.github.com> --- client/components/modals/BatchQuickMatchModel.vue | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client/components/modals/BatchQuickMatchModel.vue b/client/components/modals/BatchQuickMatchModel.vue index 233b0134..a80beefa 100644 --- a/client/components/modals/BatchQuickMatchModel.vue +++ b/client/components/modals/BatchQuickMatchModel.vue @@ -125,13 +125,10 @@ export default { }) .then(() => { this.$toast.info('Batch quick match of ' + this.selectedBookIds.length + ' books started!') - this.processing = false - this.$store.commit('setProcessingBatch', false) - this.show = false - }) - .catch((error) => { + }).catch((error) => { this.$toast.error('Batch quick match failed') console.error('Failed to batch quick match', error) + }).finally(() => { this.processing = false this.$store.commit('setProcessingBatch', false) this.show = false