From e72fd88fb932376cb74bc8e163f8d6faddb61ab5 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 13 Oct 2018 08:32:25 +0200 Subject: [PATCH] [web-src] Add "Add next" button to modal dialogs for album/artist/track/playlist details --- web-src/src/components/ListItemAlbum.vue | 10 ++++++++++ web-src/src/components/ListItemArtist.vue | 10 ++++++++++ web-src/src/components/ListItemPlaylist.vue | 10 ++++++++++ web-src/src/components/ListItemTrack.vue | 10 ++++++++++ web-src/src/components/SpotifyListItemAlbum.vue | 10 ++++++++++ web-src/src/components/SpotifyListItemArtist.vue | 10 ++++++++++ web-src/src/components/SpotifyListItemPlaylist.vue | 10 ++++++++++ web-src/src/components/SpotifyListItemTrack.vue | 10 ++++++++++ web-src/src/webapi/index.js | 8 ++++++++ 9 files changed, 88 insertions(+) diff --git a/web-src/src/components/ListItemAlbum.vue b/web-src/src/components/ListItemAlbum.vue index 52da6293..70bb8461 100644 --- a/web-src/src/components/ListItemAlbum.vue +++ b/web-src/src/components/ListItemAlbum.vue @@ -34,6 +34,9 @@ Add + + Add Next + Play @@ -78,6 +81,13 @@ export default { ) }, + queue_add_next: function () { + this.show_details_modal = false + webapi.queue_add_next(this.album.uri).then(() => + this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 }) + ) + }, + open_album: function () { this.show_details_modal = false if (this.media_kind === 'podcast') { diff --git a/web-src/src/components/ListItemArtist.vue b/web-src/src/components/ListItemArtist.vue index c7ec32c6..58b733c7 100644 --- a/web-src/src/components/ListItemArtist.vue +++ b/web-src/src/components/ListItemArtist.vue @@ -29,6 +29,9 @@ Add + + Add Next + Play @@ -73,6 +76,13 @@ export default { ) }, + queue_add_next: function () { + this.show_details_modal = false + webapi.queue_add_next(this.artist.uri).then(() => + this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 }) + ) + }, + open_artist: function () { this.show_details_modal = false this.$router.push({ path: '/music/artists/' + this.artist.id }) diff --git a/web-src/src/components/ListItemPlaylist.vue b/web-src/src/components/ListItemPlaylist.vue index 572da83e..efdeabd1 100644 --- a/web-src/src/components/ListItemPlaylist.vue +++ b/web-src/src/components/ListItemPlaylist.vue @@ -25,6 +25,9 @@ Add + + Add Next + Play @@ -69,6 +72,13 @@ export default { ) }, + queue_add_next: function () { + this.show_details_modal = false + webapi.queue_add_next(this.playlist.uri).then(() => + this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 }) + ) + }, + open_playlist: function () { this.show_details_modal = false this.$router.push({ path: '/playlists/' + this.playlist.id }) diff --git a/web-src/src/components/ListItemTrack.vue b/web-src/src/components/ListItemTrack.vue index 3f51011b..126315f9 100644 --- a/web-src/src/components/ListItemTrack.vue +++ b/web-src/src/components/ListItemTrack.vue @@ -66,6 +66,9 @@ Add + + Add Next + Play @@ -119,6 +122,13 @@ export default { ) }, + queue_add_next: function () { + this.show_details_modal = false + webapi.queue_add_next(this.track.uri).then(() => + this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 }) + ) + }, + open_album: function () { this.show_details_modal = false if (this.track.media_kind === 'podcast') { diff --git a/web-src/src/components/SpotifyListItemAlbum.vue b/web-src/src/components/SpotifyListItemAlbum.vue index 70a6805b..a138921d 100644 --- a/web-src/src/components/SpotifyListItemAlbum.vue +++ b/web-src/src/components/SpotifyListItemAlbum.vue @@ -36,6 +36,9 @@ Add + + Add Next + Play @@ -81,6 +84,13 @@ export default { this.show_details_modal = false }, + queue_add_next: function () { + webapi.queue_add_next(this.album.uri).then(() => + this.$store.dispatch('add_notification', { text: 'Album tracks appended to queue', type: 'info', timeout: 2000 }) + ) + this.show_details_modal = false + }, + show_details: function () { this.show_details_modal = true }, diff --git a/web-src/src/components/SpotifyListItemArtist.vue b/web-src/src/components/SpotifyListItemArtist.vue index b146d86a..c4ddfe0f 100644 --- a/web-src/src/components/SpotifyListItemArtist.vue +++ b/web-src/src/components/SpotifyListItemArtist.vue @@ -31,6 +31,9 @@ Add + + Add Next + Play @@ -75,6 +78,13 @@ export default { this.show_details_modal = false }, + queue_add_next: function () { + webapi.queue_add_next(this.artist.uri).then(() => + this.$store.dispatch('add_notification', { text: 'Artist tracks appended to queue', type: 'info', timeout: 2000 }) + ) + this.show_details_modal = false + }, + show_details: function () { this.show_details_modal = true }, diff --git a/web-src/src/components/SpotifyListItemPlaylist.vue b/web-src/src/components/SpotifyListItemPlaylist.vue index 5f74ddf9..aad2e0e8 100644 --- a/web-src/src/components/SpotifyListItemPlaylist.vue +++ b/web-src/src/components/SpotifyListItemPlaylist.vue @@ -36,6 +36,9 @@ Add + + Add Next + Play @@ -80,6 +83,13 @@ export default { this.show_details_modal = false }, + queue_add_next: function () { + webapi.queue_add_next(this.playlist.uri).then(() => + this.$store.dispatch('add_notification', { text: 'Playlist tracks appended to queue', type: 'info', timeout: 2000 }) + ) + this.show_details_modal = false + }, + show_details: function () { this.show_details_modal = true }, diff --git a/web-src/src/components/SpotifyListItemTrack.vue b/web-src/src/components/SpotifyListItemTrack.vue index d3c303fa..d65038df 100644 --- a/web-src/src/components/SpotifyListItemTrack.vue +++ b/web-src/src/components/SpotifyListItemTrack.vue @@ -51,6 +51,9 @@ Add + + Add Next + Play @@ -95,6 +98,13 @@ export default { this.show_details_modal = false }, + queue_add_next: function () { + webapi.queue_add_next(this.track.uri).then(() => + this.$store.dispatch('add_notification', { text: 'Track appended to queue', type: 'info', timeout: 2000 }) + ) + this.show_details_modal = false + }, + show_details: function () { this.show_details_modal = true }, diff --git a/web-src/src/webapi/index.js b/web-src/src/webapi/index.js index 684e3caa..efbbaa8d 100644 --- a/web-src/src/webapi/index.js +++ b/web-src/src/webapi/index.js @@ -45,6 +45,14 @@ export default { return axios.post('/api/queue/items/add?uris=' + uri) }, + queue_add_next (uri) { + var position = 0 + if (store.getters.now_playing && store.getters.now_playing.id) { + position = store.getters.now_playing.position + 1 + } + return axios.post('/api/queue/items/add?uris=' + uri + '&position=' + position) + }, + player_status () { return axios.get('/api/player') },