2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<article
|
2022-04-21 21:51:17 +00:00
|
|
|
v-if="showing"
|
|
|
|
:class="layout"
|
2022-04-15 14:24:30 +00:00
|
|
|
:title="artist.name"
|
|
|
|
class="item"
|
2022-05-04 20:47:12 +00:00
|
|
|
data-testid="artist-card"
|
2022-04-15 14:24:30 +00:00
|
|
|
draggable="true"
|
|
|
|
tabindex="0"
|
|
|
|
@dblclick="shuffle"
|
2022-09-03 08:32:09 +00:00
|
|
|
@dragstart="onDragStart"
|
2022-04-30 11:55:54 +00:00
|
|
|
@contextmenu.prevent="requestContextMenu"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2022-07-22 14:25:30 +00:00
|
|
|
<ArtistThumbnail :entity="artist"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<footer>
|
|
|
|
<div class="info">
|
2022-05-04 20:47:12 +00:00
|
|
|
<a class="name" :href="`#!/artist/${artist.id}`" data-testid="name">{{ artist.name }}</a>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
<p class="meta">
|
|
|
|
<span class="left">
|
2022-06-10 10:47:46 +00:00
|
|
|
{{ pluralize(artist.album_count, 'album') }}
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-06-10 10:47:46 +00:00
|
|
|
{{ pluralize(artist.song_count, 'song') }}
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-06-10 10:47:46 +00:00
|
|
|
{{ pluralize(artist.play_count, 'play') }}
|
2022-04-15 14:24:30 +00:00
|
|
|
</span>
|
|
|
|
<span class="right">
|
|
|
|
<a
|
|
|
|
:title="`Shuffle all songs by ${artist.name}`"
|
|
|
|
class="shuffle-artist"
|
|
|
|
href
|
|
|
|
role="button"
|
2022-05-04 20:47:12 +00:00
|
|
|
data-testid="shuffle-artist"
|
2022-04-21 21:51:17 +00:00
|
|
|
@click.prevent="shuffle"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2022-07-15 07:23:55 +00:00
|
|
|
<icon :icon="faRandom"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</a>
|
|
|
|
<a
|
2022-04-21 21:51:17 +00:00
|
|
|
v-if="allowDownload"
|
2022-04-15 14:24:30 +00:00
|
|
|
:title="`Download all songs by ${artist.name}`"
|
|
|
|
class="download-artist"
|
|
|
|
href
|
|
|
|
role="button"
|
2022-05-04 20:47:12 +00:00
|
|
|
data-testid="download-artist"
|
2022-04-21 21:51:17 +00:00
|
|
|
@click.prevent="download"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2022-07-15 07:23:55 +00:00
|
|
|
<icon :icon="faDownload"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</footer>
|
|
|
|
</article>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-15 07:23:55 +00:00
|
|
|
import { faDownload, faRandom } from '@fortawesome/free-solid-svg-icons'
|
2022-07-07 18:05:46 +00:00
|
|
|
import { computed, toRef, toRefs } from 'vue'
|
2022-09-03 08:32:09 +00:00
|
|
|
import { eventBus, pluralize } from '@/utils'
|
2022-05-04 20:47:12 +00:00
|
|
|
import { artistStore, commonStore, songStore } from '@/stores'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { downloadService, playbackService } from '@/services'
|
2022-09-03 08:32:09 +00:00
|
|
|
import { useDraggable } from '@/composables'
|
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import ArtistThumbnail from '@/components/ui/AlbumArtistThumbnail.vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-09-03 08:32:09 +00:00
|
|
|
const { startDragging } = useDraggable('artist')
|
|
|
|
|
2022-05-04 20:47:12 +00:00
|
|
|
const props = withDefaults(defineProps<{ artist: Artist, layout?: ArtistAlbumCardLayout }>(), { layout: 'full' })
|
2022-04-15 17:00:08 +00:00
|
|
|
const { artist, layout } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const allowDownload = toRef(commonStore.state, 'allow_download')
|
|
|
|
|
2022-07-04 13:24:02 +00:00
|
|
|
const showing = computed(() => artistStore.isStandard(artist.value))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const shuffle = async () => {
|
|
|
|
await playbackService.queueAndPlay(await songStore.fetchForArtist(artist.value), true /* shuffled */)
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const download = () => downloadService.fromArtist(artist.value)
|
2022-09-03 08:32:09 +00:00
|
|
|
const onDragStart = (event: DragEvent) => startDragging(event, artist.value)
|
2022-04-15 17:00:08 +00:00
|
|
|
const requestContextMenu = (event: MouseEvent) => eventBus.emit('ARTIST_CONTEXT_MENU_REQUESTED', event, artist.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
2022-08-10 14:56:01 +00:00
|
|
|
<style lang="scss" scoped>
|
2022-04-15 14:24:30 +00:00
|
|
|
@include artist-album-card();
|
|
|
|
</style>
|