Updated Branches:
  refs/heads/master 1c89bc78f -> 8f5d8d505
CLOUDSTACK-1910: cloudstack UI - Regions menu - GSLB - assigned load balancing 
- display assigned load balancing in listView and exclude assigned one from LB 
dropdown in Assign more load balancing dialog.


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

Branch: refs/heads/master
Commit: 8f5d8d505243372d241e1ce90a16cbaa9991c1d2
Parents: 1c89bc7
Author: Jessica Wang <jessicaw...@apache.org>
Authored: Wed Apr 24 14:55:50 2013 -0700
Committer: Jessica Wang <jessicaw...@apache.org>
Committed: Wed Apr 24 14:57:47 2013 -0700

----------------------------------------------------------------------
 ui/scripts/regions.js |  111 +++++++++++++++++++++++---------------------
 1 files changed, 58 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f5d8d50/ui/scripts/regions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/regions.js b/ui/scripts/regions.js
index ef6f976..334eb26 100644
--- a/ui/scripts/regions.js
+++ b/ui/scripts/regions.js
@@ -382,7 +382,7 @@
                                                                                
                                        detailView: {
             name: 'GSLB details',
-            viewAll: { path: 'regions.lbUnderGSLB', label: 'load balancer 
rules' },
+            viewAll: { path: 'regions.lbUnderGSLB', label: 'assigned load 
balancing' },
             actions: {              
                                                        remove: {
                 label: 'delete GSLB',
@@ -452,77 +452,82 @@
         }
       },
                                                
-                       lbUnderGSLB: {
+     lbUnderGSLB: {
         id: 'lbUnderGSLB',
         type: 'select',
-        title: 'assigned load balancer rules',
+        title: 'assigned load balancing',
         listView: {
           section: 'lbUnderGSLB',
           id: 'lbUnderGSLB',
-          label: 'assigned load balancer rules',
+          label: 'assigned load balancing',
           fields: {
-            name: { label: 'label.name' },
+            'name': { label: 'label.name' },
             publicport: { label: 'label.public.port' },
-                                               privateport: { label: 
'label.private.port' },
-                                               algorithm: { label: 
'label.algorithm' }
+           privateport: { label: 'label.private.port' },
+           algorithm: { label: 'label.algorithm' }
           },                                   
-                                       dataProvider: function(args) {          
                        
-                                               var data = {
-                                                 globalloadbalancerruleid: 
args.context.GSLB[0].id,
-                                                 listAll: true
-                                               };
-            $.ajax({
-              url: createURL('listLoadBalancerRules'),
-                                                       data: data,
-              success: function(json) {
-                var items = 
json.listloadbalancerrulesresponse.loadbalancerrule;
-                args.response.success({                                        
                         
-                  data: items
-                });
-              }
+         dataProvider: function(args) {                                        
+           var items = args.context.GSLB[0].loadbalancerrule;
+            args.response.success({                                            
                 
+              data: items
             });
           },           
-                                       actions: {            
+         actions: {            
             add: {
-              label: 'assign load balancer rule to GSLB',
-              messages: {
-                confirm: function(args) {
-                  return 'Please confirm you want to assign load balancer rule 
to GSLB';
-                },
+              label: 'assign more load balancing',
+              messages: {                
                 notification: function(args) {
-                  return 'assign load balancer rule to GSLB';
+                  return 'assign more load balancing';
                 }
               },
               createForm: {
-                title: 'assign load balancer rule to GSLB',              
+                title: 'assign more load balancing',              
                 fields: {                  
                   loadbalancerrule: {
-                    label: 'load balancer rule',                    
+                    label: 'load balancing rule',                    
                     select: function(args) {           
-                                                                               
        var data = {
-                                                                               
                globalloadbalancerruleid: args.context.GSLB[0].id,
-                                                                               
                listAll: true
-                                                                               
        };
-                                                                               
        $.ajax({
-                                                                               
                url: createURL('listLoadBalancerRules'),
-                                                                               
                data: data,
-                                                                               
                success: function(json) {
-                                                                               
                        var items = 
json.listloadbalancerrulesresponse.loadbalancerrule;
-                                                                               
                        args.response.success({                                 
                         
-                                                                               
                                data: items,
-                                                                               
                                descriptionField: 'name'
-                                                                               
                        });                                                     
                                                
-                                                                               
                }
-                                                                               
        });                                                                     
                                                                                
                        
+                     var data = {
+                       globalloadbalancerruleid: args.context.GSLB[0].id,
+                       listAll: true
+                     };
+                     $.ajax({
+                       url: createURL('listLoadBalancerRules'),
+                       data: data,
+                       success: function(json) {
+                         var allLbRules = 
json.listloadbalancerrulesresponse.loadbalancerrule;
+                          var assignedLbRules = 
args.context.GSLB[0].loadbalancerrule;
+                          var items = [];
+                          if(allLbRules != null) {
+                            for(var i = 0; i < allLbRules.length; i++) {  
+                              var isAssigned = false;                          
  
+                              if(assignedLbRules != null) {
+                                for(var k = 0; k < assignedLbRules.length; 
k++) {
+                                  if(allLbRules[i].id == 
assignedLbRules[k].id) {
+                                    isAssigned = true;
+                                    break; 
+                                  }
+                                }
+                              }
+                              if(isAssigned == false) {
+                                items.push(allLbRules[i]);
+                              }
+                            }
+                          }                        
+                         args.response.success({                               
                                 
+                           data: items,
+                           descriptionField: 'name'
+                         });                                                   
                                                
+                       }
+                     });                                                       
                                                                                
                                        
                     }
                   }  
                 }
               },
               action: function(args) {                                         
          
-                                                               var data = {
-                                                                 id: 
args.context.GSLB[0].id,
-                                                                       
loadbalancerrulelist: args.data.loadbalancerrule
-                                                               };              
        
+               var data = {
+                 id: args.context.GSLB[0].id,
+                 loadbalancerrulelist: args.data.loadbalancerrule
+               };                      
                 $.ajax({
                   url: createURL('assignToGlobalLoadBalancerRule'),
                   data: data,                 
@@ -547,16 +552,16 @@
                                        },                                      
        
                                                                        
                                        detailView: {
-            name: 'load balancer rule details',            
+            name: 'load balancing details',            
             actions: {              
               remove: {
-                label: 'remove load balancer rule from this GSLB',
+                label: 'remove load balancing from this GSLB',
                 messages: {
                   notification: function() { 
-                                                                         
return 'remove load balancer rule from GSLB'; 
+                                                                         
return 'remove load balancing from GSLB'; 
                                                                        },
                   confirm: function() { 
-                                                                         
return 'Please confirm you want to remove load balancer rule from GSLB'; 
+                                                                         
return 'Please confirm you want to remove load balancing from GSLB'; 
                                                                        }
                 },               
                 action: function(args) {                                       
                                        

Reply via email to