2022-09-19 17:29:24 +02:00
|
|
|
<template>
|
|
|
|
<modals-modal v-model="show" name="batchQuickMatch" :processing="processing" :width="500" :height="'unset'">
|
|
|
|
<template #outer>
|
|
|
|
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
|
|
|
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<div ref="container" class="w-full rounded-lg bg-primary box-shadow-md overflow-y-auto overflow-x-hidden" style="max-height: 80vh">
|
2022-11-09 00:10:08 +01:00
|
|
|
<div v-if="show" class="w-full h-full py-4">
|
2022-09-23 20:37:30 +02:00
|
|
|
<div class="w-full overflow-y-auto overflow-x-hidden max-h-96">
|
2022-09-23 18:51:34 +02:00
|
|
|
<div class="flex px-8 items-center py-2">
|
2022-11-09 00:10:08 +01:00
|
|
|
<p class="pr-4">{{ $strings.LabelProvider }}</p>
|
2022-09-23 20:37:30 +02:00
|
|
|
<ui-dropdown v-model="options.provider" :items="providers" small />
|
|
|
|
</div>
|
2022-11-09 00:10:08 +01:00
|
|
|
<p class="text-base px-8 py-2">{{ $strings.MessageBatchQuickMatchDescription }}</p>
|
2022-09-23 18:51:34 +02:00
|
|
|
<div class="flex px-8 items-end py-2">
|
2022-11-09 00:10:08 +01:00
|
|
|
<ui-toggle-switch v-model="options.overrideCover" />
|
|
|
|
<ui-tooltip :text="$strings.LabelUpdateCoverHelp">
|
2022-09-23 18:51:34 +02:00
|
|
|
<p class="pl-4">
|
2022-11-09 00:10:08 +01:00
|
|
|
{{ $strings.LabelUpdateCover }}
|
2022-11-21 14:18:10 +01:00
|
|
|
<span class="material-icons icon-text">info_outlined</span>
|
2022-09-23 18:51:34 +02:00
|
|
|
</p>
|
|
|
|
</ui-tooltip>
|
|
|
|
</div>
|
|
|
|
<div class="flex px-8 items-end py-2">
|
2022-11-09 00:10:08 +01:00
|
|
|
<ui-toggle-switch v-model="options.overrideDetails" />
|
|
|
|
<ui-tooltip :text="$strings.LabelUpdateDetailsHelp">
|
2022-09-23 18:51:34 +02:00
|
|
|
<p class="pl-4">
|
2022-11-09 00:10:08 +01:00
|
|
|
{{ $strings.LabelUpdateDetails }}
|
2022-11-21 14:18:10 +01:00
|
|
|
<span class="material-icons icon-text">info_outlined</span>
|
2022-09-23 18:51:34 +02:00
|
|
|
</p>
|
|
|
|
</ui-tooltip>
|
|
|
|
</div>
|
2022-11-09 00:10:08 +01:00
|
|
|
<div class="mt-4 pt-4 text-white text-opacity-80 border-t border-white border-opacity-5">
|
2022-09-23 18:51:34 +02:00
|
|
|
<div class="flex items-center px-4">
|
2022-11-09 00:10:08 +01:00
|
|
|
<ui-btn type="button" @click="show = false">{{ $strings.ButtonCancel }}</ui-btn>
|
2022-09-23 18:51:34 +02:00
|
|
|
<div class="flex-grow" />
|
2022-11-09 00:10:08 +01:00
|
|
|
<ui-btn color="success" @click="doBatchQuickMatch">{{ $strings.ButtonSubmit }}</ui-btn>
|
2022-09-23 18:51:34 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-23 20:37:30 +02:00
|
|
|
</div>
|
2022-09-19 17:29:24 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</modals-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2022-09-23 18:51:34 +02:00
|
|
|
processing: false,
|
2022-09-24 19:23:33 +02:00
|
|
|
lastUsedLibrary: undefined,
|
2022-09-23 20:37:30 +02:00
|
|
|
options: {
|
2022-09-24 19:23:33 +02:00
|
|
|
provider: undefined,
|
2022-09-23 20:37:30 +02:00
|
|
|
overrideDetails: true,
|
|
|
|
overrideCover: true,
|
|
|
|
overrideDefaults: true
|
|
|
|
}
|
2022-09-19 17:29:24 +02:00
|
|
|
}
|
|
|
|
},
|
2022-09-24 19:23:33 +02:00
|
|
|
watch: {
|
|
|
|
show: {
|
|
|
|
handler(newVal) {
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-09-19 17:29:24 +02:00
|
|
|
computed: {
|
|
|
|
show: {
|
|
|
|
get() {
|
|
|
|
return this.$store.state.globals.showBatchQuickMatchModal
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$store.commit('globals/setShowBatchQuickMatchModal', val)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
title() {
|
2022-11-09 00:10:08 +01:00
|
|
|
return this.$getString('MessageItemsSelected', [this.selectedBookIds.length])
|
2022-09-19 17:29:24 +02:00
|
|
|
},
|
|
|
|
showBatchQuickMatchModal() {
|
|
|
|
return this.$store.state.globals.showBatchQuickMatchModal
|
|
|
|
},
|
|
|
|
selectedBookIds() {
|
2022-12-01 00:09:00 +01:00
|
|
|
return (this.$store.state.globals.selectedMediaItems || []).map((i) => i.id)
|
2022-09-19 17:29:24 +02:00
|
|
|
},
|
|
|
|
currentLibraryId() {
|
|
|
|
return this.$store.state.libraries.currentLibraryId
|
2022-09-23 18:51:34 +02:00
|
|
|
},
|
|
|
|
providers() {
|
|
|
|
if (this.isPodcast) return this.$store.state.scanners.podcastProviders
|
|
|
|
return this.$store.state.scanners.providers
|
2022-09-24 19:23:33 +02:00
|
|
|
},
|
|
|
|
libraryProvider() {
|
|
|
|
return this.$store.getters['libraries/getLibraryProvider'](this.currentLibraryId) || 'google'
|
2022-09-25 00:38:58 +02:00
|
|
|
}
|
2022-09-19 17:29:24 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2022-09-24 19:23:33 +02:00
|
|
|
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
|
2022-11-09 00:10:08 +01:00
|
|
|
if (!this.options.provider || this.options.lastUsedLibrary != this.currentLibraryId) {
|
2022-09-24 19:23:33 +02:00
|
|
|
this.options.lastUsedLibrary = this.currentLibraryId
|
2022-09-25 00:37:59 +02:00
|
|
|
this.options.provider = this.libraryProvider
|
2022-09-23 20:37:30 +02:00
|
|
|
}
|
2022-09-24 19:23:33 +02:00
|
|
|
},
|
|
|
|
doBatchQuickMatch() {
|
|
|
|
if (!this.selectedBookIds.length) return
|
|
|
|
if (this.processing) return
|
2022-11-09 00:10:08 +01:00
|
|
|
|
2022-09-24 19:23:33 +02:00
|
|
|
this.processing = true
|
|
|
|
this.$store.commit('setProcessingBatch', true)
|
|
|
|
this.$axios
|
|
|
|
.$post(`/api/items/batch/quickmatch`, {
|
|
|
|
options: this.options,
|
|
|
|
libraryItemIds: this.selectedBookIds
|
|
|
|
})
|
2022-09-24 23:17:36 +02:00
|
|
|
.then(() => {
|
|
|
|
this.$toast.info('Batch quick match of ' + this.selectedBookIds.length + ' books started!')
|
2022-11-09 00:10:08 +01:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
2022-09-24 19:23:33 +02:00
|
|
|
this.$toast.error('Batch quick match failed')
|
|
|
|
console.error('Failed to batch quick match', error)
|
2022-11-09 00:10:08 +01:00
|
|
|
})
|
|
|
|
.finally(() => {
|
2022-09-24 19:23:33 +02:00
|
|
|
this.processing = false
|
|
|
|
this.$store.commit('setProcessingBatch', false)
|
|
|
|
this.show = false
|
|
|
|
})
|
|
|
|
}
|
2022-09-19 17:29:24 +02:00
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|