2021-08-18 13:50:24 +02:00
|
|
|
<template>
|
2021-11-04 23:35:59 +01:00
|
|
|
<div class="w-full h-20 md:h-10 relative">
|
|
|
|
<div class="flex md:hidden h-10 items-center">
|
2022-10-29 01:10:19 +02:00
|
|
|
<nuxt-link :to="`/library/${currentLibraryId}`" class="flex-grow h-full flex justify-center items-center" :class="isHomePage ? 'bg-primary bg-opacity-80' : 'bg-primary bg-opacity-40'">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="text-sm">{{ $strings.ButtonHome }}</p>
|
2021-11-04 23:35:59 +01:00
|
|
|
</nuxt-link>
|
2022-10-29 01:10:19 +02:00
|
|
|
<nuxt-link :to="`/library/${currentLibraryId}/bookshelf`" class="flex-grow h-full flex justify-center items-center" :class="isLibraryPage ? 'bg-primary bg-opacity-80' : 'bg-primary bg-opacity-40'">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="text-sm">{{ $strings.ButtonLibrary }}</p>
|
2021-11-04 23:35:59 +01:00
|
|
|
</nuxt-link>
|
2022-10-29 01:10:19 +02:00
|
|
|
<nuxt-link v-if="!isPodcastLibrary" :to="`/library/${currentLibraryId}/bookshelf/series`" class="flex-grow h-full flex justify-center items-center" :class="isSeriesPage ? 'bg-primary bg-opacity-80' : 'bg-primary bg-opacity-40'">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="text-sm">{{ $strings.ButtonSeries }}</p>
|
2022-06-26 18:34:58 +02:00
|
|
|
</nuxt-link>
|
2022-10-29 01:10:19 +02:00
|
|
|
<nuxt-link v-if="!isPodcastLibrary" :to="`/library/${currentLibraryId}/bookshelf/collections`" class="flex-grow h-full flex justify-center items-center" :class="isCollectionsPage ? 'bg-primary bg-opacity-80' : 'bg-primary bg-opacity-40'">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="text-sm">{{ $strings.ButtonCollections }}</p>
|
2022-06-26 18:34:58 +02:00
|
|
|
</nuxt-link>
|
|
|
|
<nuxt-link v-if="isPodcastLibrary && userIsAdminOrUp" :to="`/library/${currentLibraryId}/podcast/search`" class="flex-grow h-full flex justify-center items-center" :class="isPodcastSearchPage ? 'bg-primary bg-opacity-80' : 'bg-primary bg-opacity-40'">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="text-sm">{{ $strings.ButtonSearch }}</p>
|
2021-11-04 23:35:59 +01:00
|
|
|
</nuxt-link>
|
|
|
|
</div>
|
2022-02-09 18:19:02 +01:00
|
|
|
<div id="toolbar" class="absolute top-10 md:top-0 left-0 w-full h-10 md:h-full z-30 flex items-center justify-end md:justify-start px-2 md:px-8">
|
2022-09-17 22:23:33 +02:00
|
|
|
<template v-if="page !== 'search' && page !== 'podcast-search' && page !== 'recent-episodes' && !isHome">
|
2021-11-04 23:35:59 +01:00
|
|
|
<p v-if="!selectedSeries" class="font-book hidden md:block">{{ numShowing }} {{ entityName }}</p>
|
2022-04-25 00:46:21 +02:00
|
|
|
<div v-else class="items-center hidden md:flex w-full">
|
2022-09-28 00:48:45 +02:00
|
|
|
<p class="pl-2 font-book text-lg">
|
2022-04-25 00:46:21 +02:00
|
|
|
{{ seriesName }}
|
2021-09-24 23:14:33 +02:00
|
|
|
</p>
|
2021-10-09 18:09:06 +02:00
|
|
|
<div class="w-6 h-6 rounded-full bg-black bg-opacity-30 flex items-center justify-center ml-3">
|
|
|
|
<span class="font-mono">{{ numShowing }}</span>
|
|
|
|
</div>
|
2022-04-25 00:46:21 +02:00
|
|
|
<div class="flex-grow" />
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-checkbox v-model="settings.collapseBookSeries" :label="$strings.LabelCollapseSeries" checkbox-bg="bg" check-color="white" small class="mr-2" @input="updateCollapseBookSeries" />
|
|
|
|
<ui-btn color="primary" small :loading="processingSeries" class="flex items-center ml-1 sm:ml-4" @click="markSeriesFinished">
|
2022-04-25 00:46:21 +02:00
|
|
|
<div class="h-5 w-5">
|
2022-11-08 01:27:17 +01:00
|
|
|
<svg v-if="isSeriesFinished" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="rgb(63, 181, 68)">
|
|
|
|
<path d="M19 1H5c-1.1 0-1.99.9-1.99 2L3 15.93c0 .69.35 1.3.88 1.66L12 23l8.11-5.41c.53-.36.88-.97.88-1.66L21 3c0-1.1-.9-2-2-2zm-9 15l-5-5 1.41-1.41L10 13.17l7.59-7.59L19 7l-9 9z" />
|
2022-04-25 00:46:21 +02:00
|
|
|
</svg>
|
|
|
|
<svg v-else xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
2022-11-08 01:27:17 +01:00
|
|
|
<path d="M19 1H5c-1.1 0-1.99.9-1.99 2L3 15.93c0 .69.35 1.3.88 1.66L12 23l8.11-5.41c.53-.36.88-.97.88-1.66L21 3c0-1.1-.9-2-2-2zm-7 19.6l-7-4.66V3h14v12.93l-7 4.67zm-2.01-7.42l-2.58-2.59L6 12l4 4 8-8-1.42-1.42z" />
|
2022-04-25 00:46:21 +02:00
|
|
|
</svg>
|
|
|
|
</div>
|
2022-11-08 01:27:17 +01:00
|
|
|
<span class="pl-2"> {{ $strings.LabelMarkSeries }} {{ isSeriesFinished ? $strings.LabelNotFinished : $strings.LabelFinished }}</span>
|
2022-09-28 00:48:45 +02:00
|
|
|
</ui-btn>
|
2021-09-24 14:32:38 +02:00
|
|
|
</div>
|
2022-02-09 18:19:02 +01:00
|
|
|
<div class="flex-grow hidden sm:inline-block" />
|
2021-09-05 20:21:02 +02:00
|
|
|
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-checkbox v-if="isLibraryPage && !isPodcastLibrary" v-model="settings.collapseSeries" :label="$strings.LabelCollapseSeries" checkbox-bg="bg" check-color="white" small class="mr-2" @input="updateCollapseSeries" />
|
2022-10-29 22:33:38 +02:00
|
|
|
<controls-library-filter-select v-if="isLibraryPage" v-model="settings.filterBy" class="w-36 sm:w-44 md:w-48 h-7.5 ml-1 sm:ml-4" @change="updateFilter" />
|
|
|
|
<controls-library-sort-select v-if="isLibraryPage" v-model="settings.orderBy" :descending.sync="settings.orderDesc" class="w-36 sm:w-44 md:w-48 h-7.5 ml-1 sm:ml-4" @change="updateOrder" />
|
|
|
|
<controls-library-filter-select v-if="isSeriesPage" v-model="seriesFilterBy" is-series class="w-36 sm:w-44 md:w-48 h-7.5 ml-1 sm:ml-4" @change="updateSeriesFilter" />
|
2022-10-29 18:17:51 +02:00
|
|
|
<controls-sort-select v-if="isSeriesPage" v-model="seriesSortBy" :descending.sync="seriesSortDesc" :items="seriesSortItems" class="w-36 sm:w-44 md:w-48 h-7.5 ml-1 sm:ml-4" @change="updateSeriesSort" />
|
2022-04-25 01:25:33 +02:00
|
|
|
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-btn v-if="isIssuesFilter && userCanDelete" :loading="processingIssues" color="error" small class="ml-4" @click="removeAllIssues">{{ $strings.ButtonRemoveAll }} {{ numShowing }} {{ entityName }}</ui-btn>
|
2021-09-24 23:14:33 +02:00
|
|
|
</template>
|
2021-12-02 02:07:03 +01:00
|
|
|
<template v-else-if="page === 'search'">
|
2021-09-24 23:14:33 +02:00
|
|
|
<div class="flex-grow" />
|
2022-11-08 01:27:17 +01:00
|
|
|
<p>{{ $strings.MessageSearchResultsFor }} "{{ searchQuery }}"</p>
|
2021-09-24 23:14:33 +02:00
|
|
|
<div class="flex-grow" />
|
|
|
|
</template>
|
2022-05-29 19:15:39 +02:00
|
|
|
<template v-else-if="page === 'authors'">
|
|
|
|
<div class="flex-grow" />
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-btn v-if="userCanUpdate && authors && authors.length" :loading="processingAuthors" color="primary" small @click="matchAllAuthors">{{ $strings.ButtonMatchAllAuthors }}</ui-btn>
|
2022-05-29 19:15:39 +02:00
|
|
|
</template>
|
2021-08-18 13:50:24 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2021-09-24 14:32:38 +02:00
|
|
|
props: {
|
|
|
|
page: String,
|
2021-09-28 13:44:40 +02:00
|
|
|
isHome: Boolean,
|
2022-04-25 00:46:21 +02:00
|
|
|
selectedSeries: {
|
|
|
|
type: Object,
|
|
|
|
default: () => null
|
|
|
|
},
|
2021-10-30 03:42:28 +02:00
|
|
|
searchQuery: String,
|
2022-05-29 19:15:39 +02:00
|
|
|
authors: {
|
|
|
|
type: Array,
|
|
|
|
default: () => []
|
2022-09-28 00:48:45 +02:00
|
|
|
}
|
2021-09-24 14:32:38 +02:00
|
|
|
},
|
2021-08-18 13:50:24 +02:00
|
|
|
data() {
|
2021-08-19 03:18:44 +02:00
|
|
|
return {
|
2021-08-24 01:31:04 +02:00
|
|
|
settings: {},
|
2021-12-01 03:02:40 +01:00
|
|
|
hasInit: false,
|
|
|
|
totalEntities: 0,
|
2022-04-25 01:25:33 +02:00
|
|
|
processingSeries: false,
|
2022-05-29 19:15:39 +02:00
|
|
|
processingIssues: false,
|
2022-10-29 01:10:19 +02:00
|
|
|
processingAuthors: false,
|
|
|
|
seriesSortItems: [
|
|
|
|
{
|
|
|
|
text: 'Name',
|
|
|
|
value: 'name'
|
|
|
|
},
|
|
|
|
{
|
2022-10-29 18:17:51 +02:00
|
|
|
text: 'Number of Books',
|
2022-10-29 01:10:19 +02:00
|
|
|
value: 'numBooks'
|
|
|
|
},
|
|
|
|
{
|
2022-10-29 18:17:51 +02:00
|
|
|
text: 'Date Added',
|
2022-10-29 01:10:19 +02:00
|
|
|
value: 'addedAt'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'Total Duration',
|
|
|
|
value: 'totalDuration'
|
|
|
|
}
|
|
|
|
]
|
2021-08-19 03:18:44 +02:00
|
|
|
}
|
2021-08-18 13:50:24 +02:00
|
|
|
},
|
|
|
|
computed: {
|
2022-06-26 18:34:58 +02:00
|
|
|
userIsAdminOrUp() {
|
|
|
|
return this.$store.getters['user/getIsAdminOrUp']
|
|
|
|
},
|
2022-04-25 01:25:33 +02:00
|
|
|
userCanDelete() {
|
|
|
|
return this.$store.getters['user/getUserCanDelete']
|
|
|
|
},
|
2022-05-29 19:15:39 +02:00
|
|
|
userCanUpdate() {
|
|
|
|
return this.$store.getters['user/getUserCanUpdate']
|
|
|
|
},
|
2021-10-06 04:10:49 +02:00
|
|
|
currentLibraryId() {
|
|
|
|
return this.$store.state.libraries.currentLibraryId
|
2021-11-04 23:35:59 +01:00
|
|
|
},
|
2022-06-26 18:34:58 +02:00
|
|
|
currentLibraryMediaType() {
|
|
|
|
return this.$store.getters['libraries/getCurrentLibraryMediaType']
|
|
|
|
},
|
|
|
|
isPodcastLibrary() {
|
|
|
|
return this.currentLibraryMediaType === 'podcast'
|
|
|
|
},
|
2022-10-29 01:10:19 +02:00
|
|
|
isLibraryPage() {
|
|
|
|
return this.page === ''
|
|
|
|
},
|
|
|
|
isSeriesPage() {
|
|
|
|
return this.page === 'series'
|
|
|
|
},
|
|
|
|
isCollectionsPage() {
|
|
|
|
return this.page === 'collections'
|
|
|
|
},
|
|
|
|
isHomePage() {
|
2021-11-04 23:35:59 +01:00
|
|
|
return this.$route.name === 'library-library'
|
|
|
|
},
|
2022-10-29 01:10:19 +02:00
|
|
|
isPodcastSearchPage() {
|
|
|
|
return this.$route.name === 'library-library-podcast-search'
|
2021-11-04 23:35:59 +01:00
|
|
|
},
|
2022-10-29 01:10:19 +02:00
|
|
|
numShowing() {
|
|
|
|
return this.totalEntities
|
|
|
|
},
|
|
|
|
entityName() {
|
2022-11-08 01:27:17 +01:00
|
|
|
if (this.isPodcastLibrary) return this.$strings.LabelPodcasts
|
|
|
|
if (!this.page) return this.$strings.LabelBooks
|
|
|
|
if (this.isSeriesPage) return this.$strings.LabelSeries
|
|
|
|
if (this.isCollectionsPage) return this.$strings.LabelCollections
|
2022-10-29 01:10:19 +02:00
|
|
|
return ''
|
2022-04-25 00:46:21 +02:00
|
|
|
},
|
|
|
|
seriesName() {
|
|
|
|
return this.selectedSeries ? this.selectedSeries.name : null
|
|
|
|
},
|
|
|
|
seriesProgress() {
|
|
|
|
return this.selectedSeries ? this.selectedSeries.progress : null
|
|
|
|
},
|
|
|
|
seriesLibraryItemIds() {
|
|
|
|
if (!this.seriesProgress) return []
|
|
|
|
return this.seriesProgress.libraryItemIds || []
|
|
|
|
},
|
|
|
|
isSeriesFinished() {
|
|
|
|
return this.seriesProgress && !!this.seriesProgress.isFinished
|
2022-04-25 01:25:33 +02:00
|
|
|
},
|
|
|
|
filterBy() {
|
|
|
|
return this.$store.getters['user/getUserSetting']('filterBy')
|
|
|
|
},
|
|
|
|
isIssuesFilter() {
|
2022-05-12 00:39:15 +02:00
|
|
|
return this.filterBy === 'issues' && this.$route.query.filter === 'issues'
|
2022-10-29 18:17:51 +02:00
|
|
|
},
|
|
|
|
seriesSortBy: {
|
|
|
|
get() {
|
|
|
|
return this.$store.state.libraries.seriesSortBy
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$store.commit('libraries/setSeriesSortBy', val)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
seriesSortDesc: {
|
|
|
|
get() {
|
|
|
|
return this.$store.state.libraries.seriesSortDesc
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$store.commit('libraries/setSeriesSortDesc', val)
|
|
|
|
}
|
2022-10-29 22:33:38 +02:00
|
|
|
},
|
|
|
|
seriesFilterBy: {
|
|
|
|
get() {
|
|
|
|
return this.$store.state.libraries.seriesFilterBy
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$store.commit('libraries/setSeriesFilterBy', val)
|
|
|
|
}
|
2021-08-19 03:18:44 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2022-05-29 19:15:39 +02:00
|
|
|
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
|
|
|
|
},
|
2022-04-25 01:25:33 +02:00
|
|
|
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
|
|
|
|
this.$axios
|
|
|
|
.$delete(`/api/libraries/${this.currentLibraryId}/issues`)
|
|
|
|
.then(() => {
|
|
|
|
this.$toast.success('Removed library items with issues')
|
|
|
|
this.$router.push(`/library/${this.currentLibraryId}/bookshelf`)
|
|
|
|
this.processingIssues = false
|
2022-09-03 00:20:38 +02:00
|
|
|
this.$store.dispatch('libraries/fetch', this.currentLibraryId)
|
2022-04-25 01:25:33 +02:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to remove library items with issues', error)
|
|
|
|
this.$toast.error('Failed to remove library items with issues')
|
|
|
|
this.processingIssues = false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2022-04-25 00:46:21 +02:00
|
|
|
markSeriesFinished() {
|
|
|
|
var newIsFinished = !this.isSeriesFinished
|
|
|
|
this.processingSeries = true
|
|
|
|
var updateProgressPayloads = this.seriesLibraryItemIds.map((lid) => {
|
|
|
|
return {
|
2022-08-28 21:47:31 +02:00
|
|
|
libraryItemId: lid,
|
2022-04-25 00:46:21 +02:00
|
|
|
isFinished: newIsFinished
|
|
|
|
}
|
|
|
|
})
|
|
|
|
console.log('Progress payloads', updateProgressPayloads)
|
|
|
|
this.$axios
|
|
|
|
.patch(`/api/me/progress/batch/update`, updateProgressPayloads)
|
|
|
|
.then(() => {
|
|
|
|
this.$toast.success('Series update success')
|
|
|
|
this.selectedSeries.progress.isFinished = newIsFinished
|
|
|
|
this.processingSeries = false
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
this.$toast.error('Series update failed')
|
|
|
|
console.error('Failed to batch update read/not read', error)
|
|
|
|
this.processingSeries = false
|
|
|
|
})
|
|
|
|
},
|
2021-08-19 03:18:44 +02:00
|
|
|
updateOrder() {
|
|
|
|
this.saveSettings()
|
|
|
|
},
|
|
|
|
updateFilter() {
|
|
|
|
this.saveSettings()
|
|
|
|
},
|
2022-10-29 01:10:19 +02:00
|
|
|
updateSeriesSort() {
|
|
|
|
this.$eventBus.$emit('series-sort-updated')
|
|
|
|
},
|
2022-10-29 22:33:38 +02:00
|
|
|
updateSeriesFilter() {
|
|
|
|
this.$eventBus.$emit('series-sort-updated')
|
|
|
|
},
|
2022-01-25 01:03:54 +01:00
|
|
|
updateCollapseSeries() {
|
|
|
|
this.saveSettings()
|
|
|
|
},
|
2022-11-03 14:11:33 +01:00
|
|
|
updateCollapseBookSeries() {
|
|
|
|
this.saveSettings()
|
|
|
|
},
|
2021-08-19 03:18:44 +02:00
|
|
|
saveSettings() {
|
2021-08-24 01:31:04 +02:00
|
|
|
this.$store.dispatch('user/updateUserSettings', this.settings)
|
2021-08-18 13:50:24 +02:00
|
|
|
},
|
2021-08-19 03:18:44 +02:00
|
|
|
init() {
|
2021-08-24 01:31:04 +02:00
|
|
|
this.settings = { ...this.$store.state.user.settings }
|
|
|
|
},
|
|
|
|
settingsUpdated(settings) {
|
|
|
|
for (const key in settings) {
|
|
|
|
this.settings[key] = settings[key]
|
|
|
|
}
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
|
|
|
setBookshelfTotalEntities(totalEntities) {
|
|
|
|
this.totalEntities = totalEntities
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
|
|
|
},
|
2021-08-19 03:18:44 +02:00
|
|
|
mounted() {
|
|
|
|
this.init()
|
2021-08-24 01:31:04 +02:00
|
|
|
this.$store.commit('user/addSettingsListener', { id: 'bookshelftoolbar', meth: this.settingsUpdated })
|
2021-12-01 03:02:40 +01:00
|
|
|
this.$eventBus.$on('bookshelf-total-entities', this.setBookshelfTotalEntities)
|
2021-08-24 01:31:04 +02:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.$store.commit('user/removeSettingsListener', 'bookshelftoolbar')
|
2021-12-01 03:02:40 +01:00
|
|
|
this.$eventBus.$off('bookshelf-total-entities', this.setBookshelfTotalEntities)
|
2021-08-19 03:18:44 +02:00
|
|
|
}
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
#toolbar {
|
2021-09-26 22:34:08 +02:00
|
|
|
box-shadow: 0px 8px 6px #111111aa;
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
2022-09-02 03:03:41 +02:00
|
|
|
</style>
|