From 5b20e6f2a87815968aa0413872277454e2b56702 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 3 Aug 2021 00:57:41 +0530 Subject: [PATCH] ui: fix import instance form for recent changes (#5257) * ui: fix import instance form for recent changes 7123269 and 535761b introduced changes that affecting Import Instance form. Custom compute selection was not showing properly. On import error was seen with 'AddAsyncJob'. Signed-off-by: Abhishek Kumar * fix Signed-off-by: Abhishek Kumar * fix Signed-off-by: Abhishek Kumar * revert page refresh Signed-off-by: Abhishek Kumar --- ui/src/views/compute/DeployVM.vue | 8 ++-- .../views/compute/wizard/ComputeSelection.vue | 4 +- .../views/tools/ImportUnmanagedInstance.vue | 42 +++++++++++++++---- ui/src/views/tools/ManageInstances.vue | 8 +--- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/ui/src/views/compute/DeployVM.vue b/ui/src/views/compute/DeployVM.vue index f229d852ea8..670f3201d3e 100644 --- a/ui/src/views/compute/DeployVM.vue +++ b/ui/src/views/compute/DeployVM.vue @@ -802,8 +802,8 @@ export default { diskSelected: {}, diskIOpsMin: 0, diskIOpsMax: 0, - minIOPs: 0, - maxIOPs: 0 + minIops: 0, + maxIops: 0 } }, computed: { @@ -1532,8 +1532,8 @@ export default { deployVmData['details[0].configurationId'] = this.selectedTemplateConfiguration.id } if (this.isCustomizedIOPS) { - deployVmData['details[0].minIops'] = this.minIOPs - deployVmData['details[0].maxIops'] = this.maxIOPs + deployVmData['details[0].minIops'] = this.minIops + deployVmData['details[0].maxIops'] = this.maxIops } // step 4: select disk offering if (!this.template.deployasis && this.template.childtemplates && this.template.childtemplates.length > 0) { diff --git a/ui/src/views/compute/wizard/ComputeSelection.vue b/ui/src/views/compute/wizard/ComputeSelection.vue index 8c47c6e8b93..31bfa7f5e34 100644 --- a/ui/src/views/compute/wizard/ComputeSelection.vue +++ b/ui/src/views/compute/wizard/ComputeSelection.vue @@ -298,8 +298,8 @@ export default { this.$emit('handler-error', true) return } - this.$emit('update-iops-value', 'minIOPs', this.minIOps) - this.$emit('update-iops-value', 'maxIOPs', this.maxIOps) + this.$emit('update-iops-value', 'minIops', this.minIOps) + this.$emit('update-iops-value', 'maxIops', this.maxIOps) this.$emit('handler-error', false) } } diff --git a/ui/src/views/tools/ImportUnmanagedInstance.vue b/ui/src/views/tools/ImportUnmanagedInstance.vue index 499caf4a0d3..cf1a49cb9d8 100644 --- a/ui/src/views/tools/ImportUnmanagedInstance.vue +++ b/ui/src/views/tools/ImportUnmanagedInstance.vue @@ -131,7 +131,9 @@ @handle-search-filter="($event) => fetchComputeOfferings($event)" /> @@ -278,6 +281,8 @@ export default { cpuNumberKey: 'cpuNumber', cpuSpeedKey: 'cpuSpeed', memoryKey: 'memory', + minIopsKey: 'minIops', + maxIopsKey: 'maxIops', switches: {}, loading: false } @@ -296,6 +301,8 @@ export default { this.form.getFieldDecorator(this.cpuNumberKey, { initialValue: undefined, preserve: true }) this.form.getFieldDecorator(this.cpuSpeedKey, { initialValue: undefined, preserve: true }) this.form.getFieldDecorator(this.memoryKey, { initialValue: undefined, preserve: true }) + this.form.getFieldDecorator(this.minIopsKey, { initialValue: undefined, preserve: true }) + this.form.getFieldDecorator(this.maxIopsKey, { initialValue: undefined, preserve: true }) }, computed: { params () { @@ -524,8 +531,6 @@ export default { }) }, updateFieldValue (name, value) { - if (name === this.cpuNumberKey) { - } this.form.setFieldsValue({ [name]: value }) @@ -533,6 +538,10 @@ export default { updateComputeOffering (id) { this.updateFieldValue('computeofferingid', id) this.computeOffering = this.computeOfferings.filter(x => x.id === id)[0] + if (this.computeOffering && !this.computeOffering.iscustomizediops) { + this.updateFieldValue(this.minIopsKey, undefined) + this.updateFieldValue(this.maxIopsKey, undefined) + } }, updateMultiDiskOffering (data) { this.dataDisksOfferingsMapping = data @@ -611,6 +620,25 @@ export default { } } } + if (this.computeOffering.iscustomizediops) { + var iopsDetails = [this.minIopsKey, this.maxIopsKey] + for (var iopsDetail of iopsDetails) { + if (!values[iopsDetail] || values[iopsDetail] < 0) { + this.$notification.error({ + message: this.$t('message.request.failed'), + description: this.$t('message.please.enter.valid.value') + ': ' + this.$t('label.' + iopsDetail.toLowerCase()) + }) + return + } + params['details[0].' + iopsDetail] = values[iopsDetail] + } + if (values[this.minIopsKey] > values[this.maxIopsKey]) { + this.$notification.error({ + message: this.$t('message.request.failed'), + description: this.$t('error.form.message') + }) + } + } var keys = ['hostname', 'domainid', 'projectid', 'account', 'migrateallowed', 'forced'] if (this.templateType !== 'auto') { keys.push('templateid') @@ -663,14 +691,10 @@ export default { const name = this.resource.name api('importUnmanagedInstance', params).then(json => { const jobId = json.importunmanagedinstanceresponse.jobid - this.$store.dispatch('AddAsyncJob', { - title: this.$t('label.import.instance'), - jobid: jobId, - description: name, - status: 'progress' - }) this.$pollJob({ jobId, + title: this.$t('label.import.instance'), + description: name, loadingMessage: `${this.$t('label.import.instance')} ${name} ${this.$t('label.in.progress')}`, catchMessage: this.$t('error.fetching.async.job.result'), successMessage: this.$t('message.success.import.instance') + ' ' + name, diff --git a/ui/src/views/tools/ManageInstances.vue b/ui/src/views/tools/ManageInstances.vue index 6bf33753a8d..36f14796a98 100644 --- a/ui/src/views/tools/ManageInstances.vue +++ b/ui/src/views/tools/ManageInstances.vue @@ -743,14 +743,10 @@ export default { var params = { id: vm.id } api('unmanageVirtualMachine', params).then(json => { const jobId = json.unmanagevirtualmachineresponse.jobid - this.$store.dispatch('AddAsyncJob', { - title: this.$t('label.unmanage.instance'), - jobid: jobId, - description: vm.name, - status: 'progress' - }) this.$pollJob({ jobId, + title: this.$t('label.unmanage.instance'), + description: vm.name, loadingMessage: `${this.$t('label.unmanage.instance')} ${vm.name} ${this.$t('label.in.progress')}`, catchMessage: this.$t('error.fetching.async.job.result'), successMessage: this.$t('message.success.unmanage.instance') + ' ' + vm.name,