diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Browser.vue b/platypush/backend/http/webapp/src/components/panels/Media/Browser.vue
index 291cc989eb..0fb9b73caf 100644
--- a/platypush/backend/http/webapp/src/components/panels/Media/Browser.vue
+++ b/platypush/backend/http/webapp/src/components/panels/Media/Browser.vue
@@ -23,8 +23,9 @@
@@ -44,6 +45,7 @@ export default {
mixins: [Utils],
emits: [
'add-to-playlist',
+ 'back',
'create-playlist',
'path-change',
'play',
@@ -62,6 +64,10 @@ export default {
type: String,
default: '',
},
+
+ selectedPlaylist: {
+ type: Object,
+ },
},
data() {
@@ -73,7 +79,22 @@ export default {
}
},
+ computed: {
+ mediaProvidersLookup() {
+ return Object.keys(this.mediaProviders)
+ .reduce((acc, key) => {
+ acc[key.toLowerCase()] = key
+ return acc
+ }, {})
+ },
+ },
+
methods: {
+ back() {
+ this.mediaProvider = null
+ this.$emit('back')
+ },
+
registerMediaProvider(type) {
const component = shallowRef(
defineAsyncComponent(
@@ -94,10 +115,29 @@ export default {
if (config.youtube)
this.registerMediaProvider('YouTube')
},
+
+ async onPlaylistChange() {
+ if (!this.selectedPlaylist)
+ return
+
+ const playlistType = this.selectedPlaylist.type?.toLowerCase()
+ const playlistMediaProvider = this.mediaProvidersLookup[playlistType]
+
+ if (playlistMediaProvider) {
+ this.mediaProvider = this.mediaProviders[playlistMediaProvider]
+ }
+ },
},
- mounted() {
- this.refreshMediaProviders()
+ watch: {
+ selectedPlaylist() {
+ this.onPlaylistChange()
+ },
+ },
+
+ async mounted() {
+ await this.refreshMediaProviders()
+ await this.onPlaylistChange()
},
}
diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Index.vue b/platypush/backend/http/webapp/src/components/panels/Media/Index.vue
index 216f129da6..b879242bc1 100644
--- a/platypush/backend/http/webapp/src/components/panels/Media/Index.vue
+++ b/platypush/backend/http/webapp/src/components/panels/Media/Index.vue
@@ -8,7 +8,7 @@
@@ -52,7 +52,9 @@
v-else-if="selectedView === 'torrents'" />
@@ -195,6 +197,17 @@ export default {
return this.results[this.selectedResult]
},
+
+ selectedPlaylist() {
+ if (this.selectedResult == null)
+ return null
+
+ const selectedItem = this.results[this.selectedResult]
+ if (selectedItem?.item_type !== 'playlist')
+ return null
+
+ return this.results[this.selectedResult]
+ },
},
methods: {
@@ -396,17 +409,22 @@ export default {
this.selectedResult = null
}
- if (this.selectedResult != null && this.results[this.selectedResult]?.item_type === 'playlist') {
- if (this.prevSelectedView != this.selectedView) {
- this.prevSelectedView = this.selectedView
- }
-
- this.selectedView = 'browser'
+ const selectedItem = this.results[this.selectedResult]
+ if (this.selectedResult != null && selectedItem?.item_type === 'playlist') {
+ this.onPlaylistSelect()
} else {
this.selectedView = this.prevSelectedView || 'search'
}
},
+ onPlaylistSelect() {
+ if (this.prevSelectedView != this.selectedView) {
+ this.prevSelectedView = this.selectedView
+ }
+
+ this.selectedView = 'browser'
+ },
+
showPlayUrlModal() {
this.$refs.playUrlModal.show()
},
@@ -425,6 +443,13 @@ export default {
this.loading = false
}
},
+
+ onNavInput(event) {
+ this.selectedView = event
+ if (event === 'search') {
+ this.selectedResult = null
+ }
+ },
},
mounted() {
diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Providers/Mixin.vue b/platypush/backend/http/webapp/src/components/panels/Media/Providers/Mixin.vue
index 4d01819010..994b706307 100644
--- a/platypush/backend/http/webapp/src/components/panels/Media/Providers/Mixin.vue
+++ b/platypush/backend/http/webapp/src/components/panels/Media/Providers/Mixin.vue
@@ -19,6 +19,10 @@ export default {
type: String,
default: '',
},
+
+ selectedPlaylist: {
+ default: null,
+ },
},
data() {
diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube.vue b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube.vue
index bc7e8f05eb..2de3298bca 100644
--- a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube.vue
+++ b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube.vue
@@ -14,7 +14,7 @@
/>
diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Channel.vue b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Channel.vue
index bebd83539c..94d9ffa926 100644
--- a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Channel.vue
+++ b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Channel.vue
@@ -8,18 +8,23 @@
-
@@ -125,64 +130,14 @@ export default {
diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Playlist.vue b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Playlist.vue
index a4c8a8aa68..f8417e4325 100644
--- a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Playlist.vue
+++ b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Playlist.vue
@@ -1,20 +1,60 @@
@@ -49,7 +89,7 @@ export default {
default: null,
},
- playlist: {
+ metadata: {
type: Object,
default: null,
},
@@ -63,6 +103,16 @@ export default {
}
},
+ computed: {
+ name() {
+ return this.metadata?.title || this.metadata?.name
+ },
+
+ nItems() {
+ return this.metadata?.videos || this.items?.length || 0
+ },
+ },
+
methods: {
async loadItems() {
this.loading = true
@@ -86,7 +136,25 @@ export default {
diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Playlists.vue b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Playlists.vue
index e9573ab2ff..e983b66d09 100644
--- a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Playlists.vue
+++ b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Playlists.vue
@@ -1,6 +1,6 @@