Skip to content
This repository was archived by the owner on Jan 20, 2021. It is now read-only.

Commit 95c7541

Browse files
committed
Adding option to delete nodes
1 parent 23ec4ad commit 95c7541

2 files changed

Lines changed: 62 additions & 3 deletions

File tree

src/locales/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"label.action.delete.network.processing": "Deleting Network....",
114114
"label.action.delete.nexusvswitch": "Delete Nexus 1000v",
115115
"label.action.delete.nic": "Remove NIC",
116+
"label.action.delete.node": "Delete node",
116117
"label.action.delete.physical.network": "Delete physical network",
117118
"label.action.delete.pod": "Delete Pod",
118119
"label.action.delete.pod.processing": "Deleting Pod....",
@@ -2363,6 +2364,7 @@
23632364
"message.action.delete.ingress.rule": "Please confirm that you want to delete this ingress rule.",
23642365
"message.action.delete.iso": "Please confirm that you want to delete this ISO.",
23652366
"message.action.delete.iso.for.all.zones": "The ISO is used by all zones. Please confirm that you want to delete it from all zones.",
2367+
"message.action.delete.node": "Please confirm that you want to delete this node.",
23662368
"message.action.delete.network": "Please confirm that you want to delete this network.",
23672369
"message.action.delete.nexusvswitch": "Please confirm that you want to delete this nexus 1000v",
23682370
"message.action.delete.physical.network": "Please confirm that you want to delete this physical network",
@@ -2647,6 +2649,7 @@
26472649
"message.delete.backup": "Are you sure you want to delete the backup?",
26482650
"message.delete.failed": "Delete fail",
26492651
"message.delete.gateway": "Please confirm you want to delete the gateway",
2652+
"message.deleting.node": "Deleting Node",
26502653
"message.delete.port.forward.processing": "Deleting Port Forwarding rule...",
26512654
"message.delete.project": "Are you sure you want to delete this project?",
26522655
"message.delete.rule.processing": "Deleting rule...",
@@ -3096,6 +3099,7 @@
30963099
"message.success.delete": "Delete success",
30973100
"message.success.delete.acl.rule": "Successfully removed ACL rule",
30983101
"message.success.delete.backup.schedule": "Successfully deleted Configure VM backup schedule",
3102+
"message.success.delete.node": "Successfully Deleted Node",
30993103
"message.success.delete.snapshot.policy": "Successfully deleted snapshot policy",
31003104
"message.success.delete.static.route": "Successfully deleted static route",
31013105
"message.success.delete.tag": "Successfully deleted tag",

src/views/compute/KubernetesServiceTab.vue

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
<a-table
9494
class="table"
9595
size="small"
96-
:columns="this.vmColumns"
97-
:dataSource="this.virtualmachines"
96+
:columns="vmColumns"
97+
:dataSource="virtualmachines"
9898
:rowKey="item => item.id"
9999
:pagination="false"
100100
>
@@ -104,6 +104,26 @@
104104
<template slot="state" slot-scope="text">
105105
<status :text="text ? text : ''" displayText />
106106
</template>
107+
<template slot="action" slot-scope="text, record">
108+
<a-tooltip placement="bottom" >
109+
<template slot="title">
110+
{{ $t('label.action.delete.node') }}
111+
</template>
112+
<a-popconfirm
113+
:title="$t('message.action.delete.node')"
114+
@confirm="deleteNode(record)"
115+
:okText="$t('label.yes')"
116+
:cancelText="$t('label.no')"
117+
:disabled="!['Created', 'Running'].includes(resource.state)"
118+
>
119+
<a-button
120+
type="danger"
121+
icon="delete"
122+
shape="circle"
123+
:disabled="!['Created', 'Running'].includes(resource.state)" />
124+
</a-popconfirm>
125+
</a-tooltip>
126+
</template>
107127
</a-table>
108128
</a-tab-pane>
109129
<a-tab-pane :tab="$t('label.firewall')" key="firewall" v-if="publicIpAddress">
@@ -138,6 +158,7 @@ export default {
138158
Status
139159
},
140160
mixins: [mixinDevice],
161+
inject: ['parentFetchData'],
141162
props: {
142163
resource: {
143164
type: Object,
@@ -189,6 +210,11 @@ export default {
189210
{
190211
title: this.$t('label.zonename'),
191212
dataIndex: 'zonename'
213+
},
214+
{
215+
title: this.$t('label.action'),
216+
dataIndex: 'action',
217+
scopedSlots: { customRender: 'action' }
192218
}
193219
]
194220
if (!this.isAdmin()) {
@@ -284,7 +310,7 @@ export default {
284310
},
285311
fetchInstances () {
286312
this.instanceLoading = true
287-
this.virtualmachines = this.resource.virtualmachines
313+
this.virtualmachines = this.resource.virtualmachines || []
288314
this.virtualmachines.map(vm => {
289315
if (vm.nic && vm.nic.length > 0 && vm.nic[0].ipaddress) {
290316
vm.ipaddress = vm.nic[0].ipaddress
@@ -332,6 +358,35 @@ export default {
332358
elem.click()
333359
document.body.removeChild(elem)
334360
}
361+
},
362+
deleteNode (node) {
363+
const params = {
364+
id: this.resource.id,
365+
nodeids: node.id
366+
}
367+
api('scaleKubernetesCluster', params).then(json => {
368+
const jobId = json.scalekubernetesclusterresponse.jobid
369+
console.log(jobId)
370+
this.$store.dispatch('AddAsyncJob', {
371+
title: this.$t('label.action.delete.node'),
372+
jobid: jobId,
373+
description: node.name,
374+
status: 'progress'
375+
})
376+
this.$pollJob({
377+
jobId,
378+
loadingMessage: `${this.$t('message.deleting.node')} ${node.name}`,
379+
catchMessage: this.$t('error.fetching.async.job.result'),
380+
successMessage: `${this.$t('message.success.delete.node')} ${node.name}`,
381+
successMethod: () => {
382+
this.parentFetchData()
383+
}
384+
})
385+
}).catch(error => {
386+
this.$notifyError(error)
387+
}).finally(() => {
388+
this.parentFetchData()
389+
})
335390
}
336391
}
337392
}

0 commit comments

Comments
 (0)