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

Commit b9c9fae

Browse files
committed
Adding option to delete nodes
1 parent f0ee685 commit b9c9fae

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

src/locales/en.json

Lines changed: 2 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....",
@@ -2360,6 +2361,7 @@
23602361
"message.action.delete.ingress.rule": "Please confirm that you want to delete this ingress rule.",
23612362
"message.action.delete.iso": "Please confirm that you want to delete this ISO.",
23622363
"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.",
2364+
"message.action.delete.node": "Please confirm that you want to delete this node.",
23632365
"message.action.delete.network": "Please confirm that you want to delete this network.",
23642366
"message.action.delete.nexusvswitch": "Please confirm that you want to delete this nexus 1000v",
23652367
"message.action.delete.physical.network": "Please confirm that you want to delete this physical network",

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.id)"
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">
@@ -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
@@ -331,6 +357,35 @@ export default {
331357
elem.click()
332358
document.body.removeChild(elem)
333359
}
360+
},
361+
deleteNode (nodeId) {
362+
const params = {
363+
id: this.resource.id,
364+
nodeids: nodeId
365+
}
366+
api('scaleKubernetesCluster', params).then(json => {
367+
const jobId = json.scalekubernetesclusterresponse.jobid
368+
console.log(jobId)
369+
this.$store.dispatch('AddAsyncJob', {
370+
title: this.$t('label.action.destroy.instance'),
371+
jobid: jobId,
372+
description: this.resource.name,
373+
status: 'progress'
374+
})
375+
this.$pollJob({
376+
jobId,
377+
loadingMessage: `${this.$t('message.deleting.vm')} ${this.resource.name}`,
378+
catchMessage: this.$t('error.fetching.async.job.result'),
379+
successMessage: `${this.$t('message.success.delete.vm')} ${this.resource.name}`,
380+
successMethod: () => {
381+
this.parentFetchData()
382+
}
383+
})
384+
}).catch(error => {
385+
this.$notifyError(error)
386+
}).finally(() => {
387+
this.parentFetchData()
388+
})
334389
}
335390
}
336391
}

0 commit comments

Comments
 (0)