This is an automated email from the ASF dual-hosted git repository.
ni3galave 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 61f3e62 RANGER-2498: Improvement to plugin status tab.
61f3e62 is described below
commit 61f3e6280e291baf45be652bf0ec4ea0662d623a
Author: Nitin Galave <[email protected]>
AuthorDate: Fri Jul 12 20:50:03 2019 +0530
RANGER-2498: Improvement to plugin status tab.
---
.../ranger/plugin/model/RangerPluginInfo.java | 10 ++
.../java/org/apache/ranger/db/XXServiceDefDao.java | 14 +++
.../ranger/service/RangerPluginInfoService.java | 23 +++-
.../main/resources/META-INF/jpa_named_queries.xml | 4 +
.../webapp/scripts/collections/XABaseCollection.js | 3 -
.../webapp/scripts/modules/globalize/message/en.js | 3 +-
.../src/main/webapp/scripts/utils/XAUtils.js | 14 +++
.../webapp/scripts/views/reports/AuditLayout.js | 134 +++++++++++++--------
8 files changed, 152 insertions(+), 53 deletions(-)
diff --git
a/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerPluginInfo.java
b/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerPluginInfo.java
index 11c3a99..e3f9f15 100644
---
a/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerPluginInfo.java
+++
b/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerPluginInfo.java
@@ -64,6 +64,7 @@ public class RangerPluginInfo implements Serializable {
private Date updateTime;
private String serviceName;
+ private String serviceType;
private String hostName;
private String appType;
private String ipAddress;
@@ -110,6 +111,14 @@ public class RangerPluginInfo implements Serializable {
this.updateTime = updateTime;
}
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
public String getServiceName() {
return serviceName;
}
@@ -278,6 +287,7 @@ public class RangerPluginInfo implements Serializable {
sb.append("createTime={").append(createTime).append("} ");
sb.append("updateTime={").append(updateTime).append("} ");
sb.append("serviceName={").append(serviceName).append("} ");
+ sb.append("serviceType={").append(serviceType).append("} ");
sb.append("hostName={").append(hostName).append("} ");
sb.append("appType={").append(appType).append("} ");
sb.append("ipAddress={").append(ipAddress).append("} ");
diff --git
a/security-admin/src/main/java/org/apache/ranger/db/XXServiceDefDao.java
b/security-admin/src/main/java/org/apache/ranger/db/XXServiceDefDao.java
index becf0de..835e5fe 100644
--- a/security-admin/src/main/java/org/apache/ranger/db/XXServiceDefDao.java
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXServiceDefDao.java
@@ -19,6 +19,7 @@ package org.apache.ranger.db;
import javax.persistence.NoResultException;
+import org.apache.commons.lang.StringUtils;
import org.apache.ranger.common.db.BaseDao;
import org.apache.ranger.entity.XXServiceDef;
import org.springframework.stereotype.Service;
@@ -64,4 +65,17 @@ public class XXServiceDefDao extends BaseDao<XXServiceDef> {
updateSequence("X_SERVICE_DEF_SEQ", maxId + 1);
}
+ public String findServiceDefTypeByServiceName(String serviceName) {
+ String serviceType = null;
+ if (StringUtils.isNotBlank(serviceName)) {
+ try {
+ serviceType = getEntityManager()
+
.createNamedQuery("XXServiceDef.findServiceDefNameByServiceName", String.class)
+ .setParameter("name",
serviceName).getSingleResult();
+ } catch (NoResultException e) {
+ return null;
+ }
+ }
+ return serviceType;
+ }
}
\ No newline at end of file
diff --git
a/security-admin/src/main/java/org/apache/ranger/service/RangerPluginInfoService.java
b/security-admin/src/main/java/org/apache/ranger/service/RangerPluginInfoService.java
index 2bbf0d4..3ca3b8f 100644
---
a/security-admin/src/main/java/org/apache/ranger/service/RangerPluginInfoService.java
+++
b/security-admin/src/main/java/org/apache/ranger/service/RangerPluginInfoService.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ranger.biz.RangerBizUtil;
@@ -91,6 +92,13 @@ public class RangerPluginInfoService {
List<XXService> servicesWithTagService =
daoManager.getXXService().getAllServicesWithTagService();
+ // Rebuild searchFilter without serviceType
+
+ String serviceTypeToSearch =
searchFilter.getParam(SearchFilter.SERVICE_TYPE);
+ if (StringUtils.isNotBlank(serviceTypeToSearch)) {
+ searchFilter.removeParam(SearchFilter.SERVICE_TYPE);
+ }
+
List<XXPluginInfo> xObjList = searchRangerObjects(searchFilter,
searchFields, sortFields, retList);
List<Object[]> objectsList = null;
@@ -126,7 +134,10 @@ public class RangerPluginInfoService {
}
RangerPluginInfo obj =
populateViewObjectWithServiceVersionInfo(xObj, xxServiceVersionInfo,
hasAssociatedTagService);
- objList.add(obj);
+
+ if (StringUtils.isBlank(serviceTypeToSearch) ||
StringUtils.equals(serviceTypeToSearch, obj.getServiceType())) {
+ objList.add(obj);
+ }
}
retList.setList(objList);
@@ -140,6 +151,11 @@ public class RangerPluginInfoService {
ret.setCreateTime(xObj.getCreateTime());
ret.setUpdateTime(xObj.getUpdateTime());
ret.setServiceName(xObj.getServiceName());
+
+ String serviceType =
daoManager.getXXServiceDef().findServiceDefTypeByServiceName(ret.getServiceName());
+ if (StringUtils.isNotBlank(serviceType)) {
+ ret.setServiceType(serviceType);
+ }
ret.setHostName(xObj.getHostName());
ret.setAppType(xObj.getAppType());
ret.setIpAddress(xObj.getIpAddress());
@@ -166,6 +182,11 @@ public class RangerPluginInfoService {
ret.setCreateTime(xObj.getCreateTime());
ret.setUpdateTime(xObj.getUpdateTime());
ret.setServiceName(xObj.getServiceName());
+
+ String serviceType =
daoManager.getXXServiceDef().findServiceDefTypeByServiceName(ret.getServiceName());
+ if (StringUtils.isNotBlank(serviceType)) {
+ ret.setServiceType(serviceType);
+ }
ret.setHostName(xObj.getHostName());
ret.setAppType(xObj.getAppType());
ret.setIpAddress(xObj.getIpAddress());
diff --git a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
old mode 100644
new mode 100755
index bf087a9..328cf26
--- a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
+++ b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
@@ -321,6 +321,10 @@
<query>select MAX(obj.id) from XXServiceDef obj</query>
</named-query>
+ <named-query name="XXServiceDef.findServiceDefNameByServiceName">
+ <query>select obj.name from XXServiceDef obj, XXService
serviceObj where obj.id = serviceObj.type and serviceObj.name = :name</query>
+ </named-query>
+
<!-- XXResourceDef -->
<named-query name="XXResourceDef.findByNameAndDefId">
<query>select obj from XXResourceDef obj where obj.name = :name
and obj.defId = :defId order by obj.level</query>
diff --git
a/security-admin/src/main/webapp/scripts/collections/XABaseCollection.js
b/security-admin/src/main/webapp/scripts/collections/XABaseCollection.js
index aeab19e..8b7a68d 100644
--- a/security-admin/src/main/webapp/scripts/collections/XABaseCollection.js
+++ b/security-admin/src/main/webapp/scripts/collections/XABaseCollection.js
@@ -99,9 +99,6 @@ define(function(require) {
newState.pageSize = pageSize ? pageSize :
state.pageSize;
newState.currentPage = startIndex === 0 ? 0 :
Math.ceil(startIndex / newState.pageSize);
newState.startIndex = startIndex;
- if(this.mode === "client") {
- newState.pageSize =
XAGlobals.settings.PAGE_SIZE;
- }
//newState.totalPages = totalCount === 0 ? 0 :
Math.ceil(totalCount / serverState.pageSize);
return newState;
diff --git
a/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js
b/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js
index 44d7dc7..8078829 100644
--- a/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js
+++ b/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js
@@ -276,6 +276,7 @@ define(function(require) {
roles : 'Roles',
userWithGrantRolePrivilege : 'Users (Grant privilege)',
groupWithGrantRolePrivilege : 'Groups (Grant privilege)',
+ applicationType :
'Application',
},
btn : {
@@ -450,7 +451,7 @@ define(function(require) {
noDeleteGroupRow :'Please select group first to
delete.',
plsSelectUserToSetVisibility :' Please select user to set
visibility or selected user is already visible/hidden.',
plsSelectGroupToSetVisibility:' Please select group to set
visibility or selected group is already visible/hidden.',
- activationTimeDelayMsg :'Policy activation time delayed
by more than 1hr from last update time.',
+ activationTimeDelayMsg : 'Policy is updated but not yet
used for any enforcement.',
pleaseSelectAccessTypeForTagMasking : 'Please select access
type first to enable add masking options.',
addUserOrGroupOrRoleForDelegateAdmin : 'Please select
user/group/role for the selected permission(s)',
policyLabelsinfo : 'Enter label of policy',
diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
index f18229a..5fca82c 100644
--- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
+++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
@@ -1715,6 +1715,20 @@ define(function(require) {
});
}
+ //remove sort caret on grids
+ XAUtils.backgirdSort = function(col){
+ col.on('backgrid:sort', function(model) {
+ // No ids so identify model with CID
+ var cid = model.cid;
+ var filtered = model.collection.filter(function(model) {
+ return model.cid !== cid;
+ });
+ _.each(filtered, function(model) {
+ model.set('direction', null);
+ });
+ });
+ }
+
return XAUtils;
});
\ No newline at end of file
diff --git
a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
index def5e22..f7237fd 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
@@ -198,6 +198,7 @@ define(function(require) {
<th class="renderable ruser"></th>\
<th class="renderable ruser"></th>\
<th class="renderable ruser"></th>\
+ <th class="renderable ruser"></th>\
<th class="renderable cip"
colspan="3">Policy ( Time )<i class="icon-info-sign m-l-sm" data-id
="policyTimeDetails"></th>\
<th class="renderable cip" colspan="3">Tag ( Time )<i
class="icon-info-sign m-l-sm" data-id ="tagPolicyTimeDetails"></th>\
</tr>');
@@ -300,7 +301,7 @@ define(function(require) {
//To use existing collection
this.pluginInfoList.url =
'service/plugins/plugins/info';
this.pluginInfoList.modelAttrName =
'pluginInfoList';
-
this.pluginInfoList.switchMode("client")
+
this.pluginInfoList.switchMode("client", {fetch:false});
if(_.isEmpty(App.vsHistory.pluginStatus)){
this.pluginInfoList.fetch({cache : false});
}
@@ -648,10 +649,11 @@ define(function(require) {
},
addSearchForPluginStatusTab : function(){
var that = this , query = '';
- var searchOpt = [localization.tt("lbl.serviceName"),
localization.tt("lbl.serviceType"),
+ var searchOpt = [localization.tt("lbl.serviceName"),
localization.tt("lbl.serviceType"),localization.tt("lbl.applicationType"),
localization.tt("lbl.agentIp"),
localization.tt("lbl.hostName")];
- var serverAttrName = [{text :
localization.tt("lbl.serviceName"), label :"serviceName"},{text :
localization.tt("lbl.serviceType"), label :"pluginAppType"},
- {text :
localization.tt("lbl.agentIp"), label :"pluginIpAddress"}, {text :
localization.tt("lbl.hostName"), label :"pluginHostName"}];
+ var serverAttrName = [{text :
localization.tt("lbl.serviceName"), label :"serviceName"},{text :
localization.tt("lbl.applicationType"), label :"pluginAppType"},
+ {text :
localization.tt("lbl.agentIp"), label :"pluginIpAddress"}, {text :
localization.tt("lbl.hostName"), label :"pluginHostName"},
+ {text :
localization.tt("lbl.serviceType"), label :"serviceType"}];
_.map(App.vsHistory.pluginStatus, function(m){ query
+= '"'+m.get('category')+'":"'+m.get('value')+'"'; });
var pluginAttr = {
placeholder :
localization.tt('msg.searchForPluginStatus'),
@@ -668,10 +670,17 @@ define(function(require) {
callback(serviceList.map(function(model){return model.get('name');}));
});
break;
- }
-
+
+ case
'Service Type':
+
var serviveType = [];
+
that.serviceDefList.each(function(m){
+
serviveType.push({ 'label' : m.get('name') , 'value' : m.get('name')
});
+
});
+
callback(serviveType);
+
break;
+ }
}
- }
+ }
}
this.visualSearch = XAUtils.addVisualSearch(searchOpt,
serverAttrName, this.pluginInfoList, pluginAttr);
this.setEventsToFacets(this.visualSearch,
App.vsHistory.pluginStatus);
@@ -1532,52 +1541,72 @@ define(function(require) {
},
renderPluginInfoTable : function(){
this.ui.tableList.removeClass("clickable");
- this.rTableList.show(new XATableLayout({
- columns: this.getPluginInfoColums(),
- collection: this.pluginInfoList,
- includeFilter : false,
- gridOpts : {
- row : Backgrid.Row.extend({}),
- header : XABackgrid,
- emptyText : 'No plugin status
found!'
- }
- }));
- },
- getPluginInfoColums : function(){
- var that = this, cols ={
+ this.rTableList.show(new XATableLayout({
+ columns: this.getPluginInfoColums(),
+ collection: this.pluginInfoList,
+ includePagination : false,
+ includeFilter : false,
+ gridOpts : {
+ row : Backgrid.Row.extend({}),
+ header : XABackgrid,
+ emptyText : 'No plugin status
found!'
+ }
+ }));
+ XAUtils.backgirdSort(this.pluginInfoList);
+ },
+ getPluginInfoColums : function(){
+ var that = this, cols ={
serviceName : {
cell : 'html',
label :
localization.tt("lbl.serviceName"),
editable:false,
- sortable:false,
+ sortable:true,
formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue,
model) {
- rawValue =
_.escape(rawValue);
- return '<span
title="'+rawValue+'">'+rawValue+'</span>';
- }
- }),
+ rawValue =
_.escape(rawValue);
+ return '<span
title="'+rawValue+'">'+rawValue+'</span>';
+ }
+ }),
+ },
+ serviceType : {
+ cell : 'html',
+ label :
localization.tt("lbl.serviceType"),
+ editable:false,
+ sortable:true,
+ formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
+ fromRaw: function (rawValue,
model) {
+ if(_.isEmpty(rawValue)
|| _.isUndefined(rawValue)){
+ return
'<center>--</center>';
+ }
+ rawValue =
_.escape(rawValue);
+ return '<span
title="'+rawValue+'">'+rawValue+'</span>';
+ }
+ }),
},
appType : {
cell : 'html',
- label :
localization.tt("lbl.serviceType"),
+ label :
localization.tt("lbl.applicationType"),
editable:false,
- sortable:false,
+ sortable:true,
formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue,
model) {
- rawValue =
_.escape(rawValue);
- return '<span
title="'+rawValue+'">'+rawValue+'</span>';
- }
- }),
+ rawValue =
_.escape(rawValue);
+ return '<span
title="'+rawValue+'">'+rawValue+'</span>';
+ }
+ }),
},
hostName : {
cell : 'html',
label :
localization.tt("lbl.hostName"),
editable:false,
- sortable:false,
+ sortable:true,
formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue,
model) {
rawValue =
_.escape(rawValue);
- return '<span
title="'+rawValue+'">'+rawValue+'</span>';
+ if(_.isEmpty(rawValue)
|| _.isUndefined(rawValue)){
+ return
'<center>--</center>';
+ }
+ return '<span
title="'+rawValue+'">'+rawValue+'</span>';
}
}),
},
@@ -1585,7 +1614,7 @@ define(function(require) {
cell : 'string',
label :
localization.tt("lbl.agentIp"),
editable:false,
- sortable:false
+ sortable:true,
},
lastPolicyUpdateTime : {
cell : 'html',
@@ -1601,7 +1630,7 @@ define(function(require) {
||
_.isNull(model.get('info').lastPolicyUpdateTime)){
return
'<center>--</center>';
}
- return
Globalize.format(new Date(parseInt(model.get('info')['lastPolicyUpdateTime'])),
"MM/dd/yyyy hh:mm:ss tt")
+ return
that.setTimeStamp(new Date(parseInt(model.get('info')['lastPolicyUpdateTime']))
, moment);
}
})
},
@@ -1619,7 +1648,7 @@ define(function(require) {
||
_.isNull(model.get('info').policyDownloadTime)){
return
'<center>--</center>';
}
- return
Globalize.format(new Date(parseInt(model.get('info')['policyDownloadTime'])),
"MM/dd/yyyy hh:mm:ss tt")
+ return
that.setTimeStamp(new Date(parseInt(model.get('info')['policyDownloadTime'])) ,
moment);
}
})
},
@@ -1642,10 +1671,10 @@ define(function(require) {
var
lastUpdateDate = new Date(parseInt(model.get('info')['lastPolicyUpdateTime']));
if(that.isDateDifferenceMoreThanHr(activeDate, lastUpdateDate)){
return
'<i class="icon-exclamation-sign activePolicyAlert"
title="'+localization.tt("msg.activationTimeDelayMsg")+'"></i>'
-
+ Globalize.format(activeDate, "MM/dd/yyyy hh:mm:ss tt");
+
+ that.setTimeStamp(activeDate , moment);
}
}
- return
Globalize.format(activeDate, "MM/dd/yyyy hh:mm:ss tt");
+ return
that.setTimeStamp(activeDate , moment);
}
})
},
@@ -1667,7 +1696,7 @@ define(function(require) {
||
_.isNull(model.get('info').lastTagUpdateTime)){
return
'<center>--</center>';
}
- return
Globalize.format(new Date(parseInt(model.get('info')['lastTagUpdateTime'])),
"MM/dd/yyyy hh:mm:ss tt")
+ return
that.setTimeStamp(new Date(parseInt(model.get('info')['lastTagUpdateTime'])) ,
moment);
}
})
},
@@ -1685,7 +1714,8 @@ define(function(require) {
||
_.isNull(model.get('info').tagDownloadTime)){
return
'<center>--</center>';
}
- return
Globalize.format(new Date(parseInt(model.get('info')['tagDownloadTime'])),
"MM/dd/yyyy hh:mm:ss tt")
+ return
that.setTimeStamp(new Date(parseInt(model.get('info')['tagDownloadTime'])) ,
moment);
+
}
})
},
@@ -1708,10 +1738,11 @@ define(function(require) {
var
lastUpdateDate = new Date(parseInt(model.get('info')['lastTagUpdateTime']));
if(that.isDateDifferenceMoreThanHr(activeDate, lastUpdateDate)){
return '<i class="icon-exclamation-sign activePolicyAlert"
title="'+localization.tt("msg.activationTimeDelayMsg")+'"></i>'
-
+ Globalize.format(activeDate, "MM/dd/yyyy hh:mm:ss tt");
+
+ that.setTimeStamp(activeDate , moment);
}
}
- return
Globalize.format(activeDate, "MM/dd/yyyy hh:mm:ss tt");
+ return
that.setTimeStamp(activeDate , moment);
+
}
})
},
@@ -1834,9 +1865,16 @@ define(function(require) {
},
isDateDifferenceMoreThanHr : function(date1, date2){
- var diff = Math.abs(date1 - date2) / 36e5;
- return parseInt(diff) >= 1 ? true : false;
- },
+ var diff = date1 - date2 / 36e5;
+ return parseInt(diff) < 0 ? true : false;
+ },
+
+ //Time stamp
+ setTimeStamp : function(time, moment) {
+ return '<span title="'+Globalize.format(time, "MM/dd/yyyy
hh:mm:ss tt")+'">'+Globalize.format(time, "MM/dd/yyyy hh:mm:ss tt")
+ + '<div><small style="color :
#8c8c8c">'+moment(time).fromNow()+'</small></div></span>'
+ },
+
onRefresh : function(){
var that =this, coll,params = {};
var lastUpdateTime = Globalize.format(new Date(),
"MM/dd/yyyy hh:mm:ss tt");
@@ -1857,7 +1895,7 @@ define(function(require) {
coll = this.policyExportAuditList;
break;
case "#pluginStatus":
- this.pluginInfoList.switchMode("client");
+ this.pluginInfoList.switchMode("client",
{fetch:false});
coll = this.pluginInfoList;
break;
case "#userSync":
@@ -1907,7 +1945,7 @@ define(function(require) {
this.collection =
this.policyExportAuditList;
break;
case "#pluginStatus":
-
this.pluginInfoList.switchMode("client");
+
this.pluginInfoList.switchMode("client", {fetch:false});
this.collection = this.pluginInfoList;
break;
case "#userSync":
@@ -2019,4 +2057,4 @@ define(function(require) {
});
return AuditLayout;
-});
\ No newline at end of file
+});