ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prad...@apache.org
Subject [3/3] ranger git commit: RANGER-2011:Level 20 resource value is not set on UI in Ranger Edit Policy.
Date Wed, 07 Mar 2018 05:44:23 GMT
RANGER-2011:Level 20 resource value is not set on UI in Ranger Edit Policy.

Signed-off-by: pradeep <pradeep@apache.org>


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

Branch: refs/heads/master
Commit: 8f1625c26bc0dcd8970867c25b6be0b5afbbcb0f
Parents: 06bf917
Author: ni3galave <nitin.galave@gmail.com>
Authored: Wed Feb 28 19:30:10 2018 +0530
Committer: pradeep <pradeep@apache.org>
Committed: Wed Mar 7 09:21:11 2018 +0530

----------------------------------------------------------------------
 .../scripts/models/BackboneFormDataType.js      | 44 ++++++++++++++++++--
 .../scripts/views/policies/RangerPolicyForm.js  | 21 +++++++---
 .../common/ServiceManagerLayout_tmpl.html       |  9 ++--
 3 files changed, 63 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/8f1625c2/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 5c06ad9..a928470 100644
--- a/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js
+++ b/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js
@@ -89,7 +89,7 @@ define(function(require) {
 								}
 								break;
 							}
-							if($.inArray(v.level, samelevelFieldCreated) >= 0){
+                                                        if($.inArray(v.parent, samelevelFieldCreated)
>= 0){
 								return;
 							}
 							
@@ -141,8 +141,12 @@ define(function(require) {
 								if(optionsAttrs.length > 1){
 									var optionsTitle = _.map(optionsAttrs,function(field){ return field.name;});
 									formObj['sameLevelOpts'] = optionsTitle;
-									samelevelFieldCreated.push(v.level);
-									fieldName = 'sameLevel'+v.level;
+                                                                        samelevelFieldCreated.push(v.parent);
+                                                                        if(!_.isUndefined(v.parent)){
+                                                                                fieldName
= 'sameLevel'+v.level+''+v.parent;
+                                                                        }else{
+                                                                                fieldName
= 'sameLevel'+v.level;
+                                                                        }
 									formObj['title'] = '';
 									formObj['resourcesAtSameLevel'] = true;
 									
@@ -182,6 +186,7 @@ define(function(require) {
 							formObj['recursiveSupport'] = v.recursiveSupported;
 							formObj['name'] = v.name;
 							formObj['editorAttrs'] = {'data-placeholder': v.label };
+                                                        formObj.fieldAttrs = { 'data-name'
: 'field-'+v.name, 'parent' : v.parent };
 							if(!_.isUndefined(v.lookupSupported) && v.lookupSupported ){
 								var options = {
 										'containerCssClass' : v.name,
@@ -196,6 +201,39 @@ define(function(require) {
 								form.initilializePathPlugin = true;
 							}
 							formObj['initilializePathPlugin'] = true;
+                                                        var optionsAttrs = [] ,parentResource;
+                                                                if(!_.isUndefined(v.level)){
+                                                                        optionsAttrs = _.filter(config,function(field){
+                                                                                if(field.level
== v.level && field.parent == v.parent){
+                                                                                        return
field;
+                                                                                }
+                                                                        });
+                                                                }
+                                                                var resourceDef = _.findWhere(optionsAttrs,{'name':v.name});
+                                                                //for parent leftnode status
+                                                                if(v.parent){
+                                                                        parentResource =
_.findWhere(config ,{'name':v.parent});
+                                                                }
+                                                                //show only required resources
in acccess policy in order to show their access types
+                                                                if(!_.isUndefined(v.parent)
&& !_.isEmpty(v.parent)
+                                                                                &&
parentResource.isValidLeaf){
+                                                                        optionsAttrs.unshift({'level':v.level,
name:'none',label:'none'});
+                                                                }
+                                                                if(optionsAttrs.length >
1){
+                                                                        var optionsTitle
= _.map(optionsAttrs,function(field){ return field.name;});
+                                                                        formObj['sameLevelOpts']
= optionsTitle;
+                                                                        samelevelFieldCreated.push(v.parent);
+                                                                        if(!_.isUndefined(v.parent)){
+                                                                                fieldName
= 'sameLevel'+v.level+''+v.parent;
+                                                                        }else{
+                                                                                fieldName
= 'sameLevel'+v.level;
+                                                                        }
+                                                                        formObj['title']
= '';
+                                                                        formObj['resourcesAtSameLevel']
= true;
+
+                                                                        // formView is used
to listen form events
+                                                                        formObj['formView']
= form;
+                                                                }
 							break;
 						case 'password':formObj.type = 'Password';break;
 						default:formObj.type = 'Text';

http://git-wip-us.apache.org/repos/asf/ranger/blob/8f1625c2/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 c4eef7a..04dad2e 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
@@ -214,7 +214,7 @@ define(function(require){
 				_.each(this.model.get('resources'),function(obj,key){
 					var resourceDef = _.findWhere(resourceDefList,{'name':key}),
 					sameLevelResourceDef = [], parentResource ;
-					sameLevelResourceDef = _.where(resourceDefList, {'level': resourceDef.level});
+					sameLevelResourceDef = _.where(resourceDefList, {'level': resourceDef.level, 'parent'
: resourceDef.parent});
 					//for parent leftnode status
                     if(resourceDef.parent){
                     	parentResource = _.findWhere(resourceDefList ,{'name':resourceDef.parent});
@@ -227,9 +227,15 @@ define(function(require){
                     }
 					if(sameLevelResourceDef.length > 1){
 						obj['resourceType'] = key;
-						this.model.set('sameLevel'+resourceDef.level, obj)
-						//parentShowHide
-						this.selectedResourceTypes['sameLevel'+resourceDef.level]=key;
+                                                if(_.isUndefined(resourceDef.parent)){
+                                                        this.model.set('sameLevel'+resourceDef.level,
obj);
+                                                        //parentShowHide
+                                                        this.selectedResourceTypes['sameLevel'+resourceDef.level]
= key;
+                                                }else{
+                                                        this.model.set('sameLevel'+resourceDef.level+resourceDef.parent,
obj);
+                                                        this.selectedResourceTypes['sameLevel'+resourceDef.level+resourceDef.parent]
= key;
+                                                }
+
 					}else{
 						//single value support
 						/*if(! XAUtil.isSinglevValueInput(resourceDef) ){
@@ -677,7 +683,12 @@ define(function(require){
 				var currentResource = _.findWhere(this.getResources(), {'name': name });
 				//same level type
 				if(_.isUndefined(this.fields[currentResource.name])){
-					var sameLevelName = 'sameLevel'+currentResource.level;
+                                        if(!_.isUndefined(currentResource.parent)){
+                                                var sameLevelName = 'sameLevel'+currentResource.level
+ currentResource.parent;
+                                        }else{
+                                                var sameLevelName = 'sameLevel'+currentResource.level;
+                                        }
+
 					name = this.fields[sameLevelName].editor.$resourceType.val()
 					val = this.fields[sameLevelName].getValue();
 					if(isCurrentSameLevelField){

http://git-wip-us.apache.org/repos/asf/ranger/blob/8f1625c2/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
b/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
index fec2535..d4d19a6 100644
--- a/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
+++ b/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
@@ -36,10 +36,12 @@
 							<th>
 								<span class="policy-title">
                                                                 <!-- Remove alt attribut
from img tag -->
-                                   <img src="images/folder-grey.png">
-									{{./this.attributes.name}} 
+                                   <span>
+                                                                                <img src="images/folder-grey.png">
+                                                                                {{./this.attributes.name}}
+                                                                        </span>
 									{{#if ../operation}} 
-									
+                                                                        <span>
                                                                           <a href="javascript:void(0)"
title="Export" type="button" class="download  pull-right text-decoration" data-id="downloadBtnOnService"
data-servicetype="{{./this.attributes.name}}" style="margin-right: 5px;" >
                                           <i class="icon-external-link-sign"> </i>
 	                                   </a>
@@ -49,6 +51,7 @@
 									   </a>
 									   
                                                                            <a href="#!/service/{{./this.id}}/create"class="pull-right
text-decoration" title="Add New Service" style="margin-right: 2px;"> <i class="icon-plus"></i></a>
+                                    </span>
 									 
 									{{/if}}
 								</span>	


Mime
View raw message