Skip to content

Commit 6de00cb

Browse files
author
Jessica Wang
committed
CLOUDSTACK-3950: UI > template/ISO page > registerTemplate/registerISO action > zone dropdown > include only one option "All Zones" when secondary storage is region-wide.
1 parent 3905381 commit 6de00cb

3 files changed

Lines changed: 84 additions & 54 deletions

File tree

‎ui/scripts/cloudStack.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,12 @@
172172
$.cookie('KVMsnapshotenabled', g_KVMsnapshotenabled, {
173173
expires: 1
174174
});
175-
175+
176+
g_regionsecondaryenabled = json.listcapabilitiesresponse.capability.regionsecondaryenabled; //boolean
177+
$.cookie('regionsecondaryenabled', g_regionsecondaryenabled, {
178+
expires: 1
179+
});
180+
176181
if (json.listcapabilitiesresponse.capability.userpublictemplateenabled != null) {
177182
g_userPublicTemplateEnabled = json.listcapabilitiesresponse.capability.userpublictemplateenabled.toString(); //convert boolean to string if it's boolean
178183
$.cookie('userpublictemplateenabled', g_userPublicTemplateEnabled, {
@@ -342,6 +347,11 @@
342347
expires: 1
343348
});
344349

350+
g_regionsecondaryenabled = json.listcapabilitiesresponse.capability.regionsecondaryenabled; //boolean
351+
$.cookie('regionsecondaryenabled', g_regionsecondaryenabled, {
352+
expires: 1
353+
});
354+
345355
if (json.listcapabilitiesresponse.capability.userpublictemplateenabled != null) {
346356
g_userPublicTemplateEnabled = json.listcapabilitiesresponse.capability.userpublictemplateenabled.toString(); //convert boolean to string if it's boolean
347357
$.cookie('userpublictemplateenabled', g_userPublicTemplateEnabled, {
@@ -443,6 +453,7 @@
443453
g_timezone = null;
444454
g_supportELB = null;
445455
g_KVMsnapshotenabled = null;
456+
g_regionsecondaryenabled = null;
446457
g_loginCmdText = null;
447458

448459
$.cookie('JSESSIONID', null);

‎ui/scripts/sharedFunctions.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var g_timezoneoffset = null;
2626
var g_timezone = null;
2727
var g_supportELB = null;
2828
var g_KVMsnapshotenabled = null;
29+
var g_regionsecondaryenabled = null;
2930
var g_userPublicTemplateEnabled = "true";
3031
var g_cloudstackversion = null;
3132
var g_queryAsyncJobResultInterval = 3000;

‎ui/scripts/templates.js‎

Lines changed: 71 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -134,33 +134,42 @@
134134
zone: {
135135
label: 'label.zone',
136136
docID: 'helpRegisterTemplateZone',
137-
select: function(args) {
138-
$.ajax({
139-
url: createURL("listZones&available=true"),
140-
dataType: "json",
141-
async: true,
142-
success: function(json) {
143-
var zoneObjs = [];
144-
var items = json.listzonesresponse.zone;
145-
if (items != null) {
146-
for (var i = 0; i < items.length; i++) {
147-
zoneObjs.push({
148-
id: items[i].id,
149-
description: items[i].name
150-
});
151-
}
152-
}
153-
if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) {
154-
zoneObjs.unshift({
155-
id: -1,
156-
description: "All Zones"
157-
});
158-
}
159-
args.response.success({
160-
data: zoneObjs
161-
});
162-
}
163-
});
137+
select: function(args) {
138+
if(g_regionsecondaryenabled == true) {
139+
args.response.success({
140+
data: [{
141+
id: -1,
142+
description: "All Zones"
143+
}]
144+
});
145+
} else {
146+
$.ajax({
147+
url: createURL("listZones&available=true"),
148+
dataType: "json",
149+
async: true,
150+
success: function(json) {
151+
var zoneObjs = [];
152+
var items = json.listzonesresponse.zone;
153+
if (items != null) {
154+
for (var i = 0; i < items.length; i++) {
155+
zoneObjs.push({
156+
id: items[i].id,
157+
description: items[i].name
158+
});
159+
}
160+
}
161+
if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) {
162+
zoneObjs.unshift({
163+
id: -1,
164+
description: "All Zones"
165+
});
166+
}
167+
args.response.success({
168+
data: zoneObjs
169+
});
170+
}
171+
});
172+
}
164173
}
165174
},
166175
hypervisor: {
@@ -1033,32 +1042,41 @@
10331042
label: 'label.zone',
10341043
docID: 'helpRegisterISOZone',
10351044
select: function(args) {
1036-
$.ajax({
1037-
url: createURL("listZones&available=true"),
1038-
dataType: "json",
1039-
async: true,
1040-
success: function(json) {
1041-
var zoneObjs = [];
1042-
var items = json.listzonesresponse.zone;
1043-
if (items != null) {
1044-
for (var i = 0; i < items.length; i++) {
1045-
zoneObjs.push({
1046-
id: items[i].id,
1047-
description: items[i].name
1048-
});
1049-
}
1050-
}
1051-
if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) {
1052-
zoneObjs.unshift({
1053-
id: -1,
1054-
description: "All Zones"
1055-
});
1056-
}
1057-
args.response.success({
1058-
data: zoneObjs
1059-
});
1060-
}
1061-
});
1045+
if(g_regionsecondaryenabled == true) {
1046+
args.response.success({
1047+
data: [{
1048+
id: -1,
1049+
description: "All Zones"
1050+
}]
1051+
});
1052+
} else {
1053+
$.ajax({
1054+
url: createURL("listZones&available=true"),
1055+
dataType: "json",
1056+
async: true,
1057+
success: function(json) {
1058+
var zoneObjs = [];
1059+
var items = json.listzonesresponse.zone;
1060+
if (items != null) {
1061+
for (var i = 0; i < items.length; i++) {
1062+
zoneObjs.push({
1063+
id: items[i].id,
1064+
description: items[i].name
1065+
});
1066+
}
1067+
}
1068+
if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) {
1069+
zoneObjs.unshift({
1070+
id: -1,
1071+
description: "All Zones"
1072+
});
1073+
}
1074+
args.response.success({
1075+
data: zoneObjs
1076+
});
1077+
}
1078+
});
1079+
}
10621080
}
10631081
},
10641082

0 commit comments

Comments
 (0)