新增角色管理,优化服务列表

This commit is contained in:
tanghc
2019-06-30 19:08:48 +08:00
parent 21792d39b1
commit de85e5aef9
25 changed files with 323 additions and 129 deletions

View File

@@ -211,7 +211,7 @@ export default {
methods: {
// 加载树
loadTree: function() {
this.post('service.list', {}, function(resp) {
this.post('zookeeper.service.list', {}, function(resp) {
const respData = resp.data
this.treeData = this.convertToTreeData(respData, 0)
})

View File

@@ -337,7 +337,7 @@ export default {
methods: {
// 加载树
loadTree: function() {
this.post('service.list', {}, function(resp) {
this.post('zookeeper.service.list', {}, function(resp) {
const respData = resp.data
this.treeData = this.convertToTreeData(respData, 0)
})

View File

@@ -15,25 +15,19 @@
row-key="id"
>
<el-table-column
prop="name"
label="服务名称(serviceId)"
prop="serviceId"
label="服务名称"
width="200"
/>
>
<template slot-scope="scope">
<span v-html="renderServiceName(scope.row)"></span>
</template>
</el-table-column>
<el-table-column
prop="instanceId"
label="instanceId"
prop="ipPort"
label="IP端口"
width="250"
/>
<el-table-column
prop="ipAddr"
label="IP地址"
width="150"
/>
<el-table-column
prop="serverPort"
label="端口号"
width="100"
/>
<el-table-column
prop="status"
label="服务状态"
@@ -110,28 +104,30 @@ export default {
this.loadTable()
},
onOffline: function(row) {
this.confirm('确定要下线【' + row.name + '】吗?', function(done) {
const params = {
serviceId: row.name,
instanceId: row.instanceId
}
this.post('service.instance.offline', params, function() {
this.confirm('确定要下线【' + row.serviceId + '】吗?', function(done) {
this.post('service.instance.offline', row, function() {
this.tip('下线成功')
done()
})
})
},
onOnline: function(row) {
this.confirm('确定要上线【' + row.name + '】吗?', function(done) {
const params = {
serviceId: row.name,
instanceId: row.instanceId
}
this.post('service.instance.online', params, function() {
this.confirm('确定要上线【' + row.serviceId + '】吗?', function(done) {
this.post('service.instance.online', row, function() {
this.tip('上线成功')
done()
})
})
},
renderServiceName: function(row) {
let instanceCount = ''
if (row.children && row.children.length > 0) {
const onlineCount = row.children.filter(el => {
return el.status === 'UP'
}).length
instanceCount = ` (${onlineCount}/${row.children.length})`
}
return row.serviceId + instanceCount
}
}
}

View File

@@ -85,12 +85,12 @@
<el-option
v-for="item in serviceData"
:key="item.id"
:label="item.name + '(' + item.ipAddr + ':' + item.serverPort + ')'"
:label="item.serviceId + '(' + item.ipPort + ')'"
:value="item"
:disabled="isOptionDisabled(item)"
>
<span style="float: left">{{ item.name }} <span v-if="isOptionDisabled(item)">(已添加)</span></span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.ipAddr + ':' + item.serverPort }}</span>
<span style="float: left">{{ item.serviceId }} <span v-if="isOptionDisabled(item)">(已添加)</span></span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.ipPort }}</span>
</el-option>
</el-select>
</el-form-item>
@@ -156,7 +156,7 @@ export default {
})
},
isOptionDisabled: function(item) {
const ipPort = item.ipAddr + ':' + item.serverPort
const ipPort = item.ipPort
const index = this.addedInstanceList.findIndex((value, index, arr) => {
return value === ipPort
})
@@ -218,12 +218,7 @@ export default {
this.$refs['logDialogForm'].validate((valid) => {
if (valid) {
const instanceData = this.logDialogFormData.instanceData
const data = {
serviceId: instanceData.serviceId,
ip: instanceData.ipAddr,
port: instanceData.serverPort
}
this.post('monitor.instance.add', data, function(resp) {
this.post('monitor.instance.add', instanceData, function(resp) {
this.logDialogInstanceVisible = false
this.loadTable()
})

View File

@@ -343,7 +343,7 @@ export default {
methods: {
// 加载树
loadTree: function() {
this.post('service.list', {}, function(resp) {
this.post('zookeeper.service.list', {}, function(resp) {
const respData = resp.data
this.treeData = this.convertToTreeData(respData, 0)
this.$nextTick(() => {