Updated Branches: refs/heads/autoscale 77eec3d3c -> 11068b594
cloudstack 3.0 UI - autoscale - configure AutoScale - fix a bug when root-admin tried to update an AutoScale created by regular-user or domain-admin, users dropdown was not correctly populated (should be populated with users under owner account instead of users under current login account). Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/11068b59 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/11068b59 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/11068b59 Branch: refs/heads/autoscale Commit: 11068b594e1c002a2353d8b7d6da11069c65d58d Parents: 77eec3d Author: Jessica Wang <[email protected]> Authored: Tue Aug 7 15:17:08 2012 -0700 Committer: Jessica Wang <[email protected]> Committed: Wed Aug 8 10:40:06 2012 -0700 ---------------------------------------------------------------------- ui/scripts/autoscaler.js | 63 ++++++++++++++++++++++++++++------------ 1 files changed, 44 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/11068b59/ui/scripts/autoscaler.js ---------------------------------------------------------------------- diff --git a/ui/scripts/autoscaler.js b/ui/scripts/autoscaler.js index bab01cb..5b01e55 100644 --- a/ui/scripts/autoscaler.js +++ b/ui/scripts/autoscaler.js @@ -407,25 +407,50 @@ label: 'User', select: function(args) { var items = []; - if(isAdmin() || isDomainAdmin()) { - $.ajax({ - url: createURL('listUsers'), - data: { - domainid: g_domainid, - account: g_account - }, - success: function(json) { - var users = json.listusersresponse.user; - $(users).each(function(){ - items.push({id: this.id, description: this.username}); - }); - args.response.success({ data: items }); - } - }); - } - else { //regular user doesn't have access to listUers API call. - items.push({id: "", description: ""}); - } + if(args.context.originalAutoscaleData == null) { //new LB rule + if(isAdmin() || isDomainAdmin()) { + $.ajax({ + url: createURL('listUsers'), + data: { + domainid: g_domainid, + account: g_account + }, + success: function(json) { + var users = json.listusersresponse.user; + $(users).each(function(){ + items.push({id: this.id, description: this.username}); + }); + args.response.success({ data: items }); + } + }); + } + else { //regular user doesn't have access to listUers API call. + items.push({id: "", description: ""}); + args.response.success({ data: items }); + } + } + else { //existing LB rule + if(isAdmin() || isDomainAdmin()) { + $.ajax({ + url: createURL('listUsers'), + data: { + domainid: args.context.originalAutoscaleData.context.autoscaleVmProfile.domainid, + account: args.context.originalAutoscaleData.context.autoscaleVmProfile.account + }, + success: function(json) { + var users = json.listusersresponse.user; + $(users).each(function(){ + items.push({id: this.id, description: this.username}); + }); + args.response.success({ data: items }); + } + }); + } + else { //regular user doesn't have access to listUers API call. + items.push({id: "", description: ""}); + args.response.success({ data: items }); + } + } } } },
