diff --git a/client/components/modals/rssfeed/CollectionModal.vue b/client/components/modals/rssfeed/CollectionModal.vue new file mode 100644 index 00000000..0f924c8b --- /dev/null +++ b/client/components/modals/rssfeed/CollectionModal.vue @@ -0,0 +1,152 @@ + + + diff --git a/client/pages/collection/_id.vue b/client/pages/collection/_id.vue index 3d1a0ddc..5d69dd80 100644 --- a/client/pages/collection/_id.vue +++ b/client/pages/collection/_id.vue @@ -19,6 +19,11 @@ {{ streaming ? $strings.ButtonPlaying : $strings.ButtonPlay }} + + + + + @@ -37,6 +42,8 @@
+ + @@ -46,7 +53,7 @@ export default { if (!store.state.user.user) { return redirect(`/login?redirect=${route.path}`) } - var collection = await app.$axios.$get(`/api/collections/${params.id}`).catch((error) => { + const collection = await app.$axios.$get(`/api/collections/${params.id}?include=rssfeed`).catch((error) => { console.error('Failed', error) return false }) @@ -61,12 +68,14 @@ export default { store.commit('libraries/addUpdateCollection', collection) return { - collectionId: collection.id + collectionId: collection.id, + rssFeed: collection.rssFeed || null } }, data() { return { - processing: false + processing: false, + showRssFeedModal: false } }, computed: { @@ -99,6 +108,9 @@ export default { showPlayButton() { return this.playableBooks.length }, + userIsAdminOrUp() { + return this.$store.getters['user/getIsAdminOrUp'] + }, userCanUpdate() { return this.$store.getters['user/getUserCanUpdate'] }, @@ -112,6 +124,12 @@ export default { action: 'create-playlist' } ] + if (this.userIsAdminOrUp) { + items.push({ + text: this.$strings.LabelOpenRSSFeed, + action: 'open-rss-feed' + }) + } if (this.userCanDelete) { items.push({ text: this.$strings.ButtonDelete, @@ -122,11 +140,16 @@ export default { } }, methods: { + clickRSSFeed() { + this.showRssFeedModal = true + }, contextMenuAction(action) { if (action === 'delete') { this.removeClick() } else if (action === 'create-playlist') { this.createPlaylistFromCollection() + } else if (action === 'open-rss-feed') { + this.showRssFeedModal = true } }, createPlaylistFromCollection() { @@ -206,9 +229,27 @@ export default { queueItems }) } + }, + rssFeedOpen(data) { + if (data.entityId === this.collectionId) { + console.log('RSS Feed Opened', data) + this.rssFeed = data + } + }, + rssFeedClosed(data) { + if (data.entityId === this.collectionId) { + console.log('RSS Feed Closed', data) + this.rssFeed = null + } } }, - mounted() {}, - beforeDestroy() {} + mounted() { + this.$root.socket.on('rss_feed_open', this.rssFeedOpen) + this.$root.socket.on('rss_feed_closed', this.rssFeedClosed) + }, + beforeDestroy() { + this.$root.socket.off('rss_feed_open', this.rssFeedOpen) + this.$root.socket.off('rss_feed_closed', this.rssFeedClosed) + } } diff --git a/server/controllers/CollectionController.js b/server/controllers/CollectionController.js index f4161f37..0c950c41 100644 --- a/server/controllers/CollectionController.js +++ b/server/controllers/CollectionController.js @@ -26,7 +26,16 @@ class CollectionController { } findOne(req, res) { - res.json(req.collection.toJSONExpanded(this.db.libraryItems)) + const includeEntities = (req.query.include || '').split(',') + + const collectionExpanded = req.collection.toJSONExpanded(this.db.libraryItems) + + if (includeEntities.includes('rssfeed')) { + const feedData = this.rssFeedManager.findFeedForEntityId(collectionExpanded.id) + collectionExpanded.rssFeed = feedData ? feedData.toJSONMinified() : null + } + + res.json(collectionExpanded) } async update(req, res) { diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index c439f091..ca2c1b00 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -21,7 +21,7 @@ class LibraryItemController { } if (includeEntities.includes('rssfeed')) { - const feedData = this.rssFeedManager.findFeedForItem(item.id) + const feedData = this.rssFeedManager.findFeedForEntityId(item.id) item.rssFeed = feedData ? feedData.toJSONMinified() : null } diff --git a/server/managers/RssFeedManager.js b/server/managers/RssFeedManager.js index 1876816f..3790f5ee 100644 --- a/server/managers/RssFeedManager.js +++ b/server/managers/RssFeedManager.js @@ -28,8 +28,8 @@ class RssFeedManager { } } - findFeedForItem(libraryItemId) { - return Object.values(this.feeds).find(feed => feed.entityId === libraryItemId) + findFeedForEntityId(entityId) { + return Object.values(this.feeds).find(feed => feed.entityId === entityId) } findFeed(feedId) {