fix: 集群列表查询/删除
parent
4db64f287b
commit
1254045093
|
@ -2501,26 +2501,42 @@ export function policyColor(value) {
|
|||
return obj[value] || 'danger'
|
||||
}
|
||||
|
||||
export function tceClusterColor(value) {
|
||||
export function ctstackClusterColor(value) {
|
||||
const obj = {
|
||||
Running: 'success',
|
||||
Creating: 'warning',
|
||||
Abnormal: 'danger',
|
||||
Failed: 'danger',
|
||||
Initializing: 'warning',
|
||||
enabled: 'success',
|
||||
disabled: 'danger'
|
||||
normal: 'success',
|
||||
creating: 'warning',
|
||||
create_fail: 'danger',
|
||||
adjust: 'warning',
|
||||
updating: 'warning',
|
||||
suspend: 'warning',
|
||||
deleting: 'warning',
|
||||
deleted: 'success',
|
||||
delete_fail: 'danger',
|
||||
resetting: 'warning',
|
||||
resettled: 'success',
|
||||
reset_fail: 'danger',
|
||||
upgrading: 'warning',
|
||||
upgrade_fail: 'danger'
|
||||
}
|
||||
return obj[value]
|
||||
}
|
||||
|
||||
export function tceClusterText(value) {
|
||||
export function ctstackClusterText(value) {
|
||||
const obj = {
|
||||
Running: '运行中',
|
||||
Creating: '创建中',
|
||||
Abnormal: '异常',
|
||||
Failed: '失败',
|
||||
Initializing: '创建中'
|
||||
normal: '正常',
|
||||
creating: '创建中',
|
||||
create_fail: '创建失败',
|
||||
adjust: '规模调整中',
|
||||
updating: '升级中',
|
||||
suspend: '暂停',
|
||||
deleting: '删除中',
|
||||
deleted: '已删除',
|
||||
delete_fail: '删除失败',
|
||||
resetting: '节点重置中',
|
||||
resettled: '节点已重置',
|
||||
reset_fail: '节点重置失败',
|
||||
upgrading: '集群升级中',
|
||||
upgrade_fail: '集群升级失败'
|
||||
}
|
||||
return obj[value]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div>
|
||||
<cb-advance-table @cell-click="handleCellClick" :data="clusterTableData" :params="params" :columns="Clustercolumns" :get-list="getClusterData" :total="total" :loading="loading">
|
||||
<cb-advance-table :data="clusterTableData" :params="params" :columns="Clustercolumns" :get-list="getClusterData" :total="total" :loading="loading" :search-configs="searchConfigs">
|
||||
<template v-slot:action>
|
||||
<el-button type="primary" @click="addCluster()"> 新增 </el-button>
|
||||
</template>
|
||||
|
@ -9,7 +9,7 @@
|
|||
<span v-else>{{ val }}</span>
|
||||
</template>
|
||||
<template #clusterStatus="val">
|
||||
<cb-status-icon :type="val | tceClusterColor" v-if="val && val.toLowerCase() != 'stopped'">{{ val | tceClusterText }}</cb-status-icon>
|
||||
<cb-status-icon :type="val | ctstackClusterColor" v-if="val && val.toLowerCase() != 'stopped'">{{ val | ctstackClusterText }}</cb-status-icon>
|
||||
</template>
|
||||
<template #clusterOs="val">
|
||||
{{ val ? val : 'ubuntu16.04.1 LTSx86_64' }}
|
||||
|
@ -26,29 +26,23 @@
|
|||
</template>
|
||||
</cb-advance-table>
|
||||
<detail v-if="detaildialogVisible" :detail="detail" @back="detaildialogVisible = false" :platform-object="platformObject"></detail>
|
||||
<bind :add-data="bindData" v-if="bindData.dialog"></bind>
|
||||
<service ref="serviceTable" v-if="serviceVisible" :vendorId="platformObject.vendorId" :clusterInfo="clusterInfo" @close="closeService"></service>
|
||||
<modify-cluster :add-data="modifyClusterData" :vendor-id="platformObject.vendorId" v-if="modifyClusterData.dialog"></modify-cluster>
|
||||
<delete-cluster :data="deleteClusterData" :vendor-id="platformObject.vendorId" v-if="deleteClusterData.dialog" :clusterInfo="clusterInfo"></delete-cluster>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 整个 container 都是从 TCE 复制过来, 有不需要的暂时不删除
|
||||
import bind from './bind.vue'
|
||||
import { getClusterList } from 'views/resource/ctstack/services/tke.js'
|
||||
// 整个 container 都是从 TCE 复制过来, 有用不到的
|
||||
import { getClusterList, deleteCluster } from 'views/resource/ctstack/services/tke.js'
|
||||
import { removeFloatIp, detailFloatIp } from 'views/resource/ctstack/services/floatips.js'
|
||||
import { getRegion } from 'views/resource/ctstack/services/regions.js'
|
||||
import service from './service/index.vue'
|
||||
import modifyCluster from './modifyCluster.vue'
|
||||
import deleteCluster from './deleteCluster.vue'
|
||||
import webSocket from '@cmp/cmp-common/mixins/getGlobalSocket'
|
||||
import detail from './detail.vue'
|
||||
import AssignTenant from 'views/platform/assign/index.vue'
|
||||
const Clustercolumns = [
|
||||
{
|
||||
label: 'ID',
|
||||
prop: 'clusterId',
|
||||
prop: 'clusterUuid',
|
||||
disabled: true,
|
||||
scopedSlots: { customRender: 'name' }
|
||||
},
|
||||
|
@ -56,30 +50,39 @@ const Clustercolumns = [
|
|||
label: '名称',
|
||||
prop: 'name'
|
||||
},
|
||||
{
|
||||
label: '部署模式',
|
||||
prop: 'clusterSpec'
|
||||
},
|
||||
{
|
||||
label: '集群版本',
|
||||
prop: 'version'
|
||||
},
|
||||
{
|
||||
label: 'Service IP 地址范围',
|
||||
prop: 'serviceCidr'
|
||||
},
|
||||
{
|
||||
label: 'Pod IP地址范围',
|
||||
prop: 'nodeCidr'
|
||||
},
|
||||
{
|
||||
label: '资源池ID',
|
||||
prop: 'resourceGroupUuid'
|
||||
},
|
||||
{
|
||||
label: '弹性ip',
|
||||
prop: 'eipUuid'
|
||||
},
|
||||
{
|
||||
label: 'VPC',
|
||||
prop: 'vpcUuid'
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
prop: 'clusterStatus',
|
||||
scopedSlots: { customRender: 'clusterStatus' }
|
||||
},
|
||||
{
|
||||
label: '版本',
|
||||
prop: 'clusterVersion',
|
||||
scopedSlots: { customRender: 'clusterVersion' }
|
||||
},
|
||||
{
|
||||
label: '类型',
|
||||
prop: 'clusterType',
|
||||
customRender(val) {
|
||||
const map = {
|
||||
INDEPENDENT_CLUSTER: '独立集群'
|
||||
}
|
||||
return map[val] || val
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '节点数量',
|
||||
prop: 'clusterNodeNum'
|
||||
},
|
||||
{
|
||||
label: '所属租户',
|
||||
prop: 'tenantName'
|
||||
|
@ -88,11 +91,6 @@ const Clustercolumns = [
|
|||
label: '描述',
|
||||
prop: 'clusterDescription'
|
||||
},
|
||||
{
|
||||
label: '系统',
|
||||
prop: 'clusterOs',
|
||||
scopedSlots: { customRender: 'clusterOs' }
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'gmtCreate'
|
||||
|
@ -106,10 +104,7 @@ const Clustercolumns = [
|
|||
export default {
|
||||
mixins: [webSocket],
|
||||
components: {
|
||||
bind,
|
||||
service,
|
||||
modifyCluster,
|
||||
deleteCluster,
|
||||
detail,
|
||||
AssignTenant
|
||||
},
|
||||
|
@ -125,14 +120,8 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
clusterInfo: {},
|
||||
instanceVisible: false,
|
||||
secrectVisible: false,
|
||||
serviceVisible: false,
|
||||
flexibleVisible: false,
|
||||
Clustercolumns,
|
||||
clusterTableData: [],
|
||||
activeName: 'first', // 从这里开始
|
||||
loading: false,
|
||||
detaildialogVisible: false,
|
||||
detail: {},
|
||||
|
@ -141,25 +130,24 @@ export default {
|
|||
rows: 10
|
||||
},
|
||||
total: 0,
|
||||
addData: {
|
||||
dialog: false,
|
||||
data: {}
|
||||
},
|
||||
regionList: [],
|
||||
bindData: {
|
||||
dialog: false,
|
||||
data: {}
|
||||
},
|
||||
modifyClusterData: {
|
||||
dialog: false,
|
||||
data: {}
|
||||
},
|
||||
deleteClusterData: {
|
||||
dialog: false,
|
||||
data: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
platformObject: {
|
||||
handler(newVal, oldVal) {
|
||||
this.searchConfigs = [
|
||||
{ type: 'Input', label: '名称', value: 'name' },
|
||||
{ type: 'Select', label: '所属地域', data: [], value: 'regionId', props: { value: 'regionId' } },
|
||||
{ type: 'Const', value: 'vendorId', initValue: this.platformObject.vendorId }
|
||||
]
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onmessage(data) {
|
||||
const arr = ['tke.modify.cluster', 'tke.delete.instance', 'tke.add.instance', 'ctstack.sync', 'ctstack.cluster', 'tke.create.cluster', 'tke.delete.cluster']
|
||||
|
@ -170,9 +158,7 @@ export default {
|
|||
addCluster() {
|
||||
this.$router.push({ name: 'ctstackCreateCluster', query: { vendorId: this.platformObject.vendorId } })
|
||||
},
|
||||
handleCellClick(data) {
|
||||
this.clusterInfo = data
|
||||
},
|
||||
|
||||
edit(row) {
|
||||
this.modifyClusterData = {
|
||||
dialog: true,
|
||||
|
@ -184,21 +170,12 @@ export default {
|
|||
},
|
||||
handleOperate(command) {
|
||||
switch (command.flag) {
|
||||
case 1: // 密钥
|
||||
this.showSecrect(command.row)
|
||||
break
|
||||
case 2: // 服务
|
||||
this.showService(command.row)
|
||||
break
|
||||
case 3: // 删除
|
||||
this.deleteCluster(command.row)
|
||||
break
|
||||
case 4: // 添加已有节点
|
||||
this.addExistInstance(command.row)
|
||||
break
|
||||
case 5: // 伸缩组
|
||||
this.showFlexible(command.row)
|
||||
break
|
||||
case 'node':
|
||||
this.showInstance(command.row)
|
||||
break
|
||||
|
@ -206,46 +183,23 @@ export default {
|
|||
}
|
||||
},
|
||||
deleteCluster(row) {
|
||||
this.clusterInfo = row
|
||||
this.deleteClusterData = {
|
||||
dialog: true,
|
||||
mode: false,
|
||||
data: row
|
||||
this.$confirm('确定删除集群?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
deleteCluster(row).then(data => {
|
||||
if (data.success) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: data.message
|
||||
})
|
||||
this.getClusterData()
|
||||
}
|
||||
},
|
||||
closeService() {
|
||||
this.serviceVisible = false
|
||||
},
|
||||
showService(row) {
|
||||
this.serviceVisible = true
|
||||
this.clusterInfo = row
|
||||
},
|
||||
closeSecrect() {
|
||||
this.secrectVisible = false
|
||||
},
|
||||
showSecrect(row) {
|
||||
this.secrectVisible = true
|
||||
this.clusterInfo = row
|
||||
},
|
||||
showFlexible(row) {
|
||||
this.flexibleVisible = true
|
||||
this.clusterInfo = row
|
||||
},
|
||||
closeInstance() {
|
||||
this.instanceVisible = false
|
||||
},
|
||||
closeFlexible() {
|
||||
this.flexibleVisible = false
|
||||
},
|
||||
showInstance(row) {
|
||||
this.instanceVisible = true
|
||||
this.clusterInfo = row
|
||||
})
|
||||
})
|
||||
},
|
||||
getClusterData() {
|
||||
// if (this.instanceVisible) {
|
||||
// this.$refs.instanceTable.getData()
|
||||
// return
|
||||
// }
|
||||
this.loading = true
|
||||
this.clusterTableData = []
|
||||
this.total = 0
|
||||
|
@ -277,36 +231,14 @@ export default {
|
|||
this.detaildialogVisible = true
|
||||
this.detail = row
|
||||
},
|
||||
add() {
|
||||
this.addData = {
|
||||
dialog: true,
|
||||
data: {
|
||||
vendorId: this.platformObject.vendorId
|
||||
}
|
||||
}
|
||||
},
|
||||
// 获取域
|
||||
getRegion() {
|
||||
getRegion({ vendorId: this.platformObject.vendorId }).then(data => {
|
||||
if (data.success) {
|
||||
this.regionList = data.data
|
||||
this.searchConfigs[1].data = data.data
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.$router.currentRoute.params.formCreateInstance) {
|
||||
this.showInstance(this.$router.currentRoute.params.clusterInfo)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
platformObject: {
|
||||
handler(newVal, oldVal) {
|
||||
this.getClusterData()
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -64,8 +64,8 @@
|
|||
</template>
|
||||
<script>
|
||||
import instance from './instance/index.vue'
|
||||
import key from './secrect/index'
|
||||
import flexible from './flexible/index'
|
||||
import key from './secrect/index.vue'
|
||||
import flexible from './flexible/index.vue'
|
||||
import region from './region/index.vue'
|
||||
export default {
|
||||
components: { instance, key, flexible, region },
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<cb-detail :title="clusterInfo.name + ' 服务'" @goBack="goBack">
|
||||
<template v-slot:item_container>
|
||||
<cb-advance-table :data="tableData" :params="params" :columns="columns" :get-list="getData" :total="total" :loading="loading">
|
||||
<template v-slot:action> </template>
|
||||
<template #instanceState="val">
|
||||
<cb-status-icon :type="val | tceInstanceColor">{{ val | tceInstanceText }}</cb-status-icon>
|
||||
</template>
|
||||
<template #operate="val, record">
|
||||
<div class="action-divider"></div>
|
||||
<el-button type="text" @click="remove(record.id)" :disabled="record.status === 'BIND'"> 删除 </el-button>
|
||||
<div class="action-divider"></div>
|
||||
</template>
|
||||
</cb-advance-table>
|
||||
</template>
|
||||
</cb-detail>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getServiceList } from 'views/resource/ctstack/services/tke.js'
|
||||
const columns = [
|
||||
{
|
||||
label: '名称',
|
||||
prop: 'serviceName'
|
||||
},
|
||||
{
|
||||
label: '类型',
|
||||
prop: 'type'
|
||||
},
|
||||
{
|
||||
label: 'ip',
|
||||
prop: 'ipAddress'
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'createTime'
|
||||
}
|
||||
]
|
||||
export default {
|
||||
props: ['vendorId', 'clusterInfo'],
|
||||
name: '',
|
||||
data() {
|
||||
return {
|
||||
searchConfigs: [{ type: 'Input', label: '名称', value: 'serviceName' }],
|
||||
searchData: {
|
||||
serviceName: ''
|
||||
},
|
||||
columns,
|
||||
params: {
|
||||
page: 1,
|
||||
rows: 10
|
||||
},
|
||||
total: 0,
|
||||
tableData: [],
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goBack() {
|
||||
this.$emit('close')
|
||||
},
|
||||
getData() {
|
||||
const params = {
|
||||
page: this.params.page,
|
||||
rows: this.params.rows,
|
||||
params: JSON.stringify([{ param: { vendorId: this.vendorId, clusterId: this.clusterInfo.clusterId }, sign: 'EQ' }])
|
||||
}
|
||||
getServiceList(params)
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
this.tableData = data.data.rows
|
||||
this.total = data.data.total
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
clusterInfo: {
|
||||
handler(newVal, oldVal) {
|
||||
this.getData()
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -139,12 +139,8 @@ export function modifyInstance({ id, newName }) {
|
|||
}
|
||||
|
||||
// 集群 删除
|
||||
export function deleteCluster(params, mode) {
|
||||
const formData = new FormData()
|
||||
formData.append('mode', mode)
|
||||
return request.delete(`${clusterListUrl}/${params.id}`, {
|
||||
data: formData
|
||||
})
|
||||
export function deleteCluster(params) {
|
||||
return request.delete(`${clusterListUrl}/${params.id}`)
|
||||
}
|
||||
|
||||
// 容器服务 日志列表
|
||||
|
|
Loading…
Reference in New Issue