108 lines
2.8 KiB
Vue
Raw Normal View History

<template>
2022-02-19 06:18:01 +01:00
<div class="fd-page-with-tabs">
<tabs-music />
<!-- Recently added -->
<content-with-heading>
<template #heading-left>
<p class="title is-4" v-text="$t('page.music.recently-added.title')" />
</template>
<template #content>
<list-albums :albums="recently_added" />
</template>
<template #footer>
<nav class="level">
<p class="level-item">
<router-link
class="button is-light is-small is-rounded"
:to="{ name: 'music-recently-added' }"
>{{ $t('page.music.show-more') }}</router-link
2023-07-25 14:41:34 +02:00
>
</p>
</nav>
</template>
</content-with-heading>
<!-- Recently played -->
<content-with-heading>
<template #heading-left>
<p class="title is-4" v-text="$t('page.music.recently-played.title')" />
</template>
<template #content>
<list-tracks :tracks="recently_played" />
</template>
<template #footer>
<nav class="level">
<p class="level-item">
<router-link
class="button is-light is-small is-rounded"
:to="{ name: 'music-recently-played' }"
>{{ $t('page.music.show-more') }}</router-link
2023-07-25 14:41:34 +02:00
>
</p>
</nav>
</template>
</content-with-heading>
</div>
</template>
<script>
2022-02-19 06:18:01 +01:00
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import { GroupByList } from '@/lib/GroupByList'
2022-02-19 06:18:01 +01:00
import ListAlbums from '@/components/ListAlbums.vue'
import ListTracks from '@/components/ListTracks.vue'
import TabsMusic from '@/components/TabsMusic.vue'
import webapi from '@/webapi'
2022-02-19 06:18:01 +01:00
const dataObject = {
load(to) {
return Promise.all([
webapi.search({
type: 'album',
expression:
'time_added after 8 weeks ago and media_kind is music having track_count > 3 order by time_added desc',
limit: 3
}),
webapi.search({
type: 'track',
expression:
'time_played after 8 weeks ago and media_kind is music order by time_played desc',
limit: 3
})
])
},
set(vm, response) {
vm.recently_added = new GroupByList(response[0].data.albums)
vm.recently_played = new GroupByList(response[1].data.tracks)
}
}
export default {
name: 'PageMusic',
2023-07-25 14:41:34 +02:00
components: { ContentWithHeading, ListAlbums, ListTracks, TabsMusic },
beforeRouteEnter(to, from, next) {
dataObject.load(to).then((response) => {
next((vm) => dataObject.set(vm, response))
})
},
beforeRouteUpdate(to, from, next) {
const vm = this
dataObject.load(to).then((response) => {
dataObject.set(vm, response)
next()
})
},
data() {
return {
recently_added: [],
recently_played: { items: [] },
2023-12-09 10:51:57 +01:00
selected_track: {}
}
}
}
</script>
<style></style>