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

61 lines
1.5 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-added.title')" />
</template>
<template #content>
<list-albums :items="recently_added" />
</template>
</content-with-heading>
</div>
</template>
<script>
2024-02-28 15:24:55 +01:00
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import { GroupedList } from '@/lib/GroupedList'
2022-02-19 06:18:01 +01:00
import ListAlbums from '@/components/ListAlbums.vue'
import TabsMusic from '@/components/TabsMusic.vue'
2024-02-28 15:24:55 +01:00
import store from '@/store'
import webapi from '@/webapi'
2022-02-19 06:18:01 +01:00
const dataObject = {
load(to) {
2024-04-25 22:36:04 +02:00
const limit = store.getters.setting_recently_added_limit
return webapi.search({
expression:
'media_kind is music having track_count > 3 order by time_added desc',
limit,
type: 'album'
})
},
set(vm, response) {
vm.recently_added = new GroupedList(response.data.albums, {
2024-03-26 12:04:04 +01:00
criteria: [{ field: 'time_added', order: -1, type: Date }],
index: { field: 'time_added', type: Date }
})
}
}
export default {
name: 'PageMusicRecentlyAdded',
2024-02-28 13:58:04 +01:00
components: { ContentWithHeading, ListAlbums, TabsMusic },
beforeRouteEnter(to, from, next) {
dataObject.load(to).then((response) => {
next((vm) => dataObject.set(vm, response))
})
},
data() {
return {
2024-02-22 19:32:11 +01:00
recently_added: new GroupedList()
}
}
}
</script>
<style></style>