koel/resources/assets/js/components/main-wrapper/main-content/album.vue

187 lines
4.6 KiB
Vue
Raw Normal View History

2016-01-15 07:27:25 +00:00
<template>
2016-06-25 16:05:24 +00:00
<section id="albumWrapper">
<h1 class="heading">
<span class="overview">
<img :src="album.cover" width="64" height="64" class="cover">
{{ album.name }}
2016-11-17 08:37:12 +00:00
<controls-toggler :showing-controls="showingControls" @toggleControls="toggleControls"/>
2016-06-25 16:05:24 +00:00
<span class="meta" v-show="meta.songCount">
by
<a class="artist" v-if="isNormalArtist" :href="'/#!/artist/'+album.artist.id">{{ album.artist.name }}</a>
2016-06-25 16:05:24 +00:00
<span class="nope" v-else>{{ album.artist.name }}</span>
{{ meta.songCount | pluralize('song') }}
{{ meta.totalLength }}
<template v-if="sharedState.useLastfm">
2016-11-17 08:41:57 +00:00
<a class="info" href @click.prevent="showInfo" title="View album's extra information">Info</a>
2016-06-25 16:05:24 +00:00
</template>
<template v-if="sharedState.allowDownload">
2016-11-17 08:41:57 +00:00
<a class="download" href @click.prevent="download" title="Download all songs in album">Download</a>
2016-06-25 16:05:24 +00:00
</template>
</span>
</span>
2016-11-17 08:37:12 +00:00
<song-list-controls
2016-11-26 03:38:36 +00:00
v-show="state.songs.length && (!isPhone || showingControls)"
@shuffleAll="shuffleAll"
@shuffleSelected="shuffleSelected"
2016-11-17 08:37:12 +00:00
:config="songListControlConfig"
:selectedSongs="selectedSongs"
/>
2016-06-25 16:05:24 +00:00
</h1>
2016-10-31 04:28:12 +00:00
<song-list :items="album.songs" type="album"/>
2016-06-25 16:05:24 +00:00
<section class="info-wrapper" v-if="sharedState.useLastfm && info.showing">
2016-10-31 04:28:12 +00:00
<a href class="close" @click.prevent="info.showing = false"><i class="fa fa-times"></i></a>
2016-06-25 16:05:24 +00:00
<div class="inner">
2016-10-31 04:28:12 +00:00
<div class="loading" v-if="info.loading"><sound-bar/></div>
<album-info :album="album" :mode="'full'" v-else/>
2016-06-25 16:05:24 +00:00
</div>
2016-01-15 07:27:25 +00:00
</section>
2016-06-25 16:05:24 +00:00
</section>
2016-01-15 07:27:25 +00:00
</template>
<script>
2016-11-26 03:25:35 +00:00
import { pluralize, event } from '../../../utils'
import { albumStore, artistStore, sharedStore } from '../../../stores'
import { playback, download, albumInfo as albumInfoService } from '../../../services'
import router from '../../../router'
import hasSongList from '../../../mixins/has-song-list'
import albumInfo from '../extra/album-info.vue'
import soundBar from '../../shared/sound-bar.vue'
2016-06-25 16:05:24 +00:00
export default {
name: 'main-wrapper--main-content--album',
2016-07-10 17:55:20 +00:00
mixins: [hasSongList],
2016-06-25 16:05:24 +00:00
components: { albumInfo, soundBar },
filters: { pluralize },
2016-11-26 03:25:35 +00:00
data () {
2016-06-25 16:05:24 +00:00
return {
sharedState: sharedStore.state,
album: albumStore.stub,
info: {
showing: false,
2016-11-26 03:25:35 +00:00
loading: true
}
}
2016-06-25 16:05:24 +00:00
},
computed: {
2016-11-26 03:25:35 +00:00
isNormalArtist () {
return !artistStore.isVariousArtists(this.album.artist) &&
!artistStore.isUnknownArtist(this.album.artist)
}
2016-06-25 16:05:24 +00:00
},
watch: {
/**
* Watch the album's song count.
* If this is changed to 0, the user has edit the songs in this album
* and move all of them into another album.
* We should then go back to the album list.
*/
2016-09-23 09:58:34 +00:00
'album.songs.length' (newVal) {
2016-06-25 16:05:24 +00:00
if (!newVal) {
2016-11-26 03:25:35 +00:00
router.go('albums')
2016-06-25 16:05:24 +00:00
}
2016-11-26 03:25:35 +00:00
}
2016-06-25 16:05:24 +00:00
},
2016-11-26 03:25:35 +00:00
created () {
2016-06-25 16:05:24 +00:00
/**
* Listen to 'main-content-view:load' event to load the requested album
* into view if applicable.
*
* @param {String} view The view name
* @param {Object} album The album object
*/
event.on('main-content-view:load', (view, album) => {
if (view === 'album') {
2016-11-26 03:25:35 +00:00
this.info.showing = false
this.album = album
2016-06-25 16:05:24 +00:00
}
2016-11-26 03:25:35 +00:00
})
2016-06-25 16:05:24 +00:00
},
methods: {
/**
* Shuffle the songs in the current album.
*/
2016-11-26 03:25:35 +00:00
shuffle () {
playback.queueAndPlay(this.album.songs, true)
2016-06-25 16:05:24 +00:00
},
/**
* Download all songs from the album.
*/
2016-11-26 03:25:35 +00:00
download () {
download.fromAlbum(this.album)
2016-06-25 16:05:24 +00:00
},
2016-11-26 03:25:35 +00:00
showInfo () {
this.info.showing = true
2016-06-25 16:05:24 +00:00
if (!this.album.info) {
2016-11-26 03:25:35 +00:00
this.info.loading = true
albumInfoService.fetch(this.album).then(() => {
this.info.loading = false
})
2016-06-25 16:05:24 +00:00
} else {
2016-11-26 03:25:35 +00:00
this.info.loading = false
2016-06-25 16:05:24 +00:00
}
2016-11-26 03:25:35 +00:00
}
}
}
2016-01-15 07:27:25 +00:00
</script>
<style lang="sass" scoped>
2016-06-25 16:05:24 +00:00
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
#albumWrapper {
button.play-shuffle {
i {
margin-right: 0 !important;
}
}
.heading {
.overview {
position: relative;
padding-left: 84px;
@media only screen and (max-width : 768px) {
padding-left: 0;
}
2016-01-15 07:27:25 +00:00
}
2016-06-25 16:05:24 +00:00
.cover {
position: absolute;
left: 0;
top: -7px;
@media only screen and (max-width : 768px) {
display: none;
}
}
a.artist {
color: $colorMainText;
display: inline;
&:hover {
color: $colorHighlight;
}
}
}
@include artist-album-info-wrapper();
}
2016-01-15 07:27:25 +00:00
</style>