You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ra...@apache.org on 2021/06/01 02:27:36 UTC
[dubbo-admin] branch develop updated: condition route and accesses
query consumer application (#766)
This is an automated email from the ASF dual-hosted git repository.
ranke pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-admin.git
The following commit(s) were added to refs/heads/develop by this push:
new acef4bf condition route and accesses query consumer application (#766)
acef4bf is described below
commit acef4bf7c8458a5be61e717106beb6c7fb3e1c3e
Author: haoyann <10...@qq.com>
AuthorDate: Tue Jun 1 10:27:27 2021 +0800
condition route and accesses query consumer application (#766)
---
.../dubbo/admin/controller/ServiceController.java | 6 +++++
.../src/components/governance/AccessControl.vue | 4 ++--
.../src/components/governance/RoutingRule.vue | 4 ++--
dubbo-admin-ui/src/store/index.js | 26 +++++++++++++++++++++-
4 files changed, 35 insertions(+), 5 deletions(-)
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 class ServiceController {
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 @@ export default {
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 @@ export default {
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 @@ export default {
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 @@ export default {
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 @@ export const store = new Vuex.Store({
appTitle: 'Dubbo Admin',
area: null,
serviceItems: null,
- appItems: null
+ appItems: null,
+ consumerItems: null
},
mutations: {
setArea (state, area) {
@@ -36,6 +37,9 @@ export const store = new Vuex.Store({
},
setAppItems (state, appItems) {
state.appItems = appItems
+ },
+ setConsumerItems (state, consumerItems) {
+ state.consumerItems = consumerItems
}
},
actions: {
@@ -65,6 +69,18 @@ export const store = new Vuex.Store({
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 @@ export const store = new Vuex.Store({
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
+ })
}
}
})