condition route and accesses query consumer application (#766)
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/ServiceController.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/ServiceController.java
index 8142811..4a9df1a 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/ServiceController.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/ServiceController.java
@@ -126,4 +126,10 @@
public Set<String> allApplications(@PathVariable String env) {
return providerService.findApplications();
}
+
+ @RequestMapping(value = "/consumers", method = RequestMethod.GET)
+ public Set<String> allConsumers(@PathVariable String env) {
+ List<Consumer> consumers = consumerService.findAll();
+ return consumers.stream().map(Consumer::getApplication).collect(Collectors.toSet());
+ }
}
diff --git a/dubbo-admin-ui/src/components/governance/AccessControl.vue b/dubbo-admin-ui/src/components/governance/AccessControl.vue
index 40aa3ed..157a120 100644
--- a/dubbo-admin-ui/src/components/governance/AccessControl.vue
+++ b/dubbo-admin-ui/src/components/governance/AccessControl.vue
@@ -336,7 +336,7 @@
if (this.selected === 0) {
this.typeAhead = this.$store.getters.getServiceItems(v)
} else if (this.selected === 1) {
- this.typeAhead = this.$store.getters.getAppItems(v)
+ this.typeAhead = this.$store.getters.getConsumerItems(v)
}
this.searchLoading = false
this.timerID = null
@@ -534,7 +534,7 @@
this.setAppHeaders()
this.setServiceHeaders()
this.$store.dispatch('loadServiceItems')
- this.$store.dispatch('loadAppItems')
+ this.$store.dispatch('loadConsumerItems')
let query = this.$route.query
if ('service' in query) {
this.filter = query['service']
diff --git a/dubbo-admin-ui/src/components/governance/RoutingRule.vue b/dubbo-admin-ui/src/components/governance/RoutingRule.vue
index b61deb9..4dbdd02 100644
--- a/dubbo-admin-ui/src/components/governance/RoutingRule.vue
+++ b/dubbo-admin-ui/src/components/governance/RoutingRule.vue
@@ -310,7 +310,7 @@
if (this.selected === 0) {
this.typeAhead = this.$store.getters.getServiceItems(v)
} else if (this.selected === 1) {
- this.typeAhead = this.$store.getters.getAppItems(v)
+ this.typeAhead = this.$store.getters.getConsumerItems(v)
}
this.searchLoading = false
this.timerID = null
@@ -572,7 +572,7 @@
this.setAppHeaders()
this.setServiceHeaders()
this.$store.dispatch('loadServiceItems')
- this.$store.dispatch('loadAppItems')
+ this.$store.dispatch('loadConsumerItems')
this.ruleText = this.template
const query = this.$route.query
let filter = null
diff --git a/dubbo-admin-ui/src/store/index.js b/dubbo-admin-ui/src/store/index.js
index 97e9947..d553ce8 100644
--- a/dubbo-admin-ui/src/store/index.js
+++ b/dubbo-admin-ui/src/store/index.js
@@ -25,7 +25,8 @@
appTitle: 'Dubbo Admin',
area: null,
serviceItems: null,
- appItems: null
+ appItems: null,
+ consumerItems: null
},
mutations: {
setArea (state, area) {
@@ -36,6 +37,9 @@
},
setAppItems (state, appItems) {
state.appItems = appItems
+ },
+ setConsumerItems (state, consumerItems) {
+ state.consumerItems = consumerItems
}
},
actions: {
@@ -65,6 +69,18 @@
commit('setAppItems', appItems)
}
})
+ },
+ /**
+ * Load application items from consumer, put results into storage.
+ */
+ loadConsumerItems ({commit}) {
+ Vue.prototype.$axios.get('/consumers')
+ .then(response => {
+ if (response.status === 200) {
+ const consumerItems = response.data
+ commit('setConsumerItems', consumerItems)
+ }
+ })
}
},
getters: {
@@ -83,6 +99,14 @@
return state.appItems.filter(e => {
return (e || '').toLowerCase().indexOf((filter || '').toLowerCase()) > -1
})
+ },
+ /**
+ * Get application item arrays with filter
+ */
+ getConsumerItems: (state) => (filter) => {
+ return state.consumerItems.filter(e => {
+ return (e || '').toLowerCase().indexOf((filter || '').toLowerCase()) > -1
+ })
}
}
})