incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [2/2] git commit: refs/heads/ui-multiple-nics - LB/PF/NAT UI: Support secondary IP selection
Date Wed, 06 Mar 2013 22:37:29 GMT
Updated Branches:
  refs/heads/ui-multiple-nics f24ee207c -> e046364cc


LB/PF/NAT UI: Support secondary IP selection

During selection of a VM for LB/PF/Static NAT, show dropdown to select
which secondary IP will apply for the rule being created.


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

Branch: refs/heads/ui-multiple-nics
Commit: e046364ccece52b0a6c705c2ad92dee427ef3c61
Parents: ed7ebf5
Author: Brian Federle <brian.federle@citrix.com>
Authored: Wed Mar 6 14:37:26 2013 -0800
Committer: Brian Federle <brian.federle@citrix.com>
Committed: Wed Mar 6 14:37:26 2013 -0800

----------------------------------------------------------------------
 ui/scripts/network.js              |   51 +++++++++++++++++++++++++++++-
 ui/scripts/ui/widgets/multiEdit.js |   48 +++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e046364c/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index 4d8798b..6cb7cf0 100755
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -34,6 +34,36 @@
 
     return elemData;
   };
+
+  var instanceSecondaryIPSubselect = function(args) {
+    var instance = args.context.instances[0];
+    var network = args.context.networks[0];
+    var nic = $.grep(instance.nic, function(nic) {
+      return nic.networkid = network.id;
+    })[0]
+
+    // Get NIC IPs
+    $.ajax({
+      url: createURL('listNics'),
+      data: {
+        virtualmachineid: instance.id,
+        nicId: nic.id
+      },
+      success: function(json) {
+        var nic = json.listnics.nic[0];
+        var ips = nic.secondaryip ? nic.secondaryip : [];
+
+        args.response.success({
+          data: $(ips).map(function(index, ip) {
+            return {
+              id: ip.ipaddress,
+              description: ip.ipaddress
+            } ;
+          })
+        });
+      }
+    })
+  };
   
   var ipChangeNotice = function() {
     cloudStack.dialog.confirm({
@@ -1095,7 +1125,7 @@
               addRow: 'true',
               messages: {
                 confirm: function(args) {
-                  'message.acquire.new.ip';
+                  return 'message.acquire.new.ip';
                 },
                 notification: function(args) {
                   return 'label.acquire.new.ip';
@@ -1138,7 +1168,7 @@
                 virtualmachineid: args.context.instances[0].id
               },
               success: function(json) {
-                var ips = json.listnics.nic[0].secondaryip
+                var ips = json.listnics.nic ? json.listnics.nic[0].secondaryip : [];
 
                 args.response.success({
                   data: $(ips).map(function(index, ip) {
@@ -1632,6 +1662,7 @@
                     listView: $.extend(true, {}, cloudStack.sections.instances, {
                       listView: {
                         filters: false,
+                        subselect: instanceSecondaryIPSubselect,
                         dataProvider: function(args) {
                           var data = {
                             page: args.page,
@@ -2374,7 +2405,22 @@
                   loadBalancing: {
                     listView: $.extend(true, {}, cloudStack.sections.instances, {
                       listView: {
+                        fields: {
+                          name: { label: 'label.name' },
+                          displayname: { label: 'label.display.name' },
+                          zonename: { label: 'label.zone.name' },
+                          state: {
+                            label: 'label.state',
+                            indicator: {
+                              'Running': 'on',
+                              'Stopped': 'off',
+                              'Destroyed': 'off',
+                              'Error': 'off'
+                            }
+                          }
+                        },
                         filters: false,
+                        subselect: instanceSecondaryIPSubselect,
                         dataProvider: function(args) {
                           var itemData = $.isArray(args.context.multiRule) && args.context.multiRule[0]['_itemData']
?
                             args.context.multiRule[0]['_itemData'] : [];
@@ -2957,6 +3003,7 @@
                     listView: $.extend(true, {}, cloudStack.sections.instances, {
                       listView: {
                         filters: false,
+                        subselect: instanceSecondaryIPSubselect,
                         dataProvider: function(args) {
                           var networkid;
 													if('vpc' in args.context) 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e046364c/ui/scripts/ui/widgets/multiEdit.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/multiEdit.js b/ui/scripts/ui/widgets/multiEdit.js
index 2480f56..7bce128 100755
--- a/ui/scripts/ui/widgets/multiEdit.js
+++ b/ui/scripts/ui/widgets/multiEdit.js
@@ -468,6 +468,54 @@
       // Change action label
       $listView.find('th.actions').html(_l('Select'));
 
+      // Add sub-select
+      if (instances.listView.subselect) {
+        $listView.bind('cloudStack.listView.addRow', function(event, data) {
+          var $tr = data.$tr;
+          var $td = $tr.find('td.first');
+          var $select = $('<div></div>').addClass('subselect').append(
+            $('<select></select>')
+          ).hide();
+          var $selectionArea = $tr.find('td:last').find('input');
+
+          $td.append($select);
+
+          // Show and populate selection
+          $selectionArea.change(function() {
+            if ($(this).is(':checked')) {
+              // Populate data
+              instances.listView.subselect({
+                context: $.extend(true, {}, context, {
+                  instances: [$tr.data('json-obj')]
+                }),
+                response: {
+                  success: function(args) {
+                    var data = args.data;
+
+                    if (data.length) {
+                      $(data).map(function(index, item) {
+                        var $option = $('<option>');
+
+                        $option.attr('value', item.id);
+                        $option.append(item.description);
+                        $option.appendTo($select.find('select'));
+                      });
+
+                    } else {
+                      $select.hide();
+                    }
+                  }
+                }
+              });
+              $select.show();
+            } else {
+              $select.find('option').remove();
+              $select.hide();
+            }
+          });
+        });
+      }
+
       var $dataList = $listView.addClass('multi-edit-add-list').dialog({
         dialogClass: 'multi-edit-add-list panel',
         width: 825,


Mime
View raw message