2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="albumWrapper">
|
2022-04-21 10:18:11 +00:00
|
|
|
<ScreenHeader has-thumbnail>
|
2022-04-15 14:24:30 +00:00
|
|
|
{{ album.name }}
|
2022-04-15 17:00:08 +00:00
|
|
|
<ControlsToggler :showing-controls="showingControls" @toggleControls="toggleControls"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<template v-slot:thumbnail>
|
2022-04-15 17:00:08 +00:00
|
|
|
<AlbumThumbnail :entity="album"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:meta>
|
2022-04-21 16:06:45 +00:00
|
|
|
<span v-if="songs.length">
|
2022-04-15 14:24:30 +00:00
|
|
|
by
|
2022-04-21 16:06:45 +00:00
|
|
|
<a v-if="isNormalArtist" :href="`#!/artist/${album.artist.id}`" class="artist">{{ album.artist.name }}</a>
|
2022-04-15 14:24:30 +00:00
|
|
|
<span class="nope" v-else>{{ album.artist.name }}</span>
|
|
|
|
•
|
2022-04-21 16:06:45 +00:00
|
|
|
{{ pluralize(songs.length, 'song') }}
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-04-23 21:24:02 +00:00
|
|
|
{{ duration }}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-25 16:13:18 +00:00
|
|
|
<template v-if="useLastfm">
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-04-21 16:06:45 +00:00
|
|
|
<a class="info" href title="View album's extra information" @click.prevent="showInfo">Info</a>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
2022-04-25 16:13:18 +00:00
|
|
|
<template v-if="allowDownload">
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-04-21 16:06:45 +00:00
|
|
|
<a class="download" href role="button" title="Download all songs in album" @click.prevent="download">
|
2022-04-15 14:24:30 +00:00
|
|
|
Download All
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</span>
|
|
|
|
</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)"
|
2022-04-15 14:24:30 +00:00
|
|
|
:config="songListControlConfig"
|
|
|
|
:selectedSongs="selectedSongs"
|
2022-04-21 16:06:45 +00:00
|
|
|
:songs="songs"
|
|
|
|
@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-04-21 18:12:11 +00:00
|
|
|
<SongList ref="songList" :config="listConfig" :items="songs" type="album" @press:enter="onPressEnter"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-25 16:13:18 +00:00
|
|
|
<section v-if="useLastfm && showing" class="info-wrapper">
|
2022-04-15 17:00:08 +00:00
|
|
|
<CloseModalBtn @click="showing = false"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
<div class="inner">
|
2022-04-15 17:00:08 +00:00
|
|
|
<div class="loading" v-if="loading">
|
|
|
|
<SoundBar/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
2022-04-15 17:00:08 +00:00
|
|
|
<AlbumInfo :album="album" mode="full" v-else/>
|
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-04-25 16:13:18 +00:00
|
|
|
import { computed, defineAsyncComponent, ref, toRef, toRefs, watch } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { pluralize } from '@/utils'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { artistStore, commonStore } from '@/stores'
|
|
|
|
import { albumInfoService, downloadService } from '@/services'
|
2022-04-15 14:24:30 +00:00
|
|
|
import router from '@/router'
|
2022-04-23 21:24:02 +00:00
|
|
|
import { useSongList } from '@/composables'
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-04-21 16:06:45 +00:00
|
|
|
const ScreenHeader = defineAsyncComponent(() => import('@/components/ui/ScreenHeader.vue'))
|
2022-04-21 10:43:10 +00:00
|
|
|
const AlbumInfo = defineAsyncComponent(() => import('@/components/album/AlbumInfo.vue'))
|
2022-04-23 21:36:19 +00:00
|
|
|
const SoundBar = defineAsyncComponent(() => import('@/components/ui/SoundBar.vue'))
|
2022-04-21 10:18:11 +00:00
|
|
|
const AlbumThumbnail = defineAsyncComponent(() => import('@/components/ui/AlbumArtistThumbnail.vue'))
|
2022-04-24 08:29:14 +00:00
|
|
|
const CloseModalBtn = defineAsyncComponent(() => import('@/components/ui/BtnCloseModal.vue'))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-04-21 16:06:45 +00:00
|
|
|
const props = defineProps<{ album: Album }>()
|
|
|
|
const { album } = toRefs(props)
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const {
|
|
|
|
SongList,
|
|
|
|
SongListControls,
|
|
|
|
ControlsToggler,
|
2022-04-21 16:06:45 +00:00
|
|
|
songs,
|
2022-04-15 17:00:08 +00:00
|
|
|
songList,
|
2022-04-23 21:24:02 +00:00
|
|
|
duration,
|
2022-04-15 17:00:08 +00:00
|
|
|
selectedSongs,
|
|
|
|
showingControls,
|
|
|
|
songListControlConfig,
|
|
|
|
isPhone,
|
2022-04-21 18:12:11 +00:00
|
|
|
onPressEnter,
|
2022-04-15 17:00:08 +00:00
|
|
|
playAll,
|
|
|
|
playSelected,
|
|
|
|
toggleControls
|
2022-04-21 16:06:45 +00:00
|
|
|
} = useSongList(ref(album.value.songs))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
const listConfig: Partial<SongListConfig> = { columns: ['track', 'title', 'length'] }
|
2022-04-25 16:13:18 +00:00
|
|
|
const useLastfm = toRef(commonStore.state, 'useLastfm')
|
|
|
|
const allowDownload = toRef(commonStore.state, 'allowDownload')
|
2022-04-15 17:00:08 +00:00
|
|
|
const showing = ref(false)
|
|
|
|
const loading = ref(true)
|
|
|
|
|
|
|
|
const isNormalArtist = computed(() => {
|
|
|
|
return !artistStore.isVariousArtists(album.value.artist) && !artistStore.isUnknownArtist(album.value.artist)
|
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
/**
|
|
|
|
* Watch the album's song count.
|
|
|
|
* If this is changed to 0, the user has edited the songs on this album
|
|
|
|
* and moved all of them into another album.
|
|
|
|
* We should then go back to the album list.
|
|
|
|
*/
|
|
|
|
watch(() => album.value.songs.length, newSongCount => newSongCount || router.go('albums'))
|
|
|
|
|
|
|
|
watch(album, () => {
|
|
|
|
showing.value = false
|
|
|
|
songList.value?.sort()
|
|
|
|
})
|
|
|
|
|
|
|
|
const download = () => downloadService.fromAlbum(album.value)
|
|
|
|
|
|
|
|
const showInfo = async () => {
|
|
|
|
showing.value = true
|
|
|
|
|
|
|
|
if (!album.value.info) {
|
|
|
|
try {
|
|
|
|
await albumInfoService.fetch(album.value)
|
|
|
|
} catch (e) {
|
|
|
|
/* eslint no-console: 0 */
|
|
|
|
console.error(e)
|
|
|
|
} finally {
|
|
|
|
loading.value = false
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
} else {
|
|
|
|
loading.value = false
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
#albumWrapper {
|
|
|
|
@include artist-album-info-wrapper();
|
|
|
|
}
|
|
|
|
</style>
|