ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From me...@apache.org
Subject [2/2] ranger git commit: RANGER-2235: Modify the login session detail page as a modal.
Date Mon, 08 Oct 2018 13:30:22 GMT
RANGER-2235: Modify the login session detail page as a modal.

Signed-off-by: peng.jianhua <peng.jianhua@zte.com.cn>


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/3d5e5eb1
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/3d5e5eb1
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/3d5e5eb1

Branch: refs/heads/ranger-1
Commit: 3d5e5eb1c04dafb018250eee58e222cd627a0e2c
Parents: 028de96
Author: zhangqiang2 <zhangqiang2@zte.com.cn>
Authored: Wed Sep 26 16:56:13 2018 +0800
Committer: Mehul Parikh <mehul@apache.org>
Committed: Mon Oct 8 18:59:02 2018 +0530

----------------------------------------------------------------------
 .../webapp/scripts/views/reports/AuditLayout.js | 86 +++++++++++++++-----
 .../scripts/views/reports/LoginSessionDetail.js | 17 +++-
 .../reports/LoginSessionDetail_tmpl.html        | 67 +++++++--------
 3 files changed, 108 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/3d5e5eb1/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
----------------------------------------------------------------------
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 697d33d..3da1567 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
@@ -46,6 +46,7 @@ define(function(require) {
 	var RangerPolicy 				= require('models/RangerPolicy');
 	var RangerPolicyRO				= require('views/policies/RangerPolicyRO');
 	var vPlugableServiceDiffDetail	= require('views/reports/PlugableServiceDiffDetail');
+    var vLoginSessionDetail         = require('views/reports/LoginSessionDetail');
 
 	var moment = require('moment');
 	require('bootstrap-datepicker');
@@ -92,7 +93,8 @@ define(function(require) {
                         btnShowLess : '[data-id="showLess"]',
             iconqueryInfo : '[data-name="queryInfo"]',
             hidePopup : '[data-id="hide-popup"]',
-            syncDetailes : '[data-id="syncDetailes"]'
+            syncDetailes : '[data-id="syncDetailes"]',
+            viewSession : '[data-name="viewSession"]',
 		},
 
 		/** ui events hash */
@@ -107,6 +109,7 @@ define(function(require) {
                 events['click ' + this.ui.hidePopup]  = 'onClickOutSide';
             }
             events['click '+this.ui.syncDetailes] = 'onSyncDetailes';
+            events['click ' + this.ui.viewSession]  = 'onViewSession';
             return events;
 		},
 
@@ -923,17 +926,24 @@ define(function(require) {
 						}
 					})
 				},
-				sessionId : {
-					label : localization.tt("lbl.sessionId"),
-					cell: "uri",
-					href: function(model){
-						return '#!/reports/audit/loginSession/extSessionId/'+model.get('sessionId');
-					},
-					click : false,
-					drag : false,
-					sortable:false,
-					editable:false
-				}
+                sessionId : {
+                    label : localization.tt("lbl.sessionId"),
+                    cell: "html",
+                    click : false,
+                    drag : false,
+                    sortable:false,
+                    editable:false,
+                    formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                        fromRaw: function (rawValue, model) {
+                            var sessionId = model.get('sessionId');
+                            if (!_.isUndefined(sessionId)) {
+                                return '<a href="javascript:void(0);" data-name ="viewSession"
data-id="'+sessionId+'" title="'+sessionId+'">'+sessionId+'</a>';
+                            } else {
+                                return '';
+                            }
+                        }
+                    })
+                }
 			};
 			return this.trxLogList.constructor.getTableCols(cols, this.trxLogList);
 		},
@@ -1196,16 +1206,23 @@ define(function(require) {
 			});
 
 			var cols = {
-				id : {
-					label : localization.tt("lbl.sessionId"),
-					cell : "uri",
-					href: function(model){
-						return '#!/reports/audit/loginSession/id/'+model.get('id');
-					},
-					editable:false,
-					sortType: 'toggle',
-					direction: 'descending'
-				},
+                id : {
+                    label : localization.tt("lbl.sessionId"),
+                    cell : "html",
+                    editable:false,
+                    sortType: 'toggle',
+                    direction: 'descending',
+                    formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                        fromRaw: function (rawValue, model) {
+                            var sessionId = model.get('id');
+                            if (!_.isUndefined(sessionId)) {
+                                return '<a href="javascript:void(0);" data-name ="viewSession"
data-id="'+sessionId+'" title="'+sessionId+'">'+sessionId+'</a>';
+                            } else {
+                                return '';
+                            }
+                        }
+                    })
+                },
 				loginId : {
 					label : localization.tt("lbl.loginId"),
 					cell: "String",
@@ -1645,6 +1662,31 @@ define(function(require) {
         onSyncDetailes : function(e){
             XAViewUtils.syncSourceDetail(e , this);
         },
+
+        onViewSession : function(e) {
+            var authSessionList = new VXAuthSession();
+            var sessionId = $(e.currentTarget).data('id');
+            authSessionList.fetch({
+                data : {
+                    id : sessionId
+                }
+            }).done(function() {
+                var view = new vLoginSessionDetail({
+                    model : authSessionList.first()
+                });
+                var modal = new Backbone.BootstrapModal({
+                    animate : true,
+                    content : view,
+                    title : localization.tt("lbl.sessionDetail"),
+                    okText : localization.tt("lbl.ok"),
+                    allowCancel : true,
+                    escape : true
+                }).open();
+                modal.$el.addClass('modal-diff').attr('tabindex', -1);
+                modal.$el.find('.cancel').hide();
+            });
+        },
+
         isDateDifferenceMoreThanHr : function(date1, date2){
                 var diff = Math.abs(date1 - date2) / 36e5;
                 return parseInt(diff) >= 1 ? true : false;

http://git-wip-us.apache.org/repos/asf/ranger/blob/3d5e5eb1/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js b/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js
index e92929a..a0c2c1f 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js
@@ -77,10 +77,19 @@ define(function(require){
 		/** all post render plugin initialization */
 		initializePlugins: function(){
 		},
-                /* on show action button*/
-                showAction : function(){
-                        App.sessionId = this.model.get('id');
-                },
+        /* on show action button*/
+        showAction : function(){
+            App.sessionId = this.model.get('id');
+
+            var view = require('views/reports/AuditLayout');
+            var VXAccessAuditList = require('collections/VXAccessAuditList');
+            var accessAuditList = new VXAccessAuditList();
+            _.extend(accessAuditList.queryParams, {'sortBy' : 'eventTime'});
+            App.rContent.show(new view({
+                accessAuditList : accessAuditList,
+                tab : "admin"
+            }));
+        },
 		/** on close */
 		onClose: function(){
 		}

http://git-wip-us.apache.org/repos/asf/ranger/blob/3d5e5eb1/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html
b/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html
index b11fa83..4d62cc5 100644
--- a/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html
+++ b/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html
@@ -1,4 +1,4 @@
-{{!-- 
+{{!--
   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.
@@ -14,39 +14,34 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 --}}
-<h3 class="wrap-header bold">Session Detail:</h3>
-<div class="wrap non-collapsible">
-	<div class="datagrid-stretch-wrapper "style="margin-left: 44px; margin-top: 35px;">
-		<table class="table table-bordered table-condensed">
-	<tbody>
-		<tr>
-			<th>{{tt 'lbl.loginId'}}</th>
-			<td>{{loginId}}</td>
-		</tr>
-		<tr>
-			<th>{{tt 'lbl.result'}}</th>
-			<td>{{{convertEnumValueToLabel 'AuthStatus' authStatus}}}</td>
-		</tr>
-		<tr>
-			<th>{{tt 'lbl.loginType'}}</th>
-			<td>{{{convertEnumValueToLabel 'AuthType' authType}}}</td>
-		</tr>
-		<tr>
-			<th>{{tt 'lbl.ip'}}</th>
-			<td>{{requestIP}}</td>
-		</tr>
-		<tr>
-			<th>{{tt 'lbl.userAgent'}}</th>
-			<td>{{requestUserAgent}}</td>
-		</tr>
-		<tr>
-			<th style="width: 10%;">{{tt 'lbl.loginTime'}}</th>
-			<td data-id="loginTime"></td>
-		</tr>
-	</tbody>
-</table>
-	</div>
-        <a href="#!/reports/audit/admin" class="link-tag" data-id="showAction">Show
Actions</a>
+<div class="non-collapsible">
+    <table class="table table-bordered table-condensed">
+        <tbody>
+            <tr>
+                <th>{{tt 'lbl.loginId'}}</th>
+                <td>{{loginId}}</td>
+            </tr>
+            <tr>
+                <th>{{tt 'lbl.result'}}</th>
+                <td>{{{convertEnumValueToLabel 'AuthStatus' authStatus}}}</td>
+            </tr>
+            <tr>
+                <th>{{tt 'lbl.loginType'}}</th>
+                <td>{{{convertEnumValueToLabel 'AuthType' authType}}}</td>
+            </tr>
+            <tr>
+                <th>{{tt 'lbl.ip'}}</th>
+                <td>{{requestIP}}</td>
+            </tr>
+            <tr>
+                <th>{{tt 'lbl.userAgent'}}</th>
+                <td>{{requestUserAgent}}</td>
+            </tr>
+            <tr>
+                <th style="width: 10%;">{{tt 'lbl.loginTime'}}</th>
+                <td data-id="loginTime"></td>
+            </tr>
+        </tbody>
+    </table>
+    <a href="javascript:void(0);" class="link-tag" data-id="showAction">Show Actions</a>
 </div>
-
-


Mime
View raw message