You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2021/01/09 04:26:06 UTC

[ranger] branch master updated: RANGER-3117: UI updates to enable opening audit details in a separate tab

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

madhan 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 08b0915  RANGER-3117: UI updates to enable opening audit details in a separate tab
08b0915 is described below

commit 08b09151a5115cdaac9019690a839f7a67330a9b
Author: Dhaval Rajpara <dh...@gmail.com>
AuthorDate: Sat Jan 9 01:12:23 2021 +0530

    RANGER-3117: UI updates to enable opening audit details in a separate tab
    
    Signed-off-by: Madhan Neethiraj <ma...@apache.org>
---
 .../src/main/webapp/scripts/controllers/Controller.js  | 18 ++++++++++++++++++
 .../src/main/webapp/scripts/controllers/NController.js | 18 ++++++++++++++++++
 .../src/main/webapp/scripts/routers/Router.js          |  1 +
 .../scripts/views/reports/AuditAccessLogDetailView.js  | 10 +++++++++-
 .../main/webapp/scripts/views/reports/AuditLayout.js   | 15 ++++++++-------
 security-admin/src/main/webapp/styles/xa.css           | 10 +++++-----
 .../templates/reports/AuditAccessLogDetail_tmpl.html   |  5 +++++
 7 files changed, 64 insertions(+), 13 deletions(-)

diff --git a/security-admin/src/main/webapp/scripts/controllers/Controller.js b/security-admin/src/main/webapp/scripts/controllers/Controller.js
index b026b33..21eb963 100755
--- a/security-admin/src/main/webapp/scripts/controllers/Controller.js
+++ b/security-admin/src/main/webapp/scripts/controllers/Controller.js
@@ -112,6 +112,24 @@ define(function(require) {
                 }));
             });
         },
+        auditEventDetail: function(eventID) {
+            MAppState.set({
+                'currentTab': XAGlobals.AppTabs.AccessManager.value
+            });
+            var view = require('views/reports/AuditAccessLogDetailView');
+            var VXAccessAuditList = require('collections/VXAccessAuditList');
+            var auditList = new VXAccessAuditList();
+            auditList.url = 'service/assets/accessAudit?eventId='+eventID
+            auditList.fetch({
+               cache : false,
+               async : false
+            }).done(function() {
+                App.rContent.show(new view({
+                    auditaccessDetail : auditList.models[0].attributes,
+                    auditAccessView : true,
+                }));
+            })
+        },
         //************** UserProfile Related *********************/
         userProfileAction: function() {
             MAppState.set({
diff --git a/security-admin/src/main/webapp/scripts/controllers/NController.js b/security-admin/src/main/webapp/scripts/controllers/NController.js
index f6c291e..13ee4c6 100644
--- a/security-admin/src/main/webapp/scripts/controllers/NController.js
+++ b/security-admin/src/main/webapp/scripts/controllers/NController.js
@@ -114,6 +114,24 @@ define(function(require) {
                 }));
             });
         },
+        auditEventDetail: function(eventID) {
+            MAppState.set({
+                'currentTab': XAGlobals.AppTabs.AccessManager.value
+            });
+            var view = require('views/reports/AuditAccessLogDetailView');
+            var VXAccessAuditList = require('collections/VXAccessAuditList');
+            var auditList = new VXAccessAuditList();
+            auditList.url = 'service/assets/accessAudit?eventId='+eventID
+            auditList.fetch({
+               cache : false,
+               async : false
+            }).done(function() {
+                App.rContent.show(new view({
+                    auditaccessDetail : auditList.models[0].attributes,
+                    auditAccessView : true,
+                }));
+            })
+        },
         //************** UserProfile Related *********************/
         userProfileAction: function() {
             MAppState.set({
diff --git a/security-admin/src/main/webapp/scripts/routers/Router.js b/security-admin/src/main/webapp/scripts/routers/Router.js
index 0cb69a3..448659e 100644
--- a/security-admin/src/main/webapp/scripts/routers/Router.js
+++ b/security-admin/src/main/webapp/scripts/routers/Router.js
@@ -41,6 +41,7 @@ function(Backbone, Marionette, localization, MAppState, XAUtil, bootbox){
 			/****** Audit Report related **********************/
 			"!/reports/audit/:tab"					: "auditReportAction",
 			"!/reports/audit/loginSession/:paramName/:id"	: "loginSessionDetail",
+			"!/reports/audit/eventlog/:id"	: "auditEventDetail",
 			
 			/****** User Profile related **********************/
 			"!/userprofile"		: "userProfileAction",
diff --git a/security-admin/src/main/webapp/scripts/views/reports/AuditAccessLogDetailView.js b/security-admin/src/main/webapp/scripts/views/reports/AuditAccessLogDetailView.js
index 8b5181b..57ffaea 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/AuditAccessLogDetailView.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/AuditAccessLogDetailView.js
@@ -36,6 +36,10 @@ define(function(require) {
 
             template: AuditAccessLogDetailTmpl,
 
+            breadCrumbs :function(){
+                return 'Audit Access Log Detail'
+            },
+
             templateHelpers: function() {
                 var that = this, result;
                 result = _.filter(XAEnums.AccessResult, function(e){ return e.value === that.auditaccessDetail.accessResult });
@@ -47,6 +51,7 @@ define(function(require) {
                                 this.auditaccessDetail.aclEnforcer === "ranger-acl" && this.auditaccessDetail.requestData) ? true : false,
 
                     tag : this.tags ? this.tags.join() : undefined,
+                    auditAccessView : this.auditAccessView,
                 }
             },
 
@@ -66,7 +71,10 @@ define(function(require) {
              */
             initialize: function(options) {
                 console.log("Initialized a Ranger Audit Access Log Details");
-                _.extend(this, _.pick(options, 'auditaccessDetail'));
+                _.extend(this, _.pick(options, 'auditaccessDetail', 'auditAccessView'));
+                if(_.isUndefined(this.auditAccessView)) {
+                    this.auditAccessView = false
+                }
                 if (this.auditaccessDetail.tags) {
                     var tag = JSON.parse(this.auditaccessDetail.tags);
                     this.tags = _.map(tag, function(m) {
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 0f8315b..0b24c10 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
@@ -1148,6 +1148,8 @@ define(function(require) {
 				onClick: function (e) {
                     var self = this ;
                     if($(e.target).hasClass('policyIdColumn') || $(e.target).closest('td').hasClass("policyIdColumn")) {
+                        if($(e.target).is('.fa-external-link'))
+                            return;
                         if(this.model.get('repoType')){
                                     var repoType =  this.model.get('repoType');
                                 }
@@ -1198,10 +1200,12 @@ define(function(require) {
                         var view = new AuditAccessLogDetail({
                             auditaccessDetail : this.model.attributes,
                         });
+                        var url =Backbone.history.location.href.substring(0, Backbone.history.location.href.indexOf('#!'))+'#!/reports/audit/eventlog/'+this.model.get('eventId');
+                        var eventUrl = '<a href="'+url+'" target="_blank" title="Show log details in next tab"> <i class="fa-fw fa fa-external-link pull-right"></i> </a>';
                         var modal = new Backbone.BootstrapModal({
                             animate : true,
                             content     : view,
-                            title: localization.tt("lbl.auditAccessDetail"),
+                            title: localization.tt("lbl.auditAccessDetail") + eventUrl,
                             okText :localization.tt("lbl.ok"),
                             allowCancel : true,
                             escape : true,
@@ -1247,14 +1251,11 @@ define(function(require) {
                                                 }),
 						formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
 							fromRaw: function (rawValue, model) {
-								if(rawValue == -1){
+								var serviceDef = that.serviceDefList.findWhere({'id' : model.get('repoType')}),
+								href = 'javascript:void(0)';
+								if(rawValue == -1 || _.isUndefined(serviceDef)){
 									return '--';
-								}	
-								var serviceDef = that.serviceDefList.findWhere({'id' : model.get('repoType')})
-								if(_.isUndefined(serviceDef)){
-									return rawValue;
 								}
-								var href = 'javascript:void(0)';
 								return '<a href="'+href+'" title="'+rawValue+'">'+rawValue+'</a>';
 							}
 						}),
diff --git a/security-admin/src/main/webapp/styles/xa.css b/security-admin/src/main/webapp/styles/xa.css
index 8d96f6b..3cd90e1 100644
--- a/security-admin/src/main/webapp/styles/xa.css
+++ b/security-admin/src/main/webapp/styles/xa.css
@@ -4518,8 +4518,8 @@ input.textFiledInputPadding:disabled {
 
 .backgrid th:not(.renderable), .backgrid td:not(.renderable){
     display: none;
-}/*[fieldclass="resorces-css"] .control-label {
-  margin-top: 0px;
-  margin-right: -15px
-}*/
-/*End of Overriden styles*/
\ No newline at end of file
+}
+
+#serviceDetails tbody {
+  background-color: white;
+}
\ No newline at end of file
diff --git a/security-admin/src/main/webapp/templates/reports/AuditAccessLogDetail_tmpl.html b/security-admin/src/main/webapp/templates/reports/AuditAccessLogDetail_tmpl.html
index fe41386..b3e2c66 100644
--- a/security-admin/src/main/webapp/templates/reports/AuditAccessLogDetail_tmpl.html
+++ b/security-admin/src/main/webapp/templates/reports/AuditAccessLogDetail_tmpl.html
@@ -16,6 +16,11 @@
 --}}
 <div id="serviceDetails" class="row">
     <table class="table table-bordered table-condensed">
+        {{#if auditAccessView}}
+            <thead>
+                <h4>Ranger – audit log</h4>
+            </thead>
+        {{/if}}
         <tbody>
             <tr>
                 <td>