cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessicaw...@apache.org
Subject git commit: updated refs/heads/master-6-17-stable to d46ccc9
Date Tue, 02 Jul 2013 23:17:50 GMT
Updated Branches:
  refs/heads/master-6-17-stable b2d6c0828 -> d46ccc9cb


CLOUDSTACK-3164: UI - VPC section - tier - Internal LB - detailView - add assignVMs action
in detailView (will show on Quickview in listView as well).


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

Branch: refs/heads/master-6-17-stable
Commit: d46ccc9cb1029702a3e1d9681f3d33861d19d555
Parents: b2d6c08
Author: Jessica Wang <jessicawang@apache.org>
Authored: Tue Jul 2 16:14:54 2013 -0700
Committer: Jessica Wang <jessicawang@apache.org>
Committed: Tue Jul 2 16:17:35 2013 -0700

----------------------------------------------------------------------
 ui/scripts/vpc.js | 110 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 108 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d46ccc9c/ui/scripts/vpc.js
----------------------------------------------------------------------
diff --git a/ui/scripts/vpc.js b/ui/scripts/vpc.js
index 310fbb6..85ddb52 100644
--- a/ui/scripts/vpc.js
+++ b/ui/scripts/vpc.js
@@ -471,7 +471,98 @@
           detailView: {
             isMaximized: true,
             name: 'Internal LB details',
-            actions: {              
+            actions: {                
+              assignVMs: {
+                label: 'Assign VMs',
+                messages: {
+                  notification: function(args) { return 'Assign VMs'; }
+                },
+                needsRefresh: true,
+                listView: $.extend(true, {}, cloudStack.sections.instances.listView, {
+                  type: 'checkbox',
+                  filters: false,
+                  dataProvider: function(args) {       
+                    var assignedInstances;
+                    $.ajax({
+                      url: createURL('listLoadBalancers'),
+                      data: {
+                        id: args.context.internalLoadBalancers[0].id
+                      },
+                      async: false,
+                      success: function(json) {    
+                        assignedInstances = json.listloadbalancerssresponse.loadbalancer[0].loadbalancerinstance;
        
+                        if(assignedInstances == null)
+                          assignedInstances = []; 
+                      }
+                    });                     
+                    
+                    $.ajax({
+                      url: createURL('listVirtualMachines'),
+                      data: {
+                        networkid: args.context.networks[0].id,
+                        listAll: true
+                      },
+                      success: function(json) {
+                        var instances = json.listvirtualmachinesresponse.virtualmachine;
+
+                        // Pre-select existing instances in LB rule
+                        $(instances).map(function(index, instance) {
+                          instance._isSelected = $.grep(assignedInstances,              
                   
+                            function(assignedInstance) {
+                              return assignedInstance.id == instance.id;
+                            }
+                          ).length ? true : false;
+                        });
+                        
+                        //remove assigned VMs (i.e. instance._isSelected == true)
+                        var items = [];
+                        if(instances != null) {
+                          for(var i = 0; i < instances.length; i++) {
+                            if(instances[i]._isSelected == true)
+                              continue;
+                            else
+                              items.push(instances[i]);
+                          }
+                        }
+                        
+                        args.response.success({
+                          data: items
+                        });
+                      }
+                    });
+                  }
+                }),
+                action: function(args) {                          
+                  var vms = args.context.instances;
+                  var array1 = [];
+                  for(var i = 0; i < vms.length; i++) {
+                    array1.push(vms[i].id);
+                  }
+                  var virtualmachineids = array1.join(',');
+                  
+                  $.ajax({
+                    url: createURL('assignToLoadBalancerRule'),
+                    data: {
+                      id: args.context.internalLoadBalancers[0].id,
+                      virtualmachineids: virtualmachineids
+                    },
+                    dataType: 'json',
+                    async: true,
+                    success: function(data) {                          
+                      var jid = data.assigntoloadbalancerruleresponse.jobid;            
                                      
+                      args.response.success({
+                        _custom: { 
+                          jobId: jid
+                        }
+                      });
+                    }
+                  });
+                },
+                notification: {
+                  poll: pollAsyncJobResult
+                }                      
+              },
+                            
               remove: {
                 label: 'Delete Internal LB',
                 messages: {
@@ -519,7 +610,22 @@
                     sourceipaddress: { label: 'Source IP Address' },
                     sourceport: { label: 'Source Port' },
                     instanceport: { label: 'Instance Port' },
-                    algorithm: { label: 'label.algorithm' }                        
+                    algorithm: { label: 'label.algorithm' },
+                    loadbalancerinstance: { 
+                      label: 'Assigned VMs',
+                      converter: function(objArray) {                       
+                        var s = '';
+                        if(objArray != null) {
+                          for(var i = 0; i < objArray.length; i++) {
+                            if(i > 0) {
+                              s += ', ';      
+                            }                                                    
+                            s += objArray[i].name + ' ('+ objArray[i].ipaddress + ')';
+                          }
+                        }                        
+                        return s;                     
+                      }
+                    }
                   }
                 ],                    
                 dataProvider: function(args) {      


Mime
View raw message