cloudstack 3.0 UI - autoscale - add validation, prompt "Please disable the Autoscale VM Group first" when users try to update autoscale that's in Enabled state. UI does not automatically fire disableAutoScaleVmGroup API any more when VM Group is in Enabled state.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/f7177b49 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/f7177b49 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/f7177b49 Branch: refs/heads/master Commit: f7177b496f36291c106b37dfd460cb5895a7b2e6 Parents: 5259127 Author: Jessica Wang <[email protected]> Authored: Thu Aug 9 11:17:58 2012 -0700 Committer: Vijay Venkatachalam <[email protected]> Committed: Fri Nov 16 10:56:50 2012 +0530 ---------------------------------------------------------------------- ui/scripts/autoscaler.js | 112 +++++++--------------------------------- 1 files changed, 20 insertions(+), 92 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f7177b49/ui/scripts/autoscaler.js ---------------------------------------------------------------------- diff --git a/ui/scripts/autoscaler.js b/ui/scripts/autoscaler.js index 42e5829..a946796 100644 --- a/ui/scripts/autoscaler.js +++ b/ui/scripts/autoscaler.js @@ -87,7 +87,7 @@ //no actions for new LB rule } else { //existing LB rule - if(args.context.originalAutoscaleData[0].afterActionIsComplete == null) { + if(args.context.originalAutoscaleData[0].afterActionIsComplete == null) { if(args.context.originalAutoscaleData[0].context.autoscaleVmGroup.state == 'disabled') allowedActions.push('enable'); else if(args.context.originalAutoscaleData[0].context.autoscaleVmGroup.state == 'enabled') @@ -698,64 +698,33 @@ args.response.success({ data: scaleDownData }); - } - /* - actions: { - destroy: { - label: '', - action: function(args) { - $.ajax({ - url: createURL("deleteCondition&id=" + args.context.multiRule[0].counterid), - dataType: 'json', - async: true, - success: function(data) { - var jobId = data.deleteconditionresponse.jobid; - - args.response.success({ - _custom: { - jobId: jobId - } - }); - } - }); - } - } - }, - ignoreEmptyFields: true, - dataProvider: function(args) { - $.ajax({ - url: createURL('listConditions'), - dataType: 'json', - async: true, - success: function(data) { - args.response.success({ - data: $.map( - data.listconditionsresponse.condition ? - data.listconditionsresponse.condition : [], - function(elem) { - return { - counterid: elem.id, - relationaloperator: elem.relationaloperator, - threshold: elem.threshold - }; - } - ) - }); - } - }); - }*/ + } } }, actions: { apply: function(args) { - //validation (begin) ***** + //validation (begin) ***** if(!('multiRules' in args.context)) { //from a new LB if(args.formData.name == '' || args.formData.publicport == '' || args.formData.privateport == '') { args.response.error('Name, Public Port, Private Port of Load Balancing are required. Please close this dialog box and fill Name, Public Port, Private Port first.'); return; } - } + } + else { //from an existing LB + if(args.context.originalAutoscaleData.afterActionIsComplete == null) { + if(args.context.originalAutoscaleData.context.autoscaleVmGroup.state != 'disabled') { + args.response.error('An Autoscale VM Group can be updated only if it is in disabled state. Please disable the Autoscale VM Group first.'); + return; + } + } + else { + if(args.context.originalAutoscaleData.afterActionIsComplete.state != 'disabled') { + args.response.error('An Autoscale VM Group can be updated only if it is in disabled state. Please disable the Autoscale VM Group first.'); + return; + } + } + } if(isAdmin() || isDomainAdmin()) { //only admin and domain-admin has access to listUers API var havingApiKeyAndSecretKey = false; @@ -1338,49 +1307,8 @@ }; //*** API calls start!!! ******** - if(!('multiRules' in args.context)) { //from a new LB - scaleUp(args); - } - else { //from an existing LB - if(args.context.originalAutoscaleData.context.autoscaleVmGroup.state == 'disabled') { - scaleUp(args); - } - else { - $.ajax({ - url: createURL('disableAutoScaleVmGroup'), - data: { - id: args.context.originalAutoscaleData.context.autoscaleVmGroup.id - }, - success: function(json) { - var disableAutoScaleVmGroupIntervalID = setInterval(function() { - $.ajax({ - url: createURL("queryAsyncJobResult&jobid=" + json.disableautoscalevmGroupresponse.jobid), - dataType: "json", - success: function(json) { - var result = json.queryasyncjobresultresponse; - if(result.jobstatus == 0) { - return; - } - else { - clearInterval(disableAutoScaleVmGroupIntervalID); - if(result.jobstatus == 1) { - //json.queryasyncjobresultresponse.jobresult.autoscalevmgroup //do NOT update args.context.originalAutoscaleData.context.autoscaleVmGroup. So, we have original data before making API calls. - scaleUp(args); - } - else if(result.jobstatus == 2) { - args.response.error(_s(result.jobresult.errortext)); - } - } - } - }); - }, 3000); - } - }); - } - } - - //setTimeout(function() { args.response.success(); }, 1000); - //setTimeout(function() { args.response.error('Error!'); }, 1000); + scaleUp(args); + }, destroy: function(args) { $.ajax({
