Skip to content

Commit 78ce5ea

Browse files
author
Jessica Wang
committed
CLOUDSTACK-7490: UI > Templates menu (listing) > select a template from listing > Details tab > Zones tab (listing) > select a zone from listing > Details tab > fix a bug that wrong "template+zone" combination was shown.
1 parent 0940e0b commit 78ce5ea

1 file changed

Lines changed: 48 additions & 51 deletions

File tree

ui/scripts/templates.js

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,25 +1025,23 @@
10251025
}),
10261026

10271027

1028-
dataProvider: function(args) {
1029-
var jsonObj = args.context.templates[0];
1030-
var apiCmd = "listTemplates&templatefilter=self&id=" + jsonObj.id;
1031-
if (jsonObj.zoneid != null)
1032-
apiCmd = apiCmd + "&zoneid=" + jsonObj.zoneid;
1033-
1028+
dataProvider: function(args) { // UI > Templates menu (listing) > select a template from listing > Details tab
10341029
$.ajax({
1035-
url: createURL(apiCmd),
1036-
dataType: "json",
1030+
url: createURL("listTemplates"),
1031+
data: {
1032+
templatefilter: "self",
1033+
id: args.context.templates[0].id
1034+
},
10371035
success: function(json) {
10381036
var jsonObj = json.listtemplatesresponse.template[0];
1039-
1037+
10401038
if ('details' in jsonObj && 'hypervisortoolsversion' in jsonObj.details) {
10411039
if (jsonObj.details.hypervisortoolsversion == 'xenserver61')
10421040
jsonObj.xenserverToolsVersion61plus = true;
10431041
else
10441042
jsonObj.xenserverToolsVersion61plus = false;
10451043
}
1046-
1044+
10471045
args.response.success({
10481046
actionFilter: templateActionfilter,
10491047
data: jsonObj
@@ -1072,24 +1070,34 @@
10721070
hideSearchBar: true,
10731071

10741072

1075-
dataProvider: function(args) {
1076-
var jsonObj = args.context.templates[0];
1077-
var apiCmd = "listTemplates&templatefilter=self&id=" + jsonObj.id;
1078-
1079-
$.ajax({
1080-
url: createURL(apiCmd),
1081-
dataType: "json",
1082-
success: function(json) {
1083-
var templates = json.listtemplatesresponse.template;
1084-
var zones = [];
1085-
zones = templates;
1086-
1087-
args.response.success({
1088-
actionFilter: templateActionfilter,
1089-
data: zones
1090-
});
1091-
}
1092-
});
1073+
dataProvider: function(args) { // UI > Templates menu (listing) > select a template from listing > Details tab > Zones tab (listing)
1074+
$.ajax({
1075+
url: createURL("listTemplates"),
1076+
data: {
1077+
templatefilter: "self",
1078+
id: args.context.templates[0].id
1079+
},
1080+
success: function(json) {
1081+
var jsonObjs = json.listtemplatesresponse.template;
1082+
1083+
if (jsonObjs != undefined) {
1084+
for (var i = 0; i < jsonObjs.length; i++) {
1085+
var jsonObj = jsonObjs[i];
1086+
if ('details' in jsonObj && 'hypervisortoolsversion' in jsonObj.details) {
1087+
if (jsonObj.details.hypervisortoolsversion == 'xenserver61')
1088+
jsonObj.xenserverToolsVersion61plus = true;
1089+
else
1090+
jsonObj.xenserverToolsVersion61plus = false;
1091+
}
1092+
}
1093+
}
1094+
1095+
args.response.success({
1096+
actionFilter: templateActionfilter,
1097+
data: jsonObjs
1098+
});
1099+
}
1100+
});
10931101
},
10941102

10951103
detailView: {
@@ -1410,31 +1418,20 @@
14101418
}),
14111419

14121420

1413-
dataProvider: function(args) {
1414-
var jsonObj = args.context.templates[0];
1415-
var apiCmd = "listTemplates&templatefilter=self&id=" + jsonObj.id;
1416-
if (jsonObj.zoneid != null)
1417-
apiCmd = apiCmd + "&zoneid=" + jsonObj.zoneid;
1418-
1419-
$.ajax({
1420-
url: createURL(apiCmd),
1421-
dataType: "json",
1422-
success: function(json) {
1423-
var jsonObj = json.listtemplatesresponse.template[0];
1421+
dataProvider: function(args) { // UI > Templates menu (listing) > select a template from listing > Details tab > Zones tab (listing) > select a zone from listing > Details tab
1422+
var jsonObj = args.context.zones[0];
14241423

1425-
if ('details' in jsonObj && 'hypervisortoolsversion' in jsonObj.details) {
1426-
if (jsonObj.details.hypervisortoolsversion == 'xenserver61')
1427-
jsonObj.xenserverToolsVersion61plus = true;
1428-
else
1429-
jsonObj.xenserverToolsVersion61plus = false;
1430-
}
1424+
if ('details' in jsonObj && 'hypervisortoolsversion' in jsonObj.details) {
1425+
if (jsonObj.details.hypervisortoolsversion == 'xenserver61')
1426+
jsonObj.xenserverToolsVersion61plus = true;
1427+
else
1428+
jsonObj.xenserverToolsVersion61plus = false;
1429+
}
14311430

1432-
args.response.success({
1433-
actionFilter: templateActionfilter,
1434-
data: jsonObj
1435-
});
1436-
}
1437-
});
1431+
args.response.success({
1432+
actionFilter: templateActionfilter,
1433+
data: jsonObj
1434+
});
14381435
}
14391436
}
14401437
}}

0 commit comments

Comments
 (0)