From 6de00cb1f2b0f9301fbb2b7975d0803cdcb697a9 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 20 Aug 2013 14:22:47 -0700 Subject: [PATCH] CLOUDSTACK-3950: UI > template/ISO page > registerTemplate/registerISO action > zone dropdown > include only one option "All Zones" when secondary storage is region-wide. --- ui/scripts/cloudStack.js | 13 +++- ui/scripts/sharedFunctions.js | 1 + ui/scripts/templates.js | 124 +++++++++++++++++++--------------- 3 files changed, 84 insertions(+), 54 deletions(-) diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js index 7020c217c72..ffc32adee24 100644 --- a/ui/scripts/cloudStack.js +++ b/ui/scripts/cloudStack.js @@ -172,7 +172,12 @@ $.cookie('KVMsnapshotenabled', g_KVMsnapshotenabled, { expires: 1 }); - + + g_regionsecondaryenabled = json.listcapabilitiesresponse.capability.regionsecondaryenabled; //boolean + $.cookie('regionsecondaryenabled', g_regionsecondaryenabled, { + expires: 1 + }); + if (json.listcapabilitiesresponse.capability.userpublictemplateenabled != null) { g_userPublicTemplateEnabled = json.listcapabilitiesresponse.capability.userpublictemplateenabled.toString(); //convert boolean to string if it's boolean $.cookie('userpublictemplateenabled', g_userPublicTemplateEnabled, { @@ -342,6 +347,11 @@ expires: 1 }); + g_regionsecondaryenabled = json.listcapabilitiesresponse.capability.regionsecondaryenabled; //boolean + $.cookie('regionsecondaryenabled', g_regionsecondaryenabled, { + expires: 1 + }); + if (json.listcapabilitiesresponse.capability.userpublictemplateenabled != null) { g_userPublicTemplateEnabled = json.listcapabilitiesresponse.capability.userpublictemplateenabled.toString(); //convert boolean to string if it's boolean $.cookie('userpublictemplateenabled', g_userPublicTemplateEnabled, { @@ -443,6 +453,7 @@ g_timezone = null; g_supportELB = null; g_KVMsnapshotenabled = null; + g_regionsecondaryenabled = null; g_loginCmdText = null; $.cookie('JSESSIONID', null); diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index 3a05183a3c3..7d55c4f10b2 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -26,6 +26,7 @@ var g_timezoneoffset = null; var g_timezone = null; var g_supportELB = null; var g_KVMsnapshotenabled = null; +var g_regionsecondaryenabled = null; var g_userPublicTemplateEnabled = "true"; var g_cloudstackversion = null; var g_queryAsyncJobResultInterval = 3000; diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index d596bc2971b..0acb36e81d1 100644 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -134,33 +134,42 @@ zone: { label: 'label.zone', docID: 'helpRegisterTemplateZone', - select: function(args) { - $.ajax({ - url: createURL("listZones&available=true"), - dataType: "json", - async: true, - success: function(json) { - var 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 - }); - } - } - if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) { - zoneObjs.unshift({ - id: -1, - description: "All Zones" - }); - } - args.response.success({ - data: zoneObjs - }); - } - }); + select: function(args) { + if(g_regionsecondaryenabled == true) { + args.response.success({ + data: [{ + id: -1, + description: "All Zones" + }] + }); + } else { + $.ajax({ + url: createURL("listZones&available=true"), + dataType: "json", + async: true, + success: function(json) { + var 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 + }); + } + } + if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) { + zoneObjs.unshift({ + id: -1, + description: "All Zones" + }); + } + args.response.success({ + data: zoneObjs + }); + } + }); + } } }, hypervisor: { @@ -1033,32 +1042,41 @@ label: 'label.zone', docID: 'helpRegisterISOZone', select: function(args) { - $.ajax({ - url: createURL("listZones&available=true"), - dataType: "json", - async: true, - success: function(json) { - var 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 - }); - } - } - if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) { - zoneObjs.unshift({ - id: -1, - description: "All Zones" - }); - } - args.response.success({ - data: zoneObjs - }); - } - }); + if(g_regionsecondaryenabled == true) { + args.response.success({ + data: [{ + id: -1, + description: "All Zones" + }] + }); + } else { + $.ajax({ + url: createURL("listZones&available=true"), + dataType: "json", + async: true, + success: function(json) { + var 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 + }); + } + } + if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) { + zoneObjs.unshift({ + id: -1, + description: "All Zones" + }); + } + args.response.success({ + data: zoneObjs + }); + } + }); + } } },