From 7f128b98c73ef140e397edda1f210d38722318c1 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Fri, 18 Jun 2021 11:44:55 +0530 Subject: [PATCH 1/2] ui: Notify vm password on reinstall of VM (for password enabled templates) --- ui/src/views/AutogenView.vue | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index c51487c3b7a5..e1fd3786931b 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -870,6 +870,16 @@ export default { duration: 0 }) } + } else if (result.jobstatus === 1 && action.api === 'restoreVirtualMachine') { + const vm = result.jobresult.virtualmachine + const name = vm.displayname || vm.name || vm.id + if (vm.password) { + this.$notification.success({ + message: `${this.$t('label.reinstall.vm')}: ` + name, + description: `${this.$t('label.password.reset.confirm')}: ` + vm.password, + duration: 0 + }) + } } }, errorMethod: () => this.fetchData(), From 9939551af417640e52e404f9c84be793ba15c12c Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Fri, 18 Jun 2021 15:01:34 +0530 Subject: [PATCH 2/2] refactor --- ui/src/config/section/compute.js | 12 ++++++++++++ ui/src/views/AutogenView.vue | 13 +++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js index 312c0903e392..48e9a10742bd 100644 --- a/ui/src/config/section/compute.js +++ b/ui/src/config/section/compute.js @@ -144,6 +144,18 @@ export default { virtualmachineid: { value: (record) => { return record.id } } + }, + successMethod: (obj, result) => { + console.log('here') + const vm = result.jobresult.virtualmachine || {} + if (result.jobstatus === 1 && vm.password) { + const name = vm.displayname || vm.name || vm.id + obj.$notification.success({ + message: `${obj.$t('label.reinstall.vm')}: ` + name, + description: `${obj.$t('label.password.reset.confirm')}: ` + vm.password, + duration: 0 + }) + } } }, { diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index e1fd3786931b..ebeca6e4ab0c 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -870,16 +870,9 @@ export default { duration: 0 }) } - } else if (result.jobstatus === 1 && action.api === 'restoreVirtualMachine') { - const vm = result.jobresult.virtualmachine - const name = vm.displayname || vm.name || vm.id - if (vm.password) { - this.$notification.success({ - message: `${this.$t('label.reinstall.vm')}: ` + name, - description: `${this.$t('label.password.reset.confirm')}: ` + vm.password, - duration: 0 - }) - } + } + if ('successMethod' in action) { + action.successMethod(this, result) } }, errorMethod: () => this.fetchData(),