This is an automated email from the ASF dual-hosted git repository.

pradeep pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/master by this push:
     new 21a4c0d  RANGER-2794: Search is not working in Role page
21a4c0d is described below

commit 21a4c0dd2feba0b958fbc1a6d8b8009ccbbb818d
Author: maheshbandal <[email protected]>
AuthorDate: Wed Apr 22 23:35:24 2020 +0530

    RANGER-2794: Search is not working in Role page
    
    Signed-off-by: pradeep <[email protected]>
---
 .../org/apache/ranger/service/RangerRoleServiceBase.java  | 13 +++++++++++++
 security-admin/src/main/webapp/scripts/utils/XAUtils.js   | 14 ++++++++++----
 .../main/webapp/scripts/views/policies/PermissionList.js  | 15 ++++++++++++---
 .../main/webapp/scripts/views/users/UserTableLayout.js    |  6 +++---
 4 files changed, 38 insertions(+), 10 deletions(-)

diff --git 
a/security-admin/src/main/java/org/apache/ranger/service/RangerRoleServiceBase.java
 
b/security-admin/src/main/java/org/apache/ranger/service/RangerRoleServiceBase.java
index 5b22a53..39755da 100644
--- 
a/security-admin/src/main/java/org/apache/ranger/service/RangerRoleServiceBase.java
+++ 
b/security-admin/src/main/java/org/apache/ranger/service/RangerRoleServiceBase.java
@@ -34,6 +34,19 @@ public abstract class RangerRoleServiceBase<T extends 
XXRole, V extends RangerRo
 
         searchFields.add(new SearchField(SearchFilter.ROLE_ID, "obj.id", 
SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
         searchFields.add(new SearchField(SearchFilter.ROLE_NAME, "obj.name", 
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
+               searchFields.add(new SearchField(SearchFilter.GROUP_NAME, 
"xXRoleRefGroup.groupName",
+                               SearchField.DATA_TYPE.STRING, 
SearchField.SEARCH_TYPE.FULL, "XXRoleRefGroup xXRoleRefGroup",
+                               "xXRoleRefGroup.roleId = obj.id"));
+               searchFields.add(new SearchField(SearchFilter.USER_NAME, 
"xXRoleRefUser.userName", SearchField.DATA_TYPE.STRING,
+                               SearchField.SEARCH_TYPE.FULL, "XXRoleRefUser 
xXRoleRefUser", "xXRoleRefUser.roleId = obj.id"));
+               searchFields.add(new 
SearchField(SearchFilter.ROLE_NAME_PARTIAL, "obj.name", 
SearchField.DATA_TYPE.STRING,
+                               SearchField.SEARCH_TYPE.PARTIAL));
+               searchFields.add(new 
SearchField(SearchFilter.GROUP_NAME_PARTIAL, "xXRoleRefGroup.groupName",
+                               SearchField.DATA_TYPE.STRING, 
SearchField.SEARCH_TYPE.PARTIAL, "XXRoleRefGroup xXRoleRefGroup",
+                               "xXRoleRefGroup.roleId = obj.id"));
+               searchFields.add(new 
SearchField(SearchFilter.USER_NAME_PARTIAL, "xXRoleRefUser.userName",
+                               SearchField.DATA_TYPE.STRING, 
SearchField.SEARCH_TYPE.PARTIAL, "XXRoleRefUser xXRoleRefUser",
+                               "xXRoleRefUser.roleId = obj.id"));
 
         sortFields.add(new SortField(SearchFilter.CREATE_TIME, 
"obj.createTime"));
         sortFields.add(new SortField(SearchFilter.UPDATE_TIME, 
"obj.updateTime"));
diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js 
b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
index d02e077..31eb1b3 100644
--- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
+++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
@@ -1675,10 +1675,16 @@ define(function(require) {
                 url: searchUrl,
                 dataType: 'json',
                 data: function(term, page) {
-                    return {
-                        name: term,
-                        isVisible : 
XAEnums.VisibilityStatus.STATUS_VISIBLE.value,
-                    };
+                    if($select === 'roles') {
+                        return {
+                            roleNamePartial: term
+                        }
+                    } else {
+                        return {
+                            name: term,
+                            isVisible : 
XAEnums.VisibilityStatus.STATUS_VISIBLE.value,
+                        }
+                    }
                 },
                 results: function(data, page) {
                     var results = [],
diff --git 
a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js 
b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
index cf5aff9..9f6af3e 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
@@ -224,13 +224,22 @@ define(function(require) {
                                initSelection : function (element, callback) {
                                        callback(tags);
                                },
-                               ajax: { 
+                               ajax: {
                                        url: searchUrl,
                                        dataType: 'json',
                                        data: function (term, page) {
-                                               return {name : term, isVisible 
: XAEnums.VisibilityStatus.STATUS_VISIBLE.value};
+                                               if(type === 'roles') {
+                                                       return {
+                                                               
roleNamePartial: term
+                                                       }
+                                               } else {
+                                                       return {
+                                                               name: term,
+                                                               isVisible : 
XAEnums.VisibilityStatus.STATUS_VISIBLE.value,
+                                                       }
+                                               }
                                        },
-                                       results: function (data, page) { 
+                                       results: function (data, page) {
                                                var results = [] , selectedVals 
= [];
                                                //Get selected values of 
groups/users dropdown
                                                 selectedVals = 
that.getSelectedValues($select, type);
diff --git 
a/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js 
b/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js
index 2b82181..41ca572 100755
--- a/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js
@@ -991,9 +991,9 @@ define(function(require){
                 placeholder = localization.tt('h.searchForYourRole');
                 coll = this.roleList;
                 searchOpt = ['Role Name','User Name', 'Group Name', /*Role 
ID*/];//,'Start Date','End Date','Today'];
-                serverAttrName  = [{text : "Role Name", label :"roleName", 
urlLabel : "roleName"},
-                                   {text : "User Name", label :"userName", 
urlLabel : "userName"},
-                                   {text : "Group Name", label :"groupName", 
urlLabel : "groupName"},
+                serverAttrName  = [{text : "Role Name", label 
:"roleNamePartial", urlLabel : "roleName"},
+                                   {text : "User Name", label 
:"userNamePartial", urlLabel : "userName"},
+                                   {text : "Group Name", label 
:"groupNamePartial", urlLabel : "groupName"},
                                 ];
             }
             var query = '';

Reply via email to