2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2023-08-20 22:35:58 +00:00
|
|
|
<section v-if="artist" id="artistWrapper">
|
2022-12-02 16:17:37 +00:00
|
|
|
<ScreenHeaderSkeleton v-if="loading" />
|
2022-07-30 15:08:20 +00:00
|
|
|
|
|
|
|
<ScreenHeader v-if="!loading && artist" :layout="songs.length === 0 ? 'collapsed' : headerLayout">
|
2022-04-15 14:24:30 +00:00
|
|
|
{{ artist.name }}
|
2022-12-02 16:17:37 +00:00
|
|
|
<ControlsToggle v-model="showingControls" />
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
<template #thumbnail>
|
|
|
|
<ArtistThumbnail :entity="artist" />
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
<template #meta>
|
2022-10-11 15:28:43 +00:00
|
|
|
<span>{{ pluralize(albumCount, 'album') }}</span>
|
2022-09-15 09:07:25 +00:00
|
|
|
<span>{{ pluralize(songs, 'song') }}</span>
|
|
|
|
<span>{{ duration }}</span>
|
2022-07-10 17:15:56 +00:00
|
|
|
|
|
|
|
<a
|
|
|
|
v-if="allowDownload"
|
|
|
|
class="download"
|
|
|
|
role="button"
|
|
|
|
title="Download all songs by this artist"
|
|
|
|
@click.prevent="download"
|
|
|
|
>
|
|
|
|
Download All
|
|
|
|
</a>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
<template #controls>
|
2022-04-15 17:00:08 +00:00
|
|
|
<SongListControls
|
2022-04-21 16:06:45 +00:00
|
|
|
v-if="songs.length && (!isPhone || showingControls)"
|
2024-01-18 11:13:05 +00:00
|
|
|
:config="config"
|
2022-12-17 12:09:22 +00:00
|
|
|
@filter="applyFilter"
|
2022-12-02 16:17:37 +00:00
|
|
|
@play-all="playAll"
|
|
|
|
@play-selected="playSelected"
|
2022-04-15 14:24:30 +00:00
|
|
|
/>
|
|
|
|
</template>
|
2022-04-15 17:00:08 +00:00
|
|
|
</ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-18 14:07:41 +00:00
|
|
|
<ScreenTabs>
|
|
|
|
<template #header>
|
|
|
|
<label :class="{ active: activeTab === 'Songs' }">
|
|
|
|
Songs
|
2022-12-02 16:17:37 +00:00
|
|
|
<input v-model="activeTab" type="radio" name="tab" value="Songs">
|
2022-10-18 14:07:41 +00:00
|
|
|
</label>
|
|
|
|
<label :class="{ active: activeTab === 'Albums' }">
|
|
|
|
Albums
|
2022-12-02 16:17:37 +00:00
|
|
|
<input v-model="activeTab" type="radio" name="tab" value="Albums">
|
2022-10-18 14:07:41 +00:00
|
|
|
</label>
|
2022-12-02 16:17:37 +00:00
|
|
|
<label v-if="useLastfm" :class="{ active: activeTab === 'Info' }">
|
2022-10-18 14:07:41 +00:00
|
|
|
Information
|
2022-12-02 16:17:37 +00:00
|
|
|
<input v-model="activeTab" type="radio" name="tab" value="Info">
|
2022-10-18 14:07:41 +00:00
|
|
|
</label>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<div v-show="activeTab === 'Songs'" class="songs-pane">
|
2022-12-02 16:17:37 +00:00
|
|
|
<SongListSkeleton v-if="loading" />
|
2022-10-18 14:07:41 +00:00
|
|
|
<SongList
|
|
|
|
v-else
|
|
|
|
ref="songList"
|
|
|
|
@sort="sort"
|
|
|
|
@press:enter="onPressEnter"
|
|
|
|
@scroll-breakpoint="onScrollBreakpoint"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-show="activeTab === 'Albums'" class="albums-pane">
|
2022-12-17 12:09:22 +00:00
|
|
|
<ul v-if="albums" v-koel-overflow-fade class="as-list">
|
2022-10-18 14:07:41 +00:00
|
|
|
<li v-for="album in albums" :key="album.id">
|
2022-12-02 16:17:37 +00:00
|
|
|
<AlbumCard :album="album" layout="compact" />
|
2022-10-18 14:07:41 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<ul v-else class="as-list">
|
|
|
|
<li v-for="i in 12" :key="i">
|
2022-12-02 16:17:37 +00:00
|
|
|
<AlbumCardSkeleton layout="compact" />
|
2022-10-18 14:07:41 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
<div v-show="activeTab === 'Info'" v-if="useLastfm && artist" class="info-pane">
|
|
|
|
<ArtistInfo :artist="artist" mode="full" />
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
2022-10-18 14:07:41 +00:00
|
|
|
</ScreenTabs>
|
2022-04-15 14:24:30 +00:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2023-08-20 22:35:58 +00:00
|
|
|
import { computed, defineAsyncComponent, ref, toRef, watch } from 'vue'
|
2022-11-18 18:44:20 +00:00
|
|
|
import { eventBus, logger, pluralize } from '@/utils'
|
2022-10-18 14:07:41 +00:00
|
|
|
import { albumStore, artistStore, commonStore, songStore } from '@/stores'
|
2022-06-10 10:47:46 +00:00
|
|
|
import { downloadService } from '@/services'
|
2024-01-18 11:13:05 +00:00
|
|
|
import { useDialogBox, useRouter, useSongList, useSongListControls, useThirdPartyServices } from '@/composables'
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
|
2024-02-24 15:37:01 +00:00
|
|
|
import ArtistThumbnail from '@/components/ui/ArtistAlbumThumbnail.vue'
|
2022-07-30 15:08:20 +00:00
|
|
|
import ScreenHeaderSkeleton from '@/components/ui/skeletons/ScreenHeaderSkeleton.vue'
|
|
|
|
import SongListSkeleton from '@/components/ui/skeletons/SongListSkeleton.vue'
|
2022-10-18 14:07:41 +00:00
|
|
|
import ScreenTabs from '@/components/ui/ArtistAlbumScreenTabs.vue'
|
2022-07-30 15:08:20 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
const ArtistInfo = defineAsyncComponent(() => import('@/components/artist/ArtistInfo.vue'))
|
2022-10-18 14:07:41 +00:00
|
|
|
const AlbumCard = defineAsyncComponent(() => import('@/components/album/AlbumCard.vue'))
|
|
|
|
const AlbumCardSkeleton = defineAsyncComponent(() => import('@/components/ui/skeletons/ArtistAlbumCardSkeleton.vue'))
|
|
|
|
|
|
|
|
type Tab = 'Songs' | 'Albums' | 'Info'
|
|
|
|
const activeTab = ref<Tab>('Songs')
|
2022-07-07 18:05:46 +00:00
|
|
|
|
2022-11-18 17:45:38 +00:00
|
|
|
const { showErrorDialog } = useDialogBox()
|
2023-08-20 22:35:58 +00:00
|
|
|
const { getRouteParam, go, onScreenActivated } = useRouter()
|
2022-04-21 16:06:45 +00:00
|
|
|
|
2022-10-18 14:07:41 +00:00
|
|
|
const artistId = ref<number>()
|
2022-07-30 15:08:20 +00:00
|
|
|
const artist = ref<Artist>()
|
|
|
|
const songs = ref<Song[]>([])
|
|
|
|
const loading = ref(false)
|
2022-10-18 14:07:41 +00:00
|
|
|
let albums = ref<Album[] | undefined>()
|
|
|
|
let info = ref<ArtistInfo | undefined | null>()
|
2022-06-10 10:47:46 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
SongList,
|
2022-06-10 10:47:46 +00:00
|
|
|
ControlsToggle,
|
2022-07-16 09:52:39 +00:00
|
|
|
headerLayout,
|
2022-04-15 17:00:08 +00:00
|
|
|
songList,
|
|
|
|
showingControls,
|
|
|
|
isPhone,
|
2024-03-25 22:59:38 +00:00
|
|
|
context,
|
2022-09-15 09:07:25 +00:00
|
|
|
duration,
|
2022-09-16 12:10:09 +00:00
|
|
|
sort,
|
2022-04-21 18:12:11 +00:00
|
|
|
onPressEnter,
|
2022-04-15 17:00:08 +00:00
|
|
|
playAll,
|
|
|
|
playSelected,
|
2022-12-17 12:09:22 +00:00
|
|
|
applyFilter,
|
2022-07-16 09:52:39 +00:00
|
|
|
onScrollBreakpoint
|
2024-03-25 22:59:38 +00:00
|
|
|
} = useSongList(songs, { type: 'Artist' })
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
const { SongListControls, config } = useSongListControls('Artist')
|
|
|
|
|
2022-04-30 14:05:02 +00:00
|
|
|
const { useLastfm } = useThirdPartyServices()
|
2024-01-04 11:35:36 +00:00
|
|
|
const allowDownload = toRef(commonStore.state, 'allows_download')
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-10-11 15:28:43 +00:00
|
|
|
const albumCount = computed(() => {
|
|
|
|
const albums = new Set()
|
|
|
|
songs.value.forEach(song => albums.add(song.album_id))
|
|
|
|
return albums.size
|
|
|
|
})
|
|
|
|
|
2022-10-18 14:07:41 +00:00
|
|
|
watch(activeTab, async tab => {
|
|
|
|
if (tab === 'Albums' && !albums.value) {
|
|
|
|
albums.value = await albumStore.fetchForArtist(artist.value!)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
watch(artistId, async id => {
|
2023-08-20 22:35:58 +00:00
|
|
|
if (!id || loading.value) return
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-07-30 15:08:20 +00:00
|
|
|
loading.value = true
|
|
|
|
|
|
|
|
try {
|
|
|
|
[artist.value, songs.value] = await Promise.all([
|
2022-10-08 10:54:25 +00:00
|
|
|
artistStore.resolve(id),
|
|
|
|
songStore.fetchForArtist(id)
|
2022-07-30 15:08:20 +00:00
|
|
|
])
|
2024-03-25 22:59:38 +00:00
|
|
|
|
|
|
|
context.entity = artist.value
|
2022-10-18 14:07:41 +00:00
|
|
|
} catch (error) {
|
|
|
|
logger.error(error)
|
2022-11-19 22:12:38 +00:00
|
|
|
showErrorDialog('Failed to load artist. Please try again.', 'Error')
|
2022-07-30 15:08:20 +00:00
|
|
|
} finally {
|
|
|
|
loading.value = false
|
|
|
|
}
|
2022-06-10 10:47:46 +00:00
|
|
|
})
|
2022-07-04 13:24:02 +00:00
|
|
|
|
2022-10-18 14:07:41 +00:00
|
|
|
const download = () => downloadService.fromArtist(artist.value!)
|
|
|
|
|
2023-08-20 22:35:58 +00:00
|
|
|
onScreenActivated('Artist', () => (artistId.value = parseInt(getRouteParam('id')!)))
|
2022-10-18 14:07:41 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
// if the current artist has been deleted, go back to the list
|
2022-11-18 18:44:20 +00:00
|
|
|
eventBus.on('SONGS_UPDATED', () => artistStore.byId(artist.value!.id) || go('artists'))
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-07-04 15:57:08 +00:00
|
|
|
@import "#/partials/_mixins.scss";
|
|
|
|
|
2022-04-15 14:24:30 +00:00
|
|
|
#artistWrapper {
|
|
|
|
@include artist-album-info-wrapper();
|
|
|
|
}
|
|
|
|
</style>
|