From 9e392d25ba38b04f62a7f61b39ffb26676c5fd09 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 15 Apr 2013 16:05:01 -0700 Subject: [PATCH] CLOUDSTACK-2038: cloudstack UI - mixed zone management - template menu - register ISO action - populate zone dropdown upon selected zone type on top menu. --- ui/scripts/templates.js | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index f579c506511..b924841cb39 100644 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -877,16 +877,32 @@ url: createURL("listZones&available=true"), dataType: "json", async: true, - success: function(json) { - var zoneObjs = json.listzonesresponse.zone; - var items = []; - if (isAdmin() && !(cloudStack.context.projects && - cloudStack.context.projects[0])) - items.push({id: -1, description: "All Zones"}); - $(zoneObjs).each(function() { - items.push({id: this.id, description: this.name}); - }); - args.response.success({data: items}); + success: function(json) { + var zoneObjs; + if(args.context.zoneType == null || args.context.zoneType == '') { //all types + zoneObjs = []; + var items = json.listzonesresponse.zone; + if(items != null) { + for(var i = 0; i < items.length; i++) { + zoneObjs.push({id: items[i].id, description: items[i].name}); + } + } + } + else { //Basic type or Advanced type + zoneObjs = []; + var items = json.listzonesresponse.zone; + if(items != null) { + for(var i = 0; i < items.length; i++) { + if(items[i].networktype == args.context.zoneType) { + zoneObjs.push({id: items[i].id, description: items[i].name}); + } + } + } + } + if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])){ + zoneObjs.unshift({id: -1, description: "All Zones"}); + } + args.response.success({data: zoneObjs}); } }); }