From e1275b4916e580520550e3dde454213d6e9b3649 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 7 Aug 2012 15:17:08 -0700 Subject: [PATCH] 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). --- ui/scripts/autoscaler.js | 63 ++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/ui/scripts/autoscaler.js b/ui/scripts/autoscaler.js index bab01cb59b0..5b01e55af7c 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 }); + } + } } } },