2021-08-18 00:01:11 +02:00
|
|
|
<template>
|
|
|
|
<div class="w-full h-16 bg-primary relative">
|
2021-08-20 00:29:36 +02:00
|
|
|
<div id="appbar" class="absolute top-0 bottom-0 left-0 w-full h-full px-6 py-1 z-30">
|
2021-08-18 00:01:11 +02:00
|
|
|
<div class="flex h-full items-center">
|
2021-09-03 13:40:59 +02:00
|
|
|
<img v-if="!showBack" src="/Logo48.png" class="w-12 h-12 mr-4" />
|
2021-08-18 00:01:11 +02:00
|
|
|
<a v-if="showBack" @click="back" class="rounded-full h-12 w-12 flex items-center justify-center hover:bg-white hover:bg-opacity-10 mr-4 cursor-pointer">
|
|
|
|
<span class="material-icons text-4xl text-white">arrow_back</span>
|
|
|
|
</a>
|
2021-09-01 20:47:18 +02:00
|
|
|
<h1 class="text-2xl font-book mr-6">AudioBookshelf</h1>
|
2021-09-23 03:40:35 +02:00
|
|
|
<!-- <div class="-mb-2">
|
|
|
|
<h1 class="text-lg font-book leading-3 mr-6 px-1">AudioBookshelf</h1>
|
|
|
|
<div class="bg-black bg-opacity-20 rounded-sm py-1.5 px-2 mt-1.5 flex items-center justify-between border border-bg">
|
|
|
|
<p class="text-sm text-gray-400 leading-3">My Library</p>
|
|
|
|
<span class="material-icons text-sm leading-3 text-gray-400">expand_more</span>
|
|
|
|
</div>
|
|
|
|
</div> -->
|
2021-08-21 23:23:35 +02:00
|
|
|
<controls-global-search />
|
2021-08-18 00:01:11 +02:00
|
|
|
<div class="flex-grow" />
|
|
|
|
|
2021-09-18 19:45:34 +02:00
|
|
|
<nuxt-link v-if="userCanUpload" to="/upload" class="outline-none hover:text-gray-200 cursor-pointer w-8 h-8 flex items-center justify-center">
|
2021-09-14 03:18:58 +02:00
|
|
|
<span class="material-icons">upload</span>
|
|
|
|
</nuxt-link>
|
|
|
|
|
2021-09-18 19:45:34 +02:00
|
|
|
<nuxt-link v-if="isRootUser" to="/config" class="outline-none hover:text-gray-200 cursor-pointer w-8 h-8 flex items-center justify-center ml-4">
|
2021-08-18 00:01:11 +02:00
|
|
|
<span class="material-icons">settings</span>
|
|
|
|
</nuxt-link>
|
|
|
|
|
2021-09-05 20:21:02 +02:00
|
|
|
<nuxt-link to="/account" class="relative w-32 bg-fg border border-gray-500 rounded shadow-sm ml-5 pl-3 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="flex items-center">
|
|
|
|
<span class="block truncate">{{ username }}</span>
|
|
|
|
</span>
|
|
|
|
<span class="ml-3 absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
|
|
|
|
<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
|
|
|
|
|
|
|
<div v-show="numAudiobooksSelected" class="absolute top-0 left-0 w-full h-full px-4 bg-primary flex items-center">
|
|
|
|
<h1 class="text-2xl px-4">{{ numAudiobooksSelected }} Selected</h1>
|
|
|
|
<ui-btn small class="text-sm mx-2" @click="toggleSelectAll">{{ isAllSelected ? 'Select None' : 'Select All' }}</ui-btn>
|
|
|
|
|
|
|
|
<div class="flex-grow" />
|
2021-09-17 21:15:15 +02:00
|
|
|
|
|
|
|
<ui-tooltip :text="`Mark as ${selectedIsRead ? 'Not Read' : 'Read'}`" direction="bottom">
|
|
|
|
<ui-read-icon-btn :disabled="processingBatch" :is-read="selectedIsRead" @click="toggleBatchRead" class="mx-1.5" />
|
2021-09-16 15:37:09 +02:00
|
|
|
</ui-tooltip>
|
2021-09-07 00:42:15 +02:00
|
|
|
<template v-if="userCanUpdate">
|
2021-09-16 15:37:09 +02:00
|
|
|
<ui-icon-btn v-show="!processingBatchDelete" icon="edit" bg-color="warning" class="mx-1.5" @click="batchEditClick" />
|
2021-09-07 00:42:15 +02:00
|
|
|
</template>
|
2021-09-16 15:37:09 +02:00
|
|
|
<ui-icon-btn v-show="userCanDelete" :disabled="processingBatchDelete" icon="delete" bg-color="error" class="mx-1.5" @click="batchDeleteClick" />
|
2021-08-27 01:32:05 +02:00
|
|
|
<span class="material-icons text-4xl px-4 hover:text-gray-100 cursor-pointer" :class="processingBatchDelete ? 'text-gray-400' : ''" @click="cancelSelectionMode">close</span>
|
|
|
|
</div>
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-08-27 01:32:05 +02:00
|
|
|
processingBatchDelete: false
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
showBack() {
|
2021-09-24 14:32:38 +02:00
|
|
|
return this.$route.name !== 'library-id'
|
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
|
|
|
},
|
2021-08-27 14:01:47 +02:00
|
|
|
isRootUser() {
|
|
|
|
return this.$store.getters['user/getIsRoot']
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
username() {
|
|
|
|
return this.user ? this.user.username : 'err'
|
2021-08-27 01:32:05 +02:00
|
|
|
},
|
|
|
|
numAudiobooksSelected() {
|
|
|
|
return this.selectedAudiobooks.length
|
|
|
|
},
|
|
|
|
selectedAudiobooks() {
|
|
|
|
return this.$store.state.selectedAudiobooks
|
|
|
|
},
|
|
|
|
isAllSelected() {
|
|
|
|
return this.audiobooksShowing.length === this.selectedAudiobooks.length
|
|
|
|
},
|
2021-09-16 15:37:09 +02:00
|
|
|
userAudiobooks() {
|
|
|
|
return this.$store.state.user.user.audiobooks || {}
|
|
|
|
},
|
2021-08-27 01:32:05 +02:00
|
|
|
audiobooksShowing() {
|
|
|
|
return this.$store.getters['audiobooks/getFiltered']()
|
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']
|
|
|
|
},
|
2021-09-16 15:37:09 +02:00
|
|
|
selectedIsRead() {
|
|
|
|
// Find an audiobook that is not read, if none then all audiobooks read
|
|
|
|
return !this.selectedAudiobooks.find((ab) => {
|
|
|
|
var userAb = this.userAudiobooks[ab]
|
|
|
|
return !userAb || !userAb.isRead
|
|
|
|
})
|
2021-09-17 21:15:15 +02:00
|
|
|
},
|
|
|
|
processingBatch() {
|
|
|
|
return this.$store.state.processingBatch
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
back() {
|
|
|
|
if (this.$route.name === 'audiobook-id-edit') {
|
|
|
|
this.$router.push(`/audiobook/${this.$route.params.id}`)
|
|
|
|
} else {
|
2021-09-24 14:32:38 +02:00
|
|
|
this.$router.push('/library')
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
2021-08-27 01:32:05 +02:00
|
|
|
cancelSelectionMode() {
|
|
|
|
if (this.processingBatchDelete) return
|
|
|
|
this.$store.commit('setSelectedAudiobooks', [])
|
|
|
|
},
|
|
|
|
toggleSelectAll() {
|
|
|
|
if (this.isAllSelected) {
|
|
|
|
this.cancelSelectionMode()
|
|
|
|
} else {
|
|
|
|
var audiobookIds = this.audiobooksShowing.map((a) => a.id)
|
|
|
|
this.$store.commit('setSelectedAudiobooks', audiobookIds)
|
|
|
|
}
|
|
|
|
},
|
2021-09-16 15:37:09 +02:00
|
|
|
toggleBatchRead() {
|
2021-09-17 21:15:15 +02:00
|
|
|
this.$store.commit('setProcessingBatch', true)
|
2021-09-16 15:37:09 +02:00
|
|
|
var newIsRead = !this.selectedIsRead
|
|
|
|
var updateProgressPayloads = this.selectedAudiobooks.map((ab) => {
|
|
|
|
return {
|
|
|
|
audiobookId: ab,
|
|
|
|
isRead: newIsRead
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.$axios
|
|
|
|
.patch(`/api/user/audiobooks`, updateProgressPayloads)
|
|
|
|
.then(() => {
|
|
|
|
this.$toast.success('Batch update success!')
|
|
|
|
this.$store.commit('setProcessingBatch', false)
|
|
|
|
this.$store.commit('setSelectedAudiobooks', [])
|
|
|
|
})
|
|
|
|
.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() {
|
2021-09-16 15:37:09 +02:00
|
|
|
var audiobookText = this.numAudiobooksSelected > 1 ? `these ${this.numAudiobooksSelected} audiobooks` : 'this audiobook'
|
|
|
|
var confirmMsg = `Are you sure you want to remove ${audiobookText}?\n\n*Does not delete your files, only removes the audiobooks from AudioBookshelf`
|
|
|
|
if (confirm(confirmMsg)) {
|
2021-08-27 01:32:05 +02:00
|
|
|
this.processingBatchDelete = true
|
|
|
|
this.$store.commit('setProcessingBatch', true)
|
|
|
|
this.$axios
|
|
|
|
.$post(`/api/audiobooks/delete`, {
|
|
|
|
audiobookIds: this.selectedAudiobooks
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.$toast.success('Batch delete success!')
|
|
|
|
this.processingBatchDelete = false
|
|
|
|
this.$store.commit('setProcessingBatch', false)
|
|
|
|
this.$store.commit('setSelectedAudiobooks', [])
|
|
|
|
})
|
|
|
|
.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-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</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
|
|
|
}
|
|
|
|
</style>
|