From d6e21f74163212b198731ddf23dd48bc4c787b84 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 3 Dec 2015 11:53:42 +0100 Subject: [PATCH] CLOUDSTACK-9101: add UI support for root volume resize --- ui/scripts/storage.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 77bd00284b1..599802a45ab 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -1536,14 +1536,27 @@ }, createForm: { title: 'label.action.resize.volume', + preFilter: function(args) { + if (args.context.volumes != null && args.context.volumes[0].type == 'ROOT') { + args.$form.find('.form-item[rel=newdiskoffering]').hide(); + } else { + args.$form.find('.form-item[rel=newsize]').hide(); + } + }, fields: { newdiskoffering: { label: 'label.resize.new.offering.id', select: function(args) { + if (args.context.volumes != null && args.context.volumes[0].type == 'ROOT') { + args.response.success({ + data: [] + }); + return; + } + $.ajax({ url: createURL("listDiskOfferings"), dataType: "json", - async: false, success: function(json) { diskofferingObjs = json.listdiskofferingsresponse.diskoffering; var items = []; @@ -1605,8 +1618,7 @@ validation: { required: true, number: true - }, - isHidden: true + } }, shrinkok: { label: 'label.resize.shrink.ok', @@ -1640,7 +1652,7 @@ var newDiskOffering = args.data.newdiskoffering; var newSize; - if (selectedDiskOfferingObj.iscustomized == true) { + if (selectedDiskOfferingObj == null || selectedDiskOfferingObj.iscustomized == true) { newSize = args.data.newsize; } if (newDiskOffering != null && newDiskOffering.length > 0) { @@ -1651,9 +1663,9 @@ } var minIops; - var maxIops + var maxIops; - if (selectedDiskOfferingObj.iscustomizediops == true) { + if (selectedDiskOfferingObj != null && selectedDiskOfferingObj.iscustomizediops == true) { minIops = args.data.minIops; maxIops = args.data.maxIops; } @@ -2338,11 +2350,14 @@ allowedActions.push("takeSnapshot"); allowedActions.push("recurringSnapshot"); } + } - if (jsonObj.type == "DATADISK") { + if (jsonObj.hypervisor == "KVM" || jsonObj.hypervisor == "XenServer" || jsonObj.hypervisor == "VMware") { + if (jsonObj.state == "Ready" || jsonObj.state == "Allocated") { allowedActions.push("resize"); } } + if (jsonObj.state != "Allocated") { if ((jsonObj.vmstate == "Stopped" || jsonObj.virtualmachineid == null) && jsonObj.state == "Ready") { allowedActions.push("downloadVolume");