支持预发布

This commit is contained in:
tanghc
2019-07-31 20:00:25 +08:00
parent 043b760e03
commit 6125625b87
37 changed files with 484 additions and 78 deletions

View File

@@ -28,16 +28,36 @@
label="IP端口"
width="250"
/>
<el-table-column
prop="metadata"
label="当前环境"
width="100"
>
<template slot-scope="scope">
<el-tag v-if="scope.row.parentId > 0 && scope.row.metadata.env === 'pre'" type="warning">预发布</el-tag>
<el-tag v-if="scope.row.parentId > 0 && scope.row.metadata.env === 'gray'" type="info">灰度</el-tag>
<el-tag v-if="scope.row.parentId > 0 && !scope.row.metadata.env" type="success">线上</el-tag>
</template>
</el-table-column>
<el-table-column
prop="metadata"
label="metadata"
width="250"
>
<template slot-scope="scope">
<span v-if="scope.row.parentId > 0">{{ JSON.stringify(scope.row.metadata) }}</span>
</template>
</el-table-column>
<el-table-column
prop="status"
label="服务状态"
width="100"
>
<template slot-scope="scope">
<el-tag v-if="scope.row.parentId > 0 && scope.row.status === 'UP'" type="success">上线</el-tag>
<el-tag v-if="scope.row.parentId > 0 && scope.row.status === 'UP'" type="success">启用</el-tag>
<el-tag v-if="scope.row.parentId > 0 && scope.row.status === 'STARTING'" type="info">正在启动</el-tag>
<el-tag v-if="scope.row.parentId > 0 && scope.row.status === 'UNKNOWN'">未知</el-tag>
<el-tag v-if="scope.row.parentId > 0 && (scope.row.status === 'OUT_OF_SERVICE' || scope.row.status === 'DOWN')" type="danger">下线</el-tag>
<el-tag v-if="scope.row.parentId > 0 && (scope.row.status === 'OUT_OF_SERVICE' || scope.row.status === 'DOWN')" type="danger">禁用</el-tag>
</template>
</el-table-column>
<el-table-column
@@ -47,11 +67,14 @@
/>
<el-table-column
label="操作"
width="100"
width="200"
>
<template slot-scope="scope">
<el-button v-if="scope.row.parentId > 0 && scope.row.status === 'UP'" type="text" size="mini" @click="onOffline(scope.row)">线</el-button>
<el-button v-if="scope.row.parentId > 0 && scope.row.status === 'OUT_OF_SERVICE'" type="text" size="mini" @click="onOnline(scope.row)">上线</el-button>
<el-button v-if="scope.row.parentId > 0 && scope.row.metadata.env" type="text" size="mini" @click="onEnvOnline(scope.row)">线</el-button>
<el-button v-if="scope.row.parentId > 0 && !scope.row.metadata.env" type="text" size="mini" @click="onEnvPre(scope.row)">预发布</el-button>
<el-button v-if="scope.row.parentId > 0 && !scope.row.metadata.env" type="text" size="mini" @click="onEnvGray(scope.row)">灰度发布</el-button>
<el-button v-if="scope.row.parentId > 0 && scope.row.status === 'UP'" type="text" size="mini" @click="onDisable(scope.row)">禁用</el-button>
<el-button v-if="scope.row.parentId > 0 && scope.row.status === 'OUT_OF_SERVICE'" type="text" size="mini" @click="onEnable(scope.row)">启用</el-button>
</template>
</el-table-column>
</el-table>
@@ -103,22 +126,46 @@ export default {
onSearchTable: function() {
this.loadTable()
},
onOffline: function(row) {
this.confirm('确定要下线【' + row.serviceId + '】吗?', function(done) {
onDisable: function(row) {
this.confirm('确定要禁用【' + row.serviceId + '】吗?', function(done) {
this.post('service.instance.offline', row, function() {
this.tip('下线成功')
done()
})
})
},
onOnline: function(row) {
this.confirm('确定要上线【' + row.serviceId + '】吗?', function(done) {
onEnable: function(row) {
this.confirm('确定要启用【' + row.serviceId + '】吗?', function(done) {
this.post('service.instance.online', row, function() {
this.tip('上线成功')
done()
})
})
},
onEnvOnline: function(row) {
this.confirm('确定要上线【' + row.serviceId + '】吗?', function(done) {
this.post('service.instance.env.online', row, function() {
this.tip('上线成功')
done()
})
})
},
onEnvPre: function(row) {
this.confirm('确定要预发布【' + row.serviceId + '】吗?', function(done) {
this.post('service.instance.env.pre', row, function() {
this.tip('预发布成功')
done()
})
})
},
onEnvGray: function(row) {
this.confirm('确定要灰度发布【' + row.serviceId + '】吗?', function(done) {
this.post('service.instance.env.gray', row, function() {
this.tip('灰度发布发成功')
done()
})
})
},
renderServiceName: function(row) {
let instanceCount = ''
if (row.children && row.children.length > 0) {
@@ -128,6 +175,14 @@ export default {
instanceCount = ` (${onlineCount}/${row.children.length})`
}
return row.serviceId + instanceCount
},
renderMetadata: function(row) {
const metadata = row.metadata
const html = []
for (const key in metadata) {
html.push(key + '=' + metadata[key])
}
return html.join('<br />')
}
}
}