2016-02-07 04:23:12 +00:00
|
|
|
|
<template>
|
2016-06-25 16:05:24 +00:00
|
|
|
|
<section id="homeWrapper">
|
|
|
|
|
<h1 class="heading">
|
|
|
|
|
<span>{{ greeting }}</span>
|
|
|
|
|
</h1>
|
|
|
|
|
|
2016-08-13 10:51:53 +00:00
|
|
|
|
<div class="main-scroll-wrap" @scroll="scrolling" ref="wrapper">
|
2016-08-07 12:33:46 +00:00
|
|
|
|
<div class="two-cols">
|
2016-08-07 12:39:27 +00:00
|
|
|
|
<section v-show="top.songs.length">
|
2016-08-07 12:35:45 +00:00
|
|
|
|
<h1>Most Played</h1>
|
2016-06-25 16:05:24 +00:00
|
|
|
|
|
|
|
|
|
<ol class="top-song-list">
|
2016-08-07 12:39:27 +00:00
|
|
|
|
<li v-for="song in top.songs"
|
|
|
|
|
:top-play-count="top.songs.length ? top.songs[0].playCount : 0"
|
2016-06-25 16:05:24 +00:00
|
|
|
|
:song="song"
|
2016-10-31 04:28:12 +00:00
|
|
|
|
is="song-item"/>
|
2016-06-25 16:05:24 +00:00
|
|
|
|
</ol>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class="recent">
|
|
|
|
|
<h1>Recently Played</h1>
|
|
|
|
|
|
|
|
|
|
<ol class="recent-song-list" v-show="recentSongs.length">
|
|
|
|
|
<li v-for="song in recentSongs"
|
2016-08-07 12:39:27 +00:00
|
|
|
|
:top-play-count="top.songs.length ? top.songs[0].playCount : 0"
|
2016-06-25 16:05:24 +00:00
|
|
|
|
:song="song"
|
2016-10-31 04:28:12 +00:00
|
|
|
|
is="song-item"/>
|
2016-06-25 16:05:24 +00:00
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
<p class="none" v-show="!recentSongs.length">
|
2017-01-09 08:11:26 +00:00
|
|
|
|
Your recently played songs will be displayed here.<br />
|
2016-06-25 16:05:24 +00:00
|
|
|
|
Start listening!
|
|
|
|
|
</p>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
|
2016-08-07 12:33:46 +00:00
|
|
|
|
<section class="recently-added" v-show="showRecentlyAddedSection">
|
|
|
|
|
<h1>Recently Added</h1>
|
|
|
|
|
|
|
|
|
|
<div class="two-cols">
|
|
|
|
|
<div class="wrapper as-list">
|
2016-10-31 04:28:12 +00:00
|
|
|
|
<album-item v-for="album in recentlyAdded.albums" :album="album"/>
|
|
|
|
|
<span class="item filler" v-for="n in 3"/>
|
2016-08-07 12:33:46 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<ul class="recently-added-song-list" v-show="recentlyAdded.songs.length">
|
2016-10-31 04:28:12 +00:00
|
|
|
|
<li v-for="song in recentlyAdded.songs" :song="song" is="song-item"/>
|
2016-08-07 12:33:46 +00:00
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
|
2016-08-07 12:39:27 +00:00
|
|
|
|
<section class="top-artists" v-show="top.artists.length">
|
2016-06-25 16:05:24 +00:00
|
|
|
|
<h1>Top Artists</h1>
|
|
|
|
|
|
2017-03-28 10:25:24 +00:00
|
|
|
|
<div class="wrapper" :class="`as-${preferences.artistsViewMode}`">
|
2016-10-31 04:28:12 +00:00
|
|
|
|
<artist-item v-for="artist in top.artists" :artist="artist"/>
|
|
|
|
|
<span class="item filler" v-for="n in 3"/>
|
2016-02-07 04:23:12 +00:00
|
|
|
|
</div>
|
2016-06-25 16:05:24 +00:00
|
|
|
|
</section>
|
|
|
|
|
|
2017-03-28 10:25:24 +00:00
|
|
|
|
<section class="top-albums" :class="`as-${preferences.albumsViewMode}`" v-show="top.albums.length">
|
2016-06-25 16:05:24 +00:00
|
|
|
|
<h1>Top Albums</h1>
|
|
|
|
|
|
|
|
|
|
<div class="wrapper">
|
2016-10-31 04:28:12 +00:00
|
|
|
|
<album-item v-for="album in top.albums" :album="album"/>
|
|
|
|
|
<span class="item filler" v-for="n in 3"/>
|
2016-06-25 16:05:24 +00:00
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
|
2017-01-19 08:35:20 +00:00
|
|
|
|
<to-top-button/>
|
2016-06-25 16:05:24 +00:00
|
|
|
|
</div>
|
|
|
|
|
</section>
|
2016-02-07 04:23:12 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2016-11-26 03:25:35 +00:00
|
|
|
|
import { sample } from 'lodash'
|
2016-06-25 16:05:24 +00:00
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
|
import { event } from '../../../utils'
|
|
|
|
|
import { songStore, albumStore, artistStore, userStore, preferenceStore } from '../../../stores'
|
|
|
|
|
import infiniteScroll from '../../../mixins/infinite-scroll'
|
2016-06-25 16:05:24 +00:00
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
|
import albumItem from '../../shared/album-item.vue'
|
|
|
|
|
import artistItem from '../../shared/artist-item.vue'
|
|
|
|
|
import songItem from '../../shared/home-song-item.vue'
|
2016-06-25 16:05:24 +00:00
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: { albumItem, artistItem, songItem },
|
|
|
|
|
/**
|
|
|
|
|
* Note: We're not really using infinite scrolling here,
|
|
|
|
|
* but only the handy "Back to Top" button.
|
|
|
|
|
*/
|
|
|
|
|
mixins: [infiniteScroll],
|
|
|
|
|
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
greetings: [
|
|
|
|
|
'Oh hai!',
|
|
|
|
|
'Hey, %s!',
|
|
|
|
|
'Howdy, %s!',
|
|
|
|
|
'Yo!',
|
|
|
|
|
'How’s it going, %s?',
|
|
|
|
|
'Sup, %s?',
|
|
|
|
|
'How’s life, %s?',
|
|
|
|
|
'How’s your day, %s?',
|
2016-11-26 03:25:35 +00:00
|
|
|
|
'How have you been, %s?'
|
2016-06-25 16:05:24 +00:00
|
|
|
|
],
|
|
|
|
|
recentSongs: [],
|
2016-08-07 12:39:27 +00:00
|
|
|
|
top: {
|
|
|
|
|
songs: [],
|
|
|
|
|
albums: [],
|
2016-11-26 03:25:35 +00:00
|
|
|
|
artists: []
|
2016-08-07 12:39:27 +00:00
|
|
|
|
},
|
2016-08-07 12:33:46 +00:00
|
|
|
|
recentlyAdded: {
|
|
|
|
|
albums: [],
|
2016-11-26 03:25:35 +00:00
|
|
|
|
songs: []
|
2016-08-07 12:33:46 +00:00
|
|
|
|
},
|
2016-06-25 16:05:24 +00:00
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
|
preferences: preferenceStore.state
|
|
|
|
|
}
|
2016-06-25 16:05:24 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
computed: {
|
2016-11-26 03:25:35 +00:00
|
|
|
|
greeting () {
|
|
|
|
|
return sample(this.greetings).replace('%s', userStore.current.name)
|
2016-06-25 16:05:24 +00:00
|
|
|
|
},
|
2016-08-07 12:33:46 +00:00
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
|
showRecentlyAddedSection () {
|
|
|
|
|
return this.recentlyAdded.albums.length || this.recentlyAdded.songs.length
|
|
|
|
|
}
|
2016-06-25 16:05:24 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
/**
|
|
|
|
|
* Refresh the dashboard with latest data.
|
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
|
refreshDashboard () {
|
|
|
|
|
this.top.songs = songStore.getMostPlayed(7)
|
|
|
|
|
this.top.albums = albumStore.getMostPlayed(6)
|
|
|
|
|
this.top.artists = artistStore.getMostPlayed(6)
|
|
|
|
|
this.recentlyAdded.albums = albumStore.getRecentlyAdded(6)
|
|
|
|
|
this.recentlyAdded.songs = songStore.getRecentlyAdded(10)
|
2016-12-19 07:34:42 +00:00
|
|
|
|
this.recentSongs = songStore.recentlyPlayed
|
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
|
|
|
|
event.on({
|
|
|
|
|
'koel:ready': () => this.refreshDashboard(),
|
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
|
'song:played': () => this.refreshDashboard()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-07 04:23:12 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
|
<style lang="scss">
|
2016-06-25 16:05:24 +00:00
|
|
|
|
@import "../../../../sass/partials/_vars.scss";
|
|
|
|
|
@import "../../../../sass/partials/_mixins.scss";
|
2016-02-07 04:23:12 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
#homeWrapper {
|
2016-08-07 12:33:46 +00:00
|
|
|
|
.two-cols {
|
2016-06-25 16:05:24 +00:00
|
|
|
|
display: flex;
|
2016-02-14 07:18:40 +00:00
|
|
|
|
|
2016-08-07 12:33:46 +00:00
|
|
|
|
> section, > div {
|
2016-06-25 16:05:24 +00:00
|
|
|
|
flex-grow: 1;
|
|
|
|
|
flex-basis: 0;
|
2016-02-14 07:18:40 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
&:first-of-type {
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-07 04:23:12 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
.none {
|
|
|
|
|
color: $color2ndText;
|
|
|
|
|
padding: 0;
|
2016-02-07 04:23:12 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
a {
|
|
|
|
|
color: $colorHighlight;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-07 04:23:12 +00:00
|
|
|
|
|
2016-08-07 12:33:46 +00:00
|
|
|
|
.recently-added {
|
|
|
|
|
.song-item-home .details {
|
|
|
|
|
background: rgba(255, 255, 255, .02);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.top-artists .wrapper, .top-albums .wrapper, .recently-added .wrapper {
|
2016-06-25 16:05:24 +00:00
|
|
|
|
@include artist-album-wrapper();
|
|
|
|
|
}
|
2016-02-07 04:23:12 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
.main-scroll-wrap {
|
|
|
|
|
section {
|
|
|
|
|
margin-bottom: 48px;
|
|
|
|
|
}
|
2016-02-07 04:23:12 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
h1 {
|
|
|
|
|
font-size: 1.4rem;
|
|
|
|
|
margin: 0 0 1.8rem;
|
|
|
|
|
font-weight: $fontWeight_UltraThin;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-14 07:18:40 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
@media only screen and (max-width: 768px) {
|
2016-08-07 12:33:46 +00:00
|
|
|
|
.two-cols {
|
2016-06-25 16:05:24 +00:00
|
|
|
|
display: block;
|
2016-02-14 07:18:40 +00:00
|
|
|
|
|
2016-08-07 12:33:46 +00:00
|
|
|
|
> section, > div {
|
2016-06-25 16:05:24 +00:00
|
|
|
|
&:first-of-type {
|
|
|
|
|
margin-right: 0;
|
2016-02-14 07:18:40 +00:00
|
|
|
|
}
|
2016-06-25 16:05:24 +00:00
|
|
|
|
}
|
2016-02-07 04:23:12 +00:00
|
|
|
|
}
|
2016-06-25 16:05:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-07 04:23:12 +00:00
|
|
|
|
</style>
|