|
93 | 93 | <a-table |
94 | 94 | class="table" |
95 | 95 | size="small" |
96 | | - :columns="this.vmColumns" |
97 | | - :dataSource="this.virtualmachines" |
| 96 | + :columns="vmColumns" |
| 97 | + :dataSource="virtualmachines" |
98 | 98 | :rowKey="item => item.id" |
99 | 99 | :pagination="false" |
100 | 100 | > |
|
104 | 104 | <template slot="state" slot-scope="text"> |
105 | 105 | <status :text="text ? text : ''" displayText /> |
106 | 106 | </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> |
107 | 127 | </a-table> |
108 | 128 | </a-tab-pane> |
109 | 129 | <a-tab-pane :tab="$t('label.firewall')" key="firewall"> |
@@ -138,6 +158,7 @@ export default { |
138 | 158 | Status |
139 | 159 | }, |
140 | 160 | mixins: [mixinDevice], |
| 161 | + inject: ['parentFetchData'], |
141 | 162 | props: { |
142 | 163 | resource: { |
143 | 164 | type: Object, |
@@ -189,6 +210,11 @@ export default { |
189 | 210 | { |
190 | 211 | title: this.$t('label.zonename'), |
191 | 212 | dataIndex: 'zonename' |
| 213 | + }, |
| 214 | + { |
| 215 | + title: this.$t('label.action'), |
| 216 | + dataIndex: 'action', |
| 217 | + scopedSlots: { customRender: 'action' } |
192 | 218 | } |
193 | 219 | ] |
194 | 220 | if (!this.isAdmin()) { |
@@ -284,7 +310,7 @@ export default { |
284 | 310 | }, |
285 | 311 | fetchInstances () { |
286 | 312 | this.instanceLoading = true |
287 | | - this.virtualmachines = this.resource.virtualmachines |
| 313 | + this.virtualmachines = this.resource.virtualmachines || [] |
288 | 314 | this.virtualmachines.map(vm => { |
289 | 315 | if (vm.nic && vm.nic.length > 0 && vm.nic[0].ipaddress) { |
290 | 316 | vm.ipaddress = vm.nic[0].ipaddress |
@@ -331,6 +357,35 @@ export default { |
331 | 357 | elem.click() |
332 | 358 | document.body.removeChild(elem) |
333 | 359 | } |
| 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 | + }) |
334 | 389 | } |
335 | 390 | } |
336 | 391 | } |
|
0 commit comments