CLOUDSTACK-2038: cloudstack UI - mixed zone management - template menu - copy 
ISO action - populate zone dropdown upon selected zone type on top menu.


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

Branch: refs/heads/master
Commit: dd62b3de7e57fd3eeb75502e7e57564b6560b6b0
Parents: 6c2f2d3
Author: Jessica Wang <[email protected]>
Authored: Mon Apr 15 16:42:40 2013 -0700
Committer: Jessica Wang <[email protected]>
Committed: Mon Apr 15 16:42:40 2013 -0700

----------------------------------------------------------------------
 ui/scripts/templates.js |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dd62b3de/ui/scripts/templates.js
----------------------------------------------------------------------
diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js
index c1e01c1..52e1135 100644
--- a/ui/scripts/templates.js
+++ b/ui/scripts/templates.js
@@ -1222,14 +1222,30 @@
                           url: createURL("listZones&available=true"),
                           dataType: "json",
                           async: true,
-                          success: function(json) {
-                            var zoneObjs = json.listzonesresponse.zone;
-                            var items = [];
-                            $(zoneObjs).each(function() {
-                              if(this.id != args.context.isos[0].zoneid)
-                                items.push({id: this.id, description: 
this.name});
-                            });
-                            args.response.success({data: items});
+                          success: function(json) {      
+                                                                               
                                var zoneObjs = [];
+                                                                               
                                var items = json.listzonesresponse.zone;        
                                                                                
                        
+                                                                               
                                if(args.context.zoneType == null || 
args.context.zoneType == '') { //all types
+                                                                               
                                  if(items != null) {
+                                                                               
                                                for(var i = 0; i < 
items.length; i++) {                                                            
                                                                                
                                                                                
                                     
+                                                                               
                                                        if(items[i].id != 
args.context.isos[0].zoneid) { //destination zone must be different from source 
zone
+                                                                               
                                                                
zoneObjs.push({id: items[i].id, description: items[i].name});
+                                                                               
                                                        }                       
                                                                                
                                
+                                                                               
                                                }
+                                                                               
                                        }
+                                                                               
                                }
+                                                                               
                                else {  //Basic type or Advanced type           
                                                                                
        
+                                                                               
                                        if(items != null) {
+                                                                               
                                                for(var i = 0; i < 
items.length; i++) {
+                                                                               
                                                        if(items[i].networktype 
== args.context.zoneType) {     //type must be matched                          
                                                                        
+                                                                               
                                                                if(items[i].id 
!= args.context.isos[0].zoneid) { //destination zone must be different from 
source zone
+                                                                               
                                                                        
zoneObjs.push({id: items[i].id, description: items[i].name});
+                                                                               
                                                                }
+                                                                               
                                                        }
+                                                                               
                                                }
+                                                                               
                                        }
+                                                                               
                                }
+                            args.response.success({data: zoneObjs});           
        
                           }
                         });
                       }

Reply via email to