From 1dbd10e5e924e6dd74bd683b1521888df33cd4fc Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 5 Mar 2012 11:33:46 -0800 Subject: [PATCH] cloudstack 3.0 UI - Make Account page/User page available to normal-user role. --- ui/scripts/accounts.js | 67 ++++++++++++++++++++++++++-------------- ui/scripts/cloudStack.js | 4 +-- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/ui/scripts/accounts.js b/ui/scripts/accounts.js index 3977379a8bf..8d8856416bc 100644 --- a/ui/scripts/accounts.js +++ b/ui/scripts/accounts.js @@ -619,16 +619,24 @@ } var accountObj = args.context.accounts[0]; - $.ajax({ - url: createURL("listUsers&domainid=" + accountObj.domainid + "&account=" + accountObj.name + "&page=" + args.page + "&pagesize=" + pageSize + array1.join("")), - dataType: "json", - success: function(json) { - args.response.success({ - actionFilter: userActionfilter, - data: json.listusersresponse.user - }); - } - }) + if(isAdmin() || isDomainAdmin()) { + $.ajax({ + url: createURL("listUsers&domainid=" + accountObj.domainid + "&account=" + accountObj.name + "&page=" + args.page + "&pagesize=" + pageSize + array1.join("")), + dataType: "json", + success: function(json) { + args.response.success({ + actionFilter: userActionfilter, + data: json.listusersresponse.user + }); + } + }) + } + else { //normal user doesn't have access listUsers API until Bug 14127 is fixed. + args.response.success({ + actionFilter: userActionfilter, + data: accountObj.user + }); + } }, actions: { add: { @@ -970,18 +978,26 @@ ], dataProvider: function(args) { - $.ajax({ - url: createURL('listUsers'), - data: { - id: args.context.users[0].id - }, - success: function(json) { - args.response.success({ - actionFilter: userActionfilter, - data: json.listusersresponse.user[0] - }); - } - }); + if(isAdmin() || isDomainAdmin()) { + $.ajax({ + url: createURL('listUsers'), + data: { + id: args.context.users[0].id + }, + success: function(json) { + args.response.success({ + actionFilter: userActionfilter, + data: json.listusersresponse.user[0] + }); + } + }); + } + else { //normal user doesn't have access listUsers API until Bug 14127 is fixed. + args.response.success({ + actionFilter: userActionfilter, + data: args.context.users[0] + }); + } } } } @@ -1013,8 +1029,11 @@ } allowedActions.push("remove"); } - } - allowedActions.push("updateResourceCount"); + allowedActions.push("updateResourceCount"); + } + else if(isDomainAdmin()) { + allowedActions.push("updateResourceCount"); + } return allowedActions; } diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js index 566948b0102..076bcd88f14 100644 --- a/ui/scripts/cloudStack.js +++ b/ui/scripts/cloudStack.js @@ -10,10 +10,10 @@ return ["dashboard", "instances", "storage", "network", "templates", "accounts", "domains", "events", "projects"]; } else if (g_userProjectsEnabled) { - return ["dashboard", "instances", "storage", "network", "templates", "events", "projects"]; + return ["dashboard", "instances", "storage", "network", "templates", "accounts", "events", "projects"]; } else { //normal user - return ["dashboard", "instances", "storage", "network", "templates", "events"]; + return ["dashboard", "instances", "storage", "network", "templates", "accounts", "events"]; } }, sections: {