From d4354e81f816fef495e7ec1e79c46c6dbf59a339 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 27 Jun 2024 00:24:31 +0200 Subject: [PATCH] [Youtube UI] Added playlist operations. - `add_to_playlist` - `remove_from_playlist` --- .../src/components/elements/ConfirmDialog.vue | 10 +- .../src/components/elements/TextPrompt.vue | 61 ++++++- .../src/components/panels/Media/Browser.vue | 15 +- .../src/components/panels/Media/Index.vue | 21 +++ .../src/components/panels/Media/Item.vue | 36 +++- .../components/panels/Media/PlaylistAdder.vue | 162 ++++++++++++++++++ .../panels/Media/Providers/Mixin.vue | 12 +- .../panels/Media/Providers/YouTube.vue | 31 +++- .../panels/Media/Providers/YouTube/Feed.vue | 7 +- .../Media/Providers/YouTube/Playlist.vue | 12 +- .../Media/Providers/YouTube/Playlists.vue | 20 ++- .../src/components/panels/Media/Results.vue | 22 ++- 12 files changed, 388 insertions(+), 21 deletions(-) create mode 100644 platypush/backend/http/webapp/src/components/panels/Media/PlaylistAdder.vue diff --git a/platypush/backend/http/webapp/src/components/elements/ConfirmDialog.vue b/platypush/backend/http/webapp/src/components/elements/ConfirmDialog.vue index b1c82d2f84..ad93299854 100644 --- a/platypush/backend/http/webapp/src/components/elements/ConfirmDialog.vue +++ b/platypush/backend/http/webapp/src/components/elements/ConfirmDialog.vue @@ -43,13 +43,21 @@ export default { this.close() }, - show() { + open() { this.$refs.modal.show() }, close() { this.$refs.modal.hide() }, + + show() { + this.open() + }, + + hide() { + this.close() + }, }, } diff --git a/platypush/backend/http/webapp/src/components/elements/TextPrompt.vue b/platypush/backend/http/webapp/src/components/elements/TextPrompt.vue index e68aee55bf..3c0f5aa754 100644 --- a/platypush/backend/http/webapp/src/components/elements/TextPrompt.vue +++ b/platypush/backend/http/webapp/src/components/elements/TextPrompt.vue @@ -3,7 +3,7 @@
- +
@@ -38,26 +38,79 @@ export default { type: String, default: "Cancel", }, + + visible: { + type: Boolean, + default: false, + }, + + value: { + type: String, + default: "", + }, + }, + + data() { + return { + value_: "", + visible_: false, + } }, methods: { onConfirm() { - this.$emit('input', this.$refs.input.value) + this.$emit('input', this.value_) this.close() }, - show() { + open() { + if (this.visible_) + return + + this.value_ = this.value this.$refs.modal.show() + this.visible_ = true + this.focus() }, close() { + if (!this.visible_) + return + + this.value_ = "" this.$refs.modal.hide() + this.visible_ = false + }, + + show() { + this.open() + }, + + hide() { + this.close() + }, + + focus() { + this.$nextTick(() => { + this.$refs.input.focus() + }) + }, + }, + + watch: { + visible(val) { + if (val) { + this.open() + } else { + this.close() + } }, }, mounted() { + this.visible_ = this.visible + this.value_ = this.value || "" this.$nextTick(() => { - this.$refs.input.value = "" this.$refs.input.focus() }) }, 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 5244b21ec6..291cc989eb 100644 --- a/platypush/backend/http/webapp/src/components/panels/Media/Browser.vue +++ b/platypush/backend/http/webapp/src/components/panels/Media/Browser.vue @@ -23,9 +23,11 @@ + @play="$emit('play', $event)" + />
@@ -39,8 +41,17 @@ import Utils from "@/Utils"; import providersMetadata from "./Providers/meta.json"; export default { - emits: ['path-change', 'play'], mixins: [Utils], + emits: [ + 'add-to-playlist', + 'create-playlist', + 'path-change', + 'play', + 'remove-from-playlist', + 'remove-playlist', + 'rename-playlist', + ], + components: { Browser, Loading, 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 311d3bb186..364a330aff 100644 --- a/platypush/backend/http/webapp/src/components/panels/Media/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/Media/Index.vue @@ -39,6 +39,7 @@ :plugin-name="pluginName" :loading="loading" :filter="browserFilter" + @add-to-playlist="addToPlaylistItem = $event" @select="onResultSelect($event)" @play="play" @view="view" @@ -51,6 +52,7 @@ v-else-if="selectedView === 'torrents'" /> @@ -75,6 +77,16 @@ + +
+ + + +
@@ -88,6 +100,7 @@ import Header from "@/components/panels/Media/Header"; import MediaUtils from "@/components/Media/Utils"; import MediaView from "@/components/Media/View"; import Nav from "@/components/panels/Media/Nav"; +import PlaylistAdder from "@/components/panels/Media/PlaylistAdder"; import Results from "@/components/panels/Media/Results"; import Subtitles from "@/components/panels/Media/Subtitles"; import Transfers from "@/components/panels/Torrent/Transfers"; @@ -102,6 +115,7 @@ export default { MediaView, Modal, Nav, + PlaylistAdder, Results, Subtitles, Transfers, @@ -139,6 +153,7 @@ export default { awaitingPlayTorrent: null, urlPlay: null, browserFilter: null, + addToPlaylistItem: null, torrentPlugin: null, torrentPlugins: [ 'torrent', @@ -487,4 +502,10 @@ export default { } } } + +:deep(.add-to-playlist-container) { + .body { + padding: 0 !important; + } +} diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Item.vue b/platypush/backend/http/webapp/src/components/panels/Media/Item.vue index 902f46caec..0ffceb3e60 100644 --- a/platypush/backend/http/webapp/src/components/panels/Media/Item.vue +++ b/platypush/backend/http/webapp/src/components/panels/Media/Item.vue @@ -4,6 +4,7 @@ :class="{selected: selected}" @click.right.prevent="$refs.dropdown.toggle()" v-if="!hidden"> +
@@ -19,6 +20,10 @@ v-if="item.type === 'torrent'" /> + + @@ -35,10 +40,15 @@ {{ formatDateTime(item.created_at, true) }} + + + Are you sure you want to remove this item from the playlist? + + + 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 8de115bc2a..4d01819010 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 @@ -2,8 +2,18 @@ import Utils from "@/Utils"; export default { - emits: ['back', 'path-change', 'play'], mixins: [Utils], + emits: [ + 'add-to-playlist', + 'back', + 'create-playlist', + 'path-change', + 'play', + 'remove-from-playlist', + 'remove-playlist', + 'rename-playlist', + ], + props: { filter: { type: String, 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 c6491590d3..f2907cec4c 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 @@ -8,17 +8,27 @@
+ @add-to-playlist="$emit('add-to-playlist', $event)" + @play="$emit('play', $event)" + v-if="selectedView === 'feed'" + /> + + v-else-if="selectedView === 'playlists'" + /> + + v-else-if="selectedView === 'subscriptions'" + /> +
@@ -87,6 +97,21 @@ export default { } }, + async removeFromPlaylist(event) { + const playlistId = event.playlist_id + const videoId = event.item.url + this.loading = true + + try { + await this.request('youtube.remove_from_playlist', { + playlist_id: playlistId, + video_id: videoId, + }) + } finally { + this.loading = false + } + }, + selectView(view) { this.selectedView = view if (view === 'playlists') diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Feed.vue b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Feed.vue index eaadfda6ca..58793c622e 100644 --- a/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Feed.vue +++ b/platypush/backend/http/webapp/src/components/panels/Media/Providers/YouTube/Feed.vue @@ -9,6 +9,7 @@ :filter="filter" :sources="{'youtube': true}" :selected-result="selectedResult" + @add-to-playlist="$emit('add-to-playlist', $event)" @select="selectedResult = $event" @play="$emit('play', $event)" v-else /> @@ -22,8 +23,12 @@ import Results from "@/components/panels/Media/Results"; import Utils from "@/Utils"; export default { - emits: ['play'], mixins: [Utils], + emits: [ + 'add-to-playlist', + 'play', + ], + components: { Loading, NoItems, 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 c09d0089af..4a70e42e0d 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 @@ -8,9 +8,12 @@ @@ -22,8 +25,13 @@ import Results from "@/components/panels/Media/Results"; import Utils from "@/Utils"; export default { - emits: ['play'], mixins: [Utils], + emits: [ + 'add-to-playlist', + 'play', + 'remove-from-playlist', + ], + components: { Loading, NoItems, 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 823e11145e..fae4433bfc 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 @@ -18,7 +18,14 @@
- +
@@ -31,8 +38,17 @@ import Playlist from "./Playlist"; import Utils from "@/Utils"; export default { - emits: ['play', 'select'], mixins: [Utils], + emits: [ + 'add-to-playlist', + 'create-playlist', + 'play', + 'remove-from-playlist', + 'remove-playlist', + 'rename-playlist', + 'select', + ], + components: { Loading, MediaImage, diff --git a/platypush/backend/http/webapp/src/components/panels/Media/Results.vue b/platypush/backend/http/webapp/src/components/panels/Media/Results.vue index 62f14722b4..5d4292f46c 100644 --- a/platypush/backend/http/webapp/src/components/panels/Media/Results.vue +++ b/platypush/backend/http/webapp/src/components/panels/Media/Results.vue @@ -4,9 +4,12 @@