You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2014/05/02 00:50:15 UTC

[3/3] git commit: updated refs/heads/4.4-forward to 430d14b

CLOUDSTACK-6438: Filter out existing IPs in dropdown


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

Branch: refs/heads/4.4-forward
Commit: 430d14b67608039159403036dae3dc7af1e590f5
Parents: 7daabf6
Author: Brian Federle <br...@citrix.com>
Authored: Thu May 1 15:38:26 2014 -0700
Committer: Brian Federle <br...@citrix.com>
Committed: Thu May 1 15:49:37 2014 -0700

----------------------------------------------------------------------
 ui/scripts/network.js              | 23 +++++++++++++++--------
 ui/scripts/ui/widgets/multiEdit.js | 14 +++++++++++++-
 2 files changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/430d14b6/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index abfaac3..7a495c1 100755
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -179,19 +179,26 @@
                     var primaryIp = nic.ipaddress;
                     var secondaryIps = nic.secondaryip ? nic.secondaryip : [];
                     var ipSelection = [];
+                    var existingIps = $(args.context.subItemData).map(
+                        function(index, item) { return item.itemIp; }
+                    );
 
                     // Add primary IP as default
-                    ipSelection.push({
-                        id: primaryIp,
-                        description: primaryIp + ' (Primary)'
-                    });
+                    if ($.inArray(primaryIp, existingIps) == -1) {
+                        ipSelection.push({
+                            id: primaryIp,
+                            description: primaryIp + ' (Primary)'
+                        });
+                    }
 
                     // Add secondary IPs
                     $(secondaryIps).map(function(index, secondaryIp) {
-                        ipSelection.push({
-                            id: secondaryIp.ipaddress,
-                            description: secondaryIp.ipaddress
-                        });
+                        if ($.inArray(secondaryIp.ipaddress, existingIps) == -1) {
+                            ipSelection.push({
+                                id: secondaryIp.ipaddress,
+                                description: secondaryIp.ipaddress
+                            });
+                        }
                     });
 
                     args.response.success({

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/430d14b6/ui/scripts/ui/widgets/multiEdit.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/multiEdit.js b/ui/scripts/ui/widgets/multiEdit.js
index 367cc27..47e5f43 100755
--- a/ui/scripts/ui/widgets/multiEdit.js
+++ b/ui/scripts/ui/widgets/multiEdit.js
@@ -196,11 +196,21 @@
                     } else if (field.addButton && !options.noSelect) {
                         if (options.multipleAdd) {
                             $addButton.click(function() {
+                                var context = $.extend(true, {}, options.context);
+
                                 if ($td.hasClass('disabled')) return false;
 
+                                var $subItems = $td.closest('.data-item').find('.expandable-listing tr');
+
+                                if ($subItems.size()) {
+                                    context.subItemData = $subItems.map(function() {
+                                        return $(this).data('json-obj');
+                                    });
+                                }
+
                                 _medit.vmList($multi,
                                     options.listView,
-                                    options.context,
+                                    context,
                                     options.multipleAdd, _l('label.add.vms'),
                                     addItemAction, {
                                         multiRule: multiRule
@@ -820,6 +830,8 @@
                     var field = this;
                     var $tr = _medit.multiItem.itemRow(field, itemActions, multiRule, $tbody).appendTo($tbody);
 
+                    $tr.data('json-obj', field);
+
                     cloudStack.evenOdd($tbody, 'tr', {
                         even: function($elem) {
                             $elem.addClass('even');