From af87c93e7dad0f54f3d054fc161041c95e758c03 Mon Sep 17 00:00:00 2001 From: davidjumani Date: Thu, 25 Jun 2020 11:44:08 +0000 Subject: [PATCH] compute: Adding custom Vue to change the vm service offering (#413) Fixes #381 Signed-off-by: Rohit Yadav --- ui/src/config/section/compute.js | 15 +- ui/src/views/compute/ScaleVM.vue | 233 ++++++++++++++++++ .../wizard/ComputeOfferingSelection.vue | 3 + .../views/compute/wizard/ComputeSelection.vue | 3 + 4 files changed, 242 insertions(+), 12 deletions(-) create mode 100644 ui/src/views/compute/ScaleVM.vue diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js index a1e727ac12f..053acae87b7 100644 --- a/ui/src/config/section/compute.js +++ b/ui/src/config/section/compute.js @@ -292,21 +292,12 @@ export default { { api: 'scaleVirtualMachine', icon: 'arrows-alt', - // label: label.change.service.offering label: 'Scale VM', docHelp: 'adminguide/virtual_machines.html#how-to-dynamically-scale-cpu-and-ram', dataView: true, - args: ['serviceofferingid', 'details'], - show: (record) => { return ['Running'].includes(record.state) && record.hypervisor !== 'KVM' && record.hypervisor !== 'LXC' } - }, - { - api: 'changeServiceForVirtualMachine', - icon: 'sliders', - label: 'label.change.service.offering', - docHelp: 'adminguide/virtual_machines.html#changing-the-service-offering-for-a-vm', - dataView: true, - args: ['serviceofferingid'], - show: (record) => { return ['Stopped'].includes(record.state) || (['Running'].includes(record.state) && record.hypervisor !== 'KVM' && record.hypervisor !== 'LXC') } + show: (record) => { return ['Stopped'].includes(record.state) || (['Running'].includes(record.state) && record.hypervisor !== 'KVM' && record.hypervisor !== 'LXC') }, + popup: true, + component: () => import('@/views/compute/ScaleVM.vue') }, { api: 'migrateVirtualMachine', diff --git a/ui/src/views/compute/ScaleVM.vue b/ui/src/views/compute/ScaleVM.vue new file mode 100644 index 00000000000..1bff1101479 --- /dev/null +++ b/ui/src/views/compute/ScaleVM.vue @@ -0,0 +1,233 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + + + + + diff --git a/ui/src/views/compute/wizard/ComputeOfferingSelection.vue b/ui/src/views/compute/wizard/ComputeOfferingSelection.vue index 6d72af76f64..432fdb1aa7a 100644 --- a/ui/src/views/compute/wizard/ComputeOfferingSelection.vue +++ b/ui/src/views/compute/wizard/ComputeOfferingSelection.vue @@ -152,6 +152,9 @@ export default { }, loading () { if (!this.loading) { + if (!this.preFillContent) { + return + } if (this.preFillContent.computeofferingid) { this.selectedRowKeys = [this.preFillContent.computeofferingid] this.$emit('select-compute-item', this.preFillContent.computeofferingid) diff --git a/ui/src/views/compute/wizard/ComputeSelection.vue b/ui/src/views/compute/wizard/ComputeSelection.vue index 358099c02b8..c70193f889e 100644 --- a/ui/src/views/compute/wizard/ComputeSelection.vue +++ b/ui/src/views/compute/wizard/ComputeSelection.vue @@ -170,6 +170,9 @@ export default { }, methods: { fillValue () { + if (!this.preFillContent) { + return + } if (this.preFillContent.cpunumber) { this.cpuNumberInputValue = this.preFillContent.cpunumber }