You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by mi...@apache.org on 2018/09/26 15:16:50 UTC
[incubator-dubbo-ops] branch develop updated: add override page
This is an automated email from the ASF dual-hosted git repository.
min pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-ops.git
The following commit(s) were added to refs/heads/develop by this push:
new 2dee339 add override page
2dee339 is described below
commit 2dee339f285a462c03c77199dfd8d2eed21a0951
Author: nzomkxia <z8...@gmail.com>
AuthorDate: Wed Sep 26 23:15:20 2018 +0800
add override page
---
.../dubbo/admin/controller/RoutesController.java | 4 ++-
.../dubbo/admin/registry/common/domain/Route.java | 2 +-
.../{DynamicConfig.vue => Overrides.vue} | 13 ++++++--
.../src/components/RoutingRule.vue | 38 +++++++++++++++-------
dubbo-admin-frontend/src/router/index.js | 6 ++--
5 files changed, 44 insertions(+), 19 deletions(-)
diff --git a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/RoutesController.java b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/RoutesController.java
index 0e2751f..e5b1b5b 100644
--- a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/RoutesController.java
+++ b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/RoutesController.java
@@ -74,7 +74,7 @@ public class RoutesController {
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
- public void updateRule(@RequestBody RouteDTO routeDTO) {
+ public boolean updateRule(@RequestBody RouteDTO routeDTO) {
Long id = routeDTO.getId();
Route route = routeService.findRoute(id);
if (route == null) {
@@ -92,8 +92,10 @@ public class RoutesController {
newRoute.setRuntime(routeDTO.isRuntime());
newRoute.setPriority(routeDTO.getPriority());
newRoute.setRule(condition);
+ newRoute.setId(id);
routeService.updateRoute(newRoute);
}
+ return true;
}
@RequestMapping(value = "/search", method = RequestMethod.POST)
diff --git a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/registry/common/domain/Route.java b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/registry/common/domain/Route.java
index 2b001cf..45f63fc 100644
--- a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/registry/common/domain/Route.java
+++ b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/registry/common/domain/Route.java
@@ -183,7 +183,7 @@ public class Route extends Entity {
}
public void setRule(String rule) {
- this.rule = rule;
+ this.rule = rule.trim();
String[] rules = rule.split("=>");
if (rules.length != 2) {
if (rule.endsWith("=>")) {
diff --git a/dubbo-admin-frontend/src/components/DynamicConfig.vue b/dubbo-admin-frontend/src/components/Overrides.vue
similarity index 95%
rename from dubbo-admin-frontend/src/components/DynamicConfig.vue
rename to dubbo-admin-frontend/src/components/Overrides.vue
index 9b27fff..4ad1295 100644
--- a/dubbo-admin-frontend/src/components/DynamicConfig.vue
+++ b/dubbo-admin-frontend/src/components/Overrides.vue
@@ -162,8 +162,17 @@
loadBalances: [
],
template:
- 'methodName: sayHello # 0 for all methods\n' +
- 'strategy: # leastactive, random, roundrobin',
+ 'application: # consumer\'s application name, empty for all \n' +
+ 'address: 192.168.0.1 # consumer\'s ip address, empty for all consumers\n' +
+ 'dynamic: false\n' +
+ 'enabled: false # enable this rule\n' +
+ 'parameters:\n' +
+ ' - timeout: 100\n' +
+ '\n' +
+ 'mock: \n' +
+ ' - 0: \'force: return null’\n' +
+ ' - sayHello: \'force: return null\'\n' +
+ ' - test: \'fail: return empty\'',
ruleText: '',
cmOption: {
theme: 'paraiso-light',
diff --git a/dubbo-admin-frontend/src/components/RoutingRule.vue b/dubbo-admin-frontend/src/components/RoutingRule.vue
index 2bf50ff..d535563 100644
--- a/dubbo-admin-frontend/src/components/RoutingRule.vue
+++ b/dubbo-admin-frontend/src/components/RoutingRule.vue
@@ -139,6 +139,7 @@
filter: '',
dialog: false,
warn: false,
+ updateId: -1,
application: '',
service: '',
warnTitle: '',
@@ -190,11 +191,11 @@
'force: true/false\n' +
'dynamic: true/false\n' +
'conditions:\n' +
- ' - => host != 172.22.3.91\n' +
- ' - host != 10.20.153.10,10.20.153.11 =>\n' +
- ' - host = 10.20.153.10,10.20.153.11 =>\n' +
- ' - application != kylin => host != 172.22.3.95,172.22.3.96\n' +
- ' - method = find*,list*,get*,is* => host = 172.22.3.94,172.22.3.95,172.22.3.96',
+ ' - \'=> host != 172.22.3.91\'\n' +
+ ' - \'host != 10.20.153.10,10.20.153.11 =>\'\n' +
+ ' - \'host = 10.20.153.10,10.20.153.11 =>\'\n' +
+ ' - \'application != kylin => host != 172.22.3.95,172.22.3.96\'\n' +
+ ' - \'method = find*,list*,get*,is* => host = 172.22.3.94,172.22.3.95,172.22.3.96\'',
ruleText: '',
cmOption: {
theme: 'paraiso-light',
@@ -270,6 +271,7 @@
},
closeDialog: function () {
this.ruleText = this.template
+ this.updateId = -1
this.service = ''
this.dialog = false
this.cmOption.readOnly = false
@@ -290,13 +292,24 @@
saveItem: function () {
let rule = yaml.safeLoad(this.ruleText)
rule.serviceName = this.service
- AXIOS.post('/routes/create', rule)
- .then(response => {
- if (response.data) {
- this.search(this.service, true)
- }
- this.closeDialog()
- })
+ if (this.updateId !== -1) {
+ rule.id = this.updateId
+ AXIOS.post('/routes/update', rule)
+ .then(response => {
+ if (response.data) {
+ this.search(this.service, true)
+ }
+ this.closeDialog()
+ })
+ } else {
+ AXIOS.post('/routes/create', rule)
+ .then(response => {
+ if (response.data) {
+ this.search(this.service, true)
+ }
+ this.closeDialog()
+ })
+ }
},
itemOperation: function (icon, item) {
switch (icon) {
@@ -322,6 +335,7 @@
this.ruleText = result
this.cmOption.readOnly = false
this.dialog = true
+ this.updateId = item.id
})
break
case 'block':
diff --git a/dubbo-admin-frontend/src/router/index.js b/dubbo-admin-frontend/src/router/index.js
index 6fbf0cf..9327e25 100644
--- a/dubbo-admin-frontend/src/router/index.js
+++ b/dubbo-admin-frontend/src/router/index.js
@@ -23,7 +23,7 @@ import RoutingRule from '@/components/RoutingRule'
import AccessControl from '@/components/AccessControl'
import LoadBalance from '@/components/LoadBalance'
import WeightAdjust from '@/components/WeightAdjust'
-import DynamicConfig from '@/components/DynamicConfig'
+import Overrides from '@/components/Overrides'
Vue.use(Router)
@@ -61,8 +61,8 @@ export default new Router({
},
{
path: '/governance/config',
- name: 'DynamicConfig',
- component: DynamicConfig
+ name: 'Overrides',
+ component: Overrides
}
]
})