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

186 lines
6.3 KiB
Vue
Raw Normal View History

2016-01-15 07:27:25 +00:00
<template>
<section id="artistWrapper">
<h1 class="heading">
<span class="overview">
<img :src="artist.image" width="64" height="64" class="cover">
{{ artist.name }}
2016-02-19 07:20:34 +00:00
<i class="fa fa-angle-down toggler"
v-show="isPhone && !showingControls"
2016-01-15 07:27:25 +00:00
@click="showingControls = true"></i>
2016-02-19 07:20:34 +00:00
<i class="fa fa-angle-up toggler"
v-show="isPhone && showingControls"
2016-01-15 07:27:25 +00:00
@click.prevent="showingControls = false"></i>
<span class="meta" v-show="meta.songCount">
2016-06-25 05:24:55 +00:00
{{ artist.albums.length }} {{ artist.albums.length | pluralize('album') }}
2016-01-15 07:27:25 +00:00
2016-06-25 05:24:55 +00:00
{{ meta.songCount }} {{ meta.songCount | pluralize('song') }}
2016-02-19 07:20:34 +00:00
2016-01-15 07:27:25 +00:00
{{ meta.totalLength }}
2016-06-05 03:53:35 +00:00
<template v-if="sharedState.useLastfm">
<a href="#" @click.prevent="showInfo" title="View artist's extra information">Info</a>
</template>
2016-06-05 03:53:35 +00:00
<template v-if="sharedState.allowDownload">
<a href="#" @click.prevent="download" title="Download all songs by this artist">Download</a>
</template>
2016-01-15 07:27:25 +00:00
</span>
</span>
<div class="buttons" v-show="!isPhone || showingControls">
2016-02-21 11:04:57 +00:00
<button class="play-shuffle btn btn-orange" @click.prevent="shuffle" v-if="selectedSongs.length < 2">
2016-01-15 07:27:25 +00:00
<i class="fa fa-random"></i> All
</button>
2016-02-21 11:04:57 +00:00
<button class="play-shuffle btn btn-orange" @click.prevent="shuffleSelected" v-if="selectedSongs.length > 1">
2016-01-15 07:27:25 +00:00
<i class="fa fa-random"></i> Selected
</button>
2016-02-21 11:04:57 +00:00
<button class="btn btn-green" @click.prevent.stop="showingAddToMenu = !showingAddToMenu" v-if="selectedSongs.length">
2016-01-15 07:27:25 +00:00
{{ showingAddToMenu ? 'Cancel' : 'Add To…' }}
</button>
2016-01-16 18:11:24 +00:00
<add-to-menu :songs="selectedSongs" :showing="showingAddToMenu"><add-to-menu>
2016-01-15 07:27:25 +00:00
</div>
</h1>
2016-06-25 05:24:55 +00:00
<song-list :items="artist.songs" type="artist"></song-list>
<section class="info-wrapper" v-if="sharedState.useLastfm && info.showing">
2016-06-05 11:30:31 +00:00
<a href="#" class="close" @click.prevent="info.showing = false"><i class="fa fa-times"></i></a>
<div class="inner">
2016-06-25 05:24:55 +00:00
<div class="loading" v-if="info.loading">
<sound-bar></sound-bar>
</div>
<artist-info :artist="artist" :mode="'full'" v-else></artist-info>
</div>
</section>
2016-01-15 07:27:25 +00:00
</section>
</template>
<script>
import isMobile from 'ismobilejs';
2016-06-25 05:24:55 +00:00
import { pluralize, event, loadMainView } from '../../../utils';
2016-06-25 10:15:57 +00:00
import { sharedStore, artistStore } from '../../../stores';
import { playback, download, artistInfo as artistInfoService } from '../../../services';
2016-01-15 07:27:25 +00:00
import hasSongList from '../../../mixins/has-song-list';
import artistInfo from '../extra/artist-info.vue';
import soundBar from '../../shared/sound-bar.vue';
2016-01-15 07:27:25 +00:00
export default {
2016-06-25 05:24:55 +00:00
name: 'main-wrapper--main-content--artist',
2016-01-15 07:27:25 +00:00
mixins: [hasSongList],
components: { artistInfo, soundBar },
2016-06-25 05:24:55 +00:00
filters: { pluralize },
2016-01-15 07:27:25 +00:00
data() {
return {
2016-06-05 03:53:35 +00:00
sharedState: sharedStore.state,
2016-01-15 07:27:25 +00:00
artist: artistStore.stub,
isPhone: isMobile.phone,
showingControls: false,
info: {
showing: false,
loading: true,
},
2016-01-15 07:27:25 +00:00
};
},
2016-03-05 09:01:12 +00:00
watch: {
/**
* Watch the artist's album count.
* If this is changed to 0, the user has edit the songs by this artist
* and move all of them to another artist (thus delete this artist entirely).
* We should then go back to the artist list.
*/
'artist.albums.length': function (newVal) {
if (!newVal) {
2016-06-25 05:24:55 +00:00
loadMainView('artists');
2016-03-05 09:01:12 +00:00
}
},
},
2016-06-25 05:24:55 +00:00
created() {
2016-01-15 07:27:25 +00:00
/**
2016-06-25 05:24:55 +00:00
* Listen to 'main-content-view:load' event to load the requested artist
* into view if applicable.
2016-01-15 08:13:23 +00:00
*
2016-01-17 14:26:24 +00:00
* @param {String} view The view's name
2016-01-15 08:13:23 +00:00
* @param {Object} artist
2016-01-15 07:27:25 +00:00
*/
2016-06-25 05:24:55 +00:00
event.on('main-content-view:load', (view, artist) => {
2016-01-15 08:13:23 +00:00
if (view === 'artist') {
this.info.showing = false;
2016-01-15 08:13:23 +00:00
this.artist = artist;
}
2016-06-25 05:24:55 +00:00
});
2016-01-15 07:27:25 +00:00
},
methods: {
/**
* Shuffle the songs by the current artist.
*/
shuffle() {
playback.queueAndPlay(this.artist.songs, true);
},
2016-06-05 03:53:35 +00:00
/**
* Download all songs by the artist.
*/
download() {
download.fromArtist(this.artist);
},
showInfo() {
this.info.showing = true;
if (!this.artist.info) {
this.info.loading = true;
2016-06-05 11:29:49 +00:00
artistInfoService.fetch(this.artist, () => {
this.info.loading = false;
});
} else {
this.info.loading = false;
}
},
2016-01-15 07:27:25 +00:00
},
};
</script>
<style lang="sass" scoped>
2016-03-13 17:00:32 +00:00
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
2016-01-15 07:27:25 +00:00
#artistWrapper {
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
}
.cover {
position: absolute;
left: 0;
top: -7px;
@media only screen and (max-width : 768px) {
display: none;
}
2016-01-15 07:27:25 +00:00
}
}
@include artist-album-info-wrapper();
2016-01-15 07:27:25 +00:00
}
</style>