Repository: incubator-ranger Updated Branches: refs/heads/master dc49a1a49 -> 8e786fa68
RANGER-330: Show audit of policy updates for new Service Model Signed-off-by: Velmurugan Periasamy <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/8e786fa6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/8e786fa6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/8e786fa6 Branch: refs/heads/master Commit: 8e786fa6838bdbfa154c1987196ce0bdcc47db47 Parents: dc49a1a Author: Gautam Borad <[email protected]> Authored: Tue Mar 24 18:48:14 2015 +0530 Committer: Velmurugan Periasamy <[email protected]> Committed: Tue Mar 24 16:14:17 2015 -0400 ---------------------------------------------------------------------- .../scripts/models/BackboneFormDataType.js | 44 ++- .../main/webapp/scripts/modules/XAOverrides.js | 16 +- .../src/main/webapp/scripts/utils/XAEnums.js | 5 +- .../src/main/webapp/scripts/utils/XAUtils.js | 3 + .../scripts/views/policies/PermissionList.js | 4 +- .../scripts/views/policies/RangerPolicyForm.js | 51 +-- .../views/policies/RangerPolicyTableLayout.js | 11 +- .../webapp/scripts/views/reports/AuditLayout.js | 313 ++++------------ .../views/reports/OperationDiffDetail.js | 20 +- .../views/reports/PlugableServiceDiffDetail.js | 357 +++++++++++++++++++ .../scripts/views/reports/UserAccessLayout.js | 22 +- .../main/webapp/scripts/views/users/UserForm.js | 25 +- security-admin/src/main/webapp/styles/xa.css | 1 + .../main/webapp/templates/helpers/XAHelpers.js | 33 +- .../PlugableServicePolicyDeleteDiff_tmpl.html | 91 +++++ .../reports/PlugableServicePolicyDiff_tmpl.html | 87 +++++ .../PlugableServicePolicyUpdateDiff_tmpl.html | 161 +++++++++ .../reports/PolicyUpdateOperationDiff_tmpl.html | 4 +- .../reports/UserAccessLayout_tmpl.html | 2 +- .../reports/UserOperationDiff_tmpl.html | 42 +-- 20 files changed, 917 insertions(+), 375 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js b/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js index 4a2fc84..6f410cf 100644 --- a/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js +++ b/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js @@ -25,6 +25,26 @@ define(function(require) { var FormDataType = Backbone.Model.extend({ type : [ 'string', 'boolean', 'int' ], getFormElements : function(configs, enums, attrs, form) { + //Helpers + var getValidators = function(formObj, v){ + formObj.validators = []; + if (_.has(v, 'mandatory') && v.mandatory && v.type != 'bool') { + formObj.validators.push('required'); + formObj.title = formObj.title + " *" + } + if(_.has(v, 'validationRegEx') && !_.isEmpty(v.validationRegEx) && !v.lookupSupported){ + formObj.validators.push({'type': 'regexp', 'regexp':new RegExp(v.validationRegEx), 'message' : v.validationMessage}); + } + return formObj; + }; + var setDefaultValueToModel = function(form, v) { + if(_.has(v, 'defaultValue') && !_.isEmpty(v.defaultValue) && v.type != 'bool'){ + form.model.set(v.name, v.defaultValue) + } + return form; + }; + + var samelevelFieldCreated = []; _.each(configs, function(v, k,config) { if (v != null) { @@ -50,6 +70,9 @@ define(function(require) { 'type' : v.name, 'lookupURL' : "service/plugins/services/lookupResource/"+form.rangerService.get('name') }; + if(_.has(v, 'validationRegEx') && !_.isEmpty(v.validationRegEx)){ + opts['regExpValidation'] = {'type': 'regexp', 'regexp':new RegExp(v.validationRegEx), 'message' : v.validationMessage}; + } resourceOpts['select2Opts'] = form.getPlugginAttr(true, opts); formObj['resourceOpts'] = resourceOpts; } @@ -106,7 +129,12 @@ define(function(require) { 'containerCssClass' : v.name, 'lookupURL' : "service/plugins/services/lookupResource/"+form.rangerService.get('name') }; + //to support regexp level validation + if(_.has(v, 'validationRegEx') && !_.isEmpty(v.validationRegEx)){ + options['regExpValidation'] = {'type': 'regexp', 'regexp':new RegExp(v.validationRegEx), 'message' : v.validationMessage}; + } form.pathFieldName = v.name; + form.pathPluginOpts = options; form.initilializePathPlugin = true; } formObj['initilializePathPlugin'] = true; @@ -118,17 +146,10 @@ define(function(require) { if(_.isUndefined(formObj.title)){ formObj.title = v.label || v.name; } - formObj.validators = []; - if (_.has(v, 'mandatory') && v.mandatory && v.type != 'bool') { - formObj.validators.push('required'); - formObj.title = formObj.title + " *" - } + formObj = getValidators(formObj, v); if(form.model.isNew()){ - if(_.has(v, 'defaultValue') && !_.isEmpty(v.defaultValue) && v.type != 'bool'){ - form.model.set(v.name, v.defaultValue) - } - } - + form = setDefaultValueToModel(form, v) + } formObj['class'] = 'serviceConfig'; if(_.isUndefined(fieldName)){ fieldName = v.name; @@ -137,8 +158,7 @@ define(function(require) { } }); return attrs; - - } + }, }); return FormDataType; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/modules/XAOverrides.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/modules/XAOverrides.js b/security-admin/src/main/webapp/scripts/modules/XAOverrides.js index a351063..a60383e 100644 --- a/security-admin/src/main/webapp/scripts/modules/XAOverrides.js +++ b/security-admin/src/main/webapp/scripts/modules/XAOverrides.js @@ -478,16 +478,24 @@ } }, getValue: function() { + var that = this; //checkParent if(this.$el.parents('.control-group').hasClass('hideResource')){ return null; } this.value['resource'] = this.$resource.val(); //validation - if(!_.isUndefined(this.validators) && ($.inArray('required',this.validators) != -1)){ - if(_.isEmpty(this.value.resource)) - return null; - } + + + if(!_.isUndefined(this.validators)){ + if(($.inArray('required',this.validators) != -1)){ + if(_.isEmpty(this.value.resource)) + return null; + } + } + + + if(!_.isUndefined(this.$resourceType) && this.$resourceType.length > 0){ this.value['resourceType'] = this.$resourceType.val(); } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/utils/XAEnums.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/utils/XAEnums.js b/security-admin/src/main/webapp/scripts/utils/XAEnums.js index a8e9ead..31cc9e9 100644 --- a/security-admin/src/main/webapp/scripts/utils/XAEnums.js +++ b/security-admin/src/main/webapp/scripts/utils/XAEnums.js @@ -164,7 +164,10 @@ define(function(require) { CLASS_TYPE_XA_POLICY_EXPORT_AUDIT:{value:1009, label:'XA Policy Export Audit', rbkey:'xa.enum.ClassTypes.CLASS_TYPE_XA_POLICY_EXPORT_AUDIT', modelName:'VXPolicyExportAudit', type:'vXPolicyExportAudit', tt: 'lbl.ClassTypes_CLASS_TYPE_XA_POLICY_EXPORT_AUDIT'}, CLASS_TYPE_TRX_LOG:{value:1010, label:'Transaction log', rbkey:'xa.enum.ClassTypes.CLASS_TYPE_TRX_LOG', tt: 'lbl.ClassTypes_CLASS_TYPE_TRX_LOG'}, CLASS_TYPE_XA_ACCESS_AUDIT:{value:1011, label:'Access Audit', rbkey:'xa.enum.ClassTypes.CLASS_TYPE_XA_ACCESS_AUDIT', modelName:'VXAccessAudit', type:'vXAccessAudit', tt: 'lbl.ClassTypes_CLASS_TYPE_XA_ACCESS_AUDIT'}, - CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE:{value:1012, label:'Transaction log attribute', rbkey:'xa.enum.ClassTypes.CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE', tt: 'lbl.ClassTypes_CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE'} + CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE:{value:1012, label:'Transaction log attribute', rbkey:'xa.enum.ClassTypes.CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE', tt: 'lbl.ClassTypes_CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE'}, + CLASS_TYPE_RANGER_POLICY:{value:1020, label:'Ranger Policy', rbkey:'xa.enum.ClassTypes.CLASS_TYPE_RANGER_POLICY', modelName:'VXRangerPolicy', type:'vXResource', tt: 'lbl.ClassTypes_CLASS_TYPE_RANGER_POLICY'}, + CLASS_TYPE_RANGER_SERVICE:{value:1030, label:'Ranger Service', rbkey:'xa.enum.ClassTypes.CLASS_TYPE_RANGER_SERVICE', modelName:'VXRangerService', type:'vXRangerService', tt: 'lbl.ClassTypes_CLASS_TYPE_RANGER_SERVICE'}, + }); XAEnums.DataType = mergeParams(XAEnums.DataType, { http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/utils/XAUtils.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js b/security-admin/src/main/webapp/scripts/utils/XAUtils.js index efcbd83..114fc88 100644 --- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js +++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js @@ -794,5 +794,8 @@ define(function(require) { } return controller; }; + XAUtils.getRangerServiceByName = function(name) { + return "service/plugins/services/name/"+name; + }; return XAUtils; }); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js index 686836b..678d5d5 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js +++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js @@ -478,10 +478,10 @@ define(function(require) { }, addNew : function(){ var that =this; - if(this.groupList.length > this.collection.length || (this.userList.length > this.collection.length)){ +// if(this.groupList.length > this.collection.length && (this.userList.length > this.collection.length)){ this.collection.add(new Backbone.Model()); // this.toggleAddButton(); - } +// } }, toggleAddButton : function(){ var groupNames=[], userNames=[]; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js index 42b5f68..fd567e8 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js @@ -104,7 +104,7 @@ define(function(require){ Backbone.Form.prototype.render.call(this, options); //initialize path plugin for hdfs component : resourcePath if(!_.isUndefined(this.initilializePathPlugin) && this.initilializePathPlugin){ - this.initializePathPlugins(); + this.initializePathPlugins(this.pathPluginOpts); } this.renderCustomFields(); if(!this.model.isNew()){ @@ -294,7 +294,7 @@ define(function(require){ return policyItemList; }, /** all post render plugin initialization */ - initializePathPlugins: function(){ + initializePathPlugins: function(options){ var that= this,defaultValue = []; if(!this.model.isNew() && _.isUndefined(this.model.get('path'))){ defaultValue = this.model.get('path').values; @@ -306,22 +306,7 @@ define(function(require){ return split( term ).pop(); } - this.fields[that.pathFieldName].editor.$el.find('[data-js="resource"]').bind( "keydown", function( event ) { - // don't navigate away from the field on tab when selecting an item - /*if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "ui-autocomplete" ).menu.active ) { - event.preventDefault(); - } - //TODO FIXME This is not working. We need a way so that when user enters and presses ENTER - // the text box should contain /app/billing* . Currently the '*' is getting removed. - if ( event.keyCode === $.ui.keyCode.ENTER ) { - event.preventDefault(); - event.stopPropagation(); - $(this).tagit("createTag", "brand-new-tag"); - //$(this).autocomplete('close'); - //$(this).val($(this).val() + ', '); - - }*/ - }).tagit({ + this.fields[that.pathFieldName].editor.$el.find('[data-js="resource"]').tagit({ autocomplete : { cache: false, source: function( request, response ) { @@ -394,14 +379,12 @@ define(function(require){ that.fields[that.pathFieldName].$el.find('.help-inline').html(''); var tags = []; console.log(ui.tag); - if(ui.tagLabel.lastIndexOf('/') < 0 || - ui.tagLabel.lastIndexOf('/') == ui.tagLabel.length -1 && ui.tagLabel.lastIndexOf('/') != 0){ - tags = ui.tagLabel.substr(0,ui.tagLabel.lastIndexOf('/')); + if(!_.isUndefined(options.regExpValidation) && !options.regExpValidation.regexp.test(ui.tagLabel)){ that.fields[that.pathFieldName].$el.addClass('error'); - that.fields[that.pathFieldName].$el.find('.help-inline').html('Please enter valid resource path : ' + ui.tagLabel); + that.fields[that.pathFieldName].$el.find('.help-inline').html(options.regExpValidation.message); return false; } - } + } }).on('change',function(e){ //check dirty field for tagit input type : `path` XAUtil.checkDirtyField($(e.currentTarget).val(), defaultValue.toString(), $(e.currentTarget)) @@ -411,7 +394,7 @@ define(function(require){ }, getPlugginAttr :function(autocomplete, options){ var that =this; - var type = options.containerCssClass; + var type = options.containerCssClass, validRegExpString = true; if(!autocomplete) return{tags : true,width :'220px',multiple: true,minimumInputLength: 1, 'containerCssClass' : type}; else { @@ -436,10 +419,14 @@ define(function(require){ if ($(data).filter(function() { return this.text.localeCompare(term) === 0; }).length === 0) { - return { - id : term, - text: term - }; + if(!_.isUndefined(options.regExpValidation) && !options.regExpValidation.regexp.test(term)){ + validRegExpString = false; + }else{ + return { + id : term, + text: term + }; + } } }, ajax: { @@ -484,12 +471,10 @@ define(function(require){ return result.text; }, formatNoMatches : function(term){ - switch (type){ - case that.type.DATABASE :return localization.tt("msg.enterAlteastOneCharactere"); - case that.type.TABLE :return localization.tt("msg.enterAlteastOneCharactere"); - case that.type.COLUMN :return localization.tt("msg.enterAlteastOneCharactere"); - default : return "No Matches found"; + if(!validRegExpString && !_.isUndefined(options.regExpValidation)){ + return options.regExpValidation.message; } + return "No Matches found"; } }; } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js ---------------------------------------------------------------------- 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 702d79f..298933d 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js @@ -32,6 +32,7 @@ define(function(require){ var XATableLayout = require('views/common/XATableLayout'); var localization = require('utils/XALangSupport'); var vFolderInfo = require('views/folders/FolderInfo'); + var RangerService = require('models/RangerService'); var RangerServiceDef = require('models/RangerServiceDef'); var RangerPolicy = require('models/RangerPolicy'); var RangerPolicyTableLayoutTmpl = require('hbs!tmpl/policies/RangerPolicyTableLayout_tmpl'); @@ -140,7 +141,7 @@ define(function(require){ collection: this.collection, includeFilter : false, gridOpts : { -// row: TableRow, + row: Backgrid.Row.extend({}), header : XABackgrid, emptyText : 'No Policies found!' }, @@ -150,11 +151,17 @@ define(function(require){ getColumns : function(){ var that = this; var cols = { - name : { + id : { cell : "uri", href: function(model){ return '#!/service/'+that.rangerService.id+'/policies/'+model.id+'/edit'; }, + label : localization.tt("lbl.policyId"), + editable: false, + sortable : false + }, + name : { + cell : 'string', label : localization.tt("lbl.policyName"), editable: false, sortable : false http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/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 1e0d4c5..78798e4 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js +++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js @@ -31,16 +31,17 @@ define(function(require) { var XATableLayout = require('views/common/XATableLayout'); var localization = require('utils/XALangSupport'); - var VXAuthSession = require('collections/VXAuthSessionList'); - var VXTrxLogList = require('collections/VXTrxLogList'); - var VXAssetList = require('collections/VXAssetList'); - var VXPolicyExportAuditList = require('collections/VXPolicyExportAuditList'); - var RangerServiceDefList = require('collections/RangerServiceDefList'); - var RangerService = require('models/RangerService'); - var AuditlayoutTmpl = require('hbs!tmpl/reports/AuditLayout_tmpl'); - var vOperationDiffDetail = require('views/reports/OperationDiffDetail'); - var RangerPolicy = require('models/RangerPolicy'); - var RangerPolicyRO = require('views/policies/RangerPolicyRO'); + var VXAuthSession = require('collections/VXAuthSessionList'); + var VXTrxLogList = require('collections/VXTrxLogList'); + var VXAssetList = require('collections/VXAssetList'); + var VXPolicyExportAuditList = require('collections/VXPolicyExportAuditList'); + var RangerServiceDefList = require('collections/RangerServiceDefList'); + var RangerService = require('models/RangerService'); + var AuditlayoutTmpl = require('hbs!tmpl/reports/AuditLayout_tmpl'); + var vOperationDiffDetail = require('views/reports/OperationDiffDetail'); + var RangerPolicy = require('models/RangerPolicy'); + var RangerPolicyRO = require('views/policies/RangerPolicyRO'); + var vPlugableServiceDiffDetail = require('views/reports/PlugableServiceDiffDetail'); require('moment'); require('bootstrap-datepicker'); @@ -65,7 +66,6 @@ define(function(require) { /** Layout sub regions */ regions : { - //'rAuditTable' : 'div[data-id="r_auditTable"]', 'rTableList' : 'div[data-id="r_tableLists"]' }, @@ -90,8 +90,6 @@ define(function(require) { events : function() { var events = {}; events['click ' + this.ui.refresh] = 'onRefresh'; - //events['blur ' + this.ui.resourceName ] = 'onSearch'; - //events['change ' + this.ui.selectRepo ] = 'onChangeRepository'; events['click ' + this.ui.searchBtn] = 'onSearch'; events['click '+this.ui.tab+' a'] = 'onTabChange'; return events; @@ -116,7 +114,6 @@ define(function(require) { /** all events binding here */ bindEvents : function() { /*this.listenTo(this.model, "change:foo", this.modelChanged, this);*/ - /*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/ //this.listenTo(this.collection, "change:foo", this.render, this); }, initializeCollection : function(){ @@ -124,15 +121,12 @@ define(function(require) { this.collection.fetch({ reset : true, cache : false - //data : params, }); }, initializePolling : function(){ this.timerId = setInterval(function(){ // that.onRefresh(this.accessAuditList); console.log('polling collection..'); - //that.initializeCollection(); - //that.onSearch(); },XAGlobals.settings.AUDIT_REPORT_POLLING); }, initializeServiceDefColl : function() { @@ -209,7 +203,6 @@ define(function(require) { var that = this, tab; if(!_.isUndefined(e)) tab = $(e.currentTarget).attr('href'); - //tab = $(e.currentTarget).find('a').attr('href'); else tab = this.currentTab; this.$el.parents('body').find('.datepicker').remove(); @@ -218,7 +211,6 @@ define(function(require) { this.currentTab = '#bigData'; this.ui.visualSearch.show(); this.ui.visualSearch.parents('.well').show(); -// this.accessAuditList = new VXAccessAuditList(); this.renderBigDataTable(); this.modifyTableForSubcolumns(); if(this.accessAuditList.length <= 0){ @@ -244,12 +236,10 @@ define(function(require) { this.currentTab = '#loginSession'; this.authSessionList = new VXAuthSession(); this.renderLoginSessionTable(); - //var params = { sortBy : 'id',sortType: 'desc' }; //Setting SortBy as id and sortType as desc = 1 this.authSessionList.setSorting('id',1); this.authSessionList.fetch({ cache:false, - // data:params }); this.addSearchForLoginSessionTab(); break; @@ -296,6 +286,8 @@ define(function(require) { _.each(XAEnums.ClassTypes, function(obj){ if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) || + (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) || + (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) auditList.push({label :obj.label, value :obj.value+''}); @@ -344,7 +336,6 @@ define(function(require) { }, addSearchForAdminTab : function(){ var that = this; - //var searchOpt = _.pluck(this.getAdminTableColumns(), 'label'); var searchOpt = ["Operation", "Audit Type", "User", "Date", "Actions", "Session Id"]; searchOpt = _.without(searchOpt,'Date','Operation'); searchOpt = _.union(searchOpt, ['Start Date','End Date']);//'Today' @@ -360,6 +351,8 @@ define(function(require) { _.each(XAEnums.ClassTypes, function(obj){ if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) || + (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) || + (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) auditList.push({label :obj.label, value :obj.label+''}); @@ -412,10 +405,8 @@ define(function(require) { }, addSearchForLoginSessionTab : function(){ var that = this; - //var searchOpt = _.pluck(this.getLoginSessionColumns(), 'label'); var searchOpt = ["Session Id", "Login Id", "Result", "Login Type", "IP", "User Agent", "Login Time"]; searchOpt = _.without(searchOpt,'Login Time'); - //var searchOpt = ["Session Id", "Login Id", "Result", "Login Type", "IP", "User Agent", "Login Time"] searchOpt = _.union(searchOpt, ['Start Date','End Date']);//'Today' var serverAttrName = [{text : "Session Id", label :"id"}, {text : "Login Id", label :"loginId"}, {text : "Result", label :"authStatus",'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.AuthStatus)}, @@ -474,7 +465,6 @@ define(function(require) { }, addSearchForAgentTab : function(){ var that = this; - //var searchOpt = _.pluck(this.getAgentColumns(), 'label'); var searchOpt = ["Export Date", "Repository Name", "Plugin Id", "Plugin IP", "Http Response Code"]; searchOpt = _.without(searchOpt,'Export Date'); searchOpt = _.union(searchOpt, ['Start Date','End Date']);//'Today' @@ -559,21 +549,32 @@ define(function(require) { XAUtils.blockUI('unblock'); fullTrxLogListForTrxId = new VXTrxLogList(coll.vXTrxLogs); - var view = new vOperationDiffDetail({ - collection : fullTrxLogListForTrxId, - classType : self.model.get('objectClassType'), - objectName : self.model.get('objectName'), - objectId : self.model.get('objectId'), - objectCreatedDate : objectCreatedDate, - userName :self.model.get('owner'), - action : action - - }); + //diff view to support new plugable service model + if(self.model.get('objectClassType') == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value){ + var view = new vPlugableServiceDiffDetail({ + collection : fullTrxLogListForTrxId, + classType : self.model.get('objectClassType'), + objectName : self.model.get('objectName'), + objectId : self.model.get('objectId'), + objectCreatedDate : objectCreatedDate, + userName :self.model.get('owner'), + action : action + }); + }else{ + var view = new vOperationDiffDetail({ + collection : fullTrxLogListForTrxId, + classType : self.model.get('objectClassType'), + objectName : self.model.get('objectName'), + objectId : self.model.get('objectId'), + objectCreatedDate : objectCreatedDate, + userName :self.model.get('owner'), + action : action + }); + } var modal = new Backbone.BootstrapModal({ animate : true, content : view, title: localization.tt("h.operationDiff")+' : '+action, - // cancelText : localization.tt("lbl.done"), okText :localization.tt("lbl.ok"), allowCancel : true, escape : true @@ -586,7 +587,6 @@ define(function(require) { } }); -// this.ui.refreshTable.hide(); this.ui.tableList.addClass("clickable"); this.rTableList.show(new XATableLayout({ columns: this.getAdminTableColumns(), @@ -602,12 +602,14 @@ define(function(require) { getAdminTableColumns : function(){ var auditList = []; _.each(XAEnums.ClassTypes, function(obj){ - if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) - auditList.push({text :obj.label, id :obj.value}); - }); + if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) || + (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) || + (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) || + (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) || + (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) || + (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) + auditList.push({text :obj.label, id :obj.value}); + }); console.log(auditList); var cols = { operation : { @@ -620,22 +622,20 @@ define(function(require) { formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { rawValue = model.get('objectClassType'); - var action = model.get('action'); - var name = model.get('objectName'); - var html = ''; - var label = XAUtils.enumValueToLabel(XAEnums.ClassTypes,rawValue); - if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) - html = 'Repository '+action+'d '+'<b>'+name+'</b>';//'<a tabindex="-1" href="javascript:;" title="'+name+'">'+name+'</a>'; - if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) - html = 'Policy '+action+'d '+'<b>'+name+'</b>';//'<a tabindex="-1" href="javascript:;" title="'+name+'">'+name+'</a>'; + var action = model.get('action'), name = model.get('objectName'), + label = XAUtils.enumValueToLabel(XAEnums.ClassTypes,rawValue), html = ''; + if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value || rawValue == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) + html = 'Repository '+action+'d '+'<b>'+name+'</b>'; + if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value|| rawValue == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) + html = 'Policy '+action+'d '+'<b>'+name+'</b>'; if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) - html = 'User '+action+'d '+'<b>'+name+'</b>';//'<a tabindex="-1" href="javascript:;" title="'+name+'">'+name+'</a>'; + html = 'User '+action+'d '+'<b>'+name+'</b>'; if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value) - html = 'Group '+action+'d '+'<b>'+name+'</b>';//'<a tabindex="-1" href="javascript:;" title="'+name+'">'+name+'</a>'; + html = 'Group '+action+'d '+'<b>'+name+'</b>'; if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_USER_PROFILE.value) - html = 'User profile '+action+'d '+'<b>'+name+'</b>';//'<a tabindex="-1" href="javascript:;" title="'+name+'">'+name+'</a>'; + html = 'User profile '+action+'d '+'<b>'+name+'</b>'; if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_PASSWORD_CHANGE.value) - html = 'User profile '+action+'d '+'<b>'+name+'</b>';//'<a tabindex="-1" href="javascript:;" title="'+name+'">'+name+'</a>'; + html = 'User profile '+action+'d '+'<b>'+name+'</b>'; return html; } }) @@ -669,8 +669,8 @@ define(function(require) { drag : false, //sortable:false, editable:false, - sortType: 'toggle', - direction: 'descending', + sortType: 'toggle', + direction: 'descending', formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { return Globalize.format(new Date(model.get('createDate')), "MM/dd/yyyy hh:mm:ss tt"); @@ -781,7 +781,6 @@ define(function(require) { cache : false, async : false }); - // var href = '#!/service/'+rangerService.get('id')+'/policies/'+model.get('policyId')+'/edit'; var href = 'javascript:void(0)'; return '<a href="'+href+'" title="'+rawValue+'">'+rawValue+'</a>'; } @@ -791,13 +790,13 @@ define(function(require) { sortable : false }, eventTime : { - label : 'Event Time',// localization.tt("lbl.eventTime"), + label : 'Event Time', cell: "String", click : false, drag : false, editable:false, - sortType: 'toggle', - direction: 'descending', + 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"); @@ -805,7 +804,7 @@ define(function(require) { }) }, requestUser : { - label : 'User',//localization.tt("lbl.repositoryName"), + label : 'User', cell: "String", click : false, drag : false, @@ -813,7 +812,7 @@ define(function(require) { editable:false }, repoName : { - label : 'Name / Type',//localization.tt("lbl.repositoryName"), + label : 'Name / Type', cell: "html", click : false, drag : false, @@ -834,33 +833,6 @@ define(function(require) { } }) }, - /*repoType : { - label : '',//localization.tt("lbl.repoType"), - cell: "html", - click : false, - drag : false, - sortable:false, - editable:false, - formatter: _.extend({}, Backgrid.CellFormatter.prototype, { - fromRaw: function (rawValue) { - var html=''; - _.each(_.toArray(XAEnums.AssetType),function(m){ - if(parseInt(rawValue) == m.value){ - html = '<label class="label label-info">'+m.label+'</label>'; - } - }); - return rawValue; - } - }), - },*/ - /*policyType : { - label : '',//localization.tt("lbl.resourceType"), - cell: "String", - click : false, - drag : false, - sortable:false, - editable:false, - },*/ resourcePath : { label : localization.tt("lbl.resourceName"), cell: "html", @@ -899,8 +871,6 @@ define(function(require) { html = '<label class="label label-success">'+label+'</label>'; else html = '<label class="label label-important">'+label+'</label>'; - //else - // html = '<label class="label">'+label+'</label>'; } }); return html; @@ -915,177 +885,25 @@ define(function(require) { sortable:false, editable:false }, - /*policyId : { - label : 'Policy ID',//localization.tt("lbl.resourceId"), - cell: "string", - click : false, - drag : false, - // sortable:false, - editable:false - formatter: _.extend({}, Backgrid.CellFormatter.prototype, { - fromRaw: function (rawValue, model) { - return '<div>'+rawValue+'</div>\ - <div style="border-top: 1px solid #ddd;">'+model.get('resourceType')+'</div>'; - } - }), - },*/ clientIP : { - label : 'Client IP',//localization.tt("lbl.ip"), + label : 'Client IP', cell: "string", click : false, drag : false, sortable:false, editable:false - /*formatter: _.extend({}, Backgrid.CellFormatter.prototype, { - fromRaw: function (rawValue, model) { - return '<div>'+rawValue+'</div>\ - <div style="border-top: 1px solid #ddd;">'+model.get('clientType')+'</div>'; - } - }),*/ } - /*agentId : { - label : 'ID IP',//localization.tt("lbl.id"), - cell: "html", - click : false, - drag : false, - sortable:false, - editable:false, - formatter: _.extend({}, Backgrid.CellFormatter.prototype, { - fromRaw: function (rawValue, model) { - return '<div>'+rawValue+'</div>\ - <div style="border-top: 1px solid #ddd;">'+model.get('agentIp')+'</div>'; - } - }), - - },*/ - /*agentIp : { - label : localization.tt("lbl.ip"), - cell: "String", - click : false, - drag : false, - sortable:false, - editable:false, - },*/ - /* clientId : { - label : 'ID Type',//localization.tt("lbl.clientId"), - cell: "html", - click : false, - drag : false, - sortable:false, - editable:false, - formatter: _.extend({}, Backgrid.CellFormatter.prototype, { - fromRaw: function (rawValue, model) { - return '<div>'+rawValue+'</div>\ - <div style="border-top: 1px solid #ddd;">'+model.get('clientType')+'</div>'; - } - }), - },*/ - /*clientType : { - label : '',//localization.tt("lbl.clientType"), - cell: "String", - click : false, - drag : false, - sortable:false, - editable:false, - },*/ - /* auditType : { - label : '',//localization.tt("lbl.auditType"), - cell: "html", - click : false, - drag : false, - sortable:false, - editable:false, - formatter: _.extend({}, Backgrid.CellFormatter.prototype, { - fromRaw: function (rawValue) { - var html=''; - _.each(_.toArray(XAEnums.XAAuditType),function(m){ - if(parseInt(rawValue) == m.value){ - html = '<label class="label label-success">'+m.label+'</label>'; - } - }); - return html; - } - }), - }, - sessionId : { - label : '',//localization.tt("lbl.sessionId"), - cell: "String", - click : false, - drag : false, - sortable:false, - editable:false, - },*/ - }; return this.accessAuditList.constructor.getTableCols(cols, this.accessAuditList); }, renderLoginSessionTable : function(){ var that = this; this.ui.tableList.removeClass("clickable"); - - /*var TableRow = Backgrid.Row.extend({ - events: { - 'click' : 'onClick', - 'mouseenter' : 'onClick', - 'mouseleave' : 'onMouseLeave' - }, - initialize : function(){ - var that = this; - var args = Array.prototype.slice.apply(arguments); - Backgrid.Row.prototype.initialize.apply(this, args); - }, - onClick: function (e,s,a) { - var self = this; - if($(e.target).is('.icon-edit,.icon-trash,a,code')) - return; - this.$('[data-id="'+this.model.id+'"]').popover('show'); - if(!$('.popover').is('div')) - this.$('[data-id="'+this.model.id+'"]').popover('show'); - else - this.$('[data-id="'+this.model.id+'"]').popover('hide'); - // this.$el.parent('tbody').find('tr').removeClass('tr-active'); - // this.$el.toggleClass('tr-active'); - if($(e.target).has('showMore')){ - if($(e.target).is('span') && $(e.target).text() != '--'){ - var text = $(e.target).text(); - var popoverHTML = '<div type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="right" data-content="'+text+'">\ - Popover on right\ - </div>'; - $(e.target).parent().append(popoverHTML); - $('[data-toggle="popover"]').popover({ - trigger: 'hover' - }); - - }else if($(e.target).is('td') && $(e.target).text() != '--'){ - var text = $(e.target).find('span').text(); - $(e.target).find('span').css('position','relative'); - tooltip.setAttribute( "class", "tooltips" ); - tooltip.innerText = $(e.target).find('span').attr("title"); - //tooltip.style.display = "inline"; - $(tooltip).attr('style','position:absolute;display:block;').css("top", Y).css("left", X); - $(e.target).append(tooltip); - } - } - }, - onMouseLeave : function(e){ - var self = this; - // this.$('[data-toggle="popover"]').popover('hide'); -// this.$('[data-id="'+this.model.id+'"]').popover('hide'); - if($(e.target).is('.icon-edit,.icon-trash,a,code')) - return; - // this.$el.parent('tbody').find('tr').removeClass('tr-active'); - // this.$el.toggleClass('tr-active'); - // if($(e.target).has('td')) - // $('.tooltips').remove(); - } - }); - */ this.rTableList.show(new XATableLayout({ columns: this.getLoginSessionColumns(), collection:this.authSessionList, includeFilter : false, gridOpts : { -// row :TableRow,//Backgrid.Row.extend({}), row :Backgrid.Row.extend({}), header : XABackgrid, emptyText : 'No login session found!!' @@ -1157,7 +975,6 @@ define(function(require) { label= m.label; } }); - //return '<label class="label label-info">'+label+'</label>'; return label; } }) @@ -1215,8 +1032,6 @@ define(function(require) { cell : 'string', formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { - //var date = new Date(model.get('createDate')).toString(); - //var timezone = date.replace(/^.*GMT.*\(/, "").replace(/\)$/, ""); return Globalize.format(new Date(model.get('createDate')), "MM/dd/yyyy hh:mm:ss tt"); } }), @@ -1302,10 +1117,8 @@ define(function(require) { }, onSearch : function(e){ - //var param = {}; this.setCurrentTabCollection(); var resourceName= this.ui.resourceName.val(); - //var assetType = this.ui.selectRepo.select2('val'); var startDate = this.ui.startDate.val(); var endDate = this.ui.endDate.val(); var params = { 'startDate' : startDate , 'endDate' : endDate }; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js b/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js index e13f6c3..48a3715 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js +++ b/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js @@ -135,7 +135,8 @@ define(function(require){ }); }, getTemplateForView : function(){ - if(this.classType == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value){ + if(this.classType == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value + || this.classType == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value){ this.templateType=XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value; if(this.action == 'create'){ this.template = AssetOperationDiff_tmpl; @@ -212,7 +213,6 @@ define(function(require){ if(attrName == "IP Address") type = 'ipAddress'; if(m.get('attributeName') == 'Permission Type' || m.get('attributeName') == "IP Address"){ -// if(m.get('attributeName') == 'Permission Type'){ if(m.get('parentObjectClassType') == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value){ if(m.get('action') != 'delete'){ if(m.get('action') == 'create'){ @@ -278,7 +278,6 @@ define(function(require){ if(_.isUndefined(m.get('attributeName'))) modelColl.push(m); - //if(m.get('attributeName') == 'Column Type') }); this.newGroupPermList = _.groupBy(this.newGroupPermList, 'groupName'); @@ -288,15 +287,7 @@ define(function(require){ this.removeUnwantedElement(); this.createEqualLengthArr(); - console.log('UserList'); - console.log(this.userList); - console.log('GroupList'); - console.log(this.groupList); - console.log(this.newGroupPermList); - console.log(this.previousGroupPermList); - console.log(this.newUserPermList); - console.log(this.previousUserPermList); if(!_.isEmpty(this.newGroupPermList) || !_.isEmpty(this.previousGroupPermList)) this.isGroupPerm = true; if(!_.isEmpty(this.newUserPermList) || !_.isEmpty(this.previousUserPermList)) @@ -370,13 +361,6 @@ define(function(require){ if(!m.has('attributeName')) modelArr.push(m); } - //TODO - /* if(m.get('action') == 'update'){ - if(m.get('previousValue') == 'null'){ - m.set('previousValue', ''); - } - - }*/ }); if(!_.isEmpty(this.newGroupList) || !_.isEmpty(this.previousGroupList)) this.isGroup = true; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js b/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js new file mode 100644 index 0000000..ceb8898 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js @@ -0,0 +1,357 @@ +/* + * 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 XAUtils = require('utils/XAUtils'); + var RangerPolicy = require('models/RangerPolicy'); + var RangerService = require('models/RangerService'); + var RangerServiceDef = require('models/RangerServiceDef'); + var PolicyOperationDiff_tmpl = require('hbs!tmpl/reports/PlugableServicePolicyDiff_tmpl'); + var PolicyUpdateOperationDiff_tmpl = require('hbs!tmpl/reports/PlugableServicePolicyUpdateDiff_tmpl'); + var PolicyDeleteOperationDiff_tmpl = require('hbs!tmpl/reports/PlugableServicePolicyDeleteDiff_tmpl'); + var PolicyDeleteUpdateOperationDiff_tmpl = require('hbs!tmpl/reports/PolicyDeleteOperationDiff_tmpl'); + + var PlugableServiceDiffDetail = Backbone.Marionette.ItemView.extend( + /** @lends PlugableServiceDiffDetail */ + { + _viewName : 'PlugableServiceDiffDetail', + + template: PolicyOperationDiff_tmpl, + templateHelpers :function(){ + return { + collection : this.collection.models, + action : this.action, + objectName : this.objectName, + objectId : this.objectId, + objectCreatedDate : this.objectCreatedDate, + objectCreatedBy : this.objectCreatedBy, + newPolicyItems : this.newPermList, + oldPolicyItems : this.oldPermList, + policyName : this.policyName, + policyId : this.policyId, + repositoryType : this.repositoryType, + + }; + }, + /** ui selector cache */ + ui: { + groupPerm : '.groupPerm', + userPerm : '.userPerm', + oldValues : '[data-id="oldValues"]', + diff : '[data-id="diff"]', + policyDiff: '[data-name="policyDiff"]', + policyDetail: '[class="policyDetail"]' + + }, + + /** ui events hash */ + events: function() { + var events = {}; + //events['change ' + this.ui.input] = 'onInputChange'; + return events; + }, + + /** + * intialize a new PlugableServiceDiffDetail ItemView + * @constructs + */ + initialize: function(options) { + console.log("initialized a PlugableServiceDiffDetail ItemView"); + + _.extend(this, _.pick(options, 'classType','objectName','objectId','objectCreatedDate','action','userName','policyId')); + this.bindEvents(); + //this.initializeDiffOperation(); + this.initializeServiceDef(); + this.getTemplateForView(); + + }, + initializeServiceDef : function(){ + var url; + /*if(this.action == 'update'){ + var rangerPolicy = new RangerPolicy({'id':this.objectId}) + rangerPolicy.fetch({ + cache : false, + async : false + }) + this.policyName = rangerPolicy.get('name'); + url = XAUtils.getRangerServiceByName(rangerPolicy.get('service')) + }else{ + }*/ + var policyName = this.collection.findWhere({'attributeName':'Policy Name'}); + if(this.action == 'create'){ + this.policyName = policyName.get('newValue'); + }else if(this.action == 'delete'){ + this.policyName = policyName.get('previousValue'); + } + if(!_.isUndefined(this.collection.models[0]) ){ + this.policyName = _.isUndefined(this.policyName) ? this.collection.models[0].get('objectName') : this.policyName; + if(this.action != 'delete'){ + url = XAUtils.getRangerServiceByName(this.collection.models[0].get('parentObjectName')) + var rangerService = new RangerService() + rangerService.url = url; + rangerService.fetch({ + cache : false, + async : false + }) + this.rangerServiceDefModel = new RangerServiceDef(); + this.rangerServiceDefModel.url = XAUtils.getRangerServiceDef(rangerService.get('type')); + this.rangerServiceDefModel.fetch({ + cache : false, + async : false + }) + this.repositoryType = this.rangerServiceDefModel.get('name'); + } + + //get policy created/updated date/owner + var model = this.collection.models[0]; + this.objectCreatedBy = model.get('updatedBy'); + } + }, + /** all events binding here */ + bindEvents : function(){ + /*this.listenTo(this.model, "change:foo", this.modelChanged, this);*/ + /*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/ + }, + /** on render callback */ + onRender: function() { + this.initializePlugins(); + this.removeLastCommaFromSpans(this.$el.find('.policyDetail').find('ol li')) + this.removeLastCommaFromSpans(this.ui.diff.find('ol li')) + + _.each(this.ui.policyDiff.find('ol li'),function(m){ + if(_.isEmpty($(m).text().trim())) + $(m).removeClass('change-row').text('--'); + }); + //Remove last br from ol + this.$el.find('.diff-perms').find('.diff-right').find('ol:last').next().remove() + this.$el.find('.diff-perms').find('.diff-left').find('ol:last').next().remove() + + var newOl = this.$el.find('.diff-perms').find('.diff-right').find('ol'); + var oldOl = this.$el.find('.diff-perms').find('.diff-left').find('ol'); + + _.each(oldOl, function(ol, i) { + console.log() + this.highLightElement($(ol).find('.username'), $(newOl[i]).find('.username')); + this.highLightElement($(ol).find('.groupname'), $(newOl[i]).find('.groupname')); + this.highLightElement($(ol).find('.perm'), $(newOl[i]).find('.perm')); + this.highLightElement($(ol).find('.condition'), $(newOl[i]).find('.condition')); + + },this); + }, + removeLastCommaFromSpans : function($el) { + //remove last comma + _.each($el,function(m){ + var text = $(m).text().replace(/,(?=[^,]*$)/, ''); + $(m).find('span').last().remove(); + }); + }, + highLightElement : function(oldOlList, newOlList) { + var removedUsers = this.array_diff(oldOlList, newOlList) + var addedUsers = this.array_diff(newOlList, oldOlList) + _.each(removedUsers, function(userSpan) { $(userSpan).addClass('delete-text')}); + _.each(addedUsers, function(userSpan) { $(userSpan).addClass('add-text')}); + }, + array_diff :function(array1, array2){ +// var array1 = [<span>user1<span>,<span>user2<span>,<span>user3<span>,<span>user4<span>]; +// var array2 = [<span>user1<span>,<span>user3<span>]; +// array_diff = [<span>user2<span>,<span>user4<span>] + var difference = []; + var tmpArr2 = _.map(array2,function(a){ return (a.innerHTML);}) + $.grep(array1, function(el) { + if ($.inArray(el.innerHTML, tmpArr2) == -1){ + difference.push(el); + } + + }); + return difference; + }, + getTemplateForView : function(){ + if(this.action == 'create'){ + this.template = PolicyOperationDiff_tmpl; + }else if(this.action == 'update'){ + this.template = PolicyUpdateOperationDiff_tmpl; + }else{ + this.template = PolicyDeleteOperationDiff_tmpl; + } + //prepare data for template + this.newPolicyItems = null, this.oldPolicyItems = null ; + var policyStatus = this.collection.findWhere({'attributeName':'Policy Status'}) + if(!_.isUndefined(policyStatus)){ + if(!_.isEmpty(policyStatus.get('previousValue'))){ + var tmp = this.collection.get(policyStatus.id) + tmp.set("previousValue", policyStatus.get('previousValue') == "true" ? 'enabled' : 'disabled') + } + if(!_.isEmpty(policyStatus.get('newValue'))){ + var tmp = this.collection.get(policyStatus.id) + tmp.set("newValue", policyStatus.get('newValue') == "true" ? 'enabled' : 'disabled') + } + } + var policyResource = this.collection.findWhere({'attributeName':'Policy Resources'}) + if(!_.isUndefined(policyResource)){ + this.getPolicyResources(); + } + var policyItems = this.collection.findWhere({'attributeName':'Policy Items'}); + if(!_.isUndefined(policyItems)){ + this.getPolicyItems(); + } + }, + getPolicyResources : function() { + var policyResources = this.collection.findWhere({'attributeName':'Policy Resources'}); + this.collection.remove(policyResources); + if(!_.isUndefined(policyResources.get('newValue')) && !_.isEmpty(policyResources.get('newValue'))){ + var resources = {} ; + var resourceNewValues = JSON.parse(policyResources.get('newValue')); + if(!_.isUndefined(this.rangerServiceDefModel)){ + _.each(this.rangerServiceDefModel.get('resources'), function(obj) { + _.each(resourceNewValues,function(val,key){ + if(obj.name == key){ + resources[obj.name] = val.values.toString(); + if(!_.isUndefined(obj.excludesSupported) && obj.excludesSupported){ + resources[obj.name+' exclude'] = val.isExcludes.toString(); + } + if(!_.isUndefined(obj.recursiveSupported) && obj.recursiveSupported){ + resources[obj.name+' recursive'] = val.isRecursive.toString(); + } + } + }); + }); + } + } + if(!_.isUndefined(policyResources.get('previousValue')) && !_.isEmpty(policyResources.get('previousValue'))){ + var oldResources = {} ; + var resourceNewValues = JSON.parse(policyResources.get('previousValue')); + if(!_.isUndefined(this.rangerServiceDefModel)){ + _.each(this.rangerServiceDefModel.get('resources'), function(obj) { + _.each(resourceNewValues,function(val,key){ + if(obj.name == key){ + oldResources[obj.name] = val.values.toString(); + if(!_.isUndefined(obj.excludesSupported) && obj.excludesSupported){ + oldResources[obj.name+' exclude'] = val.isExcludes.toString(); + } + if(!_.isUndefined(obj.recursiveSupported) && obj.recursiveSupported){ + oldResources[obj.name+' recursive'] = val.isRecursive.toString(); + } + } + }); + }); + } + } + if(this.action == "update"){ + _.each(resources,function(val, key){ +// console.log(oldResources) + if(val != oldResources[key]) + this.collection.add({'attributeName':key, 'newValue':val.toString(),'previousValue': oldResources[key],type : "Policy Resources"}); + }, this) + }else if(this.action == "create"){ + _.each(resources,function(val, key){ this.collection.add({'attributeName':key, 'newValue':val.toString()}); }, this) + }else{ + _.each(oldResources,function(val, key){ this.collection.add({'attributeName':key, 'previousValue':val.toString()}); }, this) + } + }, + getPolicyItems : function() { + var items = {}; + var policyItems = this.collection.findWhere({'attributeName':'Policy Items'}); + this.collection.remove(policyItems); + if(!_.isUndefined(policyItems.get('newValue')) && !_.isEmpty(policyItems.get('newValue'))){ + this.newPolicyItems = JSON.parse(policyItems.get('newValue')); + _.each(this.newPolicyItems, function(obj){ + if(!_.isUndefined(obj.accesses)){ + var permissions = _.map(_.where(obj.accesses,{'isAllowed':true}), function(t) { return t.type; }); + obj['permissions'] = permissions; + obj['delegateAdmin'] = obj.delegateAdmin ? 'enabled' : 'disabled'; + } + }); + } + if(!_.isUndefined(policyItems.get('previousValue')) && !_.isEmpty(policyItems.get('previousValue'))){ + this.oldPolicyItems = JSON.parse(policyItems.get('previousValue')); + _.each(this.oldPolicyItems, function(obj){ + if(!_.isUndefined(obj.accesses)){ + var permissions = _.map(_.where(obj.accesses,{'isAllowed':true}), function(t) { return t.type; }); + obj['permissions'] = permissions; + obj['delegateAdmin'] = obj.delegateAdmin ? 'enabled' : 'disabled'; + } + }); + } + this.oldPermList =[], this.newPermList =[] + if(this.action == "update"){ + this.setOldeNewPermList(); + }else{ + this.oldPermList = this.oldPolicyItems; + this.newPermList = this.newPolicyItems; + } + }, + setOldeNewPermList : function() { + var found = false; + for(var i=0; i< this.newPolicyItems.length ;i++){ + found = false; + for(var j=0; j< this.oldPolicyItems.length ;j++){ + if(!found) + if(_.intersection(this.oldPolicyItems[j].users,this.newPolicyItems[i].users).length > 0 + || _.intersection(this.oldPolicyItems[j].groups,this.newPolicyItems[i].groups).length > 0){ + if(JSON.stringify(this.newPolicyItems[i]) != JSON.stringify(this.oldPolicyItems[j])){ + this.oldPermList.push(this.oldPolicyItems[j]) + this.newPermList.push(this.newPolicyItems[i]) + } + found = true; + } + } + if(!found){ + this.oldPermList.push({}) + this.newPermList.push(this.newPolicyItems[i]) + } + } + for(var i=0; i< this.oldPolicyItems.length ;i++){ + found = false; + for(var j=0; j < this.newPolicyItems.length;j++){ + if(!found && _.intersection(this.oldPolicyItems[i].users,this.newPolicyItems[j].users).length > 0 + || _.intersection(this.oldPolicyItems[i].groups,this.newPolicyItems[j].groups).length > 0){ + if(JSON.stringify(this.oldPolicyItems[i]) != JSON.stringify(this.newPolicyItems[j])){ + if($.inArray(this.oldPolicyItems[i], this.oldPermList) < 0){ + this.oldPermList.push(this.oldPolicyItems[i]) + this.newPermList.push(this.newPolicyItems[j]) + } + } + found = true; + } + } + if(!found){ + this.oldPermList.push(this.oldPolicyItems[i]) + this.newPermList.push({}) + } + } + console.log(this.oldPermList) + console.log(this.newPermList) + }, + /** all post render plugin initialization */ + initializePlugins: function(){ + }, + /** on close */ + onClose: function(){ + } + + }); + + return PlugableServiceDiffDetail; +}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js ---------------------------------------------------------------------- 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 9e689c0..b1ed454 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js +++ b/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js @@ -188,17 +188,23 @@ define(function(require) {'use strict'; getColumns : function(coll){ var that = this; var cols = { - name : { + id : { cell : "uri", href: function(model){ var rangerService = new RangerService(); rangerService.urlRoot += '/name/'+model.get('service'); rangerService.fetch({ - cache : true, + cache : false, async : false }); return '#!/service/'+rangerService.get('id')+'/policies/'+model.id+'/edit'; }, + label : localization.tt("lbl.policyId"), + editable: false, + sortable : false + }, + name : { + cell : 'string', label : localization.tt("lbl.policyName"), editable: false, sortable : false @@ -280,9 +286,10 @@ define(function(require) {'use strict'; this.ui.userGroup.select2({ closeOnSelect : true, placeholder : 'Select Group', - // maximumSelectionSize : 1, + maximumSelectionSize : 1, width :'220px', tokenSeparators: [",", " "], + allowClear: true, // tags : this.groupArr, initSelection : function (element, callback) { var data = []; @@ -328,7 +335,7 @@ define(function(require) {'use strict'; var that = this; var arr = []; this.userArr = this.userList.map(function(m){ - return { id : m.id , text : m.get('name')}; + return { id : m.get('name') , text : m.get('name')}; }); this.ui.userName.select2({ // multiple: true, @@ -338,12 +345,13 @@ define(function(require) {'use strict'; // 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: this, text: obj.text}); + data.push({id: obj.text, text: obj.text}); }); callback(data); }, @@ -358,7 +366,7 @@ define(function(require) {'use strict'; if(!_.isEmpty(that.ui.userName.select2('val'))) selectedVals = that.ui.userName.select2('val'); if(data.resultSize != "0"){ - results = data.vXUsers.map(function(m, i){ return {id : m.id+"", text: m.name}; }); + results = data.vXUsers.map(function(m, i){ return {id : m.name, text: m.name}; }); if(!_.isEmpty(selectedVals)) results = XAUtil.filterResultByIds(results, selectedVals); return {results : results}; @@ -513,4 +521,4 @@ define(function(require) {'use strict'; }); return UserAccessLayout; -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/scripts/views/users/UserForm.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/users/UserForm.js b/security-admin/src/main/webapp/scripts/views/users/UserForm.js index ec40b2e..a447baf 100644 --- a/security-admin/src/main/webapp/scripts/views/users/UserForm.js +++ b/security-admin/src/main/webapp/scripts/views/users/UserForm.js @@ -63,7 +63,6 @@ define(function(require){ name : { type : 'Text', title : localization.tt("lbl.userName") +' *', - //validators : ['required'], validators : ['required',{type:'regexp',regexp:/^[a-z0-9][a-z0-9,._'-]+$/i,message :"Name should start with alpha/numeric letters and can have special characters ,._'-"}], editorAttrs :{'maxlength': 32} }, @@ -84,13 +83,12 @@ define(function(require){ firstName : { type : 'Text', title : localization.tt("lbl.firstName")+' *', - validators : ['required',{type:'regexp',regexp:/^[a-z][a-z0-9]+$/i,message :'Please enter valid name'}] + validators : ['required',{type:'regexp',regexp:/^[a-zA-Z][a-z0-9- ]*[a-zA-Z0-9]+$/,message :'First name to start with alphabets & can have hyphen,space.'}] }, lastName : { type : 'Text', title : localization.tt("lbl.lastName"), - validators : [{type:'regexp',regexp:/^[a-z][a-z0-9]+$/i,message :'Please enter valid name'}] - ///^[a-zA-z][a-z ,.'-]+$/i + validators : [{type:'regexp',regexp:/^[a-zA-Z][a-z0-9- ]*[a-zA-Z0-9]+$/,message :'Last name to start with alphabets & can have hyphen,space.'}] }, emailAddress : { type : 'Text', @@ -108,13 +106,6 @@ define(function(require){ } }; }, - /*userRoleListChange : function(form, fieldEditor){ - if(fieldEditor.getValue() == 1){ - this.model.set('userRoleList',["ROLE_USER"]); - }else{ - this.model.set('userRoleList',["ROLE_SYS_ADMIN"]); - } - },*/ /** on render callback */ render: function(options) { var that = this; @@ -189,8 +180,8 @@ define(function(require){ this.fields.password.$el.hide(); this.fields.passwordConfirm.$el.hide(); - this.fields.password.editor.validators = [];//this.removeElementFromArr(this.fields.password.editor.validators , 'required'); - this.fields.passwordConfirm.editor.validators = [];//this.removeElementFromArr(this.fields.passwordConfirm.editor.validators , 'required'); + this.fields.password.editor.validators = []; + this.fields.passwordConfirm.editor.validators = []; //Remove validation checks for external users if(this.model.get('userSource') == XAEnums.UserSource.XA_USER.value){ this.fields.firstName.editor.validators = []; @@ -209,14 +200,6 @@ define(function(require){ var groupArr = this.$('[data-customfields="groupIdList"]').find('.tags').editable('getValue', true); if(_.isNumber(groupArr)) groupArr = groupArr.toString().split(','); - /*if(_.isEmpty(groupArr) ){ - this.$('[data-customfields="groupIdList"]').find('.control-group').addClass('error'); - this.$('[data-customfields="groupIdList"]').find('[data-error="groupIdList"]').show(); - return false; - }else{ - this.$('[data-customfields="groupIdList"]').find('.control-group').removeClass('error'); - this.$('[data-customfields="groupIdList"]').find('[data-error="groupIdList"]').hide(); - }*/ this.model.set('groupIdList',groupArr); this.model.set('status',XAEnums.ActivationStatus.ACT_STATUS_ACTIVE.value); this.model.unset('passwordConfirm'); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/styles/xa.css ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/styles/xa.css b/security-admin/src/main/webapp/styles/xa.css index b2ade90..c4f2f71 100644 --- a/security-admin/src/main/webapp/styles/xa.css +++ b/security-admin/src/main/webapp/styles/xa.css @@ -1405,6 +1405,7 @@ ul.tabs > li > a { top: 0; } .diff ol { + min-width: 250px; display: table-cell; margin: 0; padding: 0; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/templates/helpers/XAHelpers.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js b/security-admin/src/main/webapp/templates/helpers/XAHelpers.js index afb31d9..d2926af 100644 --- a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js +++ b/security-admin/src/main/webapp/templates/helpers/XAHelpers.js @@ -397,6 +397,35 @@ } return html; }); + Handlebars.registerHelper('highlightForPlugableServiceModel', function(newValue, oldValue, hightlightValue, attrName) { + if(attrName != 'Policy Resources'){ + return hightlightValue == 'old' ? _.escape(oldValue) : _.escape(newValue); + } + newValue = newValue.split(',') + oldValue = oldValue.split(',') + var html=''; + if(hightlightValue == 'new'){ + _.each(newValue, function(val) { + if($.inArray(val, oldValue) < 0){ + html += '<span class="add-text">'+_.escape(val)+'</span>'; + }else{ + html += '<span>'+_.escape(val)+'</span>'; + } + html+='<span>,</span>'; + }); + }else{ + _.each(oldValue, function(val) { + if($.inArray(val, newValue) < 0){ + html += '<span class="delete-text">'+_.escape(val)+'</span>'; + }else{ + html += '<span>'+_.escape(val)+'</span>'; + } + html+='<span>,</span>'; + + }); + } + return html; + }); Handlebars.registerHelper('highlightUsersForArr', function(val, arr, hightlightValue) { var html = val; if(hightlightValue == 'new'){ @@ -502,7 +531,9 @@ } return tr; }); - + Handlebars.registerHelper('capitaliseLetter', function(str) { + return str.toUpperCase(); + }); return HHelpers; }); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyDeleteDiff_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyDeleteDiff_tmpl.html b/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyDeleteDiff_tmpl.html new file mode 100644 index 0000000..0d632a4 --- /dev/null +++ b/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyDeleteDiff_tmpl.html @@ -0,0 +1,91 @@ +{{!-- + 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 class="diff-content"> + <b>Policy ID : </b><label class="label label-ranger"> {{objectId}}</label> + <label class="no-margin label-size13-weightbold">Policy Name : {{policyName}}</label> + <!-- <label class="no-margin label-size13-weightbold">Repository Type : {{repositoryType}}</label> --> + <label class="no-margin label-size13-weightbold"> Deleted Date : {{objectCreatedDate}}</label> + <label class="no-margin label-size13-weightbold" > Deleted By : {{objectCreatedBy}}</label> + +{{#if collection.length}} + <h5>Policy Details :</h5> + <div class="diff"> + <div class="diff-left"> + <h3>Fields</h3> + <ol class="attr"> + {{#each collection}} + <li class="change-row">{{./this.attributes.attributeName}}</li> + {{/each}} + </ol> + </div> + <div class="diff-left"> + <h3>Old Value</h3> + <ol class="unstyled data"> + {{#each collection}} + <li class="change-row">{{./this.attributes.previousValue}}</li> + {{/each}} + </ol> + </div> + </div> +{{/if}} + +{{#if oldPolicyItems}} + <h5>Users/Groups Permissions :</h5> + <div class="diff diff-perms"> + <div class="diff-right" data-id="diff"> + <h3>Old Value</h3> + {{#each oldPolicyItems}} + <ol class="unstyled data"> + <li class="change-row"><i>Groups</i>: + {{#if_eq this.groups compare=0}} + <empty> + {{else}} + {{#each this.groups}} + <span class="groupname">{{this}}</span><span>,</span> + {{/each}} + {{/if_eq}} + </li> + <li class="change-row"><i>Users</i>: + {{#if_eq this.users compare=0}} + <empty> + {{else}} + {{#each this.users}} + <span class="username">{{this}}</span><span>,</span> + {{/each}} + {{/if_eq}} + </li> + <li class="change-row"><i>Permissions</i>: + {{#each this.permissions}} + <span class="perm">{{this}}</span> <span>,</span> + {{/each}} + </li> + {{#if this.conditions}} + <li class="change-row"> + <i>Conditions</i>: + {{#each this.conditions}} + <span class="condition">{{this.type}} : [{{this.values}}]</span><span>,</span> + {{/each}} + </li> + {{/if}} + <li class="change-row"><i>Delegate Admin</i>: {{this.delegateAdmin}}</li> + </ol><br/> + {{/each}} + </div> + </div> +{{/if}} + +</div> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyDiff_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyDiff_tmpl.html b/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyDiff_tmpl.html new file mode 100644 index 0000000..353baa9 --- /dev/null +++ b/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyDiff_tmpl.html @@ -0,0 +1,87 @@ +{{!-- + 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 class="diff-content"> + <b>Policy ID : </b><label class="label label-ranger"> {{objectId}}</label> + <label class="no-margin label-size13-weightbold">Policy Name : {{policyName}}</label> + <label class="no-margin label-size13-weightbold">Repository Type : {{repositoryType}}</label> + <label class="no-margin label-size13-weightbold"> Created Date : {{objectCreatedDate}}</label> + <label class="no-margin label-size13-weightbold" > Created By : {{objectCreatedBy}}</label> + +{{#if collection.length}} + <h5>Policy Details :</h5> + <div class="diff"> + <div class="diff-left"> + <h3>Fields</h3> + <ol class="attr"> + {{#each collection}} + <li class="change-row">{{./this.attributes.attributeName}}</li> + {{/each}} + </ol> + </div> + <div class="diff-right"> + <h3>New Value</h3> + <ol class="unstyled data"> + {{#each collection}} + <li class="change-row">{{./this.attributes.newValue}}</li> + {{/each}} + </ol> + </div> + </div> +{{/if}} + +{{#if newPolicyItems}} + <h5>Users/Groups Permissions :</h5> + <div class="diff diff-perms" > + <div class="diff-right" data-id="diff"> + <h3>New Value</h3> + {{#each newPolicyItems}} + <ol class="unstyled data"> + <li class="change-row">Groups: + {{#if_eq this.groups compare=0}} + <empty> + {{else}} + {{this.groups}} + {{/if_eq}} + </li> + <li class="change-row">Users: + {{#if_eq this.users compare=0}} + <empty> + {{else}} + {{this.users}} + {{/if_eq}} + </li> + <li class="change-row">Permissions: + {{#each this.permissions}} + {{this}} <span>,</span> + {{/each}} + </li> + {{#if this.conditions}} + <li class="change-row"> + Conditions: + {{#each this.conditions}} + {{this.type}} : [{{this.values}}]<span>,</span> + {{/each}} + </li> + {{/if}} + <li class="change-row">Delegate Admin:{{this.delegateAdmin}}</li> + </ol><br/> + {{/each}} + </div> + </div> +{{/if}} + +</div> http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyUpdateDiff_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyUpdateDiff_tmpl.html b/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyUpdateDiff_tmpl.html new file mode 100644 index 0000000..f61e91f --- /dev/null +++ b/security-admin/src/main/webapp/templates/reports/PlugableServicePolicyUpdateDiff_tmpl.html @@ -0,0 +1,161 @@ +{{!-- + 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 class="diff-content"> + <div class="row-fluid"> + <div class="span6"> + <b>Policy ID : </b><label class="label label-ranger"> {{objectId}}</label> + <label class="no-margin label-size13-weightbold">Policy Name : {{policyName}}</label> + <label class="no-margin label-size13-weightbold">Repository Type : {{repositoryType}}</label> + <label class="no-margin label-size13-weightbold"> Updated Date : {{objectCreatedDate}}</label> + <label class="no-margin label-size13-weightbold" > Updated By : {{objectCreatedBy}}</label> + </div> + <div class="span6 text-right"> + <div class="add-text legend"></div> Added + <div class="delete-text legend"></div> Deleted + </div> + </div> +{{#if collection.length}} + <h5>Policy Details :</h5> + <div class="diff policyDetail"> + <div class="diff-left"> + <h3>Fields</h3> + <ol class="attr"> + {{#each collection}} + <li class="change-row">{{./this.attributes.attributeName}}</li> + {{/each}} + </ol> + </div> + <div class="diff-left"> + <h3>Old Value</h3> + <ol class="unstyled data"> + {{#each collection}} + {{#compare ./this.attributes.previousValue "eq" ''}} + <li>--</li> + {{else}} + <li class="change-row">{{{highlightForPlugableServiceModel ./this.attributes.newValue ./this.attributes.previousValue 'old' ./this.attributes.type}}}</li> + {{/compare}} + <!-- <li class="change-row">{{./this.attributes.previousValue}}</li> --> + {{/each}} + </ol> + </div> + <div class="diff-right"> + <h3>New Value</h3> + <ol class="unstyled data"> + {{#each collection}} + <!-- <li class="change-row">{{./this.attributes.newValue}}</li> --> + {{#compare ./this.attributes.newValue "eq" ''}} + <li>--</li> + {{else}} + <li class="change-row">{{{highlightForPlugableServiceModel ./this.attributes.newValue ./this.attributes.previousValue 'new' ./this.attributes.type}}}</li> + {{/compare}} + {{/each}} + </ol> + </div> + </div> +{{/if}} +{{#if oldPolicyItems}} + <h5>Users/Groups Permissions :</h5> + <div class="diff diff-perms"> + <div class="diff-left" data-id="diff"> + <h3>old Value</h3> + {{#each oldPolicyItems}} + <ol class="unstyled data"> + {{#if this.permissions}} + <li class="change-row"><i>Groups</i>: + {{#if_eq this.groups compare=0}} + <empty> + {{else}} + {{#each this.groups}} + <span class="groupname">{{this}}</span><span>,</span> + {{/each}} + {{/if_eq}} + </li> + <li class="change-row"><i>Users</i>: + {{#if_eq this.users compare=0}} + <empty> + {{else}} + {{#each this.users}} + <span class="username">{{this}}</span><span>,</span> + {{/each}} + {{/if_eq}} + </li> + <li class="change-row"><i>Permissions</i>: + {{#each this.permissions}} + <span class="perm">{{this}}</span> <span>,</span> + {{/each}} + </li> + {{#if this.conditions}} + <li class="change-row"> + <i>Conditions</i>: + {{#each this.conditions}} + <span class="condition">{{this.type}} : [{{this.values}}]</span><span>,</span> + {{/each}} + </li> + {{/if}} + <li class="change-row"><i>Delegate Admin</i>: {{this.delegateAdmin}}</li> + {{else}} + <li style=" min-height: 99px; line-height: 102px; text-align: center; font-weight: bold; font-style: italic;"><empty></li> + {{/if}} + </ol><br/> + {{/each}} + </div> + <div class="diff-right" data-id="diff"> + <h3>New Value</h3> + {{#each newPolicyItems}} + <ol class="unstyled data"> + {{#if this.permissions}} + <li class="change-row"><i>Groups</i>: + {{#if_eq this.groups compare=0}} + <empty> + {{else}} + {{#each this.groups}} + <span class="groupname">{{this}}</span><span>,</span> + {{/each}} + {{/if_eq}} + </li> + <li class="change-row"><i>Users</i>: + {{#if_eq this.users compare=0}} + <empty> + {{else}} + {{#each this.users}} + <span class="username">{{this}}</span><span>,</span> + {{/each}} + {{/if_eq}} + </li> + <li class="change-row"><i>Permissions</i>: + {{#each this.permissions}} + <span class="perm">{{this}}</span> <span>,</span> + {{/each}} + </li> + {{#if this.conditions}} + <li class="change-row"> + <i>Conditions</i>: + {{#each this.conditions}} + <span class="condition">{{this.type}} : [{{this.values}}]</span><span>,</span> + {{/each}} + </li> + {{/if}} + <li class="change-row"><i>Delegate Admin</i>: {{this.delegateAdmin}}</li> + {{else}} + <li style=" min-height: 99px; line-height: 102px; text-align: center; font-weight: bold; font-style: italic;"><empty></li> + {{/if}} + </ol><br/> + {{/each}} + </div> + </div> + {{/if}} +</div> http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/templates/reports/PolicyUpdateOperationDiff_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/reports/PolicyUpdateOperationDiff_tmpl.html b/security-admin/src/main/webapp/templates/reports/PolicyUpdateOperationDiff_tmpl.html index ccdc901..45c3c59 100644 --- a/security-admin/src/main/webapp/templates/reports/PolicyUpdateOperationDiff_tmpl.html +++ b/security-admin/src/main/webapp/templates/reports/PolicyUpdateOperationDiff_tmpl.html @@ -47,7 +47,7 @@ {{#compare ./this.attributes.previousValue "eq" ''}} <li>--</li> {{else}} - <li class="change-row">{{{highlightNewForAttr ./this.attributes.newValue ./this.attributes.previousValue 'old'}}}</li> + <li class="change-row">{{{highlightNewForObj ./this.attributes.newValue ./this.attributes.previousValue 'old'}}}</li> {{/compare}} {{else}} <li>--</li> @@ -63,7 +63,7 @@ {{#compare ./this.attributes.newValue "eq" ''}} <li>--</li> {{else}} - <li class="change-row">{{{highlightNewForAttr ./this.attributes.newValue ./this.attributes.previousValue 'new'}}}</li> + <li class="change-row">{{{highlightNewForObj ./this.attributes.newValue ./this.attributes.previousValue 'new'}}}</li> {{/compare}} {{else}} <li>--</li> http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/templates/reports/UserAccessLayout_tmpl.html ---------------------------------------------------------------------- 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 58798d1..e12ce7f 100644 --- a/security-admin/src/main/webapp/templates/reports/UserAccessLayout_tmpl.html +++ b/security-admin/src/main/webapp/templates/reports/UserAccessLayout_tmpl.html @@ -105,7 +105,7 @@ <div class="row-fluid"> {{#each policyHeaderList}} - <h3 class="wrap-header bold reportSearchHeader" data-js="hdfsHeader"> {{this.serviceDefName}} + <h3 class="wrap-header bold reportSearchHeader" data-js="hdfsHeader"> {{capitaliseLetter this.serviceDefName}} <span class="label label-yellow pull-right" data-js="hdfsSearchResult" ></span> </h3> <div class="wrap well position-relative"> http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/8e786fa6/security-admin/src/main/webapp/templates/reports/UserOperationDiff_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/reports/UserOperationDiff_tmpl.html b/security-admin/src/main/webapp/templates/reports/UserOperationDiff_tmpl.html index 6606c3f..c8ce957 100644 --- a/security-admin/src/main/webapp/templates/reports/UserOperationDiff_tmpl.html +++ b/security-admin/src/main/webapp/templates/reports/UserOperationDiff_tmpl.html @@ -48,28 +48,28 @@ </div> </div> {{/if}} - - <h5>Group :</h5> - <div class="diff"> - <div class="diff-left"> - <h3>Fields</h3> - <ol class="attr"> - <li class="change-row">Groups</li> - </ol> - </div> - <div class="diff-right" data-id="diff"> - <h3>New Value</h3> - <ol class="unstyled data"> - <li class="change-row"> - {{#each newGroupList}} - {{./this}} - <span>,</span> - {{/each}} - </li> - </ol> + {{#if isGroup}} + <h5>Group :</h5> + <div class="diff"> + <div class="diff-left"> + <h3>Fields</h3> + <ol class="attr"> + <li class="change-row">Groups</li> + </ol> + </div> + <div class="diff-right" data-id="diff"> + <h3>New Value</h3> + <ol class="unstyled data"> + <li class="change-row"> + {{#each newGroupList}} + {{./this}} + <span>,</span> + {{/each}} + </li> + </ol> + </div> </div> - </div> - + {{/if}} {{else}} <h4>{{tt 'msg.userDoesNotExistAnymore'}}</h4>
