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 41a8383 add logo& enhance routing rule
41a8383 is described below
commit 41a8383a7b3dea903ea827e57d49393858635eda
Author: nzomkxia <[email protected]>
AuthorDate: Tue Sep 18 23:33:32 2018 +0800
add logo& enhance routing rule
---
.../dubbo/admin/controller/RoutesController.java | 11 ++--
.../admin/governance/sync/util/SyncUtils.java | 4 ++
.../dubbo/admin/registry/common/domain/Route.java | 2 +-
dubbo-admin-frontend/index.html | 3 +-
.../src/components/RoutingRule.vue | 69 ++++++++++++++-------
dubbo-admin-frontend/static/dubbo.ico | Bin 0 -> 16958 bytes
6 files changed, 59 insertions(+), 30 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 8b8f374..a7e2af2 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
@@ -4,9 +4,7 @@ import
org.apache.dubbo.admin.governance.service.ProviderService;
import org.apache.dubbo.admin.governance.service.RouteService;
import org.apache.dubbo.admin.registry.common.domain.Route;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import org.yaml.snakeyaml.Yaml;
import java.util.List;
@@ -22,13 +20,14 @@ public class RoutesController {
private ProviderService providerService;
@RequestMapping("/create")
- public void createRule(@RequestParam(required = false) String serviceName,
+ public boolean createRule(@RequestParam(required = false) String
serviceName,
@RequestParam(required = false) String app,
@RequestParam String rule) {
if (serviceName == null && app == null) {
}
Yaml yaml = new Yaml();
+ rule = rule.replace("===", "\n");
Map<String, Object> result = yaml.load(rule);
if (serviceName != null) {
result.put("scope", serviceName);
@@ -56,13 +55,12 @@ public class RoutesController {
routeService.createRoute(route);
}
-
} else {
//new feature in 2.7
result.put("scope", "application");
result.put("appname", app);
}
-
+ return true;
}
@RequestMapping("/update")
@@ -71,6 +69,7 @@ public class RoutesController {
if (route == null) {
//TODO Exception
}
+ rule = rule.replace("===", "\n");
Yaml yaml = new Yaml();
Map<String, Object> result = yaml.load(rule);
List<String> conditions = (List)result.get("conditions");
diff --git
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/governance/sync/util/SyncUtils.java
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/governance/sync/util/SyncUtils.java
index 04d26a5..f6941c2 100644
---
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/governance/sync/util/SyncUtils.java
+++
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/governance/sync/util/SyncUtils.java
@@ -120,6 +120,10 @@ public class SyncUtils {
r.setPriority(url.getParameter(Constants.PRIORITY_KEY, 0));
r.setEnabled(url.getParameter(Constants.ENABLED_KEY, true));
r.setForce(url.getParameter(Constants.FORCE_KEY, false));
+ r.setDynamic(url.getParameter(Constants.DYNAMIC_KEY, false));
+ r.setRuntime(url.getParameter(Constants.RUNTIME_KEY, false));
+ r.setGroup(url.getParameter(Constants.GROUP_KEY, (String)null));
+ r.setVersion(url.getParameter(Constants.VERSION_KEY, (String)null));
r.setRule(url.getParameterAndDecoded(Constants.RULE_KEY));
return r;
}
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 a3240b1..f6a0b2e 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
@@ -219,7 +219,7 @@ public class Route extends Entity {
public URL toUrl() {
return URL.valueOf(Constants.ROUTE_PROTOCOL + "://" +
Constants.ANYHOST_VALUE + "/" + getService()
+ "?" + Constants.CATEGORY_KEY + "=" +
Constants.ROUTERS_CATEGORY
- + "&router=condition&runtime=false&enabled=" + isEnabled() +
"&priority=" + getPriority() + "&force=" + isForce() + "&dynamic=" + isDynamic()
+ + "&router=condition&runtime=" + isRuntime() + "&enabled=" +
isEnabled() + "&priority=" + getPriority() + "&force=" + isForce() +
"&dynamic=" + isDynamic()
+ "&name=" + getName() + "&" + Constants.RULE_KEY + "=" +
URL.encode(getRule())
+ (getGroup() == null ? "" : "&" + Constants.GROUP_KEY + "=" +
getGroup())
+ (getVersion() == null ? "" : "&" + Constants.VERSION_KEY +
"=" + getVersion()));
diff --git a/dubbo-admin-frontend/index.html b/dubbo-admin-frontend/index.html
index 29fd150..cb8b275 100644
--- a/dubbo-admin-frontend/index.html
+++ b/dubbo-admin-frontend/index.html
@@ -20,8 +20,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
- <title>Dubbo ops</title>
+ <title>Dubbo OPS</title>
<link
href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons'
rel="stylesheet">
+ <link rel="shortcut icon" href="/static/dubbo.ico" type="image/x-icon">
</head>
<body>
<div id="app"></div>
diff --git a/dubbo-admin-frontend/src/components/RoutingRule.vue
b/dubbo-admin-frontend/src/components/RoutingRule.vue
index c5f6ddd..5874d40 100644
--- a/dubbo-admin-frontend/src/components/RoutingRule.vue
+++ b/dubbo-admin-frontend/src/components/RoutingRule.vue
@@ -110,8 +110,8 @@
<v-card-text >{{this.warnText}}</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
- <v-btn color="green darken-1" flat @click.native="warn =
false">Disagree</v-btn>
- <v-btn color="green darken-1" flat
@click.native="deleteItem(warnStatus)">Agree</v-btn>
+ <v-btn color="green darken-1" flat
@click.native="closeWarn">CANCLE</v-btn>
+ <v-btn color="green darken-1" flat
@click.native="deleteItem(warnStatus)">CONFIRM</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
@@ -134,6 +134,7 @@
},
data: () => ({
dropdown_font: [ 'Service', 'App', 'IP' ],
+ ruleKeys: ['service', 'enabled', 'force', 'dynamic', 'runtime', 'group',
'version', 'rule', 'priority'],
pattern: 'Service',
filter: '',
dialog: false,
@@ -181,20 +182,11 @@
}}
],
routingRules: [
- {
- id: 0,
- rule: 'test',
- service: 'com.alibaba.dubbo.com',
- priority: 0,
- status: 'enabled'
- }
],
- template: '%yaml 1.2\n' +
- '---\n' +
+ template:
'enable: true/false\n' +
'priority:\n' +
'runtime: false/true\n' +
- 'category: routers\n' +
'force: true/false\n' +
'dynamic: true/false\n' +
'conditions:\n' +
@@ -253,24 +245,60 @@
}
})
},
-
+ handleRule: function (route) {
+ let result = {}
+ let conditions = []
+ for (let property in route) {
+ if (this.ruleKeys.includes(property)) {
+ if (property === 'rule') {
+ conditions.push(route[property])
+ } else {
+ result[property] = route[property]
+ }
+ }
+ }
+ if (conditions.length > 0) {
+ result['conditions'] = conditions
+ }
+ return yaml.safeDump(result)
+ },
closeDialog: function () {
this.ruleText = this.template
+ this.service = ''
this.dialog = false
this.cmOption.readOnly = false
},
openDialog: function () {
this.dialog = true
},
+ openWarn: function (title, text) {
+ this.warnTitle = title
+ this.warnText = text
+ this.warn = true
+ },
+ closeWarn: function () {
+ this.warnTitle = ''
+ this.warnText = ''
+ this.warn = false
+ },
+ saveItem: function () {
+ let text = this.ruleText.replace(/\n/g, '===')
+ AXIOS.get('/routes/create?serviceName=' + this.service + '&rule=' +
text)
+ .then(response => {
+ if (response.data) {
+ this.search(this.filter, false)
+ }
+ })
+ },
itemOperation: function (icon, item) {
switch (icon) {
case 'visibility':
AXIOS.get('/routes/detail?id=' + item.id)
.then(response => {
let route = response.data
- let result = yaml.safeDump(route)
+ let result = this.handleRule(route)
this.service = route.service
- this.ruleText = route.rule
+ this.ruleText = result
this.cmOption.readOnly = true
this.dialog = true
})
@@ -279,25 +307,22 @@
AXIOS.get('/routes/edit?id=' + item.id)
.then(response => {
let route = response.data
+ let result = this.handleRule(route)
this.service = route.service
- this.ruleText = route.rule
+ this.ruleText = result
this.cmOption.readOnly = false
this.dialog = true
})
break
case 'block':
case 'check_circle_outline':
- this.warnTitle = ' Are you sure to ' + icon + ' Routing Rule'
- this.warnText = 'serviceName: ' + item.service
- this.warn = true
+ this.openWarn(' Are you sure to ' + icon + ' Routing Rule',
'serviceName: ' + item.service)
this.warnStatus.operation = 'block'
this.warnStatus.id = item.id
this.warnStatus.enabled = item.enabled
break
case 'delete':
- this.warnTitle = ' Are you sure to Delete Routing Rule'
- this.warnText = 'serviceName: ' + item.service
- this.warn = true
+ this.openWarn(' Are you sure to Delete Routing Rule',
'serviceName: ' + item.service)
this.warnStatus.operation = 'delete'
this.warnStatus.id = item.id
}
diff --git a/dubbo-admin-frontend/static/dubbo.ico
b/dubbo-admin-frontend/static/dubbo.ico
new file mode 100644
index 0000000..eedaf39
Binary files /dev/null and b/dubbo-admin-frontend/static/dubbo.ico differ