From 593ce7c490d7ec27e9c397a694d443dc2797d907 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 23 May 2012 14:11:55 -0700 Subject: [PATCH] CS-14989: cloudstack 3.0 UI - VM wizard - select template step - populate only templates whose hypervisor(s) are supported in the selected zone. --- ui/scripts/instances.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index dee0cf0f307..731774e2bf4 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -105,12 +105,22 @@ } }); + + //***** get templates/ISOs (begin) ***** + var hypervisorArray = []; + $(hypervisorObjs).each(function(index, item) { + hypervisorArray.push(item.name); + }); + $.ajax({ url: createURL("listTemplates&templatefilter=featured&zoneid="+args.currentData.zoneid), dataType: "json", async: false, - success: function(json) { - featuredTemplateObjs = json.listtemplatesresponse.template; + success: function(json) { + featuredTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { + if($.inArray(item.hypervisor, hypervisorArray) > -1) + return true; + }); } }); $.ajax({ @@ -118,7 +128,10 @@ dataType: "json", async: false, success: function(json) { - communityTemplateObjs = json.listtemplatesresponse.template; + communityTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { + if($.inArray(item.hypervisor, hypervisorArray) > -1) + return true; + }); } }); $.ajax({ @@ -126,10 +139,12 @@ dataType: "json", async: false, success: function(json) { - myTemplateObjs = json.listtemplatesresponse.template; + myTemplateObjs = $.grep(json.listtemplatesresponse.template, function(item, index) { + if($.inArray(item.hypervisor, hypervisorArray) > -1) + return true; + }); } }); - $.ajax({ url: createURL("listIsos&isofilter=featured&zoneid=" + args.currentData.zoneid + "&bootable=true"), @@ -155,7 +170,9 @@ myIsoObjs = json.listisosresponse.iso; } }); - + //***** get templates/ISOs (end) ***** + + args.response.success({ hypervisor: { idField: 'name',