2018-08-11 07:47:10 +02:00
|
|
|
<template>
|
|
|
|
<content-with-heading>
|
2022-02-19 06:18:01 +01:00
|
|
|
<template v-slot:heading-left>
|
2018-08-11 07:47:10 +02:00
|
|
|
<p class="title is-4">{{ artist.name }}</p>
|
|
|
|
</template>
|
2022-02-19 06:18:01 +01:00
|
|
|
<template v-slot:heading-right>
|
2019-02-20 09:22:17 +01:00
|
|
|
<div class="buttons is-centered">
|
|
|
|
<a class="button is-small is-light is-rounded" @click="show_artist_details_modal = true">
|
|
|
|
<span class="icon"><i class="mdi mdi-dots-horizontal mdi-18px"></i></span>
|
|
|
|
</a>
|
|
|
|
<a class="button is-small is-dark is-rounded" @click="play">
|
|
|
|
<span class="icon"><i class="mdi mdi-shuffle"></i></span> <span>Shuffle</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-02-19 06:18:01 +01:00
|
|
|
<template v-slot:content>
|
2018-08-11 07:47:10 +02:00
|
|
|
<p class="heading has-text-centered-mobile">{{ total }} albums</p>
|
2020-08-02 07:33:17 +02:00
|
|
|
<spotify-list-item-album v-for="album in albums"
|
|
|
|
:key="album.id"
|
|
|
|
:album="album"
|
|
|
|
@click="open_album(album)">
|
2022-02-19 06:18:01 +01:00
|
|
|
<template v-slot:artwork v-if="is_visible_artwork">
|
2020-08-02 07:33:17 +02:00
|
|
|
<p class="image is-64x64 fd-has-shadow fd-has-action">
|
|
|
|
<cover-artwork
|
|
|
|
:artwork_url="artwork_url(album)"
|
|
|
|
:artist="album.artist"
|
|
|
|
:album="album.name"
|
|
|
|
:maxwidth="64"
|
|
|
|
:maxheight="64" />
|
|
|
|
</p>
|
|
|
|
</template>
|
2022-02-19 06:18:01 +01:00
|
|
|
<template v-slot:actions>
|
|
|
|
<a @click.prevent.stop="open_dialog(album)">
|
2018-12-17 11:52:09 +01:00
|
|
|
<span class="icon has-text-dark"><i class="mdi mdi-dots-vertical mdi-18px"></i></span>
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</spotify-list-item-album>
|
2022-02-19 06:18:01 +01:00
|
|
|
<VueEternalLoading v-if="offset < total" :load="load_next"><template #no-more>.</template></VueEternalLoading>
|
2018-12-17 11:52:09 +01:00
|
|
|
<spotify-modal-dialog-album :show="show_details_modal" :album="selected_album" @close="show_details_modal = false" />
|
2019-02-20 09:22:17 +01:00
|
|
|
<spotify-modal-dialog-artist :show="show_artist_details_modal" :artist="artist" @close="show_artist_details_modal = false" />
|
2018-08-11 07:47:10 +02:00
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-19 06:18:01 +01:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
|
|
|
import SpotifyListItemAlbum from '@/components/SpotifyListItemAlbum.vue'
|
|
|
|
import SpotifyModalDialogAlbum from '@/components/SpotifyModalDialogAlbum.vue'
|
|
|
|
import SpotifyModalDialogArtist from '@/components/SpotifyModalDialogArtist.vue'
|
|
|
|
import CoverArtwork from '@/components/CoverArtwork.vue'
|
2018-08-11 07:47:10 +02:00
|
|
|
import store from '@/store'
|
2019-02-20 09:22:17 +01:00
|
|
|
import webapi from '@/webapi'
|
2018-08-11 07:47:10 +02:00
|
|
|
import SpotifyWebApi from 'spotify-web-api-js'
|
2022-02-19 06:18:01 +01:00
|
|
|
import { VueEternalLoading } from '@ts-pro/vue-eternal-loading'
|
2018-08-11 07:47:10 +02:00
|
|
|
|
2022-02-19 06:18:01 +01:00
|
|
|
const PAGE_SIZE = 50
|
|
|
|
|
|
|
|
const dataObject = {
|
2018-08-11 07:47:10 +02:00
|
|
|
load: function (to) {
|
|
|
|
const spotifyApi = new SpotifyWebApi()
|
|
|
|
spotifyApi.setAccessToken(store.state.spotify.webapi_token)
|
|
|
|
return Promise.all([
|
|
|
|
spotifyApi.getArtist(to.params.artist_id),
|
2022-02-19 06:18:01 +01:00
|
|
|
spotifyApi.getArtistAlbums(to.params.artist_id, { limit: PAGE_SIZE, offset: 0, include_groups: 'album,single', market: store.state.spotify.webapi_country })
|
2018-08-11 07:47:10 +02:00
|
|
|
])
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (vm, response) {
|
|
|
|
vm.artist = response[0]
|
|
|
|
|
|
|
|
vm.albums = []
|
|
|
|
vm.total = 0
|
|
|
|
vm.offset = 0
|
|
|
|
vm.append_albums(response[1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'SpotifyPageArtist',
|
2022-02-19 06:18:01 +01:00
|
|
|
components: { ContentWithHeading, SpotifyListItemAlbum, SpotifyModalDialogAlbum, SpotifyModalDialogArtist, VueEternalLoading, CoverArtwork },
|
2018-08-11 07:47:10 +02:00
|
|
|
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
artist: {},
|
|
|
|
albums: [],
|
|
|
|
total: 0,
|
2018-12-17 11:52:09 +01:00
|
|
|
offset: 0,
|
|
|
|
|
|
|
|
show_details_modal: false,
|
2019-02-20 09:22:17 +01:00
|
|
|
selected_album: {},
|
|
|
|
|
|
|
|
show_artist_details_modal: false
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-08-23 19:26:54 +02:00
|
|
|
computed: {
|
|
|
|
is_visible_artwork () {
|
|
|
|
return this.$store.getters.settings_option('webinterface', 'show_cover_artwork_in_album_lists').value
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-08-11 07:47:10 +02:00
|
|
|
methods: {
|
2022-02-19 06:18:01 +01:00
|
|
|
load_next: function ({ loaded }) {
|
2018-08-11 07:47:10 +02:00
|
|
|
const spotifyApi = new SpotifyWebApi()
|
|
|
|
spotifyApi.setAccessToken(this.$store.state.spotify.webapi_token)
|
2022-02-19 06:18:01 +01:00
|
|
|
spotifyApi.getArtistAlbums(this.artist.id, { limit: PAGE_SIZE, offset: this.offset, include_groups: 'album,single' }).then(data => {
|
|
|
|
this.append_albums(data)
|
|
|
|
loaded(data.items.length, PAGE_SIZE)
|
2018-08-11 07:47:10 +02:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:18:01 +01:00
|
|
|
append_albums: function (data) {
|
2018-08-11 07:47:10 +02:00
|
|
|
this.albums = this.albums.concat(data.items)
|
|
|
|
this.total = data.total
|
|
|
|
this.offset += data.limit
|
2018-12-17 11:52:09 +01:00
|
|
|
},
|
|
|
|
|
2019-02-20 09:22:17 +01:00
|
|
|
play: function () {
|
|
|
|
this.show_details_modal = false
|
|
|
|
webapi.player_play_uri(this.artist.uri, true)
|
|
|
|
},
|
|
|
|
|
2020-08-02 07:33:17 +02:00
|
|
|
open_album: function (album) {
|
|
|
|
this.$router.push({ path: '/music/spotify/albums/' + album.id })
|
|
|
|
},
|
|
|
|
|
2018-12-17 11:52:09 +01:00
|
|
|
open_dialog: function (album) {
|
|
|
|
this.selected_album = album
|
|
|
|
this.show_details_modal = true
|
2020-08-02 07:33:17 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
artwork_url: function (album) {
|
|
|
|
if (album.images && album.images.length > 0) {
|
|
|
|
return album.images[0].url
|
|
|
|
}
|
|
|
|
return ''
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
2022-02-19 06:18:01 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
beforeRouteEnter (to, from, next) {
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
next(vm => dataObject.set(vm, response))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
beforeRouteUpdate (to, from, next) {
|
|
|
|
const vm = this
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
dataObject.set(vm, response)
|
|
|
|
next()
|
|
|
|
})
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|