Repository: cloudstack Updated Branches: refs/heads/master 0940e0b6f -> 78ce5ea2d
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. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/78ce5ea2 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/78ce5ea2 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/78ce5ea2 Branch: refs/heads/master Commit: 78ce5ea2d38cce34414878496ec8e6afb183d54e Parents: 0940e0b Author: Jessica Wang <[email protected]> Authored: Thu Sep 4 14:24:03 2014 -0700 Committer: Jessica Wang <[email protected]> Committed: Thu Sep 4 14:24:15 2014 -0700 ---------------------------------------------------------------------- ui/scripts/templates.js | 99 +++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/78ce5ea2/ui/scripts/templates.js ---------------------------------------------------------------------- diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index dbc60b0..6dcd6da 100644 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -1025,25 +1025,23 @@ }), - dataProvider: function(args) { - var jsonObj = args.context.templates[0]; - var apiCmd = "listTemplates&templatefilter=self&id=" + jsonObj.id; - if (jsonObj.zoneid != null) - apiCmd = apiCmd + "&zoneid=" + jsonObj.zoneid; - + dataProvider: function(args) { // UI > Templates menu (listing) > select a template from listing > Details tab $.ajax({ - url: createURL(apiCmd), - dataType: "json", + url: createURL("listTemplates"), + data: { + templatefilter: "self", + id: args.context.templates[0].id + }, success: function(json) { var jsonObj = json.listtemplatesresponse.template[0]; - + if ('details' in jsonObj && 'hypervisortoolsversion' in jsonObj.details) { if (jsonObj.details.hypervisortoolsversion == 'xenserver61') jsonObj.xenserverToolsVersion61plus = true; else jsonObj.xenserverToolsVersion61plus = false; } - + args.response.success({ actionFilter: templateActionfilter, data: jsonObj @@ -1072,24 +1070,34 @@ hideSearchBar: true, - dataProvider: function(args) { - var jsonObj = args.context.templates[0]; - var apiCmd = "listTemplates&templatefilter=self&id=" + jsonObj.id; - - $.ajax({ - url: createURL(apiCmd), - dataType: "json", - success: function(json) { - var templates = json.listtemplatesresponse.template; - var zones = []; - zones = templates; - - args.response.success({ - actionFilter: templateActionfilter, - data: zones - }); - } - }); + dataProvider: function(args) { // UI > Templates menu (listing) > select a template from listing > Details tab > Zones tab (listing) + $.ajax({ + url: createURL("listTemplates"), + data: { + templatefilter: "self", + id: args.context.templates[0].id + }, + success: function(json) { + var jsonObjs = json.listtemplatesresponse.template; + + if (jsonObjs != undefined) { + for (var i = 0; i < jsonObjs.length; i++) { + var jsonObj = jsonObjs[i]; + if ('details' in jsonObj && 'hypervisortoolsversion' in jsonObj.details) { + if (jsonObj.details.hypervisortoolsversion == 'xenserver61') + jsonObj.xenserverToolsVersion61plus = true; + else + jsonObj.xenserverToolsVersion61plus = false; + } + } + } + + args.response.success({ + actionFilter: templateActionfilter, + data: jsonObjs + }); + } + }); }, detailView: { @@ -1410,31 +1418,20 @@ }), - dataProvider: function(args) { - var jsonObj = args.context.templates[0]; - var apiCmd = "listTemplates&templatefilter=self&id=" + jsonObj.id; - if (jsonObj.zoneid != null) - apiCmd = apiCmd + "&zoneid=" + jsonObj.zoneid; - - $.ajax({ - url: createURL(apiCmd), - dataType: "json", - success: function(json) { - var jsonObj = json.listtemplatesresponse.template[0]; + dataProvider: function(args) { // UI > Templates menu (listing) > select a template from listing > Details tab > Zones tab (listing) > select a zone from listing > Details tab + var jsonObj = args.context.zones[0]; - if ('details' in jsonObj && 'hypervisortoolsversion' in jsonObj.details) { - if (jsonObj.details.hypervisortoolsversion == 'xenserver61') - jsonObj.xenserverToolsVersion61plus = true; - else - jsonObj.xenserverToolsVersion61plus = false; - } + if ('details' in jsonObj && 'hypervisortoolsversion' in jsonObj.details) { + if (jsonObj.details.hypervisortoolsversion == 'xenserver61') + jsonObj.xenserverToolsVersion61plus = true; + else + jsonObj.xenserverToolsVersion61plus = false; + } - args.response.success({ - actionFilter: templateActionfilter, - data: jsonObj - }); - } - }); + args.response.success({ + actionFilter: templateActionfilter, + data: jsonObj + }); } } }}
