2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="artistWrapper">
|
2022-07-30 15:08:20 +00:00
|
|
|
<ScreenHeaderSkeleton v-if="loading"/>
|
|
|
|
|
|
|
|
<ScreenHeader v-if="!loading && artist" :layout="songs.length === 0 ? 'collapsed' : headerLayout">
|
2022-04-15 14:24:30 +00:00
|
|
|
{{ artist.name }}
|
2022-09-11 08:06:34 +00:00
|
|
|
<ControlsToggle v-model="showingControls"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<template v-slot:thumbnail>
|
2022-04-15 17:00:08 +00:00
|
|
|
<ArtistThumbnail :entity="artist"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:meta>
|
2022-07-10 17:15:56 +00:00
|
|
|
<span>{{ pluralize(artist.album_count, 'album') }}</span>
|
2022-09-15 09:07:25 +00:00
|
|
|
<span>{{ pluralize(songs, 'song') }}</span>
|
|
|
|
<span>{{ duration }}</span>
|
2022-07-11 17:35:58 +00:00
|
|
|
<a v-if="useLastfm" class="info" href title="View artist information" @click.prevent="showInfo">Info</a>
|
2022-07-10 17:15:56 +00:00
|
|
|
|
|
|
|
<a
|
|
|
|
v-if="allowDownload"
|
|
|
|
class="download"
|
|
|
|
href
|
|
|
|
role="button"
|
|
|
|
title="Download all songs by this artist"
|
|
|
|
@click.prevent="download"
|
|
|
|
>
|
|
|
|
Download All
|
|
|
|
</a>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:controls>
|
2022-04-15 17:00:08 +00:00
|
|
|
<SongListControls
|
2022-04-21 16:06:45 +00:00
|
|
|
v-if="songs.length && (!isPhone || showingControls)"
|
|
|
|
@playAll="playAll"
|
|
|
|
@playSelected="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-07-30 15:08:20 +00:00
|
|
|
<SongListSkeleton v-if="loading"/>
|
2022-09-16 12:10:09 +00:00
|
|
|
<SongList v-else ref="songList" @sort="sort" @press:enter="onPressEnter" @scroll-breakpoint="onScrollBreakpoint"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-30 15:08:20 +00:00
|
|
|
<section v-if="!loading && useLastfm && showingInfo" class="info-wrapper">
|
2022-07-08 14:53:04 +00:00
|
|
|
<CloseModalBtn class="close-modal" @click="showingInfo = false"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
<div class="inner">
|
2022-06-10 10:47:46 +00:00
|
|
|
<ArtistInfo :artist="artist" mode="full"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-10-08 10:54:25 +00:00
|
|
|
import { defineAsyncComponent, onMounted, ref, toRef } from 'vue'
|
2022-09-15 09:07:25 +00:00
|
|
|
import { eventBus, logger, pluralize, requireInjection } from '@/utils'
|
2022-07-04 13:24:02 +00:00
|
|
|
import { artistStore, commonStore, songStore } from '@/stores'
|
2022-06-10 10:47:46 +00:00
|
|
|
import { downloadService } from '@/services'
|
2022-04-30 14:05:02 +00:00
|
|
|
import { useSongList, useThirdPartyServices } from '@/composables'
|
2022-10-08 10:54:25 +00:00
|
|
|
import { DialogBoxKey, RouterKey } from '@/symbols'
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
|
|
|
|
import ArtistThumbnail from '@/components/ui/AlbumArtistThumbnail.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-08 10:54:25 +00:00
|
|
|
const ArtistInfo = defineAsyncComponent(() => import('@/components/artist/ArtistInfo.vue'))
|
|
|
|
const CloseModalBtn = defineAsyncComponent(() => import('@/components/ui/BtnCloseModal.vue'))
|
2022-07-07 18:05:46 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
const dialog = requireInjection(DialogBoxKey)
|
|
|
|
const router = requireInjection(RouterKey)
|
2022-04-21 16:06:45 +00:00
|
|
|
|
2022-07-30 15:08:20 +00:00
|
|
|
const artist = ref<Artist>()
|
|
|
|
const songs = ref<Song[]>([])
|
|
|
|
const showingInfo = ref(false)
|
|
|
|
const loading = ref(false)
|
2022-06-10 10:47:46 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
SongList,
|
|
|
|
SongListControls,
|
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,
|
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-07-16 09:52:39 +00:00
|
|
|
onScrollBreakpoint
|
2022-07-30 15:08:20 +00:00
|
|
|
} = useSongList(songs, 'artist', { columns: ['track', 'title', 'album', 'length'] })
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-04-30 14:05:02 +00:00
|
|
|
const { useLastfm } = useThirdPartyServices()
|
2022-06-10 10:47:46 +00:00
|
|
|
const allowDownload = toRef(commonStore.state, 'allow_download')
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
const download = () => downloadService.fromArtist(artist.value!)
|
2022-06-10 10:47:46 +00:00
|
|
|
const showInfo = () => (showingInfo.value = true)
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
onMounted(async () => {
|
2022-10-08 10:54:25 +00:00
|
|
|
const id = parseInt(router.$currentRoute.value!.params!.id)
|
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
|
|
|
])
|
|
|
|
} catch (e) {
|
|
|
|
logger.error(e)
|
|
|
|
dialog.value.error('Failed to load artist. Please try again.')
|
|
|
|
} finally {
|
|
|
|
loading.value = false
|
|
|
|
}
|
2022-06-10 10:47:46 +00:00
|
|
|
})
|
2022-07-04 13:24:02 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
// if the current artist has been deleted, go back to the list
|
|
|
|
eventBus.on('SONGS_UPDATED', () => artistStore.byId(artist.value!.id) || router.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>
|