mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-19 03:15:58 +02:00
Add book item more menu item for Share, restrict share to admin or up, add admin socket events for open/close shares
This commit is contained in:
@@ -601,6 +601,30 @@ export default {
|
||||
this.executeRebuild()
|
||||
}
|
||||
},
|
||||
shareOpen(mediaItemShare) {
|
||||
if (this.entityName === 'items' || this.entityName === 'series-books') {
|
||||
var indexOf = this.entities.findIndex((ent) => ent?.media?.id === mediaItemShare.mediaItemId)
|
||||
if (indexOf >= 0) {
|
||||
if (this.entityComponentRefs[indexOf]) {
|
||||
const libraryItem = { ...this.entityComponentRefs[indexOf].libraryItem }
|
||||
libraryItem.mediaItemShare = mediaItemShare
|
||||
this.entityComponentRefs[indexOf].setEntity?.(libraryItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
shareClosed(mediaItemShare) {
|
||||
if (this.entityName === 'items' || this.entityName === 'series-books') {
|
||||
var indexOf = this.entities.findIndex((ent) => ent?.media?.id === mediaItemShare.mediaItemId)
|
||||
if (indexOf >= 0) {
|
||||
if (this.entityComponentRefs[indexOf]) {
|
||||
const libraryItem = { ...this.entityComponentRefs[indexOf].libraryItem }
|
||||
libraryItem.mediaItemShare = null
|
||||
this.entityComponentRefs[indexOf].setEntity?.(libraryItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
updatePagesLoaded() {
|
||||
let numPages = Math.ceil(this.totalEntities / this.booksPerFetch)
|
||||
for (let page = 0; page < numPages; page++) {
|
||||
@@ -703,6 +727,8 @@ export default {
|
||||
this.$root.socket.on('playlist_added', this.playlistAdded)
|
||||
this.$root.socket.on('playlist_updated', this.playlistUpdated)
|
||||
this.$root.socket.on('playlist_removed', this.playlistRemoved)
|
||||
this.$root.socket.on('share_open', this.shareOpen)
|
||||
this.$root.socket.on('share_closed', this.shareClosed)
|
||||
} else {
|
||||
console.error('Bookshelf - Socket not initialized')
|
||||
}
|
||||
@@ -730,6 +756,8 @@ export default {
|
||||
this.$root.socket.off('playlist_added', this.playlistAdded)
|
||||
this.$root.socket.off('playlist_updated', this.playlistUpdated)
|
||||
this.$root.socket.off('playlist_removed', this.playlistRemoved)
|
||||
this.$root.socket.off('share_open', this.shareOpen)
|
||||
this.$root.socket.off('share_closed', this.shareClosed)
|
||||
} else {
|
||||
console.error('Bookshelf - Socket not initialized')
|
||||
}
|
||||
|
@@ -528,6 +528,12 @@ export default {
|
||||
func: 'openPlaylists',
|
||||
text: this.$strings.LabelAddToPlaylist
|
||||
})
|
||||
if (this.userIsAdminOrUp) {
|
||||
items.push({
|
||||
func: 'openShare',
|
||||
text: this.$strings.LabelShare
|
||||
})
|
||||
}
|
||||
}
|
||||
if (this.ebookFormat && this.store.state.libraries.ereaderDevices?.length) {
|
||||
items.push({
|
||||
@@ -880,6 +886,10 @@ export default {
|
||||
this.store.commit('globals/setSelectedPlaylistItems', [{ libraryItem: this.libraryItem, episode: this.recentEpisode }])
|
||||
this.store.commit('globals/setShowPlaylistsModal', true)
|
||||
},
|
||||
openShare() {
|
||||
this.store.commit('setSelectedLibraryItem', this.libraryItem)
|
||||
this.store.commit('globals/setShareModal', this.mediaItemShare)
|
||||
},
|
||||
deleteLibraryItem() {
|
||||
const payload = {
|
||||
message: this.$strings.MessageConfirmDeleteLibraryItem,
|
||||
|
@@ -89,6 +89,9 @@ export default {
|
||||
this.$emit('input', val)
|
||||
}
|
||||
},
|
||||
userIsAdminOrUp() {
|
||||
return this.$store.getters['user/getIsAdminOrUp']
|
||||
},
|
||||
libraryMediaType() {
|
||||
return this.$store.getters['libraries/getCurrentLibraryMediaType']
|
||||
},
|
||||
@@ -148,7 +151,7 @@ export default {
|
||||
]
|
||||
},
|
||||
bookItems() {
|
||||
return [
|
||||
const items = [
|
||||
{
|
||||
text: this.$strings.LabelAll,
|
||||
value: 'all'
|
||||
@@ -229,13 +232,16 @@ export default {
|
||||
text: this.$strings.LabelRSSFeedOpen,
|
||||
value: 'feed-open',
|
||||
sublist: false
|
||||
},
|
||||
{
|
||||
}
|
||||
]
|
||||
if (this.userIsAdminOrUp) {
|
||||
items.push({
|
||||
text: this.$strings.LabelShareOpen,
|
||||
value: 'share-open',
|
||||
sublist: false
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
return items
|
||||
},
|
||||
podcastItems() {
|
||||
return [
|
||||
|
@@ -53,17 +53,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
value: Boolean,
|
||||
libraryItem: {
|
||||
type: Object,
|
||||
default: () => null
|
||||
},
|
||||
mediaItemShare: {
|
||||
type: Object,
|
||||
default: () => null
|
||||
}
|
||||
},
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
processing: false,
|
||||
@@ -99,12 +89,18 @@ export default {
|
||||
computed: {
|
||||
show: {
|
||||
get() {
|
||||
return this.value
|
||||
return this.$store.state.globals.showShareModal
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('input', val)
|
||||
this.$store.commit('globals/setShowShareModal', val)
|
||||
}
|
||||
},
|
||||
mediaItemShare() {
|
||||
return this.$store.state.globals.selectedMediaItemShare
|
||||
},
|
||||
libraryItem() {
|
||||
return this.$store.state.selectedLibraryItem
|
||||
},
|
||||
user() {
|
||||
return this.$store.state.user.user
|
||||
},
|
||||
|
Reference in New Issue
Block a user