2021-08-18 00:01:11 +02:00
|
|
|
<template>
|
|
|
|
<div class="w-full h-16 bg-primary relative">
|
2021-12-06 02:21:06 +01:00
|
|
|
<div id="appbar" class="absolute top-0 bottom-0 left-0 w-full h-full px-2 md:px-6 py-1 z-50">
|
2021-08-18 00:01:11 +02:00
|
|
|
<div class="flex h-full items-center">
|
2022-05-09 22:12:55 +02:00
|
|
|
<nuxt-link to="/">
|
2022-06-17 16:48:42 +02:00
|
|
|
<img src="/icon48.png" class="w-8 h-8 mr-8 sm:w-12 sm:h-12 sm:mr-4" />
|
2022-05-09 22:12:55 +02:00
|
|
|
</nuxt-link>
|
|
|
|
|
|
|
|
<nuxt-link to="/">
|
|
|
|
<h1 class="text-2xl font-book mr-6 hidden lg:block hover:underline">audiobookshelf</h1>
|
|
|
|
</nuxt-link>
|
2021-10-05 05:11:42 +02:00
|
|
|
|
2021-10-13 03:07:42 +02:00
|
|
|
<ui-libraries-dropdown />
|
2021-10-05 05:11:42 +02:00
|
|
|
|
2022-06-17 16:48:42 +02:00
|
|
|
<controls-global-search v-if="currentLibrary" class="" />
|
2021-08-18 00:01:11 +02:00
|
|
|
<div class="flex-grow" />
|
|
|
|
|
2021-11-04 23:35:59 +01:00
|
|
|
<span v-if="showExperimentalFeatures" class="material-icons text-4xl text-warning pr-0 sm:pr-2 md:pr-4">logo_dev</span>
|
2021-10-02 22:36:33 +02:00
|
|
|
|
2022-02-24 00:01:11 +01:00
|
|
|
<ui-tooltip v-if="isChromecastInitialized && !isHttps" direction="bottom" text="Casting requires a secure connection" class="flex items-center">
|
|
|
|
<span class="material-icons-outlined text-warning text-opacity-50"> cast </span>
|
|
|
|
</ui-tooltip>
|
2022-02-23 00:33:55 +01:00
|
|
|
<div v-if="isChromecastInitialized" class="w-6 h-6 mr-2 cursor-pointer">
|
|
|
|
<google-cast-launcher></google-cast-launcher>
|
|
|
|
</div>
|
|
|
|
|
2022-05-15 00:23:22 +02:00
|
|
|
<nuxt-link v-if="currentLibrary" to="/config/stats" class="outline-none hover:text-gray-200 cursor-pointer w-8 h-8 flex items-center justify-center mx-1">
|
2022-04-13 22:17:00 +02:00
|
|
|
<span class="material-icons" aria-label="User Stats" role="button">equalizer</span>
|
2021-11-08 02:52:13 +01:00
|
|
|
</nuxt-link>
|
|
|
|
|
2022-05-15 00:23:22 +02:00
|
|
|
<nuxt-link v-if="userCanUpload && currentLibrary" to="/upload" class="outline-none hover:text-gray-200 cursor-pointer w-8 h-8 flex items-center justify-center mx-1">
|
2022-04-13 22:17:00 +02:00
|
|
|
<span class="material-icons" aria-label="Upload Media" role="button">upload</span>
|
2021-09-14 03:18:58 +02:00
|
|
|
</nuxt-link>
|
|
|
|
|
2022-05-04 02:16:16 +02:00
|
|
|
<nuxt-link v-if="userIsAdminOrUp" to="/config" class="outline-none hover:text-gray-200 cursor-pointer w-8 h-8 flex items-center justify-center mx-1">
|
2022-04-13 22:17:00 +02:00
|
|
|
<span class="material-icons" aria-label="System Settings" role="button">settings</span>
|
2021-08-18 00:01:11 +02:00
|
|
|
</nuxt-link>
|
|
|
|
|
2021-11-04 23:35:59 +01:00
|
|
|
<nuxt-link to="/account" class="relative w-9 h-9 md:w-32 bg-fg border border-gray-500 rounded shadow-sm ml-1.5 sm:ml-3 md:ml-5 md:pl-3 md:pr-10 py-2 text-left focus:outline-none sm:text-sm cursor-pointer hover:bg-bg hover:bg-opacity-40" aria-haspopup="listbox" aria-expanded="true">
|
|
|
|
<span class="items-center hidden md:flex">
|
2021-09-05 20:21:02 +02:00
|
|
|
<span class="block truncate">{{ username }}</span>
|
|
|
|
</span>
|
2021-11-04 23:35:59 +01:00
|
|
|
<span class="h-full md:ml-3 md:absolute inset-y-0 md:right-0 flex items-center justify-center md:pr-2 pointer-events-none">
|
2021-09-05 20:21:02 +02:00
|
|
|
<span class="material-icons text-gray-100">person</span>
|
|
|
|
</span>
|
|
|
|
</nuxt-link>
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
2021-08-27 01:32:05 +02:00
|
|
|
|
2022-03-13 23:10:48 +01:00
|
|
|
<div v-show="numLibraryItemsSelected" class="absolute top-0 left-0 w-full h-full px-4 bg-primary flex items-center">
|
|
|
|
<h1 class="text-2xl px-4">{{ numLibraryItemsSelected }} Selected</h1>
|
2021-08-27 01:32:05 +02:00
|
|
|
<div class="flex-grow" />
|
2022-03-26 21:23:25 +01:00
|
|
|
<ui-tooltip v-if="!isPodcastLibrary" :text="`Mark as ${selectedIsFinished ? 'Not Finished' : 'Finished'}`" direction="bottom">
|
2022-03-17 19:33:22 +01:00
|
|
|
<ui-read-icon-btn :disabled="processingBatch" :is-read="selectedIsFinished" @click="toggleBatchRead" class="mx-1.5" />
|
2021-09-16 15:37:09 +02:00
|
|
|
</ui-tooltip>
|
2022-03-26 21:23:25 +01:00
|
|
|
<ui-tooltip v-if="userCanUpdate && !isPodcastLibrary" text="Add to Collection" direction="bottom">
|
2021-11-27 23:01:53 +01:00
|
|
|
<ui-icon-btn :disabled="processingBatch" icon="collections_bookmark" @click="batchAddToCollectionClick" class="mx-1.5" />
|
|
|
|
</ui-tooltip>
|
2022-03-13 23:10:48 +01:00
|
|
|
<template v-if="userCanUpdate && numLibraryItemsSelected < 50">
|
2022-04-29 00:44:07 +02:00
|
|
|
<ui-tooltip text="Edit" direction="bottom">
|
|
|
|
<ui-icon-btn v-show="!processingBatchDelete" icon="edit" bg-color="warning" class="mx-1.5" @click="batchEditClick" />
|
|
|
|
</ui-tooltip>
|
2021-09-07 00:42:15 +02:00
|
|
|
</template>
|
2022-04-29 00:44:07 +02:00
|
|
|
<ui-tooltip v-if="userCanDelete" text="Delete" direction="bottom">
|
2022-04-30 18:21:27 +02:00
|
|
|
<ui-icon-btn :disabled="processingBatchDelete" icon="delete" bg-color="error" class="mx-1.5" @click="batchDeleteClick" />
|
2022-04-29 00:44:07 +02:00
|
|
|
</ui-tooltip>
|
|
|
|
<ui-tooltip text="Deselect All" direction="bottom">
|
|
|
|
<span class="material-icons text-4xl px-4 hover:text-gray-100 cursor-pointer" :class="processingBatchDelete ? 'text-gray-400' : ''" @click="cancelSelectionMode">close</span>
|
|
|
|
</ui-tooltip>
|
2021-08-27 01:32:05 +02:00
|
|
|
</div>
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-12-01 03:02:40 +01:00
|
|
|
processingBatchDelete: false,
|
2021-12-02 02:07:03 +01:00
|
|
|
totalEntities: 0,
|
2021-12-01 03:02:40 +01:00
|
|
|
isAllSelected: false
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2021-10-05 05:11:42 +02:00
|
|
|
currentLibrary() {
|
|
|
|
return this.$store.getters['libraries/getCurrentLibrary']
|
|
|
|
},
|
|
|
|
libraryName() {
|
|
|
|
return this.currentLibrary ? this.currentLibrary.name : 'unknown'
|
|
|
|
},
|
2022-03-26 21:23:25 +01:00
|
|
|
libraryMediaType() {
|
|
|
|
return this.currentLibrary ? this.currentLibrary.mediaType : null
|
|
|
|
},
|
|
|
|
isPodcastLibrary() {
|
|
|
|
return this.libraryMediaType === 'podcast'
|
|
|
|
},
|
2021-09-28 13:44:40 +02:00
|
|
|
isHome() {
|
2021-10-05 05:11:42 +02:00
|
|
|
return this.$route.name === 'library-library'
|
2021-09-28 13:44:40 +02:00
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
user() {
|
2021-08-24 01:31:04 +02:00
|
|
|
return this.$store.state.user.user
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
2022-05-04 02:16:16 +02:00
|
|
|
userIsAdminOrUp() {
|
|
|
|
return this.$store.getters['user/getIsAdminOrUp']
|
2021-08-27 14:01:47 +02:00
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
username() {
|
|
|
|
return this.user ? this.user.username : 'err'
|
2021-08-27 01:32:05 +02:00
|
|
|
},
|
2022-03-13 23:10:48 +01:00
|
|
|
numLibraryItemsSelected() {
|
|
|
|
return this.selectedLibraryItems.length
|
2021-08-27 01:32:05 +02:00
|
|
|
},
|
2022-03-13 23:10:48 +01:00
|
|
|
selectedLibraryItems() {
|
|
|
|
return this.$store.state.selectedLibraryItems
|
2021-08-27 01:32:05 +02:00
|
|
|
},
|
2022-03-26 17:59:34 +01:00
|
|
|
userMediaProgress() {
|
|
|
|
return this.$store.state.user.user.mediaProgress || []
|
2021-09-16 15:37:09 +02:00
|
|
|
},
|
2021-09-07 00:42:15 +02:00
|
|
|
userCanUpdate() {
|
|
|
|
return this.$store.getters['user/getUserCanUpdate']
|
|
|
|
},
|
|
|
|
userCanDelete() {
|
|
|
|
return this.$store.getters['user/getUserCanDelete']
|
2021-09-16 15:37:09 +02:00
|
|
|
},
|
2021-09-18 19:45:34 +02:00
|
|
|
userCanUpload() {
|
|
|
|
return this.$store.getters['user/getUserCanUpload']
|
|
|
|
},
|
2022-03-17 19:33:22 +01:00
|
|
|
selectedIsFinished() {
|
|
|
|
// Find an item that is not finished, if none then all items finished
|
|
|
|
return !this.selectedLibraryItems.find((libraryItemId) => {
|
2022-04-09 02:27:35 +02:00
|
|
|
var itemProgress = this.userMediaProgress.find((lip) => lip.libraryItemId === libraryItemId)
|
2022-03-17 19:33:22 +01:00
|
|
|
return !itemProgress || !itemProgress.isFinished
|
2021-09-16 15:37:09 +02:00
|
|
|
})
|
2021-09-17 21:15:15 +02:00
|
|
|
},
|
|
|
|
processingBatch() {
|
|
|
|
return this.$store.state.processingBatch
|
2021-10-02 22:36:33 +02:00
|
|
|
},
|
|
|
|
showExperimentalFeatures() {
|
|
|
|
return this.$store.state.showExperimentalFeatures
|
2022-02-23 00:33:55 +01:00
|
|
|
},
|
|
|
|
isChromecastEnabled() {
|
|
|
|
return this.$store.getters['getServerSetting']('chromecastEnabled')
|
|
|
|
},
|
|
|
|
isChromecastInitialized() {
|
|
|
|
return this.$store.state.globals.isChromecastInitialized
|
2022-02-24 00:01:11 +01:00
|
|
|
},
|
|
|
|
isHttps() {
|
|
|
|
return location.protocol === 'https:' || process.env.NODE_ENV === 'development'
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2021-08-27 01:32:05 +02:00
|
|
|
cancelSelectionMode() {
|
|
|
|
if (this.processingBatchDelete) return
|
2022-03-13 23:10:48 +01:00
|
|
|
this.$store.commit('setSelectedLibraryItems', [])
|
2021-12-01 03:02:40 +01:00
|
|
|
this.$eventBus.$emit('bookshelf-clear-selection')
|
|
|
|
this.isAllSelected = false
|
2021-08-27 01:32:05 +02:00
|
|
|
},
|
2021-09-16 15:37:09 +02:00
|
|
|
toggleBatchRead() {
|
2021-09-17 21:15:15 +02:00
|
|
|
this.$store.commit('setProcessingBatch', true)
|
2022-03-17 19:33:22 +01:00
|
|
|
var newIsFinished = !this.selectedIsFinished
|
2022-03-13 23:10:48 +01:00
|
|
|
var updateProgressPayloads = this.selectedLibraryItems.map((lid) => {
|
2021-09-16 15:37:09 +02:00
|
|
|
return {
|
2022-03-17 19:33:22 +01:00
|
|
|
id: lid,
|
|
|
|
isFinished: newIsFinished
|
2021-09-16 15:37:09 +02:00
|
|
|
}
|
|
|
|
})
|
2022-04-24 00:17:05 +02:00
|
|
|
console.log('Progress payloads', updateProgressPayloads)
|
2021-09-16 15:37:09 +02:00
|
|
|
this.$axios
|
2022-03-17 19:33:22 +01:00
|
|
|
.patch(`/api/me/progress/batch/update`, updateProgressPayloads)
|
2021-09-16 15:37:09 +02:00
|
|
|
.then(() => {
|
|
|
|
this.$toast.success('Batch update success!')
|
|
|
|
this.$store.commit('setProcessingBatch', false)
|
2022-03-13 23:10:48 +01:00
|
|
|
this.$store.commit('setSelectedLibraryItems', [])
|
2021-12-02 02:07:03 +01:00
|
|
|
this.$eventBus.$emit('bookshelf-clear-selection')
|
2021-09-16 15:37:09 +02:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
this.$toast.error('Batch update failed')
|
|
|
|
console.error('Failed to batch update read/not read', error)
|
|
|
|
this.$store.commit('setProcessingBatch', false)
|
|
|
|
})
|
|
|
|
},
|
2021-08-27 01:32:05 +02:00
|
|
|
batchDeleteClick() {
|
2022-03-18 01:10:47 +01:00
|
|
|
var audiobookText = this.numLibraryItemsSelected > 1 ? `these ${this.numLibraryItemsSelected} items` : 'this item'
|
|
|
|
var confirmMsg = `Are you sure you want to remove ${audiobookText}?\n\n*Does not delete your files, only removes the items from Audiobookshelf`
|
2021-09-16 15:37:09 +02:00
|
|
|
if (confirm(confirmMsg)) {
|
2021-08-27 01:32:05 +02:00
|
|
|
this.processingBatchDelete = true
|
|
|
|
this.$store.commit('setProcessingBatch', true)
|
|
|
|
this.$axios
|
2022-03-13 23:10:48 +01:00
|
|
|
.$post(`/api/items/batch/delete`, {
|
|
|
|
libraryItemIds: this.selectedLibraryItems
|
2021-08-27 01:32:05 +02:00
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.$toast.success('Batch delete success!')
|
|
|
|
this.processingBatchDelete = false
|
|
|
|
this.$store.commit('setProcessingBatch', false)
|
2022-03-13 23:10:48 +01:00
|
|
|
this.$store.commit('setSelectedLibraryItems', [])
|
2021-12-02 02:07:03 +01:00
|
|
|
this.$eventBus.$emit('bookshelf-clear-selection')
|
2021-08-27 01:32:05 +02:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
this.$toast.error('Batch delete failed')
|
|
|
|
console.error('Failed to batch delete', error)
|
|
|
|
this.processingBatchDelete = false
|
|
|
|
this.$store.commit('setProcessingBatch', false)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
batchEditClick() {
|
|
|
|
this.$router.push('/batch')
|
2021-11-27 23:01:53 +01:00
|
|
|
},
|
|
|
|
batchAddToCollectionClick() {
|
|
|
|
this.$store.commit('globals/setShowBatchUserCollectionsModal', true)
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
2021-12-02 02:07:03 +01:00
|
|
|
setBookshelfTotalEntities(totalEntities) {
|
|
|
|
this.totalEntities = totalEntities
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
2021-12-01 03:02:40 +01:00
|
|
|
mounted() {
|
2021-12-02 02:07:03 +01:00
|
|
|
this.$eventBus.$on('bookshelf-total-entities', this.setBookshelfTotalEntities)
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2021-12-02 02:07:03 +01:00
|
|
|
this.$eventBus.$off('bookshelf-total-entities', this.setBookshelfTotalEntities)
|
2021-12-01 03:02:40 +01:00
|
|
|
}
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
#appbar {
|
2021-08-18 13:50:24 +02:00
|
|
|
box-shadow: 0px 5px 5px #11111155;
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
2022-04-29 00:44:07 +02:00
|
|
|
</style>
|