From d61b5b360e25a7b620f1dda0fcb9f8018b333a3d Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 23 Jan 2025 10:32:15 +0100 Subject: [PATCH] UI: support skipGroupAction --- ui/public/locales/en.json | 1 + ui/src/components/view/BulkActionProgress.vue | 4 +++ ui/src/config/section/compute.js | 33 +++++++++++++++++-- ui/src/config/section/network.js | 11 ++++++- ui/src/views/AutogenView.vue | 10 +++++- 5 files changed, 54 insertions(+), 5 deletions(-) diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index 8cc17bbb1286..5a57d316cea3 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -1929,6 +1929,7 @@ "label.site.to.site.vpn.connections": "Site-to-site VPN Connections", "label.size": "Size", "label.sizegb": "Size", +"label.skipped": "Skipped", "label.smb.domain": "SMB domain", "label.smb.password": "SMB password", "label.smb.username": "SMB username", diff --git a/ui/src/components/view/BulkActionProgress.vue b/ui/src/components/view/BulkActionProgress.vue index c4068d001f50..0ad76bb743bd 100644 --- a/ui/src/components/view/BulkActionProgress.vue +++ b/ui/src/components/view/BulkActionProgress.vue @@ -42,6 +42,7 @@
{{ $t('label.success') + ': ' + succeededCount }}
+
{{ $t('label.skipped') + ': ' + skippedCount }}
{{ $t('state.failed') + ': ' + failedCount }}
{{ $t('state.inprogress') + ': ' + selectedItems.filter(item => item.status === 'InProgress').length || 0 }}
@@ -144,6 +145,9 @@ export default { succeededCount () { return this.selectedItems.filter(item => item.status === 'success').length || 0 }, + skippedCount () { + return this.selectedItems.filter(item => item.status === 'skipped').length || 0 + }, failedCount () { return this.selectedItems.filter(item => item.status === 'failed').length || 0 } diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js index 37bccf86758d..5d83cc3c3a37 100644 --- a/ui/src/config/section/compute.js +++ b/ui/src/config/section/compute.js @@ -119,7 +119,16 @@ export default { dataView: true, groupAction: true, popup: true, - groupMap: (selection, values) => { return selection.map(x => { return { id: x, considerlasthost: values.considerlasthost } }) }, + groupMap: (selection, values, record) => { + return selection.map(x => { + const data = record.filter(y => { return y.id === x }) + return { + id: x, + considerlasthost: values.considerlasthost, + skipGroupAction: data[0].state !== 'Stopped' + } + }) + }, args: (record, store) => { if (['Admin'].includes(store.userInfo.roletype)) { return ['considerlasthost'] @@ -138,7 +147,16 @@ export default { docHelp: 'adminguide/virtual_machines.html#stopping-and-starting-vms', dataView: true, groupAction: true, - groupMap: (selection, values) => { return selection.map(x => { return { id: x, forced: values.forced } }) }, + groupMap: (selection, values, record) => { + return selection.map(x => { + const data = record.filter(y => { return y.id === x }) + return { + id: x, + forced: values.forced, + skipGroupAction: data[0].state !== 'Running' + } + }) + }, args: ['forced'], show: (record) => { return ['Running'].includes(record.state) } }, @@ -163,7 +181,16 @@ export default { }, groupAction: true, popup: true, - groupMap: (selection, values) => { return selection.map(x => { return { id: x, forced: values.forced } }) } + groupMap: (selection, values, record) => { + return selection.map(x => { + const data = record.filter(y => { return y.id === x }) + return { + id: x, + forced: values.forced, + skipGroupAction: data[0].state !== 'Running' + } + }) + } }, { api: 'restoreVirtualMachine', diff --git a/ui/src/config/section/network.js b/ui/src/config/section/network.js index 72eb17e0ae97..0b39f8c2eccc 100644 --- a/ui/src/config/section/network.js +++ b/ui/src/config/section/network.js @@ -857,7 +857,16 @@ export default { show: (record) => { return record.state === 'Reserved' }, groupAction: true, popup: true, - groupMap: (selection) => { return selection.map(x => { return { id: x } }) } + groupMap: (selection, values, record) => { + return selection.map(x => { + const data = record.filter(y => { return y.id === x }) + return { + id: x, + forced: values.forced, + skipGroupAction: data[0].state !== 'Reserved' + } + }) + } } ] }, diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index 3471c02d2e4a..323ca5cf0662 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -896,7 +896,7 @@ export default { this.chosenColumns = this.columns.filter(column => { return ![this.$t('label.state'), this.$t('label.hostname'), this.$t('label.hostid'), this.$t('label.zonename'), - this.$t('label.zone'), this.$t('label.zoneid'), this.$t('label.ip'), this.$t('label.ipaddress'), this.$t('label.privateip'), + this.$t('label.zone'), this.$t('label.zoneid'), this.$t('label.ip'), this.$t('label.privateip'), this.$t('label.linklocalip'), this.$t('label.size'), this.$t('label.sizegb'), this.$t('label.current'), this.$t('label.created'), this.$t('label.order')].includes(column.title) }) @@ -1423,6 +1423,7 @@ export default { filters: [ { text: 'In Progress', value: 'InProgress' }, { text: 'Success', value: 'success' }, + { text: 'Skipped', value: 'skipped' }, { text: 'Failed', value: 'failed' } ] }) @@ -1461,6 +1462,13 @@ export default { }, callGroupApi (params, resourceName) { return new Promise((resolve, reject) => { + if (params.skipGroupAction) { + eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: this.getDataIdentifier(params), state: 'skipped' }) + this.actionLoading = false + this.showAction = false + return + } + delete params.skipGroupAction const action = this.currentAction api(action.api, params).then(json => { resolve(this.handleResponse(json, resourceName, this.getDataIdentifier(params), action, false))