2022-07-04 18:17:58 +00:00
|
|
|
<script setup lang="ts">
|
2022-07-04 22:52:53 +00:00
|
|
|
import type { Track, Album, Artist, Library } from '~/types'
|
|
|
|
|
2022-07-04 18:17:58 +00:00
|
|
|
import { useGettext } from 'vue3-gettext'
|
|
|
|
import axios from 'axios'
|
|
|
|
import PlayButton from '~/components/audio/PlayButton.vue'
|
|
|
|
import EmbedWizard from '~/components/audio/EmbedWizard.vue'
|
2022-07-20 22:44:19 +00:00
|
|
|
import SemanticModal from '~/components/semantic/Modal.vue'
|
2022-07-04 18:17:58 +00:00
|
|
|
import RadioButton from '~/components/radios/Button.vue'
|
|
|
|
import TagsList from '~/components/tags/List.vue'
|
|
|
|
import useReport from '~/composables/moderation/useReport'
|
|
|
|
import useLogger from '~/composables/useLogger'
|
|
|
|
import { getDomain } from '~/utils'
|
|
|
|
import { useStore } from '~/store'
|
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
import { computed, ref, watch } from 'vue'
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
id: string
|
|
|
|
}
|
|
|
|
|
|
|
|
const props = defineProps<Props>()
|
|
|
|
const { report, getReportableObjects } = useReport()
|
|
|
|
|
|
|
|
const object = ref<Artist | null>(null)
|
|
|
|
const libraries = ref([] as Library[])
|
|
|
|
const albums = ref([] as Album[])
|
|
|
|
const tracks = ref([] as Track[])
|
|
|
|
const showEmbedModal = ref(false)
|
|
|
|
|
|
|
|
const nextAlbumsUrl = ref(null)
|
|
|
|
const nextTracksUrl = ref(null)
|
|
|
|
const totalAlbums = ref(0)
|
|
|
|
const totalTracks = ref(0)
|
|
|
|
|
|
|
|
const dropdown = ref()
|
|
|
|
|
|
|
|
const logger = useLogger()
|
|
|
|
const store = useStore()
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
const domain = computed(() => getDomain(object.value?.fid ?? ''))
|
|
|
|
const isPlayable = computed(() => !!object.value?.albums.some(album => album.is_playable))
|
|
|
|
const wikipediaUrl = computed(() => `https://en.wikipedia.org/w/index.php?search=${encodeURI(object.value?.name ?? '')}`)
|
|
|
|
const musicbrainzUrl = computed(() => object.value?.mbid ? `https://musicbrainz.org/artist/${object.value.mbid}` : null)
|
|
|
|
const discogsUrl = computed(() => `https://discogs.com/search/?type=artist&title=${encodeURI(object.value?.name ?? '')}`)
|
|
|
|
const publicLibraries = computed(() => libraries.value?.filter(library => library.privacy_level === 'everyone') ?? [])
|
|
|
|
const cover = computed(() => object.value?.cover?.urls.original
|
|
|
|
? object.value.cover
|
|
|
|
: object.value?.albums.find(album => album.cover?.urls.original)?.cover
|
|
|
|
)
|
|
|
|
const headerStyle = computed(() => cover.value?.urls.original
|
|
|
|
? { backgroundImage: `url(${store.getters['instance/absoluteUrl'](cover.value.urls.original)})` }
|
|
|
|
: ''
|
|
|
|
)
|
|
|
|
|
|
|
|
const { $pgettext } = useGettext()
|
|
|
|
const labels = computed(() => ({
|
|
|
|
title: $pgettext('*/*/*', 'Artist')
|
|
|
|
}))
|
|
|
|
|
|
|
|
const isLoading = ref(false)
|
|
|
|
const fetchData = async () => {
|
|
|
|
isLoading.value = true
|
|
|
|
logger.debug(`Fetching artist "${props.id}"`)
|
|
|
|
|
|
|
|
const artistsResponse = await axios.get(`artists/${props.id}/`, { params: { refresh: 'true' } })
|
|
|
|
if (artistsResponse.data.channel) {
|
|
|
|
return router.replace({ name: 'channels.detail', params: { id: artistsResponse.data.channel.uuid } })
|
|
|
|
}
|
|
|
|
|
|
|
|
object.value = artistsResponse.data
|
|
|
|
|
|
|
|
const [tracksResponse, albumsResponse] = await Promise.all([
|
|
|
|
axios.get('tracks/', { params: { artist: props.id, hidden: '', ordering: '-creation_date' } }),
|
|
|
|
axios.get('albums/', { params: { artist: props.id, hidden: '', ordering: '-release_date' } })
|
|
|
|
])
|
|
|
|
|
|
|
|
tracks.value = tracksResponse.data.results
|
|
|
|
nextTracksUrl.value = tracksResponse.data.next
|
|
|
|
totalTracks.value = tracksResponse.data.count
|
|
|
|
|
|
|
|
|
|
|
|
nextAlbumsUrl.value = albumsResponse.data.next
|
|
|
|
totalAlbums.value = albumsResponse.data.count
|
|
|
|
|
|
|
|
albums.value = albumsResponse.data.results
|
|
|
|
|
|
|
|
isLoading.value = false
|
|
|
|
}
|
|
|
|
|
|
|
|
watch(() => props.id, fetchData, { immediate: true })
|
|
|
|
</script>
|
|
|
|
|
2017-06-23 21:00:42 +00:00
|
|
|
<template>
|
2018-11-19 22:33:22 +00:00
|
|
|
<main v-title="labels.title">
|
2021-12-06 10:35:20 +00:00
|
|
|
<div
|
|
|
|
v-if="isLoading"
|
|
|
|
class="ui vertical segment"
|
|
|
|
>
|
|
|
|
<div :class="['ui', 'centered', 'active', 'inline', 'loader']" />
|
2017-06-23 21:00:42 +00:00
|
|
|
</div>
|
2019-04-23 10:51:31 +00:00
|
|
|
<template v-if="object && !isLoading">
|
2021-12-06 10:35:20 +00:00
|
|
|
<section
|
|
|
|
v-title="object.name"
|
|
|
|
:class="['ui', 'head', {'with-background': cover}, 'vertical', 'center', 'aligned', 'stripe', 'segment']"
|
|
|
|
:style="headerStyle"
|
|
|
|
>
|
2017-06-23 21:00:42 +00:00
|
|
|
<div class="segment-content">
|
|
|
|
<h2 class="ui center aligned icon header">
|
2021-12-06 10:35:20 +00:00
|
|
|
<i class="circular inverted users violet icon" />
|
2017-06-23 21:00:42 +00:00
|
|
|
<div class="content">
|
2019-04-17 14:11:24 +00:00
|
|
|
{{ object.name }}
|
2021-12-06 10:35:20 +00:00
|
|
|
<div
|
|
|
|
v-if="albums"
|
|
|
|
class="sub header"
|
|
|
|
>
|
|
|
|
<translate
|
|
|
|
translate-context="Content/Artist/Paragraph"
|
2018-06-30 13:28:47 +00:00
|
|
|
tag="div"
|
|
|
|
translate-plural="%{ count } tracks in %{ albumsCount } albums"
|
|
|
|
:translate-n="totalTracks"
|
2021-12-06 10:35:20 +00:00
|
|
|
:translate-params="{count: totalTracks, albumsCount: totalAlbums}"
|
|
|
|
>
|
2018-06-30 13:28:47 +00:00
|
|
|
%{ count } track in %{ albumsCount } albums
|
|
|
|
</translate>
|
2018-04-15 10:45:56 +00:00
|
|
|
</div>
|
2017-06-23 21:00:42 +00:00
|
|
|
</div>
|
|
|
|
</h2>
|
2021-12-06 10:35:20 +00:00
|
|
|
<tags-list
|
|
|
|
v-if="object.tags && object.tags.length > 0"
|
|
|
|
:tags="object.tags"
|
|
|
|
/>
|
|
|
|
<div class="ui hidden divider" />
|
2019-04-17 12:17:59 +00:00
|
|
|
<div class="header-buttons">
|
|
|
|
<div class="ui buttons">
|
2021-12-06 10:35:20 +00:00
|
|
|
<radio-button
|
|
|
|
type="artist"
|
2022-07-20 22:44:19 +00:00
|
|
|
:object-id="object.id"
|
2021-12-06 10:35:20 +00:00
|
|
|
/>
|
2019-04-17 12:17:59 +00:00
|
|
|
</div>
|
|
|
|
<div class="ui buttons">
|
2021-12-06 10:35:20 +00:00
|
|
|
<play-button
|
|
|
|
:is-playable="isPlayable"
|
|
|
|
class="vibrant"
|
|
|
|
:artist="object"
|
|
|
|
>
|
|
|
|
<translate translate-context="Content/Artist/Button.Label/Verb">
|
|
|
|
Play all albums
|
|
|
|
</translate>
|
2019-04-17 12:17:59 +00:00
|
|
|
</play-button>
|
|
|
|
</div>
|
|
|
|
|
2022-07-20 22:44:19 +00:00
|
|
|
<semantic-modal
|
2021-12-06 10:35:20 +00:00
|
|
|
v-if="publicLibraries.length > 0"
|
2022-05-01 11:45:07 +00:00
|
|
|
v-model:show="showEmbedModal"
|
2021-12-06 10:35:20 +00:00
|
|
|
>
|
2020-07-03 12:20:47 +00:00
|
|
|
<h4 class="header">
|
2021-12-06 10:35:20 +00:00
|
|
|
<translate translate-context="Popup/Artist/Title/Verb">
|
|
|
|
Embed this artist work on your website
|
|
|
|
</translate>
|
2020-07-03 12:20:47 +00:00
|
|
|
</h4>
|
2020-07-21 08:19:14 +00:00
|
|
|
<div class="scrolling content">
|
2019-03-08 09:30:04 +00:00
|
|
|
<div class="description">
|
2021-12-06 10:35:20 +00:00
|
|
|
<embed-wizard
|
|
|
|
:id="object.id"
|
|
|
|
type="artist"
|
|
|
|
/>
|
2019-03-08 09:30:04 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="actions">
|
2020-08-04 11:22:31 +00:00
|
|
|
<button class="ui deny button">
|
2021-12-06 10:35:20 +00:00
|
|
|
<translate translate-context="*/*/Button.Label/Verb">
|
|
|
|
Cancel
|
|
|
|
</translate>
|
2020-08-04 11:22:31 +00:00
|
|
|
</button>
|
2019-03-08 09:30:04 +00:00
|
|
|
</div>
|
2022-07-20 22:44:19 +00:00
|
|
|
</semantic-modal>
|
2019-04-17 12:17:59 +00:00
|
|
|
<div class="ui buttons">
|
2021-12-06 10:35:20 +00:00
|
|
|
<button
|
|
|
|
class="ui button"
|
2022-07-04 18:17:58 +00:00
|
|
|
@click="dropdown.click()"
|
2021-12-06 10:35:20 +00:00
|
|
|
>
|
|
|
|
<translate translate-context="*/*/Button.Label/Noun">
|
|
|
|
More…
|
|
|
|
</translate>
|
2019-04-17 12:17:59 +00:00
|
|
|
</button>
|
2021-12-06 10:35:20 +00:00
|
|
|
<button
|
|
|
|
ref="dropdown"
|
|
|
|
v-dropdown
|
|
|
|
class="ui floating dropdown icon button"
|
|
|
|
>
|
|
|
|
<i class="dropdown icon" />
|
2019-04-17 12:17:59 +00:00
|
|
|
<div class="menu">
|
2020-08-28 18:41:42 +00:00
|
|
|
<a
|
|
|
|
v-if="domain != $store.getters['instance/domain']"
|
2021-12-06 10:35:20 +00:00
|
|
|
:href="object.fid"
|
2020-08-28 18:41:42 +00:00
|
|
|
target="_blank"
|
2021-12-06 10:35:20 +00:00
|
|
|
class="basic item"
|
|
|
|
>
|
|
|
|
<i class="external icon" />
|
|
|
|
<translate
|
|
|
|
:translate-params="{domain: domain}"
|
|
|
|
translate-context="Content/*/Button.Label/Verb"
|
|
|
|
>View on %{ domain }</translate>
|
2020-08-28 18:41:42 +00:00
|
|
|
</a>
|
|
|
|
|
2020-08-04 11:22:31 +00:00
|
|
|
<button
|
2019-04-17 12:17:59 +00:00
|
|
|
v-if="publicLibraries.length > 0"
|
2021-12-06 10:35:20 +00:00
|
|
|
role="button"
|
|
|
|
class="basic item"
|
2020-08-04 11:22:31 +00:00
|
|
|
@click.prevent="showEmbedModal = !showEmbedModal"
|
2021-12-06 10:35:20 +00:00
|
|
|
>
|
|
|
|
<i class="code icon" />
|
|
|
|
<translate translate-context="Content/*/Button.Label/Verb">
|
|
|
|
Embed
|
|
|
|
</translate>
|
2020-08-04 11:22:31 +00:00
|
|
|
</button>
|
2021-12-06 10:35:20 +00:00
|
|
|
<a
|
|
|
|
:href="wikipediaUrl"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer noopener"
|
|
|
|
class="basic item"
|
|
|
|
>
|
|
|
|
<i class="wikipedia w icon" />
|
2019-04-17 12:17:59 +00:00
|
|
|
<translate translate-context="Content/*/Button.Label/Verb">Search on Wikipedia</translate>
|
|
|
|
</a>
|
2021-12-06 10:35:20 +00:00
|
|
|
<a
|
|
|
|
v-if="musicbrainzUrl"
|
|
|
|
:href="musicbrainzUrl"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer noopener"
|
|
|
|
class="basic item"
|
|
|
|
>
|
|
|
|
<i class="external icon" />
|
2019-04-17 12:17:59 +00:00
|
|
|
<translate translate-context="Content/*/*/Clickable, Verb">View on MusicBrainz</translate>
|
|
|
|
</a>
|
2021-12-06 10:35:20 +00:00
|
|
|
<a
|
|
|
|
:href="discogsUrl"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer noopener"
|
|
|
|
class="basic item"
|
|
|
|
>
|
|
|
|
<i class="external icon" />
|
|
|
|
<translate translate-context="Content/*/Button.Label/Verb">Search on Discogs</translate>
|
|
|
|
</a>
|
2019-04-17 14:11:24 +00:00
|
|
|
<router-link
|
|
|
|
v-if="object.is_local"
|
|
|
|
:to="{name: 'library.artists.edit', params: {id: object.id }}"
|
2021-12-06 10:35:20 +00:00
|
|
|
class="basic item"
|
|
|
|
>
|
|
|
|
<i class="edit icon" />
|
|
|
|
<translate translate-context="Content/*/Button.Label/Verb">
|
|
|
|
Edit
|
|
|
|
</translate>
|
2019-04-17 14:11:24 +00:00
|
|
|
</router-link>
|
2021-12-06 10:35:20 +00:00
|
|
|
<div class="divider" />
|
2019-09-09 09:10:25 +00:00
|
|
|
<div
|
2022-07-04 18:17:58 +00:00
|
|
|
v-for="obj in getReportableObjects({artist: object})"
|
2019-09-09 09:10:25 +00:00
|
|
|
:key="obj.target.type + obj.target.id"
|
2021-12-06 10:35:20 +00:00
|
|
|
role="button"
|
|
|
|
class="basic item"
|
2022-07-04 18:17:58 +00:00
|
|
|
@click.stop.prevent="report(obj)"
|
2021-12-06 10:35:20 +00:00
|
|
|
>
|
2019-09-09 09:10:25 +00:00
|
|
|
<i class="share icon" /> {{ obj.label }}
|
|
|
|
</div>
|
|
|
|
|
2021-12-06 10:35:20 +00:00
|
|
|
<div class="divider" />
|
|
|
|
<router-link
|
|
|
|
v-if="$store.state.auth.availablePermissions['library']"
|
|
|
|
class="basic item"
|
|
|
|
:to="{name: 'manage.library.artists.detail', params: {id: object.id}}"
|
|
|
|
>
|
|
|
|
<i class="wrench icon" />
|
|
|
|
<translate translate-context="Content/Moderation/Link">
|
|
|
|
Open in moderation interface
|
|
|
|
</translate>
|
2019-04-17 12:17:59 +00:00
|
|
|
</router-link>
|
|
|
|
<a
|
2019-04-29 13:26:54 +00:00
|
|
|
v-if="$store.state.auth.profile && $store.state.auth.profile.is_superuser"
|
2019-04-17 12:17:59 +00:00
|
|
|
class="basic item"
|
2019-04-17 14:11:24 +00:00
|
|
|
:href="$store.getters['instance/absoluteUrl'](`/api/admin/music/artist/${object.id}`)"
|
2021-12-06 10:35:20 +00:00
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<i class="wrench icon" />
|
2019-04-17 12:17:59 +00:00
|
|
|
<translate translate-context="Content/Moderation/Link/Verb">View in Django's admin</translate>
|
|
|
|
</a>
|
|
|
|
</div>
|
2020-08-04 11:22:31 +00:00
|
|
|
</button>
|
2019-04-17 12:17:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-06-23 21:00:42 +00:00
|
|
|
</div>
|
2018-11-19 22:33:22 +00:00
|
|
|
</section>
|
2019-04-23 10:51:31 +00:00
|
|
|
<router-view
|
2021-12-06 10:35:20 +00:00
|
|
|
:key="$route.fullPath"
|
2019-04-23 10:51:31 +00:00
|
|
|
:tracks="tracks"
|
|
|
|
:next-tracks-url="nextTracksUrl"
|
|
|
|
:next-albums-url="nextAlbumsUrl"
|
|
|
|
:albums="albums"
|
2022-07-04 18:17:58 +00:00
|
|
|
:is-loading-albums="isLoading"
|
2021-12-06 10:35:20 +00:00
|
|
|
:object="object"
|
|
|
|
object-type="artist"
|
2019-04-23 10:51:31 +00:00
|
|
|
@libraries-loaded="libraries = $event"
|
2021-12-06 10:35:20 +00:00
|
|
|
/>
|
2017-06-23 21:00:42 +00:00
|
|
|
</template>
|
2018-11-19 22:33:22 +00:00
|
|
|
</main>
|
2017-06-23 21:00:42 +00:00
|
|
|
</template>
|