From 1f572998f84c52a02ce7c4c5a4e5e905835e4ba9 Mon Sep 17 00:00:00 2001 From: kamidu Date: Wed, 22 Mar 2017 20:13:59 +0530 Subject: [PATCH] enable role filtering in device cloud --- .../cdmf.page.roles/public/js/role-listing.js | 47 +++++++------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js index 6899f98fb2..0dd54ad2f8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js @@ -102,38 +102,19 @@ function loadRoles() { var objects = []; var count = 0; $(data.roles).each(function (index) { - if (isCloud && data.roles[index].startsWith("devicemgt")) { - count++; - objects.push( - { - name: htmlspecialchars(data.roles[index]), - DT_RowId: "role-" + htmlspecialchars(data.roles[index]) - } - ) - } else if (!isCloud) { - objects.push( - { - name: htmlspecialchars(data.roles[index]), - DT_RowId: "role-" + htmlspecialchars(data.roles[index]) - } - ) - } + objects.push( + { + name: htmlspecialchars(data.roles[index]), + DT_RowId: "role-" + htmlspecialchars(data.roles[index]) + } + ) }); - var json = {}; - if (isCloud) { - json = { - "recordsTotal": count, - "recordsFiltered": count, - "data": objects - }; - } else { - json = { - "recordsTotal": data.count, - "recordsFiltered": data.count, - "data": objects - }; - } + var json = { + "recordsTotal": data.count, + "recordsFiltered": data.count, + "data": objects + }; return JSON.stringify(json); }; @@ -225,8 +206,12 @@ function loadRoles() { var settings = { "sorting": false }; + var roleApiUrl = '/api/device-mgt/v1.0/roles?user-store=all'; + if (isCloud) { + roleApiUrl = '/api/device-mgt/v1.0/roles/filter/devicemgt?user-store=all'; + } - $('#role-grid').datatables_extended_serverside_paging(settings, '/api/device-mgt/v1.0/roles?user-store=all', dataFilter, columns, fnCreatedRow, null, options); + $('#role-grid').datatables_extended_serverside_paging(settings, roleApiUrl, dataFilter, columns, fnCreatedRow, null, options); loadingContent.hide(); }