Repository: cloudstack
Updated Branches:
  refs/heads/master 13205e6be -> bbca8cda9


[UI] list only non-existing networks when Add network to VM


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

Branch: refs/heads/master
Commit: bbca8cda94ccdf2cf4ed115e0b0ff9e4f73b0ff0
Parents: 13205e6
Author: Wei Zhou <[email protected]>
Authored: Tue Dec 9 08:44:06 2014 +0100
Committer: Wei Zhou <[email protected]>
Committed: Tue Dec 9 08:44:06 2014 +0100

----------------------------------------------------------------------
 ui/scripts/instances.js | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bbca8cda/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 5d431b1..22df9d3 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -2002,13 +2002,30 @@
                                                     url: 
createURL('listNetworks'),
                                                     data: data1,
                                                     success: function(json) {
+                                                        var networkObjs = 
json.listnetworksresponse.network;
+                                                        var nicObjs = 
args.context.instances[0].nic;
+                                                        var items = [];
+
+                                                        for (var i = 0; i < 
networkObjs.length; i++) {
+                                                            var networkObj = 
networkObjs[i];
+                                                            var 
isNetworkExists = false;
+
+                                                            for (var j = 0; j 
< nicObjs.length; j++) {
+                                                                if 
(nicObjs[j].networkid == networkObj.id) {
+                                                                    
isNetworkExists = true;
+                                                                    break;
+                                                               }
+                                                            }
+
+                                                            if 
(!isNetworkExists) {
+                                                                items.push({
+                                                                    id: 
networkObj.id,
+                                                                    
description: networkObj.name
+                                                                });
+                                                            }
+                                                        }
                                                         args.response.success({
-                                                            data: 
$.map(json.listnetworksresponse.network, function(network) {
-                                                                return {
-                                                                    id: 
network.id,
-                                                                    
description: network.name
-                                                                };
-                                                            })
+                                                            data: items
                                                         });
                                                     }
                                                 });

Reply via email to