new role filtering related fixes

merge-requests/7/head
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).
*/
@ -467,8 +493,8 @@ var userModule = function () {
try {
carbonUser = session.get(constants.USER_SESSION_KEY);
} catch (e) {
log.error("User object was not found in the session");
carbonUser = null;
log.error("User object was not found in the session");
carbonUser = null;
}
var utility = require('/app/modules/utility.js').utility;
if (!carbonUser) {

@ -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