new role filtering related fixes

revert-70aa11f8
kamidu 8 years ago
parent 8c17418198
commit 0b94a284ad

@ -302,6 +302,32 @@ var userModule = function () {
}
};
/**
* Get User Roles from user store (Internal roles not included).
*/
publicMethods.getFilteredRoles = function (prefix) {
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
var utility = require("/app/modules/utility.js")["utility"];
if (!carbonUser) {
log.error("User object was not found in the session");
throw constants["ERRORS"]["USER_NOT_FOUND"];
}
try {
utility.startTenantFlow(carbonUser);
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
"/roles/filter/" + prefix + "?offset=0&limit=100&user-store=all";
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
if (response.status == "success") {
response.content = parse(response.content);
}
return response;
} catch (e) {
throw e;
} finally {
utility.endTenantFlow();
}
};
/**
* Get User Roles count from user store (Internal roles not included).
*/

@ -39,8 +39,11 @@ function onRequest() {
viewModel.groupCount = groupModule.getGroupCount();
viewModel.userCount = userModule.getUsersCount();
viewModel.policyCount = policyModule.getPoliciesCount();
viewModel.roleCount = userModule.getRolesCount();
viewModel.isCloud = devicemgtProps.isCloud;
if (devicemgtProps.isCloud) {
viewModel.roleCount = userModule.getFilteredRoles("devicemgt").content.count;
} else {
viewModel.roleCount = userModule.getRolesCount();
}
return viewModel;
}

@ -98,7 +98,7 @@ function loadRoles() {
var dataFilter = function (data) {
data = JSON.parse(data);
console.log(data);
var objects = [];
var count = 0;
$(data.roles).each(function (index) {
@ -137,7 +137,7 @@ function loadRoles() {
class: "",
data: "name",
render: function (name, type, row, meta) {
return '<h4>' + name + '</h4>';
return '<h4>' + name.replace("devicemgt", ""); + '</h4>';
}
},
{

Loading…
Cancel
Save