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

56 lines
1.3 KiB
Vue
Raw Normal View History

<template>
2022-02-19 06:18:01 +01:00
<div class="fd-page-with-tabs">
<tabs-music />
<content-with-heading>
<template #heading-left>
<p class="title is-4" v-text="$t('page.music.recently-played.title')" />
</template>
<template #content>
<list-tracks :items="recently_played" />
</template>
</content-with-heading>
</div>
</template>
<script>
2022-02-19 06:18:01 +01:00
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
2024-02-22 19:32:11 +01:00
import { GroupedList } from '@/lib/GroupedList'
2022-02-19 06:18:01 +01:00
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 webapi.search({
expression:
'time_played after 8 weeks ago and media_kind is music order by time_played desc',
limit: 50,
type: 'track'
})
},
set(vm, response) {
2024-02-22 19:32:11 +01:00
vm.recently_played = new GroupedList(response.data.tracks)
}
}
export default {
name: 'PageMusicRecentlyPlayed',
2024-02-28 13:58:04 +01:00
components: { ContentWithHeading, ListTracks, TabsMusic },
beforeRouteEnter(to, from, next) {
2022-02-19 06:18:01 +01:00
dataObject.load(to).then((response) => {
next((vm) => dataObject.set(vm, response))
2022-02-19 06:18:01 +01:00
})
},
data() {
return {
recently_played: {}
}
}
}
</script>
<style></style>