diff --git a/api/funkwhale_api/radios/filtersets.py b/api/funkwhale_api/radios/filtersets.py index f570b2d54..128b9ad1d 100644 --- a/api/funkwhale_api/radios/filtersets.py +++ b/api/funkwhale_api/radios/filtersets.py @@ -1,14 +1,23 @@ import django_filters +from django_filters import rest_framework as filters + from funkwhale_api.common import filters as common_filters +from funkwhale_api.music import utils + from . import models class RadioFilter(django_filters.FilterSet): scope = common_filters.ActorScopeFilter(actor_field="user__actor", distinct=True) + q = filters.CharFilter(field_name="_", method="filter_q") class Meta: model = models.Radio fields = { "name": ["exact", "iexact", "startswith", "icontains"], } + + def filter_q(self, queryset, name, value): + query = utils.get_query(value, ["name", "user__username"]) + return queryset.filter(query) diff --git a/changes/changelog.d/370.feature b/changes/changelog.d/370.feature new file mode 100644 index 000000000..381cd8e7c --- /dev/null +++ b/changes/changelog.d/370.feature @@ -0,0 +1 @@ +Dedicated, advanced search page (#370) \ No newline at end of file diff --git a/front/src/components/audio/SearchBar.vue b/front/src/components/audio/SearchBar.vue index 8df8b1826..ce72ab9dd 100644 --- a/front/src/components/audio/SearchBar.vue +++ b/front/src/components/audio/SearchBar.vue @@ -42,7 +42,7 @@ export default { // Cancel any API search request to backend… jQuery(this.$el).search('cancel query'); // Go direct to the artist page… - router.push("/library/artists?query=" + searchQuery + "&page=1&paginateBy=25&ordering=name"); + router.push(`/search?q=${searchQuery}&type=artists`); } }); @@ -147,8 +147,12 @@ export default { }, getId (t) { return t.name - } - } + }, + }, + { + code: 'more', + name: '', + }, ] categories.forEach(category => { results[category.code] = { @@ -193,6 +197,22 @@ export default { } } } + else if (category.code === 'more') { + let searchMessage = self.$pgettext('Search/*/*', 'More results 🡒') + results['more'] = { + name: '', + results: [{ + title: searchMessage, + routerUrl: { + name: 'search', + query: { + type: "artists", + q: searchQuery + } + } + }] + } + } else { initialResponse[category.code].forEach(result => { isEmptyResults = false diff --git a/front/src/router/index.js b/front/src/router/index.js index b6c9170d0..5f7a0d3d0 100644 --- a/front/src/router/index.js +++ b/front/src/router/index.js @@ -91,7 +91,9 @@ export default new Router({ import(/* webpackChunkName: "core" */ "@/views/Search"), props: route => ({ initialId: route.query.id, - type: route.query.type, + initialType: route.query.type || 'artists', + initialQuery: route.query.q, + initialPage: parseInt(route.query.page) || 1, }) }, { diff --git a/front/src/style/_main.scss b/front/src/style/_main.scss index c04600460..1f054d081 100644 --- a/front/src/style/_main.scss +++ b/front/src/style/_main.scss @@ -34,6 +34,7 @@ $bottom-player-height: 4rem; @import "./components/_playlist_editor.scss"; @import "./components/_queue.scss"; @import "./components/_settings_group.scss"; +@import "./components/_search.scss"; @import "./components/_sidebar.scss"; @import "./components/_table.scss"; @import "./components/_tags_list.scss"; diff --git a/front/src/style/components/_search.scss b/front/src/style/components/_search.scss new file mode 100644 index 000000000..502e14af7 --- /dev/null +++ b/front/src/style/components/_search.scss @@ -0,0 +1,8 @@ +.search-wrapper .category.search .results { + .category:last-child { + .results { + border-left: 0; + text-align: right; + } + } +} \ No newline at end of file diff --git a/front/src/views/Search.vue b/front/src/views/Search.vue index f2c141bd5..0ac74162d 100644 --- a/front/src/views/Search.vue +++ b/front/src/views/Search.vue @@ -1,9 +1,83 @@