From d7291e520054c0f6c70bf5feca00b7ff727779b2 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 12 May 2014 15:33:40 -0700 Subject: [PATCH] CLOUDSTACK-6379: UI > fix a bug that domain admin failed to be created when current login doesn't have visibility to root domain object. --- ui/scripts/accounts.js | 3 +- ui/scripts/accountsWizard.js | 67 +++++------------------------------- 2 files changed, 10 insertions(+), 60 deletions(-) diff --git a/ui/scripts/accounts.js b/ui/scripts/accounts.js index 935ba92ebec..4eaa401113f 100644 --- a/ui/scripts/accounts.js +++ b/ui/scripts/accounts.js @@ -17,8 +17,7 @@ (function(cloudStack) { var domainObjs; - var rootDomainId; - + cloudStack.sections.accounts = { title: 'label.accounts', id: 'accounts', diff --git a/ui/scripts/accountsWizard.js b/ui/scripts/accountsWizard.js index d84fbfa59bd..e02a04eea85 100644 --- a/ui/scripts/accountsWizard.js +++ b/ui/scripts/accountsWizard.js @@ -16,6 +16,8 @@ // under the License. (function(cloudStack, $) { + var rootDomainId; + cloudStack.accountsWizard = { informationWithinLdap: { @@ -75,20 +77,9 @@ validation: { required: true }, - select: function(args) { - var data = {}; - - if (args.context.users) { // In accounts section - data.listAll = true; - } else if (args.context.domains) { // In domain section (use specific domain) - data.id = args.context.domains[0].id; - } - + select: function(args) { $.ajax({ - url: createURL("listDomains"), - data: data, - dataType: "json", - async: false, + url: createURL("listDomains"), success: function(json) { var items = []; domainObjs = json.listdomainsresponse.domain; @@ -204,8 +195,10 @@ } var accountType = args.data.accounttype; - if (args.data.accounttype == "1" && args.data.domainid != rootDomainId) { //if account type is admin, but domain is not Root domain - accountType = "2"; // Change accounttype from root-domain("1") to domain-admin("2") + if (accountType == "1") { //if "admin" is selected in account type dropdown + if (rootDomainId == undefined || args.data.domainid != rootDomainId ) { //but current login has no visibility to root domain object, or the selected domain is not root domain + accountType = "2"; // change accountType from root-domain("1") to domain-admin("2") + } } array1.push("&accounttype=" + accountType); @@ -268,48 +261,6 @@ } }); } - } - /* - action: function(args) { - var array1 = []; - - var username = args.data.username; - - array1.push("&domainid=" + args.data.domainid); - - if (args.data.account != null && args.data.account.length != 0) { - array1.push("&account=" + args.data.account); - } - - if (args.data.accounttype == "1" && args.data.domainid != rootDomainId) { - args.data.accounttype = "2"; - } - array1.push("&accountType=" + args.data.accounttype); - - if (args.data.timezone != null && args.data.timezone.length != 0) { - array1.push("&timezone=" + args.data.timezone); - } - if (args.data.networkdomain != null && args.data.networkdomain != 0) { - array1.push("&networkDomain=" + args.data.networkdomain); - } - - for (var i = 0; i < username.length; i++) { - $.ajax({ - url: createURL("ldapCreateAccount&username=" + username[i] + array1.join("")), - dataType: "json", - async: false, - success: function(json) { - var item = json.createaccountresponse.account; - args.response.success({ - data: item - }); - }, - error: function(XMLHttpResponse) { - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } - }); - } - } - */ + } }; }(cloudStack, jQuery)); \ No newline at end of file