Skip to content

Commit ff8a5a9

Browse files
authored
fix(#2338): URI is not updated by search input (#2339)
closes #2338
1 parent 41e9cfc commit ff8a5a9

File tree

3 files changed

+44
-11
lines changed

3 files changed

+44
-11
lines changed

spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@
4141
},
4242
"notification_filter_center": {
4343
"description": "Benachrichtigungen für folgende Applikationen / Instanzen werden unterdrückt."
44+
},
45+
"filter": {
46+
"no_results": "Keine Ergebnisse für den eingestellten Filter."
4447
}
4548
}

spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@
4747
},
4848
"notification_filter_center": {
4949
"description": "Notifications on following applications or instances will be suppressed."
50+
},
51+
"filter": {
52+
"no_results": "No results matching your filter."
5053
}
5154
}

spring-boot-admin-server-ui/src/main/frontend/views/applications/index.vue

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,15 @@
6060

6161
<template v-if="applicationsInitialized">
6262
<TransitionGroup>
63+
<sba-panel
64+
v-if="hasActiveFilter && statusGroups.length === 0"
65+
class="text-center"
66+
>
67+
{{ t('filter.no_results') }}
68+
</sba-panel>
6369
<sba-panel
6470
v-for="group in statusGroups"
71+
v-else
6572
:key="group.status"
6673
:seamless="true"
6774
:title="t('term.applications_tc', group.applications.length)"
@@ -112,8 +119,9 @@
112119

113120
<script>
114121
import { groupBy, sortBy, transform } from 'lodash-es';
115-
import { ref } from 'vue';
122+
import { computed, ref, watch } from 'vue';
116123
import { useI18n } from 'vue-i18n';
124+
import { useRoute, useRouter } from 'vue-router';
117125
118126
import SbaStickySubnav from '@/components/sba-sticky-subnav';
119127
import SbaWave from '@/components/sba-wave';
@@ -164,15 +172,40 @@ export default {
164172
default: null,
165173
},
166174
},
167-
setup: function () {
175+
setup: function (props) {
168176
const { t } = useI18n();
177+
const router = useRouter();
178+
const route = useRoute();
169179
const { applications, applicationsInitialized } = useApplicationStore();
180+
const filter = ref(route.query.q);
181+
182+
watch(filter, (q) => {
183+
let to = {
184+
name: 'applications',
185+
params: { selected: props.selected },
186+
};
187+
188+
if (q?.length > 0) {
189+
to = {
190+
...to,
191+
query: { q },
192+
};
193+
}
194+
195+
router.replace(to);
196+
});
197+
198+
const hasActiveFilter = computed(() => {
199+
return filter.value?.length > 0;
200+
});
170201
171202
return {
172203
applications,
173204
applicationsInitialized,
174205
t,
175-
filter: ref(null),
206+
filter,
207+
router,
208+
hasActiveFilter,
176209
hasNotificationFiltersSupport: ref(false),
177210
showNotificationFilterSettingsObject: ref(null),
178211
notificationFilters: ref([]),
@@ -205,12 +238,6 @@ export default {
205238
},
206239
},
207240
watch: {
208-
'$route.query': {
209-
immediate: true,
210-
handler() {
211-
this.filter = this.$route.query.q || '';
212-
},
213-
},
214241
selected: {
215242
immediate: true,
216243
handler(newVal) {
@@ -223,7 +250,7 @@ export default {
223250
},
224251
methods: {
225252
select(name) {
226-
this.$router.replace({
253+
this.router.replace({
227254
name: 'applications',
228255
params: { selected: name },
229256
});
@@ -234,7 +261,7 @@ export default {
234261
}
235262
this.toggleNotificationFilterSettings(null);
236263
if (this.selected === expectedSelected || !expectedSelected) {
237-
this.$router.replace({ name: 'applications' });
264+
this.router.replace({ name: 'applications' });
238265
}
239266
},
240267
async scrollIntoView(id, behavior) {

0 commit comments

Comments
 (0)