You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ga...@apache.org on 2016/05/10 11:53:55 UTC

[2/2] incubator-ranger git commit: RANGER-974 : Allow users to move policy items in create / edit Policy screen

RANGER-974 : Allow users to move policy items in create / edit Policy screen

Signed-off-by: Gautam Borad <ga...@apache.org>


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

Branch: refs/heads/master
Commit: f4a7037dba4e9714535990dc619db5c0b445d90f
Parents: d4fd012
Author: Mehul Parikh <me...@freestoneinfotech.com>
Authored: Fri May 6 15:57:08 2016 +0530
Committer: Gautam Borad <ga...@apache.org>
Committed: Tue May 10 17:23:38 2016 +0530

----------------------------------------------------------------------
 .../scripts/views/policies/PermissionList.js    | 68 ++++++--------------
 .../views/policymanager/ServiceLayout.js        |  1 +
 .../webapp/scripts/views/reports/AuditLayout.js |  1 +
 security-admin/src/main/webapp/styles/xa.css    | 19 ++++++
 .../templates/policies/PermissionList.html      |  2 +-
 5 files changed, 40 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f4a7037d/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 326c84c..45d4d15 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
@@ -173,13 +173,11 @@ define(function(require) {
 					} else {
 						that.model.unset(name+'Name');
 					}
-					that.toggleAddButton(e);
 					return;
 				}
 				if(!_.isUndefined(e.added)){
 					var nameList = _.map($(e.currentTarget).select2("data"), function(obj){return obj.text});
 					that.model.set(name+'Name',nameList.toString());
-					that.toggleAddButton(e);
 				}
 			});
 		},
@@ -520,7 +518,6 @@ define(function(require) {
 		evDelete : function(){
 			var that = this;
 			this.collection.remove(this.model);
-			this.toggleAddButton();
 		},
 		evClickTD : function(e){
 			var $el = $(e.currentTarget);
@@ -552,34 +549,6 @@ define(function(require) {
 			perms = _.map(perms,function(obj){return obj.permType;});
 			XAUtil.checkDirtyField(permList, perms, this.$el);
 		},
-		toggleAddButton : function(e){
-			var grpTemp = [], usrTemp = [];
-			this.collection.each(function(m){
-				if(!_.isUndefined(m.get('groupName')) && !_.isNull(m.get('groupName'))){
-					grpTemp.push.apply(grpTemp, m.get('groupName').split(','));
-				}
-				if(!_.isUndefined(m.get('userName')) && !_.isNull(m.get('userName'))){
-					usrTemp.push.apply(usrTemp, m.get('userName').split(','));
-				}	
-			});
-			if(!_.isUndefined(e)){
-				if( !_.isUndefined(e.added)){
-					if((grpTemp.length ) == this.groupList.length && ((usrTemp.length) == this.userList.length)){
-						$('[data-action="addGroup"]').hide();
-					} else {
-						$('[data-action="addGroup"]').show();
-					}
-				} 
-				if(!_.isUndefined(e.removed))
-					$('[data-action="addGroup"]').show();
-			} else {
-				if((grpTemp.length ) == this.groupList.length && ((usrTemp.length) == this.userList.length)){
-					$('[data-action="addGroup"]').hide();
-				} else {
-					$('[data-action="addGroup"]').show();
-				}
-			}
-		},
 		policyCondtionChange :function(e){
 			if(!_.isEmpty($(e.currentTarget).val()) && !_.isEmpty(this.policyConditions)){
 				var policyCond = { 'type' : $(e.currentTarget).attr('data-js'), 'value' : $(e.currentTarget).val() } ;
@@ -717,30 +686,13 @@ define(function(require) {
 				this.collection.add(new Backbone.Model());
 		},
 		onRender : function(){
+			this.makePolicyItemSortable();
 		},
 
 		addNew : function(){
 			var that =this;
 			this.collection.add(new Backbone.Model());
 		},
-		toggleAddButton : function(){
-			var groupNames=[], userNames=[];
-			this.collection.each(function(m){
-				if(!_.isUndefined(m.get('groupName'))){
-					var temp = m.get('groupName').split(',');
-					groupNames.push.apply(groupNames,temp);
-				}
-				if(!_.isUndefined(m.get('userName'))){
-					var temp = m.get('userName').split(',');
-					userNames.push.apply(userNames,temp);
-				}
-			});
-			if(groupNames.length == this.groupList.length && userNames.length == this.userList.length ){
-				this.$('button[data-action="addGroup"]').hide();
-			} else {
-				this.$('button[data-action="addGroup"]').show();
-			}
-		},
 		getPermHeaders : function(){
 			var permList = [];
 			if(this.rangerServiceDefModel.get('name') != XAEnums.ServiceType.SERVICE_TAG.label){
@@ -780,7 +732,23 @@ define(function(require) {
 					this.accessTypes =  _.map(rowFilterDef.accessTypes, function(m){return _.findWhere(this.accessTypes, {'name' : m.name });}, this);
 				}
 			}
+		},
+		makePolicyItemSortable : function(){
+			var that = this, draggedModel;
+			this.$el.find(".js-formInput" ).sortable({
+				placeholder: "ui-state-highlight",
+				start : function(event, ui){
+					var row = ui.item[0].rowIndex - 1;
+					draggedModel = that.collection.at(row);
+				},
+				stop : function(event, ui){
+					var row = ui.item[0].rowIndex -1;
+					that.collection.remove(draggedModel, { silent : true});
+					that.collection.add(draggedModel ,{ at: row, silent : true });
+					that.$el.find(ui.item[0]).addClass("dirtyField");
+				},
+			});
 		}
 	});
 
-});
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f4a7037d/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js b/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js
index bac6c34..aae7543 100644
--- a/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js
@@ -98,6 +98,7 @@ define(function(require){
 		},
 
 		initializeServices : function(){
+			this.services.setPageSize(100);
 			this.services.fetch({
 			   cache : false,
 			   async : false

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f4a7037d/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 623ae03..23e8b54 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
@@ -293,6 +293,7 @@ define(function(require) {
 						switch (facet) {
 							case 'Service Name':
 								var serviceList 	= new RangerServiceList();
+								serviceList.setPageSize(100);
 								serviceList.fetch().done(function(){
 									callback(serviceList.map(function(model){return model.get('name');}));
 								});

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f4a7037d/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 1613015..f8e7273 100644
--- a/security-admin/src/main/webapp/styles/xa.css
+++ b/security-admin/src/main/webapp/styles/xa.css
@@ -1918,3 +1918,22 @@ input[type="radio"], input[type="checkbox"] {margin-top: 0;}
 .controls-margin {
 	margin-left: 90px !important;
 }
+.permissionItemSortable > tr > td:first-child {
+  padding-left: 20px;
+  position: relative;
+}
+.permissionItemSortable > tr:not(.ui-state-highlight) > td:first-child:after {
+  content: '';
+  position: absolute;
+   box-sizing: border-box;
+   left: 5px;
+   top: 10%;
+   height: 80%;
+   width: 6px;
+   border: 2px dotted rgba(0,0,0,0.25);
+   background: transparent;
+   cursor: move;
+}
+.permissionItemSortable > tr:hover > td:first-child:after {
+  border-color: rgba(0,0,0,0.5);
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f4a7037d/security-admin/src/main/webapp/templates/policies/PermissionList.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/PermissionList.html b/security-admin/src/main/webapp/templates/policies/PermissionList.html
index 68c7931..9216376 100644
--- a/security-admin/src/main/webapp/templates/policies/PermissionList.html
+++ b/security-admin/src/main/webapp/templates/policies/PermissionList.html
@@ -35,7 +35,7 @@
 
 				</tr>
 			</thead>
-			<tbody class="js-formInput">
+			<tbody class="js-formInput permissionItemSortable">
 
 			</tbody>
 		</table>