提交 bca94f87 编写于 作者: B beiwei30

Merge branch 'develop' of https://github.com/apache/incubator-dubbo-ops into develop

......@@ -106,15 +106,13 @@ public class RoutesController {
return route;
}
@RequestMapping("/enable")
public boolean enableRoute(@RequestParam long id) {
routeService.enableRoute(id);
return true;
}
@RequestMapping("/disable")
public boolean disableRoute(@RequestParam long id) {
routeService.disableRoute(id);
@RequestMapping("/changeStatus")
public boolean enableRoute(@RequestParam long id, @RequestParam boolean enabled) {
if (enabled) {
routeService.disableRoute(id);
} else {
routeService.enableRoute(id);
}
return true;
}
......
......@@ -57,7 +57,7 @@ public class ServiceController {
List<Provider> allProviders = providerService.findAll();
List<ServiceDO> result = new ArrayList<>();
if (pattern.equals("App")) {
if (pattern.equals("application")) {
for (Provider provider : allProviders) {
Map<String, String> map = StringUtils.parseQueryString(provider.getParameters());
String app = map.get(Constants.APPLICATION_KEY);
......@@ -71,7 +71,7 @@ public class ServiceController {
}
}
} else if (pattern.equals("Service")) {
} else if (pattern.equals("service name")) {
for (Provider provider : allProviders) {
String service = provider.getService();
Map<String, String> map = StringUtils.parseQueryString(provider.getParameters());
......@@ -85,7 +85,7 @@ public class ServiceController {
}
}
} else if (pattern.equals("Ip")) {
} else if (pattern.equals("IP")) {
for (Provider provider : allProviders) {
String address = provider.getAddress();
Map<String, String> map = StringUtils.parseQueryString(provider.getParameters());
......
......@@ -52,16 +52,16 @@
class="elevation-0"
>
<template slot="items" slot-scope="props">
<td>{{ props.item.rule }}</td>
<td class="text-xs-left">{{ props.item.service }}</td>
<td class="text-xs-left">{{ props.item.group }}</td>
<td class="text-xs-left">{{ props.item.priority }}</td>
<td class="text-xs-left">{{ props.item.status }}</td>
<td class="text-xs-left">{{ props.item.enabled }}</td>
<td class="justify-center px-0">
<v-tooltip bottom v-for="op in operations" :key="op.callback">
<v-icon small class="mr-2" slot="activator" @click="op.callback">
<v-tooltip bottom v-for="op in operations" :key="op.id">
<v-icon small class="mr-2" slot="activator" @click="itemOperation(op.icon, props.item)">
{{op.icon}}
</v-icon>
<span>{{op.tooltip}}</span>
<span>{{op.tooltip(props.item)}}</span>
</v-tooltip>
</td>
</template>
......@@ -70,7 +70,7 @@
</v-card>
</v-flex>
<v-dialog v-model="dialog" full-width persistent>
<v-dialog v-model="dialog" width="800px" persistent >
<v-card>
<v-card-title class="justify-center">
<span class="headline">Create New Routing Rule</span>
......@@ -94,6 +94,8 @@
:value="code"
:options="cmOption">
</codemirror>
<codemirror v-model='ruleText' :placeholder='placeholder' :options="cmOption"></codemirror>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
......@@ -102,6 +104,17 @@
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="warn" persistent max-width="500px">
<v-card>
<v-card-title class="headline">{{this.warnTitle}}</v-card-title>
<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(currentId)">Agree</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-container>
</template>
......@@ -112,6 +125,7 @@
import 'codemirror/mode/yaml/yaml.js'
import 'codemirror/addon/display/autorefresh.js'
import 'codemirror/addon/display/placeholder'
import {AXIOS} from './http-common'
export default {
components: {
codemirror
......@@ -121,13 +135,38 @@
pattern: 'Service',
filter: '',
dialog: false,
warn: false,
application: '',
service: '',
ruleText: '',
warnTitle: '',
warnText: '',
currentId: 0,
height: 0,
operations: [
{icon: 'visibility', callback: 'viewItem(props.item)', tooltip: 'View'},
{icon: 'edit', callback: 'editItem(props.item)', tooltip: 'Edit'},
{icon: 'delete', callback: 'deleteItem(props.item)', tooltip: 'Delete'}
{id: 0,
icon: 'visibility',
tooltip: function (item) {
return 'View'
}},
{id: 1,
icon: 'edit',
tooltip: function (item) {
return 'Edit'
}},
{id: 2,
icon: 'block',
tooltip: function (item) {
if (item.enabled === true) {
return 'Disable'
}
return 'Enable'
}},
{id: 3,
icon: 'delete',
tooltip: function (item) {
return 'Delete'
}}
],
routingRules: [
{
......@@ -160,14 +199,15 @@
},
headers: [
{
text: 'Rule Name',
value: 'rule',
text: 'Service Name',
value: 'service',
align: 'left'
},
{
text: 'Service Name',
value: 'service',
text: 'Group',
value: 'group',
align: 'left'
},
{
text: 'Priority',
......@@ -175,8 +215,8 @@
sortable: false
},
{
text: 'Status',
value: 'status',
text: 'Enabled',
value: 'enabled',
sortable: false
},
{
......@@ -188,19 +228,61 @@
}),
methods: {
submit: function () {
console.log('submit')
this.search(this.filter, true)
},
search: function (filter, rewrite) {
AXIOS.get('/routes/all?serviceName=' + filter)
.then(response => {
this.routingRules = response.data
if (rewrite) {
this.$router.push({path: 'routingRule', query: {serviceName: filter}})
}
})
},
openDialog: function () {
this.dialog = true
},
enable: function (status) {
if (status === 'enabled') {
return 'disable'
itemOperation: function (icon, item) {
switch (icon) {
case 'visibility':
AXIOS.get('/routes/detail?id=' + item.id)
.then(response => {
let route = response.data
this.service = route.service
this.ruleText = route.rule
this.cmOption.readOnly = true
this.dialog = true
})
break
case 'edit':
AXIOS.get('/routes/edit?id=' + item.id)
.then(response => {
console.log('edit')
this.dialog = true
})
break
case 'block':
AXIOS.get('/routes/changeStatus?id=' + item.id)
.then(response => {
this.dialog = true
})
break
case 'delete':
this.warnTitle = ' Are you sure to Delete Routing Rule'
this.warnText = 'serviceName: ' + item.service
this.warn = true
this.currentId = item.id
}
return 'enable'
},
setHeight: function () {
this.height = window.innerHeight * 0.5
},
deleteItem: function (id) {
AXIOS.get('/routes/delete?id=' + id)
.then(response => {
this.warn = false
})
}
},
computed: {
......@@ -210,6 +292,19 @@
},
created () {
this.setHeight()
},
mounted: function () {
let query = this.$route.query
let service = ''
Object.keys(query).forEach(function (key) {
if (key === 'serviceName') {
service = query[key]
}
})
if (service !== '') {
this.filter = service
this.search(service, false)
}
}
}
......
......@@ -166,6 +166,14 @@
}
})
if (filter !== '' && pattern !== '') {
this.filter = filter
if (pattern === 'service name') {
this.selected = 0
} else if (pattern === 'application') {
this.selected = 2
} else if (pattern === 'IP') {
this.selected = 1
}
this.search(filter, pattern, false)
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册