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 8445329 RANGER-2670 : Bookmark functionality for Report Tab and Add
sort By query param in URL.
8445329 is described below
commit 84453294076e1bfe4739a0008543a8402292014b
Author: Nitin Galave <[email protected]>
AuthorDate: Wed Jan 29 17:13:06 2020 +0530
RANGER-2670 : Bookmark functionality for Report Tab and Add sort By query
param in URL.
---
.../main/java/org/apache/ranger/biz/XUserMgr.java | 10 +-
.../org/apache/ranger/service/XTrxLogService.java | 2 +
.../scripts/collection_bases/VXTrxLogListBase.js | 2 +-
.../webapp/scripts/collections/XABaseCollection.js | 3 +-
.../main/webapp/scripts/controllers/Controller.js | 5 +-
.../webapp/scripts/modules/globalize/message/en.js | 10 +-
.../src/main/webapp/scripts/routers/Router.js | 2 +-
.../src/main/webapp/scripts/utils/XAUtils.js | 64 +++-
.../webapp/scripts/views/kms/KMSTableLayout.js | 8 +
.../views/permissions/ModulePermsTableLayout.js | 5 +-
.../views/policies/RangerPolicyTableLayout.js | 5 +-
.../views/reports/AuditAccessLogDetailView.js | 86 ++++++
.../webapp/scripts/views/reports/AuditLayout.js | 340 ++++++++++++++-------
.../scripts/views/reports/UserAccessLayout.js | 175 +++++++----
.../webapp/scripts/views/users/UserTableLayout.js | 7 +-
security-admin/src/main/webapp/styles/xa.css | 7 +
.../reports/AuditAccessLogDetail_tmpl.html | 214 +++++++++++++
.../templates/reports/UserAccessLayout_tmpl.html | 2 +-
18 files changed, 754 insertions(+), 193 deletions(-)
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/XUserMgr.java
b/security-admin/src/main/java/org/apache/ranger/biz/XUserMgr.java
old mode 100644
new mode 100755
index 037c591..1c29d82
--- a/security-admin/src/main/java/org/apache/ranger/biz/XUserMgr.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/XUserMgr.java
@@ -1752,8 +1752,10 @@ public class XUserMgr extends XUserMgrBase {
} catch (Exception e){
logger.error("Error getting the exact match of user
=>"+e);
}
- if(vXUserList.getVXUsers().isEmpty()) {
- searchCriteria.setSortBy("id");
+ if (vXUserList.getVXUsers().isEmpty()) {
+ if (StringUtils.isBlank(searchCriteria.getSortBy())) {
+ searchCriteria.setSortBy("id");
+ }
vXUserList = xUserService.searchXUsers(searchCriteria);
}
if(vXUserList!=null &&
!hasAccessToModule(RangerConstants.MODULE_USER_GROUPS)){
@@ -1861,7 +1863,9 @@ public class XUserMgr extends XUserMgrBase {
logger.error("Error getting the exact match of group
=>"+e);
}
if(vXGroupList.getList().isEmpty()) {
- searchCriteria.setSortBy("id");
+ if(StringUtils.isBlank(searchCriteria.getSortBy())) {
+ searchCriteria.setSortBy("id");
+ }
vXGroupList=xGroupService.searchXGroups(searchCriteria);
}
diff --git
a/security-admin/src/main/java/org/apache/ranger/service/XTrxLogService.java
b/security-admin/src/main/java/org/apache/ranger/service/XTrxLogService.java
index 38884c7..c892813 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XTrxLogService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XTrxLogService.java
@@ -179,6 +179,8 @@ public class XTrxLogService extends
XTrxLogServiceBase<XXTrxLog, VXTrxLog> {
VXTrxLogList vxTrxLogList = new VXTrxLogList();
vxTrxLogList.setStartIndex(startIndex);
vxTrxLogList.setPageSize(pageSize);
+ vxTrxLogList.setSortBy(searchCriteria.getSortBy());
+ vxTrxLogList.setSortType(searchCriteria.getSortType());
if (session != null && (session.isKeyAdmin() ||
session.isAuditKeyAdmin()) ) {
vxTrxLogList.setVXTrxLogs(keyAdminTrxLogList);
} else {
diff --git
a/security-admin/src/main/webapp/scripts/collection_bases/VXTrxLogListBase.js
b/security-admin/src/main/webapp/scripts/collection_bases/VXTrxLogListBase.js
index 8e24b71..328a6a1 100644
---
a/security-admin/src/main/webapp/scripts/collection_bases/VXTrxLogListBase.js
+++
b/security-admin/src/main/webapp/scripts/collection_bases/VXTrxLogListBase.js
@@ -54,7 +54,7 @@ define(function(require){
return this.constructor.nonCrudOperation.call(this,
url, 'GET', options);
},
comparator : function(model) {
- return -model.get("id");
+ // return -model.get("id");
}
},{
// static class members
diff --git
a/security-admin/src/main/webapp/scripts/collections/XABaseCollection.js
b/security-admin/src/main/webapp/scripts/collections/XABaseCollection.js
index 8b7a68d..b497a79 100644
--- a/security-admin/src/main/webapp/scripts/collections/XABaseCollection.js
+++ b/security-admin/src/main/webapp/scripts/collections/XABaseCollection.js
@@ -45,7 +45,8 @@ define(function(require) {
*/
state : {
firstPage: 0,
- pageSize : XAGlobals.settings.PAGE_SIZE
+ pageSize : XAGlobals.settings.PAGE_SIZE,
+ order : 1
},
mode : 'server',
/**
diff --git a/security-admin/src/main/webapp/scripts/controllers/Controller.js
b/security-admin/src/main/webapp/scripts/controllers/Controller.js
index 99b69a4..1c3ec62 100755
--- a/security-admin/src/main/webapp/scripts/controllers/Controller.js
+++ b/security-admin/src/main/webapp/scripts/controllers/Controller.js
@@ -56,7 +56,7 @@ define(function(require) {
},
//************** Analytics(reports) Related *********************/
- userAccessReportAction : function(){
+ userAccessReportAction : function(tab){
MAppState.set({ 'currentTab' :
XAGlobals.AppTabs.AccessManager.value });
var view =
require('views/reports/UserAccessLayout');
var RangerPolicyList =
require('collections/RangerPolicyList');
@@ -67,7 +67,8 @@ define(function(require) {
App.rContent.show(new view({
collection : new RangerPolicyList(),
groupList : new VXGroupList(),
- userList : new VXUserList()
+ userList : new VXUserList(),
+ urlQueryParams : tab.indexOf("?") !== -1 ?
tab.substring(tab.indexOf("?") + 1) : undefined,
}));
},
auditReportAction : function(tab){
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 a559248..d8838c0 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
@@ -277,8 +277,13 @@ define(function(require) {
roles : 'Roles',
userWithGrantRolePrivilege : 'Users (Grant privilege)',
groupWithGrantRolePrivilege : 'Groups (Grant privilege)',
- applicationType :
'Application',
- displayName :
'Display Name',
+ applicationType : 'Application',
+ displayName : 'Display Name',
+ auditAccessDetail : 'Audit Access Log Detail',
+ hiveQuery : 'Hive Query',
+ clientIP : 'Client IP',
+ eventCount : 'Event Count',
+ tags : 'Tags',
},
btn : {
@@ -454,6 +459,7 @@ define(function(require) {
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 is updated but not yet
used for any enforcement.',
+ downloadTimeDelayMsg : 'Policy is updated but not yet
downloaded(sync-up with Ranger).',
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/routers/Router.js
b/security-admin/src/main/webapp/scripts/routers/Router.js
index 14f4916..7c893e5 100644
--- a/security-admin/src/main/webapp/scripts/routers/Router.js
+++ b/security-admin/src/main/webapp/scripts/routers/Router.js
@@ -35,7 +35,7 @@ function(Backbone, Marionette, localization, MAppState,
XAUtil){
"!/policymanager/:tag" :
"serviceManagerAction",
/****** Analytics Report related **********************/
- "!/reports/userAccess" :
"userAccessReportAction",
+ "!/reports/:userAccess" :
"userAccessReportAction",
/****** Audit Report related **********************/
"!/reports/audit/:tab"
: "auditReportAction",
diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
index 5ec258f..0b172eb 100644
--- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
+++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
@@ -790,12 +790,6 @@ define(function(require) {
var serverParamName = _.findWhere(serverAttrName, {
text : m.attributes.category
});
- // pass label in url params
- // if(_.isUndefined(serverParamName)) {
- // var serverParamName = _.findWhere(serverAttrName, {
- // label : m.attributes.category
- // });
- // }
var extraParam = {};
if (serverParamName && _.has(serverParamName, 'multiple') &&
serverParamName.multiple) {
extraParam[serverParamName.label] =
XAUtils.enumLabelToValue(serverParamName.optionsArr, m.get('value'));
@@ -830,6 +824,21 @@ define(function(require) {
}
})
})
+
+ if(!_.contains(["vXUsers","vXGroups","roles","vXModuleDef"],
collection.modelAttrName)) {
+ //set sortBy value to url
+ if(!_.isUndefined(collection.queryParams) &&
collection.queryParams.sortBy && !_.isNull(collection.queryParams.sortBy)) {
+ var sortparams = _.pick(collection.queryParams, 'sortBy');
+ collection.state.order == 1 ? sortparams['sortType'] =
"descending" : sortparams['sortType'] = "ascending";
+ urlLabelParam = _.extend(urlLabelParam, sortparams)
+ }
+ //set sortKey value to url
+ if(!_.isUndefined(collection.state) &&
collection.state.sortKey && !_.isNull(collection.state.sortKey) &&
!_.contains(urlLabelParam, 'sortBy')) {
+ var sortparams = _.pick(collection.state, 'sortKey');
+ collection.state.order == 1 ? sortparams['sortType'] =
"descending" : sortparams['sortType'] = "ascending";
+ urlLabelParam = _.extend(urlLabelParam, sortparams)
+ }
+ }
XAUtils.changeParamToUrlFragment(urlLabelParam,
collection.modelName);
collection.fetch({
reset : true,
@@ -1741,16 +1750,33 @@ define(function(require) {
}
//remove sort caret on grids
- XAUtils.backgirdSort = function(col){
+ XAUtils.backgridSort = function(col){
+ if(!_.isUndefined(col.queryParams) && col.queryParams.sortBy &&
!_.isNull(col.queryParams.sortBy)) {
+ var sortparams = _.pick(col.queryParams, 'sortBy');
+ col.state.order == 1 ? sortparams['sortType'] = "descending" :
sortparams['sortType'] = "ascending";
+ XAUtils.changeParamToUrlFragment(sortparams);
+ }
col.on('backgrid:sort', function(model) {
// No ids so identify model with CID
- var cid = model.cid;
+ var cid = model.cid, urlObj = {};
var filtered = model.collection.filter(function(model) {
return model.cid !== cid;
});
_.each(filtered, function(model) {
model.set('direction', null);
});
+ if(Backbone.history.fragment.indexOf("?") !== -1) {
+ var urlFragment =
Backbone.history.fragment.substring(Backbone.history.fragment.indexOf("?") + 1);
+ urlObj =
XAUtils.changeUrlToSearchQuery(decodeURIComponent(urlFragment));
+ }
+ urlObj['sortBy'] = model.get('name');
+ if(_.isNull(model.get('direction'))) {
+ delete urlObj.sortType;
+ delete urlObj.sortBy;
+ } else {
+ urlObj['sortType'] = model.get('direction');
+ }
+ XAUtils.changeParamToUrlFragment(urlObj);
});
}
@@ -1818,11 +1844,6 @@ define(function(require) {
return query_string;
}
- //convert URL to visual search query parameter
- XAUtils.changeUrlToVSSearchQuery = function(urlQuery) {
- return '"'+decodeURIComponent(urlQuery.replace(/"/g,
'\\"').replace(/&/g, '""').replace(/=/g, '":"'))+'"'
- }
-
//Return key from serverAttrName for vsSearch
XAUtils.filterKeyForVSQuery = function(list, key) {
var value = _.filter(list, function(m) {
@@ -1843,5 +1864,22 @@ define(function(require) {
}).replace(/\s+/g, '');
}
+ //Set backgrid table sorting direction
+ XAUtils.backgridSortType = function(collection, column) {
+ _.filter(column, function(val, key){
+ if(key == collection.queryParams.sortBy) {
+ val['direction'] = collection.state.order == 1 ? "descending"
: "ascending"
+ }
+ })
+ }
+
+ //Set default sort by and sort order in collection
+ XAUtils.setSorting = function(collectin, sortParams) {
+ _.extend(collectin.queryParams,{ 'sortBy' : sortParams.sortBy });
+ if(sortParams.sortType) {
+ sortParams.sortType == "ascending" ?
collectin.setSorting(sortParams.sortBy,-1) :
collectin.setSorting(sortParams.sortBy,1);
+ }
+ }
+
return XAUtils;
});
\ No newline at end of file
diff --git a/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js
b/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js
index 4954b74..ccc7b45 100755
--- a/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js
@@ -251,6 +251,14 @@ define(function(require){
serverAttrName = [ {text : "Key Name",
label :"name", urlLabel : "keyName"}];
}
var query = (!_.isUndefined(coll.VSQuery)) ?
coll.VSQuery : '';
+ if(!_.isUndefined(this.urlQueryParams)) {
+ var urlQueryParams =
XAUtil.changeUrlToSearchQuery(this.urlQueryParams);
+ _.map(urlQueryParams, function(val , key) {
+ if (_.some(serverAttrName, function(m){return m.urlLabel
== key})) {
+ query +=
'"'+XAUtil.filterKeyForVSQuery(serverAttrName, key)+'":"'+val+'"';
+ }
+ });
+ }
var pluginAttr = {
placeholder :placeholder,
container : this.ui.visualSearch,
diff --git
a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js
b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js
index 798fe79..9e2260a 100644
---
a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js
+++
b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js
@@ -231,9 +231,10 @@ define(function(require){
if(!_.isUndefined(this.urlQueryParams)) {
var urlQueryParams =
XAUtil.changeUrlToSearchQuery(this.urlQueryParams);
_.map(urlQueryParams, function(val , key) {
- query += '"'+XAUtil.filterKeyForVSQuery(serverAttrName,
key)+'":"'+val+'"';
+ if (_.some(serverAttrName, function(m){return m.urlLabel
== key})) {
+ query +=
'"'+XAUtil.filterKeyForVSQuery(serverAttrName, key)+'":"'+val+'"';
+ }
});
- // query +=
XAUtil.changeUrlToVSSearchQuery(this.urlQueryParams);
}
var pluginAttr = {
placeholder
:localization.tt('h.searchForPermissions'),
diff --git
a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
index 4ee9487..5162dec 100644
---
a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
+++
b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
@@ -501,9 +501,10 @@ define(function(require){
if(!_.isUndefined(this.urlQueryParams)) {
var urlQueryParams =
XAUtil.changeUrlToSearchQuery(this.urlQueryParams);
_.map(urlQueryParams, function(val , key) {
- query += '"'+XAUtil.filterKeyForVSQuery(serverAttrName,
key)+'":"'+val+'"';
+ if (_.some(serverAttrName, function(m){return m.urlLabel
== key})) {
+ query +=
'"'+XAUtil.filterKeyForVSQuery(serverAttrName, key)+'":"'+val+'"';
+ }
});
- // query +=
XAUtil.changeUrlToVSSearchQuery(this.urlQueryParams);
}
var pluginAttr = {
placeholder
:localization.tt('h.searchForPolicy'),
diff --git
a/security-admin/src/main/webapp/scripts/views/reports/AuditAccessLogDetailView.js
b/security-admin/src/main/webapp/scripts/views/reports/AuditAccessLogDetailView.js
new file mode 100644
index 0000000..f70103e
--- /dev/null
+++
b/security-admin/src/main/webapp/scripts/views/reports/AuditAccessLogDetailView.js
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+define(function(require) {
+ 'use strict';
+
+ var Backbone = require('backbone');
+ var XAEnums = require('utils/XAEnums');
+ var XALinks = require('modules/XALinks');
+ var XAGlobals = require('utils/XAGlobals');
+ var localization = require('utils/XALangSupport');
+ var XAUtils = require('utils/XAUtils');
+
+ var AuditAccessLogDetailTmpl =
require('hbs!tmpl/reports/AuditAccessLogDetail_tmpl');
+
+ var AuditAccessLogDetailView = Backbone.Marionette.Layout.extend({
+
+ _viewName: 'AuditAccessLogDetailView',
+
+ template: AuditAccessLogDetailTmpl,
+
+ templateHelpers: function() {
+ var that = this;
+ return {
+ auditaccessDetail : this.auditaccessDetail,
+ eventTime : Globalize.format(new
Date(this.auditaccessDetail.eventTime), "MM/dd/yyyy hh:mm:ss tt"),
+ result : this.auditaccessDetail.accessResult == 1 ?
'Allowed' : 'Denied',
+ hiveQuery : ((this.auditaccessDetail.serviceType ===
XAEnums.ServiceType.Service_HIVE.label || this.auditaccessDetail.serviceType
=== XAEnums.ServiceType.Service_HBASE.label) &&
+ this.auditaccessDetail.aclEnforcer ===
"ranger-acl" && this.auditaccessDetail.requestData) ? true : false,
+
+ tag : this.tags ? this.tags.join() : undefined,
+ }
+ },
+
+ ui: {
+ copyQuery : '[data-name="copyQuery"]',
+ },
+
+ /** ui events hash */
+ events : function() {
+ var events = {};
+ events['click ' + this.ui.copyQuery] = 'copyQuery';
+ return events
+ },
+ /**
+ * Initialize a new AuditAccessLogDetailsView Layout
+ * @constructs
+ */
+ initialize: function(options) {
+ console.log("Initialized a Ranger Audit Access Log Details");
+ _.extend(this, _.pick(options, 'auditaccessDetail'));
+ if (this.auditaccessDetail.tags) {
+ var tag = JSON.parse(this.auditaccessDetail.tags);
+ this.tags = _.map(tag, function(m) {
+ return m.type
+ });
+ }
+ },
+
+ copyQuery: function(e) {
+ XAUtils.copyToClipboard(e ,
this.auditaccessDetail.requestData);
+ },
+
+ /** on close */
+ onClose: function() {}
+ });
+
+ return AuditAccessLogDetailView;
+});
\ 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 7345f5a..e50fa7d 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
@@ -48,6 +48,7 @@ define(function(require) {
var vPlugableServiceDiffDetail =
require('views/reports/PlugableServiceDiffDetail');
var vLoginSessionDetail =
require('views/reports/LoginSessionDetail');
var RangerZoneList = require('collections/RangerZoneList');
+ var AuditAccessLogDetail =
require('views/reports/AuditAccessLogDetailView');
var moment = require('moment');
require('bootstrap-datepicker');
@@ -137,21 +138,23 @@ define(function(require) {
}
//Add url params to vsHistory
if(!_.isUndefined(this.tab.split('?')[1])) {
- App.vsHistory[that.tab.split('?')[0]] = [];
+ App.vsHistory[that.tab.split('?')[0]] = [];
var searchFregment =
XAUtils.changeUrlToSearchQuery(decodeURIComponent(this.tab.substring(this.tab.indexOf("?")
+ 1)));
_.map (searchFregment, function(val, key) {
- if (_.isArray(val)) {
- _.map(val, function (v) {
- App.vsHistory[that.tab.split('?')[0]].push(new
Backbone.Model( {'category': key, 'value' : v}));
- })
- } else {
- App.vsHistory[that.tab.split('?')[0]].push(new
Backbone.Model( {'category': key, 'value' : val}));
+ if (key !== "sortBy" && key !== "sortType" && key !==
"sortKey") {
+ if (_.isArray(val)) {
+ _.map(val, function (v) {
+ App.vsHistory[that.tab.split('?')[0]].push(new
Backbone.Model( {'category': key, 'value' : v}));
+ })
+ } else {
+ App.vsHistory[that.tab.split('?')[0]].push(new
Backbone.Model( {'category': key, 'value' : val}));
+ }
}
} )
}
//if url params are not present then set a default value in Audit
assecc vsHistory
if(_.isEmpty(App.vsHistory.bigData)){
- var startDateModel = new
Backbone.Model({'category':'startDate', value:Globalize.format(new
Date(),"MM/dd/yyyy")});
+ var startDateModel = new Backbone.Model({'category':'Start
Date', value:Globalize.format(new Date(),"MM/dd/yyyy")});
App.vsHistory['bigData'].push(startDateModel);
}
},
@@ -184,6 +187,14 @@ define(function(require) {
this.ui.tab.find('li[class="active"]').removeClass();
this.ui.tab.find('[href="'+this.currentTab+'"]').parent().addClass('active');
} else {
+ var sortObj = {};
+ if(Backbone.history.fragment.indexOf("?") !== -1) {
+ var sortFragment =
Backbone.history.fragment.substring(Backbone.history.fragment.indexOf("?") + 1);
+ sortObj =
_.pick(XAUtils.changeUrlToSearchQuery(decodeURIComponent(sortFragment)),
'sortType','sortBy');
+ }
+ if(!_.isEmpty(sortObj)) {
+ XAUtils.setSorting(this.accessAuditList, sortObj);
+ }
this.renderBigDataTable();
this.addSearchForBigDataTab();
this.modifyTableForSubcolumns();
@@ -235,12 +246,16 @@ define(function(require) {
},
onTabChange : function(e){
- var that = this, tab;
+ var that = this, tab, sortObj = {};
tab = !_.isUndefined(e) ?
$(e.currentTarget).attr('href') : this.currentTab;
this.$el.parents('body').find('.datepicker').remove();
if (!_.isUndefined(e)) {
Backbone.history.navigate("!/reports/audit/"+
tab.slice(1), false)
}
+ if(Backbone.history.fragment.indexOf("?") !== -1) {
+ var sortFragment =
Backbone.history.fragment.substring(Backbone.history.fragment.indexOf("?") + 1);
+ sortObj =
_.pick(XAUtils.changeUrlToSearchQuery(decodeURIComponent(sortFragment)),
'sortType','sortBy');
+ }
switch (tab) {
case "#bigData":
this.currentTab = '#bigData';
@@ -259,8 +274,11 @@ define(function(require) {
case "#admin":
this.currentTab = '#admin';
App.vsHistory.admin =
XAUtils.removeEmptySearchValue(App.vsHistory.admin);
- this.trxLogList = new VXTrxLogList();
- this.renderAdminTable();
+ this.trxLogList = new VXTrxLogList();
+ if(!_.isEmpty(sortObj)) {
+ XAUtils.setSorting(this.trxLogList, sortObj);
+ }
+ this.renderAdminTable();
if(_.isEmpty(App.vsHistory.admin) &&
_.isUndefined(App.sessionId)){
this.trxLogList.fetch({
cache : false
@@ -277,9 +295,14 @@ define(function(require) {
this.currentTab = '#loginSession';
App.vsHistory.loginSession =
XAUtils.removeEmptySearchValue(App.vsHistory.loginSession);
this.authSessionList = new
VXAuthSession();
- this.renderLoginSessionTable();
+ if(!_.isEmpty(sortObj)) {
+ XAUtils.setSorting(this.authSessionList, sortObj);
+ } else {
+ _.extend(this.authSessionList.queryParams,{ 'sortBy'
: 'id' });
//Setting SortBy as id and sortType as
desc = 1
-
this.authSessionList.setSorting('id',1);
+
this.authSessionList.setSorting('id',1);
+ }
+ this.renderLoginSessionTable();
if(_.isEmpty(App.vsHistory.loginSession)){
this.authSessionList.fetch({
cache:false,
@@ -294,11 +317,16 @@ define(function(require) {
break;
case "#agent":
this.currentTab = '#agent';
- App.vsHistory.agent =
XAUtils.removeEmptySearchValue(App.vsHistory.agent);
+ App.vsHistory.agent =
XAUtils.removeEmptySearchValue(App.vsHistory.agent);
this.policyExportAuditList = new
VXPolicyExportAuditList();
var params = { priAcctId : 1 };
- that.renderAgentTable();
+ if(!_.isEmpty(sortObj)) {
+ XAUtils.setSorting(this.policyExportAuditList,
sortObj);
+ } else {
+ _.extend(this.policyExportAuditList.queryParams,{
'sortBy' : 'createDate' });
this.policyExportAuditList.setSorting('createDate',1);
+ }
+ that.renderAgentTable();
if(_.isEmpty(App.vsHistory.agent)){
this.policyExportAuditList.fetch({
cache : false,
@@ -317,6 +345,9 @@ define(function(require) {
App.vsHistory.pluginStatus =
XAUtils.removeEmptySearchValue(App.vsHistory.pluginStatus);
this.ui.visualSearch.show();
this.pluginInfoList = new
VXPolicyExportAuditList();
+ if(!_.isEmpty(sortObj)){
+ XAUtils.setSorting(this.pluginInfoList, sortObj);
+ }
this.renderPluginInfoTable();
this.modifyPluginStatusTableSubcolumns();
XAUtils.customPopover(this.$el.find('[data-id
="policyTimeDetails"]'),'Policy (Time
details)',localization.tt('msg.policyTimeDetails'),'left');
@@ -339,12 +370,17 @@ define(function(require) {
this.currentTab = '#userSync';
this.ui.visualSearch.show();
this.userSyncAuditList = new VXUserList();
+ if(!_.isEmpty(sortObj)) {
+ XAUtils.setSorting(this.userSyncAuditList, sortObj);
+ } else {
+ _.extend(this.userSyncAuditList.queryParams,{ 'sortBy'
: 'eventTime' });
+ this.userSyncAuditList.setSorting('eventTime',1);
+ }
this.renderUserSyncTable();
this.modifyUserSyncTableSubcolumns();
//To use existing collection
this.userSyncAuditList.url =
'service/assets/ugsyncAudits';
this.userSyncAuditList.modelAttrName =
'vxUgsyncAuditInfoList';
- this.userSyncAuditList.setSorting('id',1);
this.addSearchForUserSyncTab();
this.listenTo(this.userSyncAuditList, "request",
that.updateLastRefresh);
this.listenTo(this.userSyncAuditList, "sync reset",
that.showPageDetail);
@@ -768,7 +804,7 @@ define(function(require) {
{text : 'Start Date',label :'startDate',
urlLabel : 'startDate'},
{text : 'End Date',label :'endDate',
urlLabel : 'endDate'}];
if(_.isEmpty(App.vsHistory.userSync)){
- query = '"startDate": "'+Globalize.format(new
Date(),"MM/dd/yyyy")+'"';
+ query = '"Start Date": "'+Globalize.format(new
Date(),"MM/dd/yyyy")+'"';
App.vsHistory.userSync.push(new
Backbone.Model({'category':'startDate', value:Globalize.format(new
Date(),"MM/dd/yyyy")}));
}else{
_.map(App.vsHistory.userSync, function(a) {
@@ -902,7 +938,6 @@ define(function(require) {
});
}
});
- this.ui.tableList.addClass("clickable");
this.rTableList.show(new XATableLayout({
columns: this.getAdminTableColumns(),
collection:this.trxLogList,
@@ -912,7 +947,9 @@ define(function(require) {
header : XABackgrid,
emptyText : 'No service found!!'
}
- }));
+ }));
+ //Trigger backgrid sort event
+ XAUtils.backgridSort(this.trxLogList);
},
getExportImportTemplate : function(trxLogs){
var log = trxLogs.models[0],fields = '', values = '',
infoJson = {};
@@ -1027,12 +1064,10 @@ define(function(require) {
createDate : {
label : localization.tt("lbl.date") + '
( '+this.timezone+' )',
cell: "String",
- click : false,
- drag : false,
editable:false,
sortType: 'toggle',
- direction: 'descending',
- formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
+ sortable : true,
+ formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue,
model) {
return
Globalize.format(new Date(model.get('createDate')), "MM/dd/yyyy hh:mm:ss tt");
}
@@ -1085,6 +1120,9 @@ define(function(require) {
})
}
};
+ if (this.trxLogList.queryParams.sortBy &&
!_.isEmpty(this.trxLogList.queryParams.sortBy)) {
+ XAUtils.backgridSortType(this.trxLogList, cols);
+ }
return this.trxLogList.constructor.getTableCols(cols,
this.trxLogList);
},
@@ -1102,51 +1140,66 @@ define(function(require) {
},
onClick: function (e) {
var self = this ;
- if($(e.target).hasClass('tagsColumn') ||
$(e.target).closest('td').hasClass("tagsColumn")){
- return;
- }
- if(this.model.get('repoType')){
- var repoType = this.model.get('repoType');
- }
- var policyId =
this.model.get('policyId');
- if(policyId == -1){
- return;
- }
- var eventTime = this.model.get('eventTime');
+ if($(e.target).hasClass('policyIdColumn') ||
$(e.target).closest('td').hasClass("policyIdColumn")) {
+ if(this.model.get('repoType')){
+ var repoType = this.model.get('repoType');
+ }
+ var policyId =
this.model.get('policyId');
+ if(policyId == -1){
+ return;
+ }
+ var eventTime = this.model.get('eventTime');
- var policyVersion = this.model.get('policyVersion');
+ var policyVersion =
this.model.get('policyVersion');
- var application = this.model.get('agentId');
+ var application = this.model.get('agentId');
- var policy = new RangerPolicy({
- id: policyId,
- version:policyVersion
- });
- var policyVersionList =
policy.fetchVersions();
- var view = new RangerPolicyRO({
- policy: policy,
- policyVersionList :
policyVersionList,
- serviceDefList: that.serviceDefList,
- eventTime : eventTime,
- repoType : repoType
- });
- var modal = new
Backbone.BootstrapModal({
- animate : true,
- content : view,
- title:
localization.tt("h.policyDetails"),
- okText
:localization.tt("lbl.ok"),
- allowCancel : true,
- escape : true
- }).open();
- modal.$el.find('.cancel').hide();
- var policyVerEl =
modal.$el.find('.modal-footer').prepend('<div class="policyVer
pull-left"></div>').find('.policyVer');
- policyVerEl.append('<i id="preVer"
class="icon-chevron-left '+ ((policy.get('version')>1) ? 'active' : '')
+'"></i><text>Version '+ policy.get('version')
+'</text>').find('#preVer').click(function(e){
- view.previousVer(e);
- });
- var policyVerIndexAt =
policyVersionList.indexOf(policy.get('version'));
- policyVerEl.append('<i id="nextVer"
class="icon-chevron-right '+
(!_.isUndefined(policyVersionList[++policyVerIndexAt])? 'active' :
'')+'"></i>').find('#nextVer').click(function(e){
- view.nextVer(e);
- });
+ var policy = new RangerPolicy({
+ id: policyId,
+ version:policyVersion
+ });
+ var policyVersionList =
policy.fetchVersions();
+ var view = new RangerPolicyRO({
+ policy: policy,
+ policyVersionList :
policyVersionList,
+ serviceDefList: that.serviceDefList,
+ eventTime : eventTime,
+ repoType : repoType
+ });
+ var modal = new
Backbone.BootstrapModal({
+ animate : true,
+ content
: view,
+ title:
localization.tt("h.policyDetails"),
+ okText
:localization.tt("lbl.ok"),
+ allowCancel : true,
+ escape : true
+ }).open();
+ modal.$el.find('.cancel').hide();
+ var policyVerEl =
modal.$el.find('.modal-footer').prepend('<div class="policyVer
pull-left"></div>').find('.policyVer');
+ policyVerEl.append('<i
id="preVer" class="icon-chevron-left '+ ((policy.get('version')>1) ? 'active' :
'') +'"></i><text>Version '+ policy.get('version')
+'</text>').find('#preVer').click(function(e){
+ view.previousVer(e);
+ });
+ var policyVerIndexAt =
policyVersionList.indexOf(policy.get('version'));
+ policyVerEl.append('<i
id="nextVer" class="icon-chevron-right '+
(!_.isUndefined(policyVersionList[++policyVerIndexAt])? 'active' :
'')+'"></i>').find('#nextVer').click(function(e){
+ view.nextVer(e);
+ });
+ } else {
+ if($(e.target).hasClass('tagsColumn') ||
$(e.target).closest('td').hasClass("tagsColumn")) {
+ return;
+ }
+ var view = new AuditAccessLogDetail({
+ auditaccessDetail : this.model.attributes,
+ });
+ var modal = new Backbone.BootstrapModal({
+ animate : true,
+ content : view,
+ title: localization.tt("lbl.auditAccessDetail"),
+ okText :localization.tt("lbl.ok"),
+ allowCancel : true,
+ escape : true,
+ }).open();
+ modal.$el.find('.cancel').hide();
+ }
}
});
@@ -1161,14 +1214,17 @@ define(function(require) {
emptyText : 'No Access Audit found!'
}
}));
-
+ XAUtils.backgridSort(this.accessAuditList);
},
getColumns : function(){
var that = this;
var cols = {
policyId : {
- cell : "html",
+ // cell : "html",
+ cell:
Backgrid.HtmlCell.extend({
+ className :
'policyIdColumn'
+ }),
formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
fromRaw: function
(rawValue, model) {
if(rawValue ==
-1){
@@ -1187,15 +1243,19 @@ define(function(require) {
sortable : false
},
policyVersion: {
- label : localization.tt("lbl.policyVersion"),
- cell: "html",
- click: false,
- formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue, model) {
- rawValue = _.escape(rawValue);
- return '<span
title="'+rawValue+'">'+rawValue+'</span>';
- }
- }),
+ label : localization.tt("lbl.policyVersion"),
+ cell: "html",
+ click: false,
+ formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
+ fromRaw: function (rawValue, model) {
+ rawValue = _.escape(rawValue);
+ if(_.isUndefined(rawValue) ||
_.isEmpty(rawValue)) {
+ return '--'
+ } else {
+ return '<span
title="'+rawValue+'">'+rawValue+'</span>';
+ }
+ }
+ }),
drag: false,
sortable: false,
editable: false,
@@ -1207,8 +1267,7 @@ define(function(require) {
drag : false,
editable:false,
sortType: 'toggle',
- direction: 'descending',
- formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
+ formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
fromRaw: function
(rawValue, model) {
return
Globalize.format(new Date(rawValue), "MM/dd/yyyy hh:mm:ss tt");
}
@@ -1219,14 +1278,16 @@ define(function(require) {
cell: "String",
click : false,
drag : false,
- editable:false
+ editable:false,
+ sortable : false,
},
requestUser : {
label : 'User',
cell: "String",
click : false,
drag : false,
- editable:false
+ editable:false,
+ sortable : false,
},
repoName : {
label : 'Name / Type',
@@ -1269,6 +1330,7 @@ define(function(require) {
click : false,
drag : false,
editable:false,
+ sortable : false,
formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
fromRaw: function
(rawValue) {
var label = '',
html = '';
@@ -1318,19 +1380,23 @@ define(function(require) {
sortable:false,
editable:false
},
- clusterName : {
- label :
localization.tt("lbl.clusterName"),
- cell: 'html',
- click : false,
- drag : false,
- sortable:false,
- editable:false,
- formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
- fromRaw: function
(rawValue, model) {
- rawValue =
_.escape(rawValue);
- return '<span
title="'+rawValue+'">'+rawValue+'</span>';
- }
- }),
+ clusterName : {
+ label : localization.tt("lbl.clusterName"),
+ cell: 'html',
+ click : false,
+ drag : false,
+ sortable:false,
+ editable:false,
+ formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
+ fromRaw: function (rawValue, model) {
+ rawValue = _.escape(rawValue);
+ if (_.isUndefined(rawValue) ||
_.isEmpty(rawValue)) {
+ '--'
+ } else {
+ return '<span
title="'+rawValue+'">'+rawValue+'</span>';
+ }
+ }
+ }),
},
zoneName: {
label :
localization.tt("lbl.zoneName"),
@@ -1373,7 +1439,10 @@ define(function(require) {
}
}),
},
- };
+ };
+ if (this.accessAuditList.queryParams.sortBy &&
!_.isEmpty(this.accessAuditList.queryParams.sortBy)) {
+ XAUtils.backgridSortType(this.accessAuditList, cols);
+ }
return
this.accessAuditList.constructor.getTableCols(cols, this.accessAuditList);
},
renderLoginSessionTable : function(){
@@ -1388,7 +1457,8 @@ define(function(require) {
header : XABackgrid,
emptyText : 'No login session found!!'
}
- }));
+ }));
+ XAUtils.backgridSort(this.authSessionList);
},
getLoginSessionColumns : function(){
var authStatusList = [],authTypeList = [];
@@ -1407,7 +1477,7 @@ define(function(require) {
cell : "html",
editable:false,
sortType: 'toggle',
- direction: 'descending',
+ sortable : true,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue, model) {
var sessionId = model.get('id');
@@ -1490,6 +1560,7 @@ define(function(require) {
label :
localization.tt("lbl.loginTime")+ ' ( '+this.timezone+' )',
cell: "String",
editable:false,
+ sortable : false,
formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue,
model) {
return
Globalize.format(new Date(model.get('authTime')), "MM/dd/yyyy hh:mm:ss tt");
@@ -1497,6 +1568,9 @@ define(function(require) {
})
}
};
+ if (this.authSessionList.queryParams.sortBy &&
!_.isEmpty(this.authSessionList.queryParams.sortBy)) {
+ XAUtils.backgridSortType(this.authSessionList, cols);
+ }
return
this.authSessionList.constructor.getTableCols(cols, this.authSessionList);
},
renderAgentTable : function(){
@@ -1510,7 +1584,8 @@ define(function(require) {
header : XABackgrid,
emptyText : 'No plugin found!'
}
- }));
+ }));
+ XAUtils.backgridSort(this.policyExportAuditList);
},
getAgentColumns : function(){
var cols = {
@@ -1524,7 +1599,7 @@ define(function(require) {
label :
localization.tt('lbl.createDate')+ ' ( '+this.timezone+' )',
editable:false,
sortType: 'toggle',
- direction: 'descending'
+ sortable : true,
},
repositoryName : {
cell : 'html',
@@ -1593,6 +1668,9 @@ define(function(require) {
};
+ if (this.policyExportAuditList.queryParams.sortBy &&
!_.isEmpty(this.policyExportAuditList.queryParams.sortBy)) {
+ XAUtils.backgridSortType(this.policyExportAuditList, cols);
+ }
return
this.policyExportAuditList.constructor.getTableCols(cols,
this.policyExportAuditList);
},
renderPluginInfoTable : function(){
@@ -1608,7 +1686,7 @@ define(function(require) {
emptyText : 'No plugin status
found!'
}
}));
- XAUtils.backgirdSort(this.pluginInfoList);
+ XAUtils.backgridSort(this.pluginInfoList);
},
getPluginInfoColums : function(){
var that = this, cols ={
@@ -1716,6 +1794,20 @@ define(function(require) {
||
_.isNull(model.get('info').policyDownloadTime)){
return
'<center>--</center>';
}
+ var downloadDate = new
Date(parseInt(model.get('info')['policyDownloadTime']));
+
if(!_.isUndefined(model.get('info')['lastPolicyUpdateTime'])){
+ var
lastUpdateDate = new Date(parseInt(model.get('info')['lastPolicyUpdateTime']));
+
if(that.isDateDifferenceMoreThanHr(downloadDate, lastUpdateDate)){
+
if(moment(downloadDate).diff(moment(lastUpdateDate),'minutes') >= -2) {
+
return '<span class="text-warning"><i class="icon-exclamation-sign
activePolicyAlert" title="'+localization.tt("msg.downloadTimeDelayMsg")+'"></i>'
+
+ that.setTimeStamp(downloadDate , moment) +'</span>';
+ } else
{
+
return '<span class="text-error"><i class="icon-exclamation-sign
activePolicyAlert" title="'+localization.tt("msg.downloadTimeDelayMsg")+'"></i>'
+
+ that.setTimeStamp(downloadDate , moment)+'</span>';
+ }
+
+ }
+ }
return
that.setTimeStamp(new Date(parseInt(model.get('info')['policyDownloadTime'])) ,
moment);
}
})
@@ -1739,8 +1831,14 @@ define(function(require) {
if(!_.isUndefined(model.get('info')['lastPolicyUpdateTime'])){
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>'
-
+ that.setTimeStamp(activeDate , moment);
+
if(moment(activeDate).diff(moment(lastUpdateDate),'minutes') >= -2) {
+
return '<span class="text-warning"><i class="icon-exclamation-sign
activePolicyAlert"
title="'+localization.tt("msg.activationTimeDelayMsg")+'"></i>'
+
+ that.setTimeStamp(activeDate , moment) +'</span>';
+ } else
{
+
return '<span class="text-error"><i class="icon-exclamation-sign
activePolicyAlert"
title="'+localization.tt("msg.activationTimeDelayMsg")+'"></i>'
+
+ that.setTimeStamp(activeDate , moment)+'</span>';
+ }
+
}
}
return
that.setTimeStamp(activeDate , moment);
@@ -1783,6 +1881,20 @@ define(function(require) {
||
_.isNull(model.get('info').tagDownloadTime)){
return
'<center>--</center>';
}
+ var downloadTagDate =
new Date(parseInt(model.get('info')['tagDownloadTime']));
+
if(!_.isUndefined(model.get('info')['lastTagUpdateTime'])){
+ var
lastUpdateDate = new Date(parseInt(model.get('info')['lastTagUpdateTime']));
+
if(that.isDateDifferenceMoreThanHr(downloadTagDate, lastUpdateDate)){
+
if(moment(downloadTagDate).diff(moment(lastUpdateDate),'minutes') >= -2) {
+
return '<span class="text-warning"><i class="icon-exclamation-sign
activePolicyAlert" title="'+localization.tt("msg.downloadTimeDelayMsg")+'"></i>'
+
+ that.setTimeStamp(downloadTagDate , moment) +'</span>';
+ } else
{
+
return '<span class="text-error"><i class="icon-exclamation-sign
activePolicyAlert" title="'+localization.tt("msg.downloadTimeDelayMsg")+'"></i>'
+
+ that.setTimeStamp(downloadTagDate , moment)+'</span>';
+ }
+
+ }
+ }
return
that.setTimeStamp(new Date(parseInt(model.get('info')['tagDownloadTime'])) ,
moment);
}
@@ -1806,16 +1918,24 @@ define(function(require) {
if(!_.isUndefined(model.get('info')['lastTagUpdateTime'])){
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>'
-
+ that.setTimeStamp(activeDate , moment);
+
if(moment(activeDate).diff(moment(lastUpdateDate),'minutes') >= -2) {
+
return '<span class="text-warning"><i class="icon-exclamation-sign
activePolicyAlert"
title="'+localization.tt("msg.activationTimeDelayMsg")+'"></i>'
+
+ that.setTimeStamp(activeDate , moment) +'</span>';
+
} else {
+
return '<span class="text-error"><i class="icon-exclamation-sign
activePolicyAlert"
title="'+localization.tt("msg.activationTimeDelayMsg")+'"></i>'
+
+ that.setTimeStamp(activeDate , moment)+'</span>';
+
}
}
}
- return
that.setTimeStamp(activeDate , moment);
+ return
that.setTimeStamp(activeDate , moment);
}
})
},
}
+ if (this.pluginInfoList.queryParams.sortBy &&
!_.isEmpty(this.pluginInfoList.queryParams.sortBy)) {
+ XAUtils.backgridSortType(this.pluginInfoList, cols);
+ }
return
this.pluginInfoList.constructor.getTableCols(cols, this.pluginInfoList);
},
renderUserSyncTable : function(){
@@ -1831,6 +1951,7 @@ define(function(require) {
emptyText : 'No user sync audit found!'
}
}));
+ XAUtils.backgridSort(this.userSyncAuditList);
},
getUserSyncColums : function(){
var cols ={
@@ -1882,8 +2003,8 @@ define(function(require) {
click : false,
drag : false,
editable:false,
+ sortable : true,
sortType: 'toggle',
- direction: 'descending',
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue, model) {
return Globalize.format(new Date(rawValue),
"MM/dd/yyyy hh:mm:ss tt");
@@ -1902,6 +2023,9 @@ define(function(require) {
}),
}
}
+ if (this.userSyncAuditList.queryParams.sortBy &&
!_.isEmpty(this.userSyncAuditList.queryParams.sortBy)) {
+ XAUtils.backgridSortType(this.userSyncAuditList, cols);
+ }
return this.userSyncAuditList.constructor.getTableCols(cols,
this.userSyncAuditList);
},
@@ -1934,14 +2058,14 @@ define(function(require) {
},
isDateDifferenceMoreThanHr : function(date1, date2){
- var diff = date1 - date2 / 36e5;
- return parseInt(diff) < 0 ? true : false;
+ var diff = (date1 - date2) / 36e5;
+ return 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>'
+ + '<div
class="text-muted"><small>'+moment(time).fromNow()+'</small></div></span>'
},
onRefresh : function(){
diff --git
a/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js
b/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js
index 5672552..ecda127 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js
@@ -84,6 +84,7 @@ define(function(require) {'use strict';
iconSearchInfo : '[data-id="searchInfo"]',
policyLabels : '[data-id="policyLabels"]',
zoneName :
'[data-id="zoneName"]',
+ selectUserGroup :
'[data-id="btnUserGroup"]'
},
/** ui events hash */
@@ -108,7 +109,7 @@ define(function(require) {'use strict';
*/
initialize : function(options) {
console.log("initialized a UserAccessLayout Layout");
- _.extend(this, _.pick(options, 'groupList','userList'));
+ _.extend(this, _.pick(options, 'groupList','userList',
'urlQueryParams'));
this.bindEvents();
this.previousSearchUrl = '';
this.searchedFlag = false;
@@ -153,14 +154,41 @@ define(function(require) {'use strict';
onRender : function() {
this.initializePlugins();
- this.setupGroupAutoComplete();
+ if( this.urlQueryParams) {
+ this.urlParam =
XAUtil.changeUrlToSearchQuery(decodeURIComponent(this.urlQueryParams));
+ if (this.urlParam['polResource']) {
+
this.ui.resourceName.val(this.urlParam['polResource']);
+ }
+ if(this.urlParam['policyNamePartial']) {
+
this.ui.policyName.val(this.urlParam['policyNamePartial']);
+ }
+ if(!_.isUndefined(this.urlParam['user']) &&
!_.isEmpty(this.urlParam['user'])) {
+ this.ui.userName.show();
+ this.setupUserAutoComplete();
+ this.ui.userGroup.select2('destroy');
+ this.ui.userGroup.val('').hide();
+
this.ui.selectUserGroup.find('span').first().text('Username')
+ } else {
+ this.ui.userGroup.show();
+ this.setupGroupAutoComplete();
+ this.ui.userName.select2('destroy');
+ this.ui.userName.val('').hide();
+
this.ui.selectUserGroup.find('span').first().text('Group')
+ }
+ } else {
+ this.setupGroupAutoComplete();
+ }
this.renderComponentAndPolicyTypeSelect();
- var policyType = this.ui.policyType.val();
-// Show policies listing for each service and GET policies
for each service
- _.each(this.policyCollList, function(obj,i){
- this.renderTable(obj.collName,
obj.serviceDefName);
-
this.getResourceLists(obj.collName,obj.serviceDefName,policyType);
- },this);
+ if(this.urlQueryParams) {
+ this.onSearch()
+ } else {
+ var policyType = this.ui.policyType.val();
+ // Show policies listing for each service and GET
policies for each service
+ _.each(this.policyCollList, function(obj,i){
+ this.renderTable(obj.collName,
obj.serviceDefName);
+
this.getResourceLists(obj.collName,obj.serviceDefName,policyType);
+ },this);
+ }
this.$el.find('[data-js="policyName"]').focus()
var urlString = XAUtil.getBaseUrl();
if(urlString.slice(-1) == "/") {
@@ -401,6 +429,7 @@ define(function(require) {'use strict';
}
}),
editable : false,
+ sortable : false,
},
resources: {
label: 'Resources',
@@ -464,6 +493,7 @@ define(function(require) {'use strict';
cell :
Backgrid.HtmlCell.extend({className: 'cellWidth-1'}),
label : localization.tt("lbl.zoneName"),
editable : false,
+ sortable : false,
formatter: _.extend({},
Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue,
model) {
var labels ="";
@@ -575,11 +605,17 @@ define(function(require) {'use strict';
var zoneListOptions = _.map(this.rangerZoneList.models,
function(m){
return { 'id':m.get('name'),
'text':m.get('name')}
});
+ var tags = [];
+ if (this.urlParam &&
this.urlParam['policyLabelsPartial'] &&
!_.isEmpty(this.urlParam['policyLabelsPartial'])) {
+ tags.push( { 'id' : _.escape(
this.urlParam['policyLabelsPartial'] ), 'text' : _.escape(
this.urlParam['policyLabelsPartial'] ) } );
+ }
this.ui.componentType.select2({
multiple: true,
closeOnSelect: true,
placeholder: 'Select Component',
//maximumSelectionSize : 1,
+ value : (!_.isUndefined(that.urlParam) &&
!_.isUndefined(that.urlParam['serviceType']) &&
!_.isEmpty(that.urlParam['serviceType'])) ?
+
this.ui.componentType.val(that.urlParam['serviceType']) :
this.ui.componentType.val(""),
width: '220px',
allowClear: true,
data: options
@@ -588,30 +624,62 @@ define(function(require) {'use strict';
closeOnSelect: false,
maximumSelectionSize : 1,
width: '220px',
- value : this.ui.policyType.val("0"),
+ value : (!_.isUndefined(that.urlParam) &&
!_.isUndefined(that.urlParam['policyType']) &&
!_.isEmpty(that.urlParam['policyType'])) ?
+
this.ui.policyType.val(that.urlParam['policyType']) :
this.ui.policyType.val("0"),
allowClear: false,
data: policyTypes
});
this.ui.policyLabels.select2({
- multiple: false,
- closeOnSelect: true,
- placeholder: 'Select Policy Label',
- allowClear: true,
- width: '220px',
- ajax :{
- url: "service/plugins/policyLabels",
- async : false,
- dataType : 'JSON',
- data: function (term, page) {
- return {policyLabel : term};
- },
- results: function (data, page) {
- var results = [];
- results = data.map(function(m,
i){return {id : _.escape(m), text: _.escape(m) };});
- return {results : results};
- }
- }
+ multiple: true,
+ closeOnSelect : true,
+ placeholder : 'Policy Label',
+ width :'220px',
+ allowClear: true,
+ tokenSeparators: ["," , " "],
+ tags : true,
+ maximumSelectionSize : 1,
+ initSelection : function (element, callback) {
+ callback(tags);
+ },
+ createSearchChoice: function(term, data) {
+ term = _.escape(term);
+ if ($(data).filter(function() {
+ return this.text.localeCompare(term) === 0;
+ }).length === 0) {
+ if($.inArray(term, this.val()) >= 0){
+ return null;
+ }else{
+ return {
+ id : term,
+ text: term
+ };
+ }
+ }
+ },
+ ajax: {
+ url: 'service/plugins/policyLabels',
+ dataType: 'json',
+ data: function (term, page) {
+ return {policyLabel : term};
+ },
+ results: function (data, page) {
+ var results = [] , selectedVals = [];
+ if(data.resultSize != "0"){
+ results = data.map(function(m){ return {id :
_.escape(m), text: _.escape(m) }; });
+ }
+ return {results : results};
+ },
+ },
+ formatResult : function(result){
+ return result.text;
+ },
+ formatSelection : function(result){
+ return result.text;
+ },
});
+ if(this.urlParam &&
this.urlParam['policyLabelsPartial']) {
+
this.ui.policyLabels.val(this.urlParam['policyLabelsPartial']).trigger('change');
+ }
this.ui.zoneName.select2({
closeOnSelect: false,
maximumSelectionSize : 1,
@@ -619,6 +687,8 @@ define(function(require) {'use strict';
allowClear: true,
data: zoneListOptions,
placeholder: 'Select Zone Name',
+ value : (!_.isUndefined(that.urlParam) &&
!_.isUndefined(that.urlParam['zoneName']) &&
!_.isEmpty(that.urlParam['zoneName'])) ?
+
this.ui.zoneName.val(that.urlParam['zoneName']) : this.ui.zoneName.val(""),
});
},
onDownload: function(e){
@@ -671,10 +741,7 @@ define(function(require) {'use strict';
},
/** on render callback */
setupGroupAutoComplete : function(){
- this.groupArr = this.groupList.map(function(m){
- return { id : m.get('name') , text :
_.escape(m.get('name'))};
- });
- var that = this, arr = [];
+ var that = this;
this.ui.userGroup.select2({
closeOnSelect : true,
placeholder : 'Select Group',
@@ -684,11 +751,8 @@ define(function(require) {'use strict';
allowClear: true,
// tags : this.groupArr,
initSelection : function (element, callback) {
- var data = [];
-
$(element.val().split(",")).each(function () {
- var obj =
_.findWhere(that.groupArr,{id:this});
- data.push({id: obj.text, text:
obj.text});
- });
+ var data = {};
+ data = {id: element.val(), text:
element.val()};
callback(data);
},
ajax: {
@@ -720,29 +784,20 @@ define(function(require) {'use strict';
return 'No group found.';
}
})//.on('select2-focus', XAUtil.select2Focus);
- },
+ if(this.urlParam && this.urlParam['group'] &&
!_.isEmpty(this.urlParam['group'])) {
+
this.ui.userGroup.val(this.urlParam['group']).trigger('change');
+ }
+ },
setupUserAutoComplete : function(){
var that = this;
- var arr = [];
- this.userArr = this.userList.map(function(m){
- return { id : m.get('name') , text :
_.escape(m.get('name')) };
- });
this.ui.userName.select2({
-// multiple: true,
-// minimumInputLength: 1,
closeOnSelect : true,
placeholder : 'Select User',
-// maximumSelectionSize : 1,
width :'220px',
- tokenSeparators: [",", " "],
allowClear: true,
- // tags : this.userArr,
initSelection : function (element, callback) {
- var data = [];
-
$(element.val().split(",")).each(function () {
- var obj =
_.findWhere(that.userArr,{id:this});
- data.push({id: obj.text, text:
obj.text});
- });
+ var data = {};
+ data = {id: element.val(), text:
element.val()};
callback(data);
},
ajax: {
@@ -775,6 +830,9 @@ define(function(require) {'use strict';
}
})//.on('select2-focus', XAUtil.select2Focus);
+ if(this.urlParam && this.urlParam['user'] &&
!_.isEmpty(this.urlParam['user'])) {
+
this.ui.userName.val(this.urlParam['user']).trigger('change');
+ }
},
/** all post render plugin initialization */
initializePlugins : function() {
@@ -811,16 +869,23 @@ define(function(require) {'use strict';
},
onSearch : function(e){
- var that = this, url = '', urlString =
XAUtil.getBaseUrl();
+ var that = this, url = '', urlString =
XAUtil.getBaseUrl(), urlParam = {};
//Get search values
- var groups = (this.ui.userGroup.is(':visible')) ?
this.ui.userGroup.select2('val'):undefined;
- var users = (this.ui.userName.is(':visible')) ?
this.ui.userName.select2('val'):undefined;
+ var groups = (this.ui.selectUserGroup.text().trim() ==
"Group" ) ? this.ui.userGroup.select2('val'):undefined;
+ var users = (this.ui.selectUserGroup.text().trim() ==
"Username") ? this.ui.userName.select2('val'):undefined;
var rxName = this.ui.resourceName.val(), policyName =
this.ui.policyName.val() , policyType = this.ui.policyType.val(),
policyLabel = this.ui.policyLabels.val(), zoneName =
this.ui.zoneName.val()
var params = {group : groups, user : users, polResource
: rxName, policyNamePartial : policyName, policyType: policyType,
policyLabelsPartial:policyLabel,
zoneName : zoneName};
var component = (this.ui.componentType.val() != "") ?
this.ui.componentType.select2('val'):undefined;
- that.initializeRequiredData();
+ urlParam = _.extend(params, {'serviceType':
this.ui.componentType.val()});
+ _.each(urlParam, function(value, key, obj){
+ if (value === "" || value === undefined) {
+ delete obj[key];
+ }
+ })
+ XAUtil.changeParamToUrlFragment(urlParam);
+ that.initializeRequiredData();
_.each(this.policyCollList, function(obj,i){
this.renderTable(obj.collName, obj.serviceDefName);
},this);
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 d1f421f..2b82181 100755
--- a/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js
@@ -386,6 +386,7 @@ define(function(require){
},
editable:false,
sortable:false,
+ sortType: 'toggle',
cell :'uri'
},
emailAddress : {
@@ -567,6 +568,7 @@ define(function(require){
cell : Backgrid.HtmlCell.extend({className:
'cellWidth-1'}),
drag : false,
editable : false,
+ sortable : false,
formatter : _.extend({}, Backgrid.CellFormatter.prototype,
{
fromRaw : function (rawValue,model) {
return ('<div align="center"><button
class="userViewicon" title = "View Users" data-js="showUserList" data-name="' +
model.get('name')
@@ -998,9 +1000,10 @@ define(function(require){
if(!_.isUndefined(this.urlQueryParams) &&
!_.isEmpty(this.urlQueryParams)) {
var urlQueryParams =
XAUtil.changeUrlToSearchQuery(this.urlQueryParams);
_.map(urlQueryParams, function(val , key) {
- query += '"'+XAUtil.filterKeyForVSQuery(serverAttrName,
key)+'":"'+val+'"';
+ if (_.some(serverAttrName, function(m){return m.urlLabel
== key})) {
+ query +=
'"'+XAUtil.filterKeyForVSQuery(serverAttrName, key)+'":"'+val+'"';
+ }
});
- // query +=
XAUtil.changeUrlToVSSearchQuery(this.urlQueryParams);
}
var pluginAttr = {
placeholder :placeholder,
diff --git a/security-admin/src/main/webapp/styles/xa.css
b/security-admin/src/main/webapp/styles/xa.css
index f75facb..c8eb397 100644
--- a/security-admin/src/main/webapp/styles/xa.css
+++ b/security-admin/src/main/webapp/styles/xa.css
@@ -2807,6 +2807,13 @@ div#zoneServiceAccordion table thead {
border-right: 1px solid #ddd;
}
+.text-muted {
+ opacity: 0.7;
+}
+
+.center {
+ text-align: center;
+}
/*Overriden styles - Use later for bootstrap 3*/
a{
diff --git
a/security-admin/src/main/webapp/templates/reports/AuditAccessLogDetail_tmpl.html
b/security-admin/src/main/webapp/templates/reports/AuditAccessLogDetail_tmpl.html
new file mode 100644
index 0000000..457dae3
--- /dev/null
+++
b/security-admin/src/main/webapp/templates/reports/AuditAccessLogDetail_tmpl.html
@@ -0,0 +1,214 @@
+{{!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--}}
+<div id="serviceDetails" class="row-fluid">
+ <p class="formHeader">
+ {{tt 'lbl.auditAccessDetail'}} :
+ </p>
+ <table class="table table-bordered table-condensed">
+ <tbody>
+ <tr>
+ <td>
+ {{tt 'lbl.policyId'}}
+ </td>
+ {{#compare auditaccessDetail.policyId "eq" '-1'}}
+ <td> -- </td>
+ {{else}}
+ <td>
+ {{auditaccessDetail.policyId}}
+ </td>
+ {{/compare}}
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.policyVersion'}}
+ </td>
+ <td>
+ {{#if auditaccessDetail.policyVersion}}
+ {{auditaccessDetail.policyVersion}}
+ {{else}}
+ --
+ {{/if}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.eventTime'}}
+ </td>
+ <td>
+ {{eventTime}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.application'}}
+ </td>
+ <td>
+ {{auditaccessDetail.agentId}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.user'}}
+ </td>
+ <td>
+ {{auditaccessDetail.requestUser}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.serviceName'}}
+ </td>
+ <td>
+ {{auditaccessDetail.repoName}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.serviceType'}}
+ </td>
+ <td>
+ {{auditaccessDetail.serviceType}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.resourcePath'}}
+ </td>
+ <td>
+ {{#if auditaccessDetail.resourcePath}}
+ {{auditaccessDetail.resourcePath}}
+ {{else}}
+ --
+ {{/if}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.resourceType'}}
+ </td>
+ <td>
+ {{#if auditaccessDetail.resourceType}}
+ {{auditaccessDetail.resourceType}}
+ {{else}}
+ --
+ {{/if}}
+ </td>
+ </tr>
+ {{#if hiveQuery}}
+ <tr>
+ <td>
+ {{tt 'lbl.hiveQuery'}}
+ </td>
+ <td>
+ <span class="pull-right link-tag query-icon copyQuery
btn btn-mini" data-name="copyQuery" title="Copy Query">
+ <i class="icon-copy"></i>
+ </span>
+ <span>{{auditaccessDetail.requestData}}</span>
+ </td>
+ </tr>
+ {{/if}}
+ <tr>
+ <td>
+ {{tt 'lbl.accessType'}}
+ </td>
+ <td>
+ {{auditaccessDetail.accessType}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.result'}}
+ </td>
+ <td>
+ {{result}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.aclEnforcer'}}
+ </td>
+ <td>
+ {{auditaccessDetail.aclEnforcer}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.agentHost'}}
+ </td>
+ <td>
+ {{auditaccessDetail.agentHost}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.clientIP'}}
+ </td>
+ <td>
+ {{#if auditaccessDetail.clientIP}}
+ {{auditaccessDetail.clientIP}}
+ {{else}}
+ --
+ {{/if}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.clusterName'}}
+ </td>
+ <td>
+ {{#if auditaccessDetail.clusterName}}
+ {{auditaccessDetail.clusterName}}
+ {{else}}
+ --
+ {{/if}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.zoneName'}}
+ </td>
+ <td>
+ {{#if auditaccessDetail.zoneName}}
+ {{auditaccessDetail.zoneName}}
+ {{else}}
+ --
+ {{/if}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.eventCount'}}
+ </td>
+ <td>
+ {{auditaccessDetail.eventCount}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{tt 'lbl.tags'}}
+ </td>
+ <td>
+ {{#if tag}}
+ {{tag}}
+ {{else}}
+ --
+ {{/if}}
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
\ No newline at end of file
diff --git
a/security-admin/src/main/webapp/templates/reports/UserAccessLayout_tmpl.html
b/security-admin/src/main/webapp/templates/reports/UserAccessLayout_tmpl.html
index befb230..887d1bf 100644
---
a/security-admin/src/main/webapp/templates/reports/UserAccessLayout_tmpl.html
+++
b/security-admin/src/main/webapp/templates/reports/UserAccessLayout_tmpl.html
@@ -76,7 +76,7 @@
<div class="controls"
data-js="searchBy">
<div class="">
<div
class="btn-group">
-
<button class="btn dropdown-toggle" data-toggle="dropdown">
+
<button class="btn dropdown-toggle" data-id="btnUserGroup"
data-toggle="dropdown">
<span>Group</span>
<span class="caret"> </span>
</button>