[web] Add album/track count in genre views

This commit is contained in:
chme 2022-03-26 21:43:23 +01:00
parent 7598a71aea
commit 01f4f8b137
4 changed files with 52 additions and 19 deletions

View File

@ -11,6 +11,22 @@
genre.name genre.name
}}</a> }}</a>
</p> </p>
<div class="content is-small">
<p>
<span class="heading">Albums</span>
<span class="title is-6">{{ genre.album_count }}</span>
</p>
<p>
<span class="heading">Tracks</span>
<span class="title is-6">{{ genre.track_count }}</span>
</p>
<p>
<span class="heading">Length</span>
<span class="title is-6">{{
$filters.duration(genre.length_ms)
}}</span>
</p>
</div>
</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

@ -6,7 +6,7 @@
</template> </template>
<template #heading-left> <template #heading-left>
<p class="title is-4"> <p class="title is-4">
{{ name }} {{ genre.name }}
</p> </p>
</template> </template>
<template #heading-right> <template #heading-right>
@ -27,13 +27,15 @@
</template> </template>
<template #content> <template #content>
<p class="heading has-text-centered-mobile"> <p class="heading has-text-centered-mobile">
{{ albums_list.total }} albums | {{ genre.album_count }} albums |
<a class="has-text-link" @click="open_tracks">tracks</a> <a class="has-text-link" @click="open_tracks"
>{{ genre.track_count }} tracks</a
>
</p> </p>
<list-albums :albums="albums_list" /> <list-albums :albums="albums_list" />
<modal-dialog-genre <modal-dialog-genre
:show="show_genre_details_modal" :show="show_genre_details_modal"
:genre="{ name: name }" :genre="genre"
@close="show_genre_details_modal = false" @close="show_genre_details_modal = false"
/> />
</template> </template>
@ -51,12 +53,15 @@ import { bySortName, GroupByList } from '@/lib/GroupByList'
const dataObject = { const dataObject = {
load: function (to) { load: function (to) {
return webapi.library_genre(to.params.genre) return Promise.all([
webapi.library_genre(to.params.genre),
webapi.library_genre_albums(to.params.genre)
])
}, },
set: function (vm, response) { set: function (vm, response) {
vm.name = vm.$route.params.genre vm.genre = response[0].data
vm.albums_list = new GroupByList(response.data.albums) vm.albums_list = new GroupByList(response[1].data.albums)
vm.albums_list.group(bySortName('name_sort')) vm.albums_list.group(bySortName('name_sort'))
} }
} }
@ -89,7 +94,7 @@ export default {
data() { data() {
return { return {
name: '', genre: {},
albums_list: new GroupByList(), albums_list: new GroupByList(),
show_genre_details_modal: false show_genre_details_modal: false
@ -99,12 +104,15 @@ export default {
methods: { methods: {
open_tracks: function () { open_tracks: function () {
this.show_details_modal = false this.show_details_modal = false
this.$router.push({ name: 'GenreTracks', params: { genre: this.name } }) this.$router.push({
name: 'GenreTracks',
params: { genre: this.genre.name }
})
}, },
play: function () { play: function () {
webapi.player_play_expression( webapi.player_play_expression(
'genre is "' + this.name + '" and media_kind is music', 'genre is "' + this.genre.name + '" and media_kind is music',
true true
) )
} }

View File

@ -6,7 +6,7 @@
</template> </template>
<template #heading-left> <template #heading-left>
<p class="title is-4"> <p class="title is-4">
{{ genre }} {{ genre.name }}
</p> </p>
</template> </template>
<template #heading-right> <template #heading-right>
@ -27,13 +27,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_genre">albums</a> | <a class="has-text-link" @click="open_genre"
{{ tracks.total }} tracks >{{ genre.album_count }} albums</a
>
| {{ genre.track_count }} tracks
</p> </p>
<list-tracks :tracks="tracks.items" :expression="expression" /> <list-tracks :tracks="tracks.items" :expression="expression" />
<modal-dialog-genre <modal-dialog-genre
:show="show_genre_details_modal" :show="show_genre_details_modal"
:genre="{ name: genre }" :genre="genre"
@close="show_genre_details_modal = false" @close="show_genre_details_modal = false"
/> />
</template> </template>
@ -50,12 +52,15 @@ import webapi from '@/webapi'
const dataObject = { const dataObject = {
load: function (to) { load: function (to) {
return webapi.library_genre_tracks(to.params.genre) return Promise.all([
webapi.library_genre(to.params.genre),
webapi.library_genre_tracks(to.params.genre)
])
}, },
set: function (vm, response) { set: function (vm, response) {
vm.genre = vm.$route.params.genre vm.genre = response[0].data
vm.tracks = response.data.tracks vm.tracks = response[1].data.tracks
} }
} }
@ -102,14 +107,14 @@ export default {
}, },
expression() { expression() {
return 'genre is "' + this.genre + '" and media_kind is music' return 'genre is "' + this.genre.name + '" and media_kind is music'
} }
}, },
methods: { methods: {
open_genre: function () { open_genre: function () {
this.show_details_modal = false this.show_details_modal = false
this.$router.push({ name: 'Genre', params: { genre: this.genre } }) this.$router.push({ name: 'Genre', params: { genre: this.genre.name } })
}, },
play: function () { play: function () {

View File

@ -297,6 +297,10 @@ export default {
}, },
library_genre(genre) { library_genre(genre) {
return axios.get(`./api/library/genres/${encodeURIComponent(genre)}`)
},
library_genre_albums(genre) {
const genreParams = { const genreParams = {
type: 'albums', type: 'albums',
media_kind: 'music', media_kind: 'music',