diff --git a/api/funkwhale_api/federation/factories.py b/api/funkwhale_api/federation/factories.py index 7dad1daa9..4a13842da 100644 --- a/api/funkwhale_api/federation/factories.py +++ b/api/funkwhale_api/federation/factories.py @@ -171,6 +171,7 @@ class LibraryTrackFactory(factory.DjangoModelFactory): audio_url = factory.Faker("url") audio_mimetype = "audio/ogg" metadata = factory.SubFactory(LibraryTrackMetadataFactory) + published_date = factory.LazyFunction(timezone.now) class Meta: model = models.LibraryTrack diff --git a/changes/changelog.d/326.enhancement b/changes/changelog.d/326.enhancement new file mode 100644 index 000000000..48389b6b7 --- /dev/null +++ b/changes/changelog.d/326.enhancement @@ -0,0 +1 @@ +Can now order tracks on federated track list (#326) diff --git a/front/src/components/federation/LibraryTrackTable.vue b/front/src/components/federation/LibraryTrackTable.vue index 082629197..781cb86dd 100644 --- a/front/src/components/federation/LibraryTrackTable.vue +++ b/front/src/components/federation/LibraryTrackTable.vue @@ -15,6 +15,21 @@ +
+ + +
+
+ + +
@@ -96,8 +111,10 @@ import _ from 'lodash' import Pagination from '@/components/Pagination' import ActionTable from '@/components/common/ActionTable' +import OrderingMixin from '@/components/mixins/Ordering' export default { + mixins: [OrderingMixin], props: { filters: {type: Object, required: false}, showLibrary: {type: Boolean, default: false} @@ -113,7 +130,15 @@ export default { page: 1, paginateBy: 25, search: '', - importedFilter: null + importedFilter: null, + orderingDirection: '-', + ordering: 'published_date', + orderingOptions: [ + ['published_date', 'Published date'], + ['title', 'Title'], + ['album_title', 'Album title'], + ['artist_name', 'Artist name'] + ] } }, created () { @@ -130,6 +155,7 @@ export default { let params = _.merge({ 'page': this.page, 'page_size': this.paginateBy, + 'ordering': this.getOrderingAsString(), 'q': this.search }, this.filters) if (this.importedFilter !== null) { @@ -178,6 +204,14 @@ export default { } }, watch: { + orderingDirection: function () { + this.page = 1 + this.fetchData() + }, + ordering: function () { + this.page = 1 + this.fetchData() + }, search (newValue) { this.page = 1 this.fetchData()