cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [4/50] [abbrv] git commit: Conditionally show select SG step
Date Wed, 30 Jan 2013 00:06:07 GMT
Conditionally show select SG step

Only show select security group step if at least one guest network
with SecurityGroup service is selected.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a2b2d45e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a2b2d45e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a2b2d45e

Branch: refs/heads/ui-quick-view-v2
Commit: a2b2d45e401bd73a2261db461368b030c56f69c8
Parents: 6f90a86
Author: Brian Federle <brian.federle@citrix.com>
Authored: Thu Jan 24 13:43:15 2013 -0800
Committer: Brian Federle <brian.federle@citrix.com>
Committed: Thu Jan 24 14:57:43 2013 -0800

----------------------------------------------------------------------
 ui/scripts/instanceWizard.js           |   33 ++++++++++++++++++++++++--
 ui/scripts/ui-custom/instanceWizard.js |   10 ++++++++
 2 files changed, 40 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2b2d45e/ui/scripts/instanceWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instanceWizard.js b/ui/scripts/instanceWizard.js
index 8ebee62..070f7e7 100644
--- a/ui/scripts/instanceWizard.js
+++ b/ui/scripts/instanceWizard.js
@@ -16,7 +16,7 @@
 // under the License. 
 
 (function($, cloudStack) {
-  var zoneObjs, hypervisorObjs, featuredTemplateObjs, communityTemplateObjs, myTemplateObjs,
featuredIsoObjs, community;
+  var zoneObjs, hypervisorObjs, featuredTemplateObjs, communityTemplateObjs, myTemplateObjs,
featuredIsoObjs, community, networkObjs;
   var selectedZoneObj, selectedTemplateObj, selectedHypervisor, selectedDiskOfferingObj;

   var step5ContainerType = 'nothing-to-select'; //'nothing-to-select', 'select-network',
'select-security-group'
 
@@ -40,6 +40,33 @@
         !data.vpcid;
     },
 
+    // Runs when advanced SG-enabled zone is run, before
+    // the security group step
+    //
+    // -- if it returns false, then 'Select Security Group' is skipped.
+    //
+    advSGFilter: function(args) {
+      var selectedNetworks;
+      
+      if ($.isArray(args.data['my-networks'])) {
+        selectedNetworks = $(args.data['my-networks']).map(function(index, myNetwork) {
+          return $.grep(networkObjs, function(networkObj) {
+            return networkObj.id == myNetwork;
+          });
+        });        
+      } else {
+        selectedNetworks = $.grep(networkObjs, function(networkObj) {
+          return networkObj.id == args.data['my-networks'];
+        });
+      }
+
+      return $.grep(selectedNetworks, function(network) {
+        return $.grep(network.service, function(service) {
+          return service.name == 'SecurityGroup';
+        }).length;
+      }).length;
+    },
+
     // Data providers for each wizard step
     steps: [
     
@@ -347,7 +374,7 @@
           networkData.account = g_account;
         }
 
-        var networkObjs, vpcObjs;
+        var vpcObjs;
 
         //listVPCs without account/domainid/listAll parameter will return only VPCs belonging
to the current login. That's what should happen in Instances page's VM Wizard. 
 				//i.e. If the current login is root-admin, do not show VPCs belonging to regular-user/domain-admin
in Instances page's VM Wizard. 
@@ -365,7 +392,7 @@
           async: false,
           success: function(json) {
             networkObjs = json.listnetworksresponse.network ? json.listnetworksresponse.network
: [];
-												
+
 						if(networkObjs.length > 0) {
 						  for(var i = 0; i < networkObjs.length; i++) {
 								var networkObj = networkObjs[i];    

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2b2d45e/ui/scripts/ui-custom/instanceWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js
index d1f2507..67d2a69 100644
--- a/ui/scripts/ui-custom/instanceWizard.js
+++ b/ui/scripts/ui-custom/instanceWizard.js
@@ -821,6 +821,16 @@
                 cloudStack.dialog.notice({ message: 'message.step.4.continue' });
                 return false;
               }
+
+              if ($activeStep.hasClass('next-use-security-groups')) {
+                var advSGFilter = args.advSGFilter({
+                  data: cloudStack.serializeForm($form)
+                });
+
+                if (!advSGFilter) {
+                  showStep(6);
+                }
+              }
             }
 						
 						//step 6 - review (spcifiy displyname, group as well)		


Mime
View raw message