owntone-server/web-src/src/pages/PageBrowseRecentlyPlayed.vue

64 lines
1.4 KiB
Vue
Raw Normal View History

<template>
2022-02-19 06:18:01 +01:00
<div class="fd-page-with-tabs">
<tabs-music></tabs-music>
<content-with-heading>
2022-02-19 06:18:01 +01:00
<template v-slot:heading-left>
<p class="title is-4">Recently played</p>
<p class="heading">tracks</p>
</template>
2022-02-19 06:18:01 +01:00
<template v-slot:content>
<list-tracks :tracks="recently_played.items"></list-tracks>
</template>
</content-with-heading>
</div>
</template>
<script>
2022-02-19 06:18:01 +01:00
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import TabsMusic from '@/components/TabsMusic.vue'
import ListTracks from '@/components/ListTracks.vue'
import webapi from '@/webapi'
2022-02-19 06:18:01 +01:00
const dataObject = {
load: function (to) {
return webapi.search({
type: 'track',
expression: 'time_played after 8 weeks ago and media_kind is music order by time_played desc',
limit: 50
})
},
set: function (vm, response) {
vm.recently_played = response.data.tracks
}
}
export default {
name: 'PageBrowseType',
components: { ContentWithHeading, TabsMusic, ListTracks },
data () {
return {
recently_played: {}
}
2022-02-19 06:18:01 +01:00
},
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()
})
}
}
</script>
<style>
</style>