From a55c6ed941ef63659023161a2d4efac59792f979 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Thu, 23 Mar 2023 23:19:55 +0100 Subject: [PATCH 1/7] #1473 Add sort by rating for composer, genre, and artist tracks. --- web-src/src/components/ListTracks.vue | 73 +++++++++--------- web-src/src/lib/GroupByList.js | 16 ++++ web-src/src/locales/de.json | 23 +++++- web-src/src/locales/en.json | 15 +++- web-src/src/locales/fr.json | 17 ++++- web-src/src/pages/PageAlbum.vue | 6 +- web-src/src/pages/PageArtistTracks.vue | 74 +++++++++++++------ web-src/src/pages/PageAudiobooksAlbum.vue | 6 +- web-src/src/pages/PageBrowse.vue | 4 +- .../src/pages/PageBrowseRecentlyPlayed.vue | 5 +- web-src/src/pages/PageComposerTracks.vue | 64 ++++++++++++++-- web-src/src/pages/PageGenreTracks.vue | 71 +++++++++++++----- web-src/src/pages/PagePlaylist.vue | 8 +- web-src/src/pages/PagePodcast.vue | 11 ++- web-src/src/pages/PagePodcasts.vue | 6 +- web-src/src/pages/PageRadioStreams.vue | 7 +- web-src/src/pages/PageSearch.vue | 6 +- web-src/src/store/index.js | 12 +++ web-src/src/store/mutation_types.js | 3 + 19 files changed, 310 insertions(+), 117 deletions(-) diff --git a/web-src/src/components/ListTracks.vue b/web-src/src/components/ListTracks.vue index 974aa9db..13f61e0a 100644 --- a/web-src/src/components/ListTracks.vue +++ b/web-src/src/components/ListTracks.vue @@ -1,40 +1,47 @@ { + const fieldA = a[field] || defaultValue + const fieldB = b[field] || defaultValue + const result = fieldA > fieldB + return direction === 'asc' ? result : result * -1 + }, + + groupKeyFn: (item) => { + const fieldValue = item[field] || defaultValue + return Math.floor(fieldValue / 10) + } + } +} + export function byYear(field, { direction = 'asc', defaultValue = '0000' }) { return { compareFn: (a, b) => { diff --git a/web-src/src/locales/de.json b/web-src/src/locales/de.json index 7a947ac4..a355e1f2 100644 --- a/web-src/src/locales/de.json +++ b/web-src/src/locales/de.json @@ -270,6 +270,7 @@ "sort-by": { "title": "Sortieren nach", "name": "Name", + "rating": "Bewertung", "release-date": "Erscheinungsdatum" } }, @@ -333,7 +334,12 @@ "composer": { "album-count": "{count} Alben", "shuffle": "Zufallswiedergabe", - "track-count": "{count} Tracks" + "track-count": "{count} Tracks", + "sort-by": { + "title": "Sortieren nach", + "name": "Name", + "rating": "Bewertung" + } }, "composers": { "count": "{count} Komponisten", @@ -346,7 +352,12 @@ "genre": { "album-count": "{count} Alben", "shuffle": "Zufallswiedergabe", - "track-count": "{count} Tracks" + "track-count": "{count} Tracks", + "sort-by": { + "title": "Sortieren nach", + "name": "Name", + "rating": "Bewertung" + } }, "genres": { "count": "{count} Genres", @@ -395,8 +406,7 @@ "albums": "Alben", "artists": "Künstler", "audiobooks": "Hörbücher", - "composers": "Komponisten", - + "composers": "Komponisten", "help": "Tip: Du kannst mit einer Smart-Playlist-Abfrage-Sprache nach Ausdrücken suchen wenn Du dem Ausdruck ein query: voranstellst.", "no-albums": "Keine Alben gefunden", "no-artists": "Keine Künstler gefunden", @@ -546,5 +556,10 @@ "today": "Heute", "last-week": "Letzte Woche", "last-month": "Letzer Monat" + }, + "filter": { + "mono": "Mono", + "stereo": "Stereo", + "channels": "{count} Kanäle" } } diff --git a/web-src/src/locales/en.json b/web-src/src/locales/en.json index d57deb5e..093607c6 100644 --- a/web-src/src/locales/en.json +++ b/web-src/src/locales/en.json @@ -270,6 +270,7 @@ "sort-by": { "title": "Sort by", "name": "Name", + "rating": "Rating", "release-date": "Release date" } }, @@ -333,7 +334,12 @@ "composer": { "album-count": "{count} albums", "shuffle": "Shuffle", - "track-count": "{count} tracks" + "track-count": "{count} tracks", + "sort-by": { + "title": "Sort by", + "name": "Name", + "rating": "Rating" + } }, "composers": { "count": "{count} composers", @@ -346,7 +352,12 @@ "genre": { "album-count": "{count} albums", "shuffle": "Shuffle", - "track-count": "{count} tracks" + "track-count": "{count} tracks", + "sort-by": { + "title": "Sort by", + "name": "Name", + "rating": "Rating" + } }, "genres": { "count": "{count} genres", diff --git a/web-src/src/locales/fr.json b/web-src/src/locales/fr.json index 079fabd3..cd923e9a 100644 --- a/web-src/src/locales/fr.json +++ b/web-src/src/locales/fr.json @@ -41,7 +41,7 @@ "type": "Type", "year": "Année" }, - "artiste": { + "artist": { "add-next": "Ajouter ensuite", "add": "Ajouter", "added-on": "Ajouté le", @@ -270,6 +270,7 @@ "sort-by": { "title": "Trier par", "name": "Nom", + "rating": "Classement", "release-date": "Date de sortie" } }, @@ -333,7 +334,12 @@ "composer": { "album-count": "{count} albums", "shuffle": "Lecture aléatoire", - "track-count": "{count} pistes" + "track-count": "{count} pistes", + "sort-by": { + "title": "Trier par", + "name": "Nom", + "rating": "Classement" + } }, "composers": { "count": "{count} compositeurs", @@ -346,7 +352,12 @@ "genre": { "album-count": "{count} albums", "shuffle": "Lecture aléatoire", - "track-count": "{count} pistes" + "track-count": "{count} pistes", + "sort-by": { + "title": "Trier par", + "name": "Nom", + "rating": "Classement" + } }, "genres": { "count": "{count} genres", diff --git a/web-src/src/pages/PageAlbum.vue b/web-src/src/pages/PageAlbum.vue index 5a90d245..fbf87292 100644 --- a/web-src/src/pages/PageAlbum.vue +++ b/web-src/src/pages/PageAlbum.vue @@ -49,6 +49,7 @@ import ListTracks from '@/components/ListTracks.vue' import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue' import CoverArtwork from '@/components/CoverArtwork.vue' import webapi from '@/webapi' +import { GroupByList } from '@/lib/GroupByList' const dataObject = { load: function (to) { @@ -60,7 +61,7 @@ const dataObject = { set: function (vm, response) { vm.album = response[0].data - vm.tracks = response[1].data.items + vm.tracks = new GroupByList(response[1].data) } } @@ -84,8 +85,7 @@ export default { data() { return { album: {}, - tracks: [], - + tracks: new GroupByList(), show_album_details_modal: false } }, diff --git a/web-src/src/pages/PageArtistTracks.vue b/web-src/src/pages/PageArtistTracks.vue index 037456ac..ca998769 100644 --- a/web-src/src/pages/PageArtistTracks.vue +++ b/web-src/src/pages/PageArtistTracks.vue @@ -2,7 +2,20 @@
@@ -21,6 +21,7 @@ import ContentWithHeading from '@/templates/ContentWithHeading.vue' import TabsMusic from '@/components/TabsMusic.vue' import ListTracks from '@/components/ListTracks.vue' import webapi from '@/webapi' +import { GroupByList } from '@/lib/GroupByList' const dataObject = { load: function (to) { @@ -33,7 +34,7 @@ const dataObject = { }, set: function (vm, response) { - vm.recently_played = response.data.tracks + vm.recently_played = new GroupByList(response.data.tracks) } } diff --git a/web-src/src/pages/PageComposerTracks.vue b/web-src/src/pages/PageComposerTracks.vue index 71794460..73d4c954 100644 --- a/web-src/src/pages/PageComposerTracks.vue +++ b/web-src/src/pages/PageComposerTracks.vue @@ -1,6 +1,22 @@