RANGER-203: UI updates to: 1) support to include and recursive flags. 2) validate config and resource lookup. 3) show `Policy ID` column as link in audit page 4) use dynamically obtained repository types in audit page 5) enable search of policies in policy list page
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/93e578d4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/93e578d4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/93e578d4 Branch: refs/heads/master Commit: 93e578d48bf5caa36097ca84b432312919be7884 Parents: fda7b9f Author: Gautam Borad <[email protected]> Authored: Wed Feb 4 23:54:16 2015 -0800 Committer: Madhan Neethiraj <[email protected]> Committed: Wed Feb 4 23:54:16 2015 -0800 ---------------------------------------------------------------------- .../scripts/model_bases/RangerServiceBase.js | 13 +- .../scripts/models/BackboneFormDataType.js | 66 ++++-- .../main/webapp/scripts/modules/XAOverrides.js | 132 ++++++++++++ .../scripts/modules/globalize/message/en.js | 3 +- .../scripts/views/policies/PermissionList.js | 6 +- .../scripts/views/policies/RangerPolicyForm.js | 201 ++++++------------- .../views/policies/RangerPolicyTableLayout.js | 23 ++- .../webapp/scripts/views/reports/AuditLayout.js | 42 +++- .../scripts/views/service/ServiceCreate.js | 2 +- security-admin/src/main/webapp/styles/xa.css | 18 +- .../policies/RangerPolicyForm_tmpl.html | 19 -- 11 files changed, 319 insertions(+), 206 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/security-admin/src/main/webapp/scripts/model_bases/RangerServiceBase.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/model_bases/RangerServiceBase.js b/security-admin/src/main/webapp/scripts/model_bases/RangerServiceBase.js index a4abfda..7c2f737 100644 --- a/security-admin/src/main/webapp/scripts/model_bases/RangerServiceBase.js +++ b/security-admin/src/main/webapp/scripts/model_bases/RangerServiceBase.js @@ -77,7 +77,18 @@ define(function(require){ this.modelName = 'RangerServiceBase'; //this.bind("error", XAUtils.defaultErrorHandler); this.bindErrorEvents(); - } + }, + testConfig : function(vRangerService, options){ + var url = this.urlRoot + '/validateConfig'; + + options = _.extend({ + data : JSON.stringify(vRangerService), + contentType : 'application/json', + dataType : 'json' + }, options); + + return this.constructor.nonCrudOperation.call(this, url, 'POST', options); + }, }, { // static class members http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/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 b5792fb..847cecf 100644 --- a/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js +++ b/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js @@ -25,29 +25,39 @@ define(function(require) { var FormDataType = Backbone.Model.extend({ type : [ 'string', 'boolean', 'int' ], getFormElements : function(configs, enums, attrs, form) { -// var attrs = []; - _.each(configs, function(v, k) { + var samelevelFieldCreated = []; + _.each(configs, function(v, k,config) { if (v != null) { var formObj = {}; switch (v.type) { case 'string': - if(!_.isUndefined(v.lookupSupported) && v.lookupSupported ){ - formObj.type = 'Select2Remote'; - if(_.isUndefined(v.url)){ - var options = {'containerCssClass' : v.name }; - formObj.pluginAttr = form.getPlugginAttr(false, options); - }else{ - var options = {'url' : v.url , 'containerCssClass' : v.name }; - formObj.pluginAttr = form.getPlugginAttr(true, options); - } - formObj.editorAttrs = {'data-placeholder': v.label }, - // - formObj.level = v.level; + if($.inArray(v.level, samelevelFieldCreated) >= 0){ + return; + } + if(v.excludesSupported || v.recursiveSupported || v.lookupSupported){ + formObj.type = 'Resource'; + if(!_.isUndefined(v.lookupSupported) && v.lookupSupported ){ + var options = {'containerCssClass' : v.name, + lookupURL : "service/plugins/services/lookupResource/"+form.rangerService.get('name') + }; + formObj['select2Opts'] = form.getPlugginAttr(true, options); + } + formObj['excludeSupport']= v.excludesSupported; + formObj['recursiveSupport'] = v.recursiveSupported; formObj.name = v.name; - formObj.options = function(callback, editor){ - callback(); - }, - formObj.onFocusOpen = true + formObj.level = v.level; + formObj.editorAttrs = {'data-placeholder': v.label }; + //check whether resourceType drop down is created for same level or not + var optionsAttrs = _.filter(config,function(field){ if(field.level == v.level) return field;}) + if(optionsAttrs.length > 1){ + formObj['resourcesAtSameLevel'] = true; + var optionsTitle = _.map(optionsAttrs,function(field){ return field.name;}); + formObj['sameLevelOpts'] = optionsTitle; + samelevelFieldCreated.push(v.level); + + v.name='sameLevel'+v.level; + v.label = ''; + } }else{ formObj.type = 'Text'; } @@ -63,9 +73,25 @@ define(function(require) { formObj.options = _.pluck(_.compact(enumObj.elements),'label'); break; case 'path' : - formObj.type = 'Text'; + /*formObj.type = 'Text'; form.initilializePathPlugin = true; - form.pathFieldName = v.name; + form.pathFieldName = v.name;*/ + formObj.type = 'Resource'; + if(!_.isUndefined(v.lookupSupported) && v.lookupSupported ){ + var options = {'containerCssClass' : v.name, + lookupURL : "service/plugins/services/lookupResource/"+form.rangerService.get('name') + }; + form.pathFieldName = v.name; + form.initilializePathPlugin = true; + } + formObj['excludeSupport']= v.excludesSupported; + formObj['recursiveSupport'] = v.recursiveSupported; + formObj['initilializePathPlugin'] = true; + formObj.name = v.name; + formObj.level = v.level; + formObj.editorAttrs = {'data-placeholder': v.label }; + + break; default:formObj.type = 'Text';break; } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/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 72bcaab..2dd0421 100644 --- a/security-admin/src/main/webapp/scripts/modules/XAOverrides.js +++ b/security-admin/src/main/webapp/scripts/modules/XAOverrides.js @@ -244,6 +244,7 @@ */ var Form = require('backbone-forms'); require('select2'); + Form.editors.Select2 = Form.editors.Select.extend({ initialize : function(options){ this.pluginAttr = _.extend( {'width' : 'resolve'}, options.schema.pluginAttr || {}); @@ -340,6 +341,137 @@ }); + /** + * #RANGER RESOURCE + * https://github.com/simontabor/jquery-toggles + * + */ + Form.editors.Resource = Form.editors.Base.extend({ + ui : { + 'resource' : '[data-js="resource"]', + 'excludeSupport' : '[data-js="include"]', + 'recursiveSupport' : '[data-js="recursive"]', + 'resourceType' : '[data-js="resourceType"]', + }, + events: { + 'click': function(event) { + }, + }, + + initialize: function(options) { + Form.editors.Base.prototype.initialize.call(this, options); + _.extend(this, _.pick(this.schema,'excludeSupport','recursiveSupport','select2Opts','resourcesAtSameLevel','sameLevelOpts','level','initilializePathPlugin')); + + this.template = this.getTemplate(); +// this.resourceObj = { 'level' : this.level}; + if(_.isUndefined(this.value) || _.isNull(this.value)){ + this.value = {}; + } + }, + getTemplate : function() { + var optionsHtml="", selectTemplate = '',excludeSupportToggleDiv='', recursiveSupportToggleDiv=''; + if(!_.isUndefined(this.resourcesAtSameLevel) && this.resourcesAtSameLevel){ + _.each(this.sameLevelOpts, function(option){ + return optionsHtml += "<option value='"+option+"'>"+option+"</option>" + }); + selectTemplate = '<select data-js="resourceType" class="btn dropdown-toggle" style="margin-right: 18px;margin-left: -116px;width: 100px;height: 29px;font-family: Tahoma;font-size: 14px;border-radius: 10px;border: 2px #cccccc solid;">\ + '+optionsHtml+'\ + </select>'; + } + if(!_.isUndefined(this.excludeSupport) && this.excludeSupport){ + excludeSupportToggleDiv = '<div class="toggle-xa include-toggle" data-js="include"><div class="toggle"></div></div>'; + } + if(!_.isUndefined(this.recursiveSupport) && this.recursiveSupport){ + kclass = !_.isEmpty(excludeSupportToggleDiv) ? 'recursive-toggle' : 'include-toggle'; + if(!_.isUndefined(this.initilializePathPlugin) && this.initilializePathPlugin){ + kclass = "recursive-toggle-path"; + } + recursiveSupportToggleDiv = '<div class="toggle-xa '+kclass+'" data-js="recursive"><div class="toggle"></div></div>'; + } + return _.template(selectTemplate+'<input data-js="resource" maxlength="255" type="text">'+excludeSupportToggleDiv+''+recursiveSupportToggleDiv); + }, + + /** + * Adds the editor to the DOM + */ + render: function() { + var that = this; + this.$el.html( this.template ); + this.$resource = this.$el.find(this.ui.resource) + this.$excludeSupport = this.$el.find(this.ui.excludeSupport) + this.$recursiveSupport = this.$el.find(this.ui.recursiveSupport) + this.$resourceType = this.$el.find(this.ui.resourceType) + + if(!_.isNull(this.value) && !_.isEmpty(this.value)){ + this.$resource.val(this.value.values.toString()) + } + if(!_.isUndefined(this.select2Opts)){ + this.$resource.select2(this.select2Opts); + } + var isExcludes = true, isRecursive = true; + if(this.excludeSupport){ + if(!_.isNull(this.value)){ + this.value.isExcludes = _.isUndefined(this.value.isExcludes) ? true : this.value.isExcludes; + isExcludes = this.value.isExcludes + } + this.$excludeSupport.toggles({ + on: isExcludes, + text : {on : 'include', off : 'exclude' }, + width: 80, + }).on('toggle', function (e, active) { + that.value.isExcludes = active; + }); + } + if(this.recursiveSupport){ + if(!_.isNull(this.value)){ + this.value.isRecursive = _.isUndefined(this.value.isRecursive) ? true : this.value.isRecursive; + isRecursive = this.value.isRecursive; + } + this.$recursiveSupport.toggles({ + on: isRecursive, + text : {on : 'recursive', off : 'nonrecursive' }, + width: 122, +// height: 20 + }).on('toggle', function (e, active) { + that.value.isRecursive = active; + }); + } + if(!_.isUndefined(this.$resourceType) && this.$resourceType.length > 0){ + if(!_.isNull(this.value) && !_.isEmpty(this.value)){ + this.$resourceType.val(this.value.resourceType); + } + this.$resourceType.on('change', function(e) { + if(!_.isUndefined(that.select2Opts)){ + that.$resource.select2('val', '') + }else{ + that.$resource.val(''); + } + //reset values + that.value.isExcludes = true; + that.value.isRecursive = true; + that.$excludeSupport.trigger('toggleOn'); + that.$recursiveSupport.trigger('toggleOn'); + }); + } + return this; + }, + + getValue: function() { + + if(!_.isUndefined(this.$resourceType) && this.$resourceType.length > 0){ + this.value['resourceType'] = this.$resourceType.val(); + } + this.value['resource'] = this.$resource.val(); + return this.value; + //return this.$el.find('.active').text() == "ON" ? true : false; + }, + + setValue: function(val) { + return true; + }, + + }); + //Scroll to top functionality on all views -- if the scroll height is > 500 px. http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js b/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js index 94f1444..5e3377a 100644 --- a/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js +++ b/security-admin/src/main/webapp/scripts/modules/globalize/message/en.js @@ -206,7 +206,8 @@ define(function(require) { topologyName : 'Topology Name', serivceName : 'Service Name', ipAddress : 'IP Address', - delegatedAdmin : 'Delegate Admin' + delegatedAdmin : 'Delegate Admin', + policyId : 'Policy ID' }, btn : { add : 'Add', http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/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 004f9fa..a1f95c5 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js +++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js @@ -86,7 +86,7 @@ define(function(require) { setupFormForEditMode : function() { this.accessItems = _.map(this.accessTypes, function(perm){ if(!_.isUndefined(perm)) - return {'type':perm.label,isAllowed : false} + return {'type':perm.name,isAllowed : false} }); if(this.model.has('editMode') && this.model.get('editMode')){ if(!_.isUndefined(this.model.get('groupName')) && !_.isNull(this.model.get('groupName'))){ @@ -120,7 +120,7 @@ define(function(require) { if( this.model.has('editMode') && this.model.get('editMode')){ _.each(this.model.get('accesses'), function(p){ if(p.isAllowed){ - var access = _.find(that.accessTypes,function(obj){if(obj.label == p.type) return obj}); + var access = _.find(that.accessTypes,function(obj){if(obj.name == p.type) return obj}); this.permsIds.push(access.name); } @@ -264,7 +264,7 @@ define(function(require) { _.each(that.accessTypes, function(obj) { if(_.contains(values, obj.name)){ - var type = obj.label + var type = obj.name _.each(that.accessItems, function(item){ if(item.type == type) item.isAllowed = true }); } }); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/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 d668c6f..d4e1a83 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js @@ -49,10 +49,6 @@ define(function(require){ { _viewName : 'RangerPolicyForm', - templateData : function() { - - return this.getTemplateData(); - }, /** * intialize a new RangerPolicyForm Form View * @constructs @@ -60,7 +56,7 @@ define(function(require){ initialize: function(options) { console.log("initialized a RangerPolicyForm Form View"); _.extend(this, _.pick(options, 'rangerServiceDefModel', 'rangerService')); - this.setupForm() + this.setupForm(); Backbone.Form.prototype.initialize.call(this, options); this.initializeCollection(); @@ -80,10 +76,6 @@ define(function(require){ this.on('resourceStatus:change', function(form, fieldEditor){ this.evResourceStatusChange(form, fieldEditor); }); - - /*this.on('sameLevelType:change', function(form, fieldEditor){ - this.evResourceTypeChange(form, fieldEditor); - });*/ }, /** fields for the form @@ -94,101 +86,19 @@ define(function(require){ }, getSchema : function(){ var attrs = {}; - var schemaNames = this.rangerServiceDefModel.get('name') == "hdfs" ? ['description', 'isRecursive', 'isAuditEnabled'] : ['description', 'isAuditEnabled']; + var schemaNames = ['description', 'isAuditEnabled']; var formDataType = new BackboneFormDataType(); attrs = formDataType.getFormElements(this.rangerServiceDefModel.get('resources'),this.rangerServiceDefModel.get('enums'), attrs, this); - attrs = this.setSameLevelField(attrs, schemaNames); - var attr1 = _.pick(_.result(this.model,'schemaBase'), 'name','isEnabled'); var attr2 = _.pick(_.result(this.model,'schemaBase'),schemaNames); return _.extend(attr1,_.extend(attrs,attr2)); }, - setSameLevelField : function(attrs, schemaNames) { - var level = [],sameLevel = [],that = this; - this.sameLevelType = [],this.selectOptions = {}; - this.sameLevelFound = false; - //Get array of all levels like [1,2,2,3,4,4,4,5,6] - _.each(attrs, function(obj){ level.push(obj.level) }) - - /* count levels - counts = { 1 : 1, 2 : 2, 3 : 1, 4: 3, 5 : 1, 6 : 1} - */ - var counts = {}; - level.forEach(function(x) { counts[x] = (counts[x] || 0)+1; }); - //create level counter array which has more than one same level - _.each(counts, function(cnt,l) { - if(cnt > 1){ - sameLevel.push(l); - this.sameLevelFound = true; - } - }, this); - - if(this.sameLevelFound){ - this.schemaBase = ['name','isEnabled']; - this.schemaBase1 = schemaNames; - var editorsAttr = [], fieldAttrs = []; - //iterate over same level array - _.each(sameLevel, function(lev, i) { - //get same level resources - var OptionsAttrs = _.filter(attrs,function(field){ if(field.level == lev) return field;}) - var optionsTitle = _.map(OptionsAttrs,function(field){ return field.name;}); - - //cretae selectType for same level resource - attrs['sameLevelType'+lev] = { - type : 'Select', - options : optionsTitle, - editorAttrs : {'class':'btn dropdown-toggle','style': 'width: 100px;height: 29px;font-family: Tahoma;font-size: 14px;border-radius: 10px;border: 2px #cccccc solid;'} - }; - //hide all select options - _.each(optionsTitle, function(field,i){ - if( i > 0 ) attrs[field].editorAttrs['style']='display:none'; - }) - //create sameLevelType array - var tmp = { 'name' : "sameLevelType"+lev, 'options' : optionsTitle.toString() }; - this.sameLevelType.push(tmp); - - editorsAttr = editorsAttr.concat(optionsTitle) - }, this) - - //create fieldAttrs array - _.each(attrs, function(obj){ - if(!_.isUndefined(obj.name) && $.inArray(obj.name, editorsAttr) < 0 ){ - fieldAttrs.push(obj.name); - } - }); - - // Add Resources in same order as give in JSON - var addToschemaBase = true; - _.each(attrs,function(field, i) { - if(!_.isUndefined(field.name)){ - if($.inArray(field.name, editorsAttr) < 0 && addToschemaBase){ - this.schemaBase.push(field.name) - } - if($.inArray(field.name, editorsAttr) >= 0){ - addToschemaBase = false; - } - if($.inArray(field.name, editorsAttr) < 0 && !addToschemaBase){ - this.schemaBase1.unshift(field.name) - } - - } - }, this); - - - } - //add change events on all sameLevelType - _.each(this.sameLevelType, function(obj, i){ - that.on(obj.name+':change', function(form, fieldEditor) { - this.evResourceTypeChange(form, fieldEditor); - }); - }); - return attrs; - }, /** on render callback */ render: function(options) { var that = this; + Backbone.Form.prototype.render.call(this, options); //initialize path plugin for hdfs component : resourcePath if(!_.isUndefined(this.initilializePathPlugin) && this.initilializePathPlugin){ @@ -199,7 +109,6 @@ define(function(require){ this.setUpSwitches(); } this.$el.find('.field-isEnabled').find('.control-label').remove(); - this.setupSameLevelType(); }, evAuditChange : function(form, fieldEditor){ XAUtil.checkDirtyFieldForToggle(fieldEditor); @@ -210,47 +119,25 @@ define(function(require){ evResourceStatusChange : function(form, fieldEditor){ XAUtil.checkDirtyFieldForToggle(fieldEditor); }, - getTemplateData : function() { - var obj={ 'fieldsets' : true }; - if(this.sameLevelFound){ - obj = { sameLevelType : this.sameLevelType, - schemaBase : this.schemaBase.toString(), - schemaBase1 : this.schemaBase1.toString(), - - }; - if(this.schemaBase.length <= 2) - obj.marginBottom57 = 'margin-bottom-57'; - } - return obj; - }, setupForm : function() { - _.each(this.model.attributes.resources,function(obj,key){ - this.model.set(key, obj.values.toString()); - if(!_.isUndefined(obj.isRecursive)){ - this.model.set('isRecursive', obj.isRecursive); - } - },this) + if(!this.model.isNew()){ + _.each(this.model.get('resources'),function(obj,key){ + var resourceDef = _.findWhere(this.rangerServiceDefModel.get('resources'),{'name':key}) + var sameLevelResourceDef = _.where(this.rangerServiceDefModel.get('resources'), {'level': resourceDef.level}); + if(sameLevelResourceDef.length > 1){ + obj['resourceType'] = key; + this.model.set('sameLevel'+resourceDef.level, obj) + }else{ + this.model.set(resourceDef.name, obj) + } + },this) + } }, setUpSwitches :function(){ var that = this; this.fields.isAuditEnabled.editor.setValue(this.model.get('isAuditEnabled')); this.fields.isEnabled.editor.setValue(this.model.get('isEnabled')); - if(!_.isUndefined(this.fields.isRecursive)) - this.fields.isRecursive.editor.setValue(this.model.get('isRecursive')); - }, - setupSameLevelType : function() { - //setup sameLevelType `select` if there - _.each(this.sameLevelType, function(obj, i){ - if(!this.model.isNew()){ - var sameLevelOpt = obj.options.split(','); - var sameLevelVal = _.find(sameLevelOpt, function(type){ if(!_.isEmpty(this.model.get(type))) return type;},this) - console.log(this.model.attributes) - this.model.set(obj.name,sameLevelVal); - this.fields[obj.name].editor.$el.val(sameLevelVal).trigger('change') - }else{ - this.fields[obj.name].editor.$el.trigger('change') - } - }, this); + }, /** all custom field rendering */ renderCustomFields: function(){ @@ -289,9 +176,25 @@ define(function(require){ _.each(this.rangerServiceDefModel.get('resources'),function(obj){ if(!_.isNull(obj)){ var rPolicyResource = new RangerPolicyResource(); - rPolicyResource.set('values',that.model.get(obj.name).split(',')); - rPolicyResource.set('isRecursive',that.model.get('isRecursive')) - resources[obj.name] = rPolicyResource; + var tmpObj = that.model.get(obj.name); + if(!_.isUndefined(tmpObj) && _.isObject(tmpObj)){ + rPolicyResource.set('values',tmpObj.resource.split(',')); + if(!_.isUndefined(tmpObj.isRecursive)){ + rPolicyResource.set('isRecursive', tmpObj.isRecursive) + } + if(!_.isUndefined(tmpObj.isExcludes)){ + rPolicyResource.set('isExcludes', tmpObj.isExcludes) + } + } + if(rPolicyResource.has('values')){ + if(!_.isUndefined(tmpObj) && !_.isUndefined(tmpObj.resourceType)){ + resources[tmpObj.resourceType] = rPolicyResource; + }else{ + if(_.isUndefined(resources[obj.name])){ + resources[obj.name] = rPolicyResource; + } + } + } that.model.unset(obj.name); } }); @@ -353,7 +256,7 @@ define(function(require){ return split( term ).pop(); } - this.fields[that.pathFieldName].editor.$el.bind( "keydown", function( event ) { + 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(); @@ -372,9 +275,18 @@ define(function(require){ autocomplete : { cache: false, source: function( request, response ) { - var p = $.getJSON( "service/assets/hdfs/resources", { - dataSourceName: that.rangerService.get('name'), - baseDirectory: extractLast( request.term ) + var url = "service/plugins/services/lookupResource/"+that.rangerService.get('name'); + var context ={ + 'userInput' : extractLast( request.term ), + 'resourceName' : null, + 'resources' : { null:null } + }; + var p = $.ajax({ + url : url, + type : "POST", + data : JSON.stringify(context), + dataType : 'json', + contentType: "application/json; charset=utf-8", }).done(function(data){ if(data.vXStrings){ response(data.vXStrings); @@ -451,7 +363,7 @@ define(function(require){ return { - containerCssClass : options.type, + containerCssClass : options.containerCssClass, closeOnSelect : true, tags:true, multiple: true, @@ -475,15 +387,22 @@ define(function(require){ }; } }, - ajax: { + ajax: { url: options.lookupURL, - dataType: 'json', + type : 'POST', params : { - timeout: 3000 + timeout: 3000, + contentType: "application/json; charset=utf-8", }, cache: false, data: function (term, page) { - return _.extend(that.getDataParams(type, term)); +// return _.extend(that.getDataParams(type, term)); + var context ={ + 'userInput' : term, + 'resourceName' : null, + 'resources' : { null:null } + }; + return JSON.stringify(context); }, results: function (data, page) { http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/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 de14a37..a805e27 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js @@ -124,7 +124,7 @@ define(function(require){ /** on render callback */ onRender: function() { // this.initializePlugins(); -// this.addVisualSearch(); + this.addVisualSearch(); this.renderTable(); // XAUtil.highlightDisabledPolicy(this); @@ -308,9 +308,9 @@ define(function(require){ }, addVisualSearch : function(){ var that = this; - var searchOpt = ['Resource Path','Group','Policy Name'];//,'Start Date','End Date','Today']; - var serverAttrName = [{text : "Resource Path", label :"name"}, {text : "Group", label :"groupName"}, - {text : "Policy Name", label :"policyName"}]; + var searchOpt = ['Policy Name','Group Name','User Name','Status'];//,'Start Date','End Date','Today']; + var serverAttrName = [{text : "Policy Name", label :"policyName"},{text : "Group Name", label :"group"}, + {text : "User Name", label :"user"}, {text : "Status", label :"status"}]; // {text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'}, // {text : 'Today',label :'today'}]; @@ -321,13 +321,13 @@ define(function(require){ callbacks : { valueMatches :function(facet, searchTerm, callback) { switch (facet) { - case 'Result': - callback(XAUtil.enumToSelectLabelValuePairs(XAEnums.AuthStatus)); + case 'Status': + callback(this.getActiveStatusNVList()); break; - case 'Login Type': + /* case 'Audit Status': callback(XAUtil.enumToSelectLabelValuePairs(XAEnums.AuthType)); break; - /*case 'Start Date' : + case 'Start Date' : setTimeout(function () { XAUtil.displayDatepicker(that.ui.visualSearch, callback); }, 0); break; case 'End Date' : @@ -344,6 +344,13 @@ define(function(require){ }; window.vs = XAUtil.addVisualSearch(searchOpt,serverAttrName, this.collection,pluginAttr); }, + getActiveStatusNVList : function() { + var activeStatusList = _.filter(XAEnums.ActiveStatus, function(obj){ + if(obj.label != XAEnums.ActiveStatus.STATUS_DELETED.label) + return obj; + }); + return _.map(activeStatusList, function(status) { return { 'label': status.label, 'value': status.label.toLowerCase()}; }) + }, /** on close */ onClose: function(){ } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/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 cf4be4c..2c79ed2 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js +++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js @@ -35,6 +35,8 @@ define(function(require) { 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'); @@ -162,6 +164,7 @@ define(function(require) { }, modifyTableForSubcolumns : function(){ this.$el.find('[data-id="r_tableList"] table thead').prepend('<tr>\ + <th class="renderable pid"></th>\ <th class="renderable ruser"></th>\ <th class="renderable ruser"></th>\ <th class="renderable cip">Repository</th>\ @@ -257,12 +260,13 @@ define(function(require) { }, addSearchForBigDataTab :function(){ var that = this; - + var serviceDefList = this.getServiceDefList(); + var serverListForRepoType = serviceDefList.map(function(serviceDef){ return {'label' : serviceDef.get('name').toUpperCase(), 'value' : serviceDef.get('id')}; }) var serverAttrName = [{text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'}, {text : 'Today',label :'today'},{text : 'User',label :'requestUser'}, {text : 'Resource Name',label :'resourcePath'},{text : 'Policy ID',label :'policyId'}, {text : 'Resource Type',label :'resourceType'},{text : 'Repository Name',label :'repoName'}, - {text : 'Repository Type',label :'repoType','multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.AssetType)}, + {text : 'Repository Type',label :'repoType','multiple' : true, 'optionsArr' : serverListForRepoType}, {text : 'Result',label :'accessResult', 'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.AccessResult)}, {text : 'Access Type',label :'accessType'},{text : 'Access Enforcer',label :'aclEnforcer'}, {text : 'Audit Type',label :'auditType'},{text : 'Session ID',label :'sessionId'}, @@ -295,12 +299,8 @@ define(function(require) { }); break; case 'Repository Type': - var assetTypeList = _.filter(XAEnums.AssetType, function(obj){ - if(obj.label != XAEnums.AssetType.ASSET_UNKNOWN.label - && obj.label != XAEnums.AssetType.ASSET_AGENT.label) - return obj; - }); - callback(XAUtils.hackForVSLabelValuePairs(assetTypeList)); + var serviceList = serviceDefList.map(function(serviceDef){ return {'label' : serviceDef.get('name').toUpperCase(), 'value' : serviceDef.get('name').toUpperCase()}; }) + callback(serviceList); break; case 'Result': callback(XAUtils.hackForVSLabelValuePairs(XAEnums.AccessResult)); @@ -332,6 +332,15 @@ define(function(require) { }; this.visualSearch = XAUtils.addVisualSearch(searchOpt,serverAttrName, this.accessAuditList, pluginAttr); }, + getServiceDefList : function() { + var serviceList=[]; + var serviceDefList = new RangerServiceDefList(); + serviceDefList.fetch({ + cache : false, + async:false + }); + return serviceDefList; + }, addSearchForAdminTab : function(){ var that = this; //var searchOpt = _.pluck(this.getAdminTableColumns(), 'label'); @@ -723,6 +732,21 @@ define(function(require) { getColumns : function(){ var that = this; var cols = { + policyId : { + cell : "uri", + href: function(model){ + var rangerService = new RangerService(); + rangerService.urlRoot += '/name/'+model.get('repoName'); + rangerService.fetch({ + cache : false, + async : false + }); + return '#!/service/'+rangerService.get('id')+'/policies/'+model.get('policyId')+'/edit'; + }, + label : localization.tt("lbl.policyId"), + editable: false, + sortable : false + }, eventTime : { label : 'Event Time',// localization.tt("lbl.eventTime"), cell: "String", @@ -1296,4 +1320,4 @@ define(function(require) { }); return AuditLayout; -}); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js b/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js index b4dd88b..413f125 100644 --- a/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js +++ b/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js @@ -73,7 +73,7 @@ define(function(require){ events['click ' + this.ui.btnSave] = 'onSave'; events['click ' + this.ui.btnCancel] = 'onCancel'; events['click ' + this.ui.btnDelete] = 'onDelete'; -// events['click ' + this.ui.btnTestConn] = 'onTestConnection'; + events['click ' + this.ui.btnTestConn] = 'onTestConnection'; return events; }, http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/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 6ee259f..18110c2 100644 --- a/security-admin/src/main/webapp/styles/xa.css +++ b/security-admin/src/main/webapp/styles/xa.css @@ -1690,9 +1690,6 @@ margin-bottom: 0 !important; .policy-form .field-isEnabled .controls{ margin-left:30px; } -.policy-form .field-database,.policy-form .field-table, .policy-form .field-path, .policy-form .field-topology{ - clear: both; -} .margin-bottom-5{ margin-bottom: 5px; } @@ -1724,4 +1721,19 @@ margin-bottom: 5px; } .policy-manager .row-fluid [class*="span"]:nth-child(3n+4) { clear: both; +} +.field-isEnabled + div { + clear:both; +} +.include-toggle{ + margin-left: 264px; + margin-top: -29px; +} +.recursive-toggle{ + margin-left: 363px; + margin-top: -20px; +} +.recursive-toggle-path { +margin-left: 347px; +margin-top: -29px; } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/93e578d4/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html index d2f26fe..0479ea8 100644 --- a/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html +++ b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html @@ -20,26 +20,7 @@ Policy Details : </p> - - -{{#if fieldsets}} <b data-fieldsets class="policy-form"></b> -{{else}} - <div data-fields="{{schemaBase}}" class="policy-form {{marginBottom57}}" ></div> - <div> - {{#each sameLevelType}} - <div style="margin-left: 65px;margin-bottom: 19px;"> - <span data-editors="{{this.name}}" class="policy-form" ></span> - <span data-editors="{{this.options}}" class="policy-form" style=" margin-left: 11px; "></span> - </div> - {{/each}} - <!-- <b data-editors="udf" class="policy-form"></b> --> - </div> - <div data-fields="{{schemaBase1}}" class="policy-form" ></div> -{{/if}} - <!-- <b data-fieldsets class="policy-form"></b> --> - - </fieldset> <fieldset>
