[web] Add album/track count to composer pages

This commit is contained in:
chme 2022-03-26 21:53:04 +01:00
parent 01f4f8b137
commit 0772997e27
4 changed files with 40 additions and 20 deletions

View File

@ -23,6 +23,12 @@
composer.track_count composer.track_count
}}</a> }}</a>
</p> </p>
<p>
<span class="heading">Length</span>
<span class="title is-6">{{
$filters.duration(composer.length_ms)
}}</span>
</p>
</div> </div>
<footer class="card-footer"> <footer class="card-footer">
<a class="card-footer-item has-text-dark" @click="queue_add"> <a class="card-footer-item has-text-dark" @click="queue_add">

View File

@ -3,7 +3,7 @@
<content-with-heading> <content-with-heading>
<template #heading-left> <template #heading-left>
<p class="title is-4"> <p class="title is-4">
{{ name }} {{ composer.name }}
</p> </p>
</template> </template>
<template #heading-right> <template #heading-right>
@ -24,14 +24,16 @@
</template> </template>
<template #content> <template #content>
<p class="heading has-text-centered-mobile"> <p class="heading has-text-centered-mobile">
{{ albums_list.total }} albums | {{ composer.album_count }} albums |
<a class="has-text-link" @click="open_tracks">tracks</a> <a class="has-text-link" @click="open_tracks"
>{{ composer.track_count }} tracks</a
>
</p> </p>
<list-albums :albums="albums_list" :hide_group_title="true" /> <list-albums :albums="albums_list" :hide_group_title="true" />
<modal-dialog-composer <modal-dialog-composer
:show="show_composer_details_modal" :show="show_composer_details_modal"
:composer="{ name: name }" :composer="composer"
@close="show_composer_details_modal = false" @close="show_composer_details_modal = false"
/> />
</template> </template>
@ -48,12 +50,15 @@ import { GroupByList } from '@/lib/GroupByList'
const dataObject = { const dataObject = {
load: function (to) { load: function (to) {
return webapi.library_composer(to.params.composer) return Promise.all([
webapi.library_composer(to.params.composer),
webapi.library_composer_albums(to.params.composer)
])
}, },
set: function (vm, response) { set: function (vm, response) {
vm.name = vm.$route.params.composer vm.composer = response[0].data
vm.albums_list = new GroupByList(response.data.albums) vm.albums_list = new GroupByList(response[1].data.albums)
} }
} }
@ -80,7 +85,7 @@ export default {
data() { data() {
return { return {
name: '', composer: {},
albums_list: new GroupByList(), albums_list: new GroupByList(),
show_composer_details_modal: false show_composer_details_modal: false
} }
@ -90,13 +95,13 @@ export default {
open_tracks: function () { open_tracks: function () {
this.$router.push({ this.$router.push({
name: 'ComposerTracks', name: 'ComposerTracks',
params: { composer: this.name } params: { composer: this.composer.name }
}) })
}, },
play: function () { play: function () {
webapi.player_play_expression( webapi.player_play_expression(
'composer is "' + this.name + '" and media_kind is music', 'composer is "' + this.composer.name + '" and media_kind is music',
true true
) )
} }

View File

@ -3,7 +3,7 @@
<content-with-heading> <content-with-heading>
<template #heading-left> <template #heading-left>
<p class="title is-4"> <p class="title is-4">
{{ composer }} {{ composer.name }}
</p> </p>
</template> </template>
<template #heading-right> <template #heading-right>
@ -24,13 +24,15 @@
</template> </template>
<template #content> <template #content>
<p class="heading has-text-centered-mobile"> <p class="heading has-text-centered-mobile">
<a class="has-text-link" @click="open_albums">albums</a> | <a class="has-text-link" @click="open_albums"
{{ tracks.total }} tracks >{{ composer.album_count }} albums</a
>
| {{ composer.track_count }} tracks
</p> </p>
<list-tracks :tracks="tracks.items" :expression="play_expression" /> <list-tracks :tracks="tracks.items" :expression="play_expression" />
<modal-dialog-composer <modal-dialog-composer
:show="show_composer_details_modal" :show="show_composer_details_modal"
:composer="{ name: composer }" :composer="composer"
@close="show_composer_details_modal = false" @close="show_composer_details_modal = false"
/> />
</template> </template>
@ -46,12 +48,15 @@ import webapi from '@/webapi'
const dataObject = { const dataObject = {
load: function (to) { load: function (to) {
return webapi.library_composer_tracks(to.params.composer) return Promise.all([
webapi.library_composer(to.params.composer),
webapi.library_composer_tracks(to.params.composer)
])
}, },
set: function (vm, response) { set: function (vm, response) {
vm.composer = vm.$route.params.composer vm.composer = response[0].data
vm.tracks = response.data.tracks vm.tracks = response[1].data.tracks
} }
} }
@ -79,7 +84,7 @@ export default {
data() { data() {
return { return {
tracks: { items: [] }, tracks: { items: [] },
composer: '', composer: {},
show_composer_details_modal: false show_composer_details_modal: false
} }
@ -87,7 +92,7 @@ export default {
computed: { computed: {
play_expression() { play_expression() {
return 'composer is "' + this.composer + '" and media_kind is music' return 'composer is "' + this.composer.name + '" and media_kind is music'
} }
}, },
@ -96,7 +101,7 @@ export default {
this.show_details_modal = false this.show_details_modal = false
this.$router.push({ this.$router.push({
name: 'ComposerAlbums', name: 'ComposerAlbums',
params: { composer: this.composer } params: { composer: this.composer.name }
}) })
}, },

View File

@ -338,6 +338,10 @@ export default {
}, },
library_composer(composer) { library_composer(composer) {
return axios.get(`./api/library/composers/${encodeURIComponent(composer)}`)
},
library_composer_albums(composer) {
const params = { const params = {
type: 'albums', type: 'albums',
media_kind: 'music', media_kind: 'music',