From 06d897498bd77997477a31187c8adc90302e89aa Mon Sep 17 00:00:00 2001 From: Isaac Chiang Date: Wed, 24 Jul 2013 16:33:49 +0800 Subject: [PATCH] CLOUDSTACK-3700: The dedication process should be listed as a step through zone wizard --- .../classes/resources/messages.properties | 1 + ui/dictionary.jsp | 1 + ui/scripts/zoneWizard.js | 169 ++++++++++++++---- 3 files changed, 133 insertions(+), 38 deletions(-) diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index 367459be102..0aeb4906b9b 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -1343,6 +1343,7 @@ message.creating.primary.storage=Creating primary storage message.creating.secondary.storage=Creating secondary storage message.creating.zone=Creating zone message.decline.invitation=Are you sure you want to decline this project invitation? +message.dedicate.zone=Dedicating zone message.delete.account=Please confirm that you want to delete this account. message.delete.affinity.group=Please confirm that you would like to remove this affinity group. message.delete.gateway=Please confirm you want to delete the gateway diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp index 748cc7d5b28..e3d8f772867 100644 --- a/ui/dictionary.jsp +++ b/ui/dictionary.jsp @@ -1310,6 +1310,7 @@ dictionary = { 'message.creating.secondary.storage': '', 'message.creating.zone': '', 'message.decline.invitation': '', +'message.dedicate.zone': '', 'message.delete.account': '', 'message.delete.affinity.group': '', 'message.delete.gateway': '', diff --git a/ui/scripts/zoneWizard.js b/ui/scripts/zoneWizard.js index 759b123ae3c..0af57a187be 100755 --- a/ui/scripts/zoneWizard.js +++ b/ui/scripts/zoneWizard.js @@ -2099,33 +2099,33 @@ }) }); - dedicatedZoneId = json.createzoneresponse.zone.id; - //EXPLICIT ZONE DEDICATION - if (args.data.pluginFrom == null && args.data.zone.ispublic != null) { - var array2 = []; - if (args.data.zone.domain != null) - array2.push("&domainid=" + args.data.zone.domain); - if (args.data.zone.accountId != "") - array2.push("&account=" + todb(args.data.zone.accountId)); + // dedicatedZoneId = json.createzoneresponse.zone.id; + // //EXPLICIT ZONE DEDICATION + // if (args.data.pluginFrom == null && args.data.zone.ispublic != null) { + // var array2 = []; + // if (args.data.zone.domain != null) + // array2.push("&domainid=" + args.data.zone.domain); + // if (args.data.zone.accountId != "") + // array2.push("&account=" + todb(args.data.zone.accountId)); - if (dedicatedZoneId != null) { - $.ajax({ - url: createURL("dedicateZone&ZoneId=" + dedicatedZoneId + array2.join("")), - dataType: "json", - success: function(json) { - var dedicatedObj = json.dedicatezoneresponse.jobid; - //args.response.success({ data: $.extend(item, dedicatedObj)}); + // if (dedicatedZoneId != null) { + // $.ajax({ + // url: createURL("dedicateZone&ZoneId=" + dedicatedZoneId + array2.join("")), + // dataType: "json", + // success: function(json) { + // var dedicatedObj = json.dedicatezoneresponse.jobid; + // //args.response.success({ data: $.extend(item, dedicatedObj)}); - }, + // }, - error: function(json) { + // error: function(json) { - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } - }); + // args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + // } + // }); - } - } + // } + // } }, error: function(XMLHttpResponse) { @@ -4027,11 +4027,22 @@ }, addSecondaryStorage: function(args) { + + var dedicatedZone = (args.data.pluginFrom == null && args.data.zone.ispublic != null); + if (args.data.secondaryStorage.provider == '') { - complete({ - data: args.data - }); - return; //skip addSecondaryStorage if provider dropdown is blank + + if (dedicatedZone) { + stepFns.dedicateZone({ + data: args.data + }); + } else { + complete({ + data: args.data + }) + } + + return; //skip addSecondaryStorage if provider dropdown is blank } @@ -4059,11 +4070,21 @@ url: createURL('addImageStore'), data: data, success: function(json) { - complete({ - data: $.extend(args.data, { - returnedSecondaryStorage: json.addimagestoreresponse.secondarystorage + + if (dedicatedZone) { + stepFns.dedicateZone({ + data: $.extend(args.data, { + returnedSecondaryStorage: json.addimagestoreresponse.secondarystorage + }) }) - }); + } else { + complete({ + data: $.extend(args.data, { + returnedSecondaryStorage: json.addimagestoreresponse.secondarystorage + }) + }); + } + }, error: function(XMLHttpResponse) { var errorMsg = parseXMLHttpResponse(XMLHttpResponse); @@ -4111,11 +4132,20 @@ url: createURL('addImageStore'), data: data, success: function(json) { - complete({ - data: $.extend(args.data, { - returnedSecondaryStorage: json.addimagestoreresponse.secondarystorage + if (dedicatedZone) { + stepFns.dedicateZone({ + data: $.extend(args.data, { + returnedSecondaryStorage: json.addimagestoreresponse.secondarystorage + }) }) - }); + } else { + complete({ + data: $.extend(args.data, { + returnedSecondaryStorage: json.addimagestoreresponse.secondarystorage + }) + }); + } + }, error: function(XMLHttpResponse) { var errorMsg = parseXMLHttpResponse(XMLHttpResponse); @@ -4179,11 +4209,19 @@ url: createURL('addImageStore'), data: data, success: function(json) { - complete({ - data: $.extend(args.data, { - returnedSecondaryStorage: json.addimagestoreresponse.secondarystorage + if (dedicatedZone) { + stepFns.dedicateZone({ + data: $.extend(args.data, { + returnedSecondaryStorage: json.addimagestoreresponse.secondarystorage + }) }) - }); + } else { + complete({ + data: $.extend(args.data, { + returnedSecondaryStorage: json.addimagestoreresponse.secondarystorage + }) + }); + } }, error: function(XMLHttpResponse) { var errorMsg = parseXMLHttpResponse(XMLHttpResponse); @@ -4194,6 +4232,61 @@ } }); } + }, + dedicateZone: function(args) { + + if(args.data.pluginFrom == null && args.data.zone.ispublic != null) { + var dedicatedZoneId = args.data.returnedZone.id; + message(dictionary['message.dedicate.zone']); + + var array2 = []; + if (args.data.zone.domain != null) + array2.push("&domainid=" + args.data.zone.domain); + if (args.data.zone.accountId != "") + array2.push("&account=" + todb(args.data.zone.accountId)); + + if (dedicatedZoneId != null) { + $.ajax({ + url: createURL("dedicateZone&ZoneId=" + dedicatedZoneId + array2.join("")), + dataType: "json", + success: function(json) { + var jobId = json.dedicatezoneresponse.jobid; + var dedicatedZoneIntervalId = setInterval(function() { + $.ajax({ + url: createURL("queryAsyncJobResult&jobid=" + jobId), + dataType: "json", + success: function(json) { + if (json.queryasyncjobresultresponse.jobstatus == 0) { // not complete + return; + } else { + clearInterval(dedicatedZoneIntervalId); + if(json.queryasyncjobresultresponse.jobstatus == 1) { // successed + complete({ + data: $.extend(args.data, { + returnedDedicateZone: json.queryasyncjobresultresponse.jobresult + }) + }); + } else if(json.queryasyncjobresultresponse.jobstatus == 2) { // failed + error('addZone', json.queryasyncjobresultresponse.jobresult.errortext, { + fn: 'dedicateZone', + args: args + }) + } + } + + } + }); + }, g_queryAsyncJobResultInterval); + } + }); + + } + } else { + complete({ + data: args.data + }); + } + } };