Repository: incubator-ranger Updated Branches: refs/heads/master 65d7fbc6e -> 62f86ef64
RANGER-458 : Recursive button in HDFS and Yarn Service definition needs to be changed Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/62f86ef6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/62f86ef6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/62f86ef6 Branch: refs/heads/master Commit: 62f86ef64c06219e81810946b0c97684d7beccfa Parents: 65d7fbc Author: Gautam Borad <[email protected]> Authored: Thu Jun 23 19:02:59 2016 +0530 Committer: Gautam Borad <[email protected]> Committed: Fri Jun 24 15:54:58 2016 +0530 ---------------------------------------------------------------------- .../main/webapp/scripts/models/RangerPolicy.js | 8 +++++ .../main/webapp/scripts/modules/XAOverrides.js | 17 ---------- .../scripts/views/policies/RangerPolicyForm.js | 34 +++++++++++++++++--- .../scripts/views/policies/RangerPolicyRO.js | 3 +- .../templates/policies/RangerPolicyRO_tmpl.html | 8 +++++ 5 files changed, 48 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/62f86ef6/security-admin/src/main/webapp/scripts/models/RangerPolicy.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/models/RangerPolicy.js b/security-admin/src/main/webapp/scripts/models/RangerPolicy.js index 46e498b..f348034 100644 --- a/security-admin/src/main/webapp/scripts/models/RangerPolicy.js +++ b/security-admin/src/main/webapp/scripts/models/RangerPolicy.js @@ -80,6 +80,14 @@ define(function(require){ offText : 'NO', switchOn : true }, + //recursive(ON/OFF) toggle + recursive : { + type : 'Switch', + title : 'Recursive', + onText : 'ON', + offText : 'OFF', + switchOn : true + } }); }, http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/62f86ef6/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 24f9bc2..5604237 100644 --- a/security-admin/src/main/webapp/scripts/modules/XAOverrides.js +++ b/security-admin/src/main/webapp/scripts/modules/XAOverrides.js @@ -454,15 +454,6 @@ 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: 105 -// height: 20 - }).on('toggle', function (e, active) { - that.value.isRecursive = active; - XAUtil.checkDirtyFieldForToggle($(e.currentTarget)) - }); } }, renderSameLevelResource : function() { @@ -482,7 +473,6 @@ that.value.isExcludes = false; that.value.isRecursive = false; that.$excludeSupport.trigger('toggleOn'); - that.$recursiveSupport.trigger('toggleOn'); ($(e.currentTarget).addClass('dirtyField')) //resource are shown if parent is selected or showned @@ -556,13 +546,6 @@ if(this.excludeSupport){ excludeSupportToggleDiv = '<div class="toggle-xa include-toggle" data-js="include"><div class="toggle"></div></div>'; } - if(this.recursiveSupport){ - kclass = !_.isEmpty(excludeSupportToggleDiv) ? 'recursive-toggle' : 'include-toggle'; - if(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" type="text">'+ excludeSupportToggleDiv+''+recursiveSupportToggleDiv); }, http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/62f86ef6/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 775fd25..d910187 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js @@ -104,13 +104,13 @@ define(function(require){ }, /** fields for the form */ - fields: ['name', 'description', 'isEnabled', 'isAuditEnabled'], + fields: ['name', 'description', 'isEnabled', 'isAuditEnabled','recursive'], schema :function(){ return this.getSchema(); }, getSchema : function(){ - var attrs = {}; - var basicSchema = ['name','isEnabled'] + var attrs = {},that = this; + var basicSchema = ['name','isEnabled']; var schemaNames = this.getPolicyBaseFieldNames(); var formDataType = new BackboneFormDataType(); @@ -118,6 +118,22 @@ define(function(require){ var attr1 = _.pick(_.result(this.model,'schemaBase'),basicSchema); var attr2 = _.pick(_.result(this.model,'schemaBase'),schemaNames); + var arr = {}; + + _.each(attrs,function(resourceObject,resourceName){ + if(resourceObject.hasOwnProperty('recursiveSupport')) { + if(resourceObject.recursiveSupport) { + var recursiveAttrSchema = _.pick(_.result(that.model,'schemaBase'),'recursive'); + if(!_.isUndefined(that.model.get('id'))) { + recursiveAttrSchema.recursive.switchOn=(that.model.get(resourceName)).isRecursive; + } + arr[resourceName] = resourceObject; + _.extend(arr,recursiveAttrSchema); + } + } + }); + _.extend(attrs,arr); + return _.extend(attr1,_.extend(attrs,attr2)); }, /** on render callback */ @@ -349,6 +365,16 @@ define(function(require){ var that = this, resources = []; var resources = {}; + //set 'isRecursive' attribute of resource object to value of field recursive + var recursiveValue = ''; + if(!_.isUndefined(this.model.get('recursive'))){ + recursiveValue = that.model.get('recursive'); + } + _.each(this.model.attributes,function(val) { + if(_.isObject(val) && !_.isUndefined(val.isRecursive)) { + val.isRecursive = recursiveValue; + } + });// 'isRecursive' attribute of model is updated //set sameLevel fieldAttr value with resource name _.each(this.model.attributes, function(val, key) { if(key.indexOf("sameLevel") >= 0){ @@ -722,7 +748,7 @@ define(function(require){ return obj; }, getPolicyBaseFieldNames : function(){ - var fields = ['description', 'isAuditEnabled']; + var fields = ['isAuditEnabled','description']; return fields; } }); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/62f86ef6/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js index 3ac07a2..0d8e3df 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js @@ -89,6 +89,7 @@ define(function(require) { details.resources = []; details.service = this.policy.get('service'); details.serviceType = this.serviceDef.get('name'); + details.isRecursive = undefined; _.each(this.serviceDef.get('resources'), function(def, i){ if(!_.isUndefined(this.policy.get('resources')[def.name])){ var resource = {}, @@ -96,7 +97,7 @@ define(function(require) { resource.label = def.label; resource.values = policyResources.values; if(def.recursiveSupported){ - resource.Rec_Exc = policyResources.isRecursive ? XAEnums.RecursiveStatus.STATUS_RECURSIVE.label : XAEnums.RecursiveStatus.STATUS_NONRECURSIVE.label; + details.isRecursive = policyResources.isRecursive ? 'ON': 'OFF'; } else if(def.excludesSupported){ resource.Rec_Exc = policyResources.isExcludes ? XAEnums.ExcludeStatus.STATUS_EXCLUDE.label : XAEnums.ExcludeStatus.STATUS_INCLUDE.label; } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/62f86ef6/security-admin/src/main/webapp/templates/policies/RangerPolicyRO_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/policies/RangerPolicyRO_tmpl.html b/security-admin/src/main/webapp/templates/policies/RangerPolicyRO_tmpl.html index 7dc48ad..6ff5329 100644 --- a/security-admin/src/main/webapp/templates/policies/RangerPolicyRO_tmpl.html +++ b/security-admin/src/main/webapp/templates/policies/RangerPolicyRO_tmpl.html @@ -70,7 +70,15 @@ {{PolicyDetails.description}} </td> </tr> + {{#if PolicyDetails.isRecursive}} + <tr> + <td>Recursive</td> + <td> + <span class="label label-info">{{PolicyDetails.isRecursive}}</span> + </td> </tr> + {{/if}} + <tr> <td> {{tt 'lbl.auditLogging'}} </td>
