mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Switch to using the websocket for confirmation of batch updates, allowing the main request to be done asynchronously
This commit is contained in:
parent
2d6f9bab8b
commit
3e7a76574b
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user