Skip to content

Commit

Permalink
UI: support skipGroupAction apache#7965
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Dec 12, 2024
1 parent 43f4204 commit 98e4746
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 5 deletions.
1 change: 1 addition & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,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",
Expand Down
4 changes: 4 additions & 0 deletions ui/src/components/view/BulkActionProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</template>
<a-card :bordered="false" style="background:#f1f1f1">
<div><check-circle-outlined style="color: #52c41a; margin-right: 8px"/> {{ $t('label.success') + ': ' + succeededCount }}</div>
<div><check-circle-outlined style="color: #6e6e6e; margin-right: 8px"/> {{ $t('label.skipped') + ': ' + skippedCount }}</div>
<div><close-circle-outlined style="color: #f5222d; margin-right: 8px"/> {{ $t('state.failed') + ': ' + failedCount }}</div>
<div><sync-outlined style="color: #1890ff; margin-right: 8px"/> {{ $t('state.inprogress') + ': ' + selectedItems.filter(item => item.status === 'InProgress').length || 0 }}</div>
</a-card>
Expand Down Expand Up @@ -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
}
Expand Down
33 changes: 30 additions & 3 deletions ui/src/config/section/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,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']
Expand All @@ -140,7 +149,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: (record, store, group) => {
return (['Admin'].includes(store.userInfo.roletype) || store.features.allowuserforcestopvm)
? ['forced'] : []
Expand Down Expand Up @@ -168,7 +186,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',
Expand Down
11 changes: 10 additions & 1 deletion ui/src/config/section/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,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'
}
})
}
}
]
},
Expand Down
10 changes: 9 additions & 1 deletion ui/src/views/AutogenView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,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)
})
Expand Down Expand Up @@ -1432,6 +1432,7 @@ export default {
filters: [
{ text: 'In Progress', value: 'InProgress' },
{ text: 'Success', value: 'success' },
{ text: 'Skipped', value: 'skipped' },
{ text: 'Failed', value: 'failed' }
]
})
Expand Down Expand Up @@ -1470,6 +1471,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))
Expand Down

0 comments on commit 98e4746

Please sign in to comment.