You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2015/01/28 17:56:37 UTC

[2/4] incubator-ranger git commit: RANGER-203: UI - policy delete implemented; policy permissions selection updated; landing page layout fixes

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/knox/KnoxPolicyForm.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/knox/KnoxPolicyForm.js b/security-admin/src/main/webapp/scripts/views/knox/KnoxPolicyForm.js
deleted file mode 100644
index b34f132..0000000
--- a/security-admin/src/main/webapp/scripts/views/knox/KnoxPolicyForm.js
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * 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 localization	= require('utils/XALangSupport');
-	var XAUtil			= require('utils/XAUtils');
-    
-	var VXPermMapList	= require('collections/VXPermMapList');
-	var VXGroupList		= require('collections/VXGroupList');
-	var VXAuditMapList	= require('collections/VXAuditMapList');
-	var VXAuditMap		= require('models/VXAuditMap');
-	var VXPermMap		= require('models/VXPermMap');
-	var VXUserList		= require('collections/VXUserList');
-	var FormInputItemList = require('views/common/FormInputItemList');
-	var UserPermissionList = require('views/common/UserPermissionList');
-
-
-
-	require('Backbone.BootstrapModal');
-	require('backbone-forms.list');
-	require('backbone-forms.templates');
-	require('backbone-forms');
-
-	var HivePolicyForm = Backbone.Form.extend(
-	/** @lends PolicyForm */
-	{
-		_viewName : 'PolicyForm',
-		
-		type : {
-			TOPOLOGY : 1,
-			SERVICE    : 2,
-		},
-
-    	/**
-		* intialize a new PolicyForm Form View 
-		* @constructs
-		*/
-		initialize: function(options) {
-			console.log("initialized a PolicyForm Form View");
-    		Backbone.Form.prototype.initialize.call(this, options);
-
-			_.extend(this, _.pick(options, 'assetModel'));
-			this.initializeCollection();
-			this.bindEvents();
-		},
-		
-		/** all events binding here */
-		bindEvents : function(){
-			this.on('_vAuditListToggle:change', function(form, fieldEditor){
-    			this.evAuditChange(form, fieldEditor);
-    		});
-			this.on('resourceStatus:change', function(form, fieldEditor){
-    			this.evResourceStatusChange(form, fieldEditor);
-    		});
-		},
-		initializeCollection: function(){
-			this.permMapList = this.model.isNew() ? new VXPermMapList() : this.model.get('permMapList');
-			this.auditList = this.model.isNew() ? new VXAuditMapList() : this.model.get('auditList');
-			
-		   
-		   /*If the model passed to the fn is new return an empty collection
-		    * otherwise return a collection that has models like 
-		    * {
-		    * 	groupId : 5,
-		    * 	permissionList : [4,3]
-		    * }
-		    * The formInputList will be passed to the forminputitemlist view.
-		    */
-		   
-		   this.formInputList = XAUtil.makeCollForGroupPermission(this.model);
-		   this.userPermInputList = XAUtil.makeCollForUserPermission(this.model);
-		   
-		},
-		/** fields for the form
-		*/
-	//	fields: ['name', 'description', '_vAuditListToggle', 'isEncrypt','isRecursive'],
-		schema :function(){
-			var that = this;
-			//var plugginAttr = this.getPlugginAttr(true);
-			
-			return {
-				policyName : {
-					   type 		: 'Text',
-					   title		: localization.tt("lbl.policyName"),
-					   editorAttrs 	:{ maxlength: 255},
-//					   validators  	: [{'type' :'required'}] 
-				},
-				topologies : {
-					type		: 'Select2Remote',
-					title		: localization.tt("lbl.selectTopologyName")+' *',
-					editorAttrs :{'data-placeholder': 'Select Topology'},
-					validators  : ['required'],//,{type:'regexp',regexp:/^[a-zA-Z*?][a-zA-Z0-9_'&-/\$]*[A-Za-z0-9]*$/i,message :localization.tt('validationMessages.enterValidName')}],
-					pluginAttr  : this.getPlugginAttr(true,this.type.TOPOLOGY),
-	                options    : function(callback, editor){
-	                    callback();
-	                },
-	                onFocusOpen : true
-
-					
-				},
-				services : {
-					type		: 'Select2Remote',
-					title		: localization.tt("lbl.selectServiceName")+' *',
-					validators  : ['required'],//[{type:'regexp',regexp:/^[a-zA-Z*?][a-zA-Z0-9_'&-/\$]*[A-Za-z0-9]*$/i,message :localization.tt('validationMessages.enterValidName')}],
-					editorAttrs :{'data-placeholder': 'Select Service'},//'disabled' :'disabled'},
-					//fieldAttrs :{'disabled' :'disabled',},
-					pluginAttr  : this.getPlugginAttr(true,this.type.SERVICE)
-				},
-				_vAuditListToggle : {
-					type		: 'Switch',
-					title		: localization.tt("lbl.auditLogging"),
-					listType	: 'VNameValue',
-					switchOn	: true
-				},
-				permMapList : {
-					getValue : function(){
-						console.log(this);
-					}
-				},
-				resourceStatus : {
-					type		: 'Switch',
-					title		: localization.tt("lbl.policyStatus"),
-					onText		: 'enabled',
-					offText		: 'disabled',
-					width		: 89,
-					height		: 22,
-					switchOn	: true
-				},
-				description : { 
-					type		: 'TextArea',
-					title		: localization.tt("lbl.description"), 
-				//	validators	: [/^[A-Za-z ,.'-]+$/i],
-					template	:_.template('<div class="altField" data-editor></div>')
-				}
-			};	
-		},
-
-		evAuditChange : function(form, fieldEditor){
-			XAUtil.checkDirtyFieldForToggle(fieldEditor);
-			if(fieldEditor.getValue() == 1){
-				this.model.set('auditList', new VXAuditMapList(new VXAuditMap({
-					'auditType' : XAEnums.XAAuditType.XA_AUDIT_TYPE_ALL.value,//fieldEditor.getValue()//
-					'resourceId' :this.model.get('id')
-					
-				})));
-			} else {
-					var validation  = this.formValidation();
-					if(validation.groupPermSet || validation.isUsers)
-						this.model.unset('auditList');
-					else{
-						XAUtil.alertPopup({
-							msg :localization.tt("msg.policyNotHavingPerm"),
-							callback : function(){
-								fieldEditor.setValue('ON');
-							}
-						});
-					}
-			}
-			console.log(fieldEditor);
-		},
-		evResourceStatusChange : function(form, fieldEditor){
-			XAUtil.checkDirtyFieldForToggle(fieldEditor);
-		},
-		/** on render callback */
-		render: function(options) {
-			Backbone.Form.prototype.render.call(this, options);
-			this.initializePlugins();
-		//	this.renderSelectTagsFields();
-			this.renderCustomFields();
-			if(!this.model.isNew()){
-				this.setUpSwitches();
-			}
-			if(this.model.isNew() && this.fields._vAuditListToggle.editor.getValue() == 1){
-				this.model.set('auditList', new VXAuditMapList(new VXAuditMap({
-					'auditType' : XAEnums.XAAuditType.XA_AUDIT_TYPE_ALL.value,//fieldEditor.getValue()//
-					'resourceId' :this.model.get('id')
-					
-				})));
-			}
-		},
-		setUpSwitches :function(){
-			var that = this;
-			var encryptStatus = false,auditStatus = false;
-			auditStatus = this.model.has('auditList') ? true : false; 
-			this.fields._vAuditListToggle.editor.setValue(auditStatus);
-			
-//			_.each(_.toArray(XAEnums.BooleanValue),function(m){
-//				if(parseInt(that.model.get('isEncrypt')) == m.value)
-//					encryptStatus =  (m.label == XAEnums.BooleanValue.BOOL_TRUE.label) ? true : false;
-//			});
-//			this.fields.isEncrypt.editor.setValue(encryptStatus);
-			
-			if(parseInt(this.model.get('resourceStatus')) != XAEnums.BooleanValue.BOOL_TRUE.value)
-				this.fields.resourceStatus.editor.setValue(false);
-			
-			
-		},
-		renderSelectTagsFields :function(){
-			var that = this;
-			this.fields.databases.editor.$el.on('change',function(e){
-				console.log('change on database Name');
-				that.checkMultiselectDirtyField(e, that.type.DATABASE);
-				if(!_.isEmpty(e.currentTarget.value)){
-					that.fields.tables.editor.$el.attr('disabled',false);
-				}
-				else{
-					that.fields.udfs.editor.$el.prop('disabled',true);
-				}
-					
-			});
-			this.fields.tables.editor.$el.on('change',function(e){
-				console.log('change on table Name');
-				that.checkMultiselectDirtyField(e, that.type.TABLE);
-					
-			});
-			
-		},
-		getDataParams : function(type, term){
-			var dataParams = {
-				dataSourceName : this.assetModel.get('name')
-			};
-			if (type == this.type.TOPOLOGY && this.fields) {
-				dataParams.topologyName = term;
-			}
-			if (type == this.type.SERVICE && this.fields.topologies) {
-				dataParams.topologyName = this.fields.topologies.editor.$el.select2('data')[0].text;
-				dataParams.serviceName = term;
-			}
-			return dataParams;
-		},
-		getPlugginAttr :function(autocomplete, searchType){
-			var that =this;
-			var type = searchType;
-			if(!autocomplete)
-				return{tags : true,width :'220px',multiple: true,minimumInputLength: 1};
-			else {
-				
-				
-				return {
-					closeOnSelect : true,
-					//placeholder : 'Select User',
-					tags:true,
-					multiple: true,
-					minimumInputLength: 1,
-					width :'220px',
-					tokenSeparators: [",", " "],
-					initSelection : function (element, callback) {
-						var data = [];
-						$(element.val().split(",")).each(function () {
-							data.push({id: this, text: this});
-						});
-						callback(data);
-					},
-					createSearchChoice: function(term, data) {
-						if ($(data).filter(function() {
-							return this.text.localeCompare(term) === 0;
-						}).length === 0) {
-							return {
-								id : term,
-								text: term
-							};
-						}
-					},
-					ajax: { 
-						url: "service/assets/knox/resources",
-						dataType: 'json',
-						params : {
-							timeout: 3000
-						},
-						cache: false,
-						data: function (term, page) {
-							return _.extend(that.getDataParams(type, term));
-							
-						},
-						results: function (data, page) { 
-							var results = [];
-							if(!_.isUndefined(data)){
-								if(data.resultSize != "0"){
-									results = data.vXStrings.map(function(m, i){	return {id : m.value, text: m.value};	});
-								}
-							}	
-							return { 
-								results : results
-							};
-						},
-						transport: function (options) {
-							$.ajax(options).error(function() { 
-								console.log("ajax failed");
-								this.success({
-									resultSize : 0
-								});
-							});
-							/*$.ajax.error(function(data) { 
-								console.log("ajax failed");
-								return {
-									results : []
-								};
-							});*/
-
-						}
-
-					},	
-					formatResult : function(result){
-						return result.text;
-					},
-					formatSelection : function(result){
-						return result.text;
-					},
-					formatNoMatches : function(term){
-						switch (type){
-							case  that.type.TOPOLOGY :return localization.tt("msg.enterAlteastOneCharactere");
-							case  that.type.SERVICE :return localization.tt("msg.enterAlteastOneCharactere");
-							default : return "No Matches found";
-						}
-					}
-				};	
-			}
-		},
-		formValidation : function(){
-			var groupSet = false,permSet = false,auditStatus= false,encryptStatus= false,groupPermSet = false, groupIPSet = false,
-							userSet=false,userPerm = false,isUsers =false, userIPSet = false;;
-			console.log('validation called..');
-			var breakFlag =false;
-			this.formInputList.each(function(m){
-				if(m.has('groupId') ||  m.has('_vPermList') || m.has('ipAddress')){
-					if(! breakFlag){
-						groupSet = m.has('groupId') ? true : false ;
-						groupIPSet = m.has('ipAddress') ? true : false ;
-						if(!m.has('_vPermList')){
-							permSet = false;
-						}else
-							permSet = true;
-						if(groupSet && permSet)
-							groupPermSet = true;
-						else
-							breakFlag=true;
-					}
-				}
-			});
-			breakFlag = false;
-			this.userPermInputList.each(function(m){
-				if(! breakFlag){
-					userSet = m.has('userId') ? true : false ;//|| userSet;
-					userIPSet = m.has('ipAddress') ? true : false ;
-					if(!m.has('_vPermList')){
-						userPerm = false;
-					}else
-						userPerm = true;
-					if(userSet && userPerm)
-						isUsers = true;
-					else
-						breakFlag=true;
-				}
-			});
-			auditStatus = this.fields._vAuditListToggle.editor.getValue();
-			if(!_.isUndefined(this.fields.isEncrypt))
-				encryptStatus = this.fields.isEncrypt.editor.getValue();
-			var auditLoggin = (auditStatus == XAEnums.BooleanValue.BOOL_TRUE.value) ? true : false;
-			var encrypted = (encryptStatus == XAEnums.BooleanValue.BOOL_TRUE.value) ? true : false;
-			
-			return { groupPermSet	: groupPermSet ,
-					 groupSet 		: groupSet,
-					 groupIPSet 	: groupIPSet,
-					 permSet 		: permSet,
-					 auditLoggin 	:auditLoggin,
-					 encrypted 		: encrypted,
-					 userSet 		: userSet,
-					 userPerm		:userPerm,
-					 userIPSet 		:userIPSet ,
-					 isUsers		:isUsers
-				};	
-		},
-		/** all custom field rendering */
-		renderCustomFields: function(){
-			var that = this;
-			this.groupList = new VXGroupList();
-			var params = {sortBy : 'name'};
-			this.groupList.setPageSize(100,{fetch:false});
-			this.groupList.fetch({
-					cache :true,
-					data : params
-				}).done(function(){
-					that.$('[data-customfields="groupPerms"]').html(new FormInputItemList({
-						collection 	: that.formInputList,
-						groupList  	: that.groupList,
-						model 		: that.model,
-						policyType 	: XAEnums.AssetType.ASSET_KNOX.value
-					
-					}).render().el);
-			});
-			
-			this.userList = new VXUserList();
-			var params = {sortBy : 'name'};
-			this.userList.setPageSize(100,{fetch:false});
-			this.userList.fetch({
-				cache :true,
-				data : params
-				}).done(function(){
-					that.$('[data-customfields="userPerms"]').html(new UserPermissionList({
-						collection 	: that.userPermInputList,
-						model 		: that.model,
-						userList 	: that.userList,
-						policyType 	: XAEnums.AssetType.ASSET_KNOX.value
-					}).render().el);
-			});
-		},
-		afterCommit : function(){
-			var that = this;
-			//TODO FIXME remove the hard coding 
-			//this.model.set('assetId', XAGlobals.hardcoded.HiveAssetId);
-			this.model.set('assetId', this.assetModel.id);
-			var permMapList = new VXPermMapList();
-			this.formInputList.each(function(m){
-				if(!_.isUndefined(m.get('groupId'))){
-					var uniqueID = _.uniqueId(new Date()+':');
-					_.each(m.get('groupId').split(","),function(groupId){
-						_.each(m.get('_vPermList'), function(perm){
-							var params = {
-									//groupId: m.get('groupId'),
-									groupId: groupId,
-									permFor : XAEnums.XAPermForType.XA_PERM_FOR_GROUP.value,
-									permType : perm.permType,
-									permGroup : uniqueID,
-							};
-							//TODO FIXME remove the hardcoding
-							if(parseInt(groupId) == perm.groupId)
-								params = $.extend(params, {id : perm.id});
-							if(!_.isUndefined(m.get('ipAddress')))
-								params = $.extend(params, {ipAddress : m.get('ipAddress').toString()});
-							
-							permMapList.add(new VXPermMap(params));
-						}, this);
-					});
-				}
-			}, this);
-			
-			this.userPermInputList.each(function(m){
-				if(!_.isUndefined(m.get('userId'))){
-					var uniqueID = _.uniqueId(new Date()+':');
-					_.each(m.get('userId').split(","),function(userId){
-						_.each(m.get('_vPermList'), function(perm){
-							var params = {
-									//groupId: m.get('groupId'),
-									userId: userId,
-									permFor : XAEnums.XAPermForType.XA_PERM_FOR_USER.value,
-									permType : perm.permType,
-									permGroup : uniqueID,
-							};
-							if(parseInt(userId) == perm.userId)
-								params = $.extend(params, {id : perm.id});
-							if(!_.isUndefined(m.get('ipAddress')))
-								params = $.extend(params, {ipAddress : m.get('ipAddress').toString()});
-							//TODO FIXME remove the hardcoding
-							permMapList.add(new VXPermMap(params));
-						}, this);
-					});
-				}
-			}, this);
-			
-			this.model.set('permMapList', permMapList);
-			if(this.model.get('resourceStatus') != XAEnums.BooleanValue.BOOL_TRUE.value){
-				this.model.set('resourceStatus', XAEnums.ActiveStatus.STATUS_DISABLED.value);
-			}
-			
-			var resourceType = _.isEmpty(this.model.get('services')) ? XAEnums.ResourceType.RESOURCE_TOPOLOGY.value : XAEnums.ResourceType.RESOURCE_SERVICE.value ;
-			this.model.set('resourceType',resourceType);
-			this.setResourceTypeAsPerWildCard();
-		},
-		checkMultiselectDirtyField : function(e, type){
-			var elem = $(e.currentTarget),columnName='',nameList = [], newNameList = [];
-			switch(type){
-				case 1 :columnName = 'databases';break;
-				case 2 :columnName = 'tables';break;
-				case 3 :columnName = 'columns';break;
-			}
-			if(!_.isUndefined(this.model.get(columnName)) && !_.isEqual(this.model.get(columnName),""))
-				nameList = this.model.get(columnName).split(',');
-			if(!_.isEqual(e.currentTarget.value, ""))
-				newNameList = e.currentTarget.value.split(',');
-			XAUtil.checkDirtyField(nameList, newNameList, elem);
-		},
-		setResourceTypeAsPerWildCard :function(){
-			var type = this.model.get('resourceType');
-			//Set resourceType as per WildCard operator '*'
-			switch(this.model.get('resourceType')){
-				case XAEnums.ResourceType.RESOURCE_SERVICE.value :
-					if(_.isEqual(this.model.get('services'),"*")){
-						type = XAEnums.ResourceType.RESOURCE_TOPOLOGY.value;
-						
-					}
-					break;
-			}
-			this.model.set('resourceType',type);
-		},
-		/** all post render plugin initialization */
-		initializePlugins: function(){
-		}
-
-	});
-
-	return HivePolicyForm;
-});

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/knox/KnoxTableLayout.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/knox/KnoxTableLayout.js b/security-admin/src/main/webapp/scripts/views/knox/KnoxTableLayout.js
deleted file mode 100644
index 6564e87..0000000
--- a/security-admin/src/main/webapp/scripts/views/knox/KnoxTableLayout.js
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * 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 XAGlobals 		= require('utils/XAGlobals');
-	var SessionMgr 		= require('mgrs/SessionMgr');
-	var XAUtil			= require('utils/XAUtils');
-
-	var VXResource = require('models/VXResource');
-	
-	var XABackgrid		= require('views/common/XABackgrid');
-	var XATableLayout	= require('views/common/XATableLayout');
-	var localization	= require('utils/XALangSupport');
-	var vFolderInfo 		= require('views/folders/FolderInfo');
-	var KnoxTableLayoutTmpl = require('hbs!tmpl/knox/KnoxTableLayout_tmpl');
-
-	var KnoxTableLayout = Backbone.Marionette.Layout.extend(
-	/** @lends KnoxTableLayout */
-	{
-		_viewName : 'KnoxTableLayout',
-		
-    	template: KnoxTableLayoutTmpl,
-    	templateHelpers :function(){
-    		return {
-    			isSysAdmin :this.isSysAdmin,
-    			assetId		  : this.assetModel.id,
-    			assetModel : this.assetModel,
-    			version : XAGlobals.version
-    		};
-    	},
-    	breadCrumbs : function(){
-    		return [XALinks.get('RepositoryManager'),XALinks.get('ManageKnoxPolicies',{model : this.assetModel})];
-   		},
-		/** Layout sub regions */
-    	regions: {
-    		'rTableList' :'div[data-id="r_tableList"]',
-    		'rPolicyDetail'	: '#policyDetail'
-    	},
-
-    	/** ui selector cache */
-    	ui: {
-			'btnExport' : 'a[data-js="export"]',
-			'btnDeletePolicy' : '[data-name="deletePolicy"]',
-			'btnShowMore' : '[data-id="showMore"]',
-			'btnShowLess' : '[data-id="showLess"]',
-			'visualSearch' : '.visual_search'
-		},
-
-		/** ui events hash */
-		events: function() {
-			var events = {};
-			//events['change ' + this.ui.input]  = 'onInputChange';
-			events['click ' + this.ui.btnExport]  = 'onExport';
-			events['click ' + this.ui.btnDeletePolicy]  = 'onDelete';
-			events['click ' + this.ui.btnShowMore]  = 'onShowMore';
-			events['click ' + this.ui.btnShowLess]  = 'onShowLess';
-			return events;
-		},
-
-    	/**
-		* intialize a new KnoxTableLayout Layout 
-		* @constructs
-		*/
-		initialize: function(options) {
-			console.log("initialized a KnoxTableLayout Layout");
-
-			_.extend(this, _.pick(options, 'assetModel'));
-			this.collection.extraSearchParams = {
-	//				resourceType : XAEnums.AssetType.ASSET_HIVE.value
-					assetId : this.assetModel.id
-				};
-			this.bindEvents();
-			this.isSysAdmin = SessionMgr.isSystemAdmin();
-		},
-
-		/** all events binding here */
-		bindEvents : function(){
-			//this.listenTo(this.collection, "remove", this.render, this);
-			/*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/
-		},
-
-		/** on render callback */
-		onRender: function() {
-			var that = this;
-			this.initializePlugins();
-			this.addVisualSearch();
-			this.renderTable();
-			XAUtil.highlightDisabledPolicy(this);
-		},
-
-		/** all post render plugin initialization */
-		initializePlugins: function(){
-		},
-		renderTable : function(){
-			var that = this;
-			/*var tableRow = Backgrid.Row.extend({
-				events: {
-					'click' : 'onClick'
-				},
-				initialize : function(){
-					var that = this;
-					var args = Array.prototype.slice.apply(arguments);
-					Backgrid.Row.prototype.initialize.apply(this, args);
-					this.listenTo(this.model, 'model1:highlightBackgridRow', function(){
-						that.$el.addClass("alert");
-						$("html, body").animate({scrollTop: that.$el.position().top},"linear");
-						setTimeout(function () {
-							that.$el.removeClass("alert");
-						}, 1500);
-					}, this);
-				},
-				onClick: function (e) {
-					if($(e.toElement).is('.icon-edit,.icon-trash,a,code'))
-						return;
-					this.$el.parent('tbody').find('tr').removeClass('tr-active');
-					this.$el.toggleClass('tr-active');
-					if(that.rPolicyDetail){
-						$(that.rPolicyDetail.el).hide();
-						$(that.rPolicyDetail.el).html(new vFolderInfo({
-							model : this.model
-						}).render().$el).slideDown();
-					}	
-									
-				}
-			});*/
-			this.rTableList.show(new XATableLayout({
-				columns: this.getColumns(),
-				collection: this.collection,
-				includeFilter : false,
-				gridOpts : {
-//					row: tableRow,
-					header : XABackgrid,
-					emptyText : 'No Policies found!'
-				}
-			}));	
-		},
-
-		getColumns : function(){
-			var cols = {
-				policyName : {
-					cell : "uri",
-					href: function(model){
-						return '#!/knox/'+model.get('assetId')+'/policy/' + model.id;
-					},
-					label	: localization.tt("lbl.policyName"),
-					editable: false,
-					sortable : false
-				},	
-				topologies : {
-					label	: localization.tt("lbl.topologyName")+'(s)',
-					/*href: function(model){
-						return '#!/knox/'+model.get('assetId')+'/policy/' + model.id;
-					},*/
-					editable:false,
-//					cell :'uri',
-					cell :'string',
-					sortable : false
-						
-				},
-				services: {
-					label	: localization.tt("lbl.serivceName")+'(s)',
-					editable:false,
-					cell :'string',
-					formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
-						fromRaw: function (rawValue) {	return rawValue ? rawValue : '--';}
-					}),
-					sortable : false
-				},
-				permMapList : {
-					reName : 'groupName',
-					cell	: Backgrid.HtmlCell.extend({className: 'cellWidth-1'}),
-					label : localization.tt("lbl.group"),
-					formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
-						fromRaw: function (rawValue) {
-							if(!_.isUndefined(rawValue))
-								return XAUtil.showGroups(rawValue);
-							else 
-								return '--';
-						}
-					}),
-					editable : false,
-					sortable : false
-				},
-				auditList : {
-					label : localization.tt("lbl.auditLogging"),
-					cell: "html",
-					formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
-						fromRaw: function (rawValue, model) {
-							return model.has('auditList') ? '<label class="label label-success">ON</label>' : '<label class="label label">OFF</label>';
-						}
-					}),
-					click : false,
-					drag : false,
-					sortable : false,
-					editable : false
-				},
-				resourceStatus:{
-					label:localization.tt('lbl.status'),
-					cell :"html",
-					editable:false,
-					formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
-						fromRaw: function (rawValue) {
-							var status;
-							_.each(_.toArray(XAEnums.BooleanValue),function(m){
-								if(parseInt(rawValue) == m.value){
-									status =  (m.label == XAEnums.BooleanValue.BOOL_TRUE.label) ? true : false;
-								}	
-							});
-							return status ? '<label class="label label-success">Enabled</label>' : '<label class="label label-important">Disabled</label>';
-						}
-					}),
-					click : false,
-					drag : false,
-					sortable : false
-				},
-				permissions : {
-					cell :  "html",
-					label : localization.tt("lbl.action"),
-					formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
-						fromRaw: function (rawValue,model) {
-							return '<a href="#!/knox/'+model.get('assetId')+'/policy/'+model.id+'" class="btn btn-mini" title="Edit"><i class="icon-edit icon-large" /></a>\
-									<a href="javascript:void(0);" data-name ="deletePolicy" data-id="'+model.id+'"  class="btn btn-mini btn-danger" title="Delete"><i class="icon-trash icon-large" /></a>';
-							//You can use rawValue to custom your html, you can change this value using the name parameter.
-						}
-					}),
-					editable:false,
-					sortable : false	
-				}
-				
-			};
-			return this.collection.constructor.getTableCols(cols, this.collection);
-		},
-
-		onExport : function(e){
-			$(e.currentTarget).attr('href', 'service/assets/policyList/'+this.assetModel.get('name')+'?epoch=0');
-			//$(e.currentTarget).attr('href', 'service/assets/hive?epoch=0');
-		},
-		onDelete :function(e){
-			var that = this;
-			var obj = this.collection.get($(e.currentTarget).data('id'));
-			var model = new VXResource(obj.attributes);
-			model.collection = this.collection;
-			XAUtil.confirmPopup({
-				//msg :localize.tt('msg.confirmDelete'),
-				msg :'Are you sure want to delete ?',
-				callback : function(){
-					XAUtil.blockUI();
-					model.destroy({
-						success: function(model, response) {
-							XAUtil.blockUI('unblock');
-							that.collection.remove(model.get('id'));
-							$(that.rPolicyDetail.el).hide();
-							XAUtil.notifySuccess('Success', localization.tt('msg.policyDeleteMsg'));
-							if(that.collection.length ==  0){
-								that.renderTable();
-								that.collection.fetch();
-							}
-						},
-						error: function (model, response, options) {
-							XAUtil.blockUI('unblock');
-							if ( response && response.responseJSON && response.responseJSON.msgDesc){
-								    XAUtil.notifyError('Error', response.responseJSON.msgDesc);
-							    }else
-							    	XAUtil.notifyError('Error', 'Error deleting Policy!');
-							    console.log("error");
-						}
-					});
-				}
-			});
-		},
-		onShowMore : function(e){
-			var id = $(e.currentTarget).attr('policy-group-id');
-			this.rTableList.$el.find('[policy-group-id="'+id+'"]').show();
-			$('[data-id="showLess"][policy-group-id="'+id+'"]').show();
-			$('[data-id="showMore"][policy-group-id="'+id+'"]').hide();
-		},
-		onShowLess : function(e){
-			var id = $(e.currentTarget).attr('policy-group-id');
-			this.rTableList.$el.find('[policy-group-id="'+id+'"]').slice(4).hide();
-			$('[data-id="showLess"][policy-group-id="'+id+'"]').hide();
-			$('[data-id="showMore"][policy-group-id="'+id+'"]').show();
-		},
-		addVisualSearch : function(){
-			var that = this;
-			var searchOpt = ['Topology Name(s)','Service Name(s)',,'Group','Policy Name'];//,'Start Date','End Date','Today'];
-			var serverAttrName  = [{text : "Topology Name(s)", label :"topologies"}, {text : "Service Name(s)", label :"services"},
-			                       {text : "Group", label :"groupName"},{text : "Policy Name", label :"policyName"}];
-			                     //  {text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'},
-				                 //  {text : 'Today',label :'today'}];
-									
-			var pluginAttr = {
-				      placeholder :localization.tt('h.searchForPolicy'),
-				      container : this.ui.visualSearch,
-				      query     : '',
-				      callbacks :  { 
-				    	  valueMatches :function(facet, searchTerm, callback) {
-								switch (facet) {
-									case 'Result':
-										callback(XAUtil.enumToSelectLabelValuePairs(XAEnums.AuthStatus));
-										break;
-									case 'Login Type':
-										callback(XAUtil.enumToSelectLabelValuePairs(XAEnums.AuthType));
-										break;	
-								/*	case 'Start Date' :
-										setTimeout(function () { XAUtil.displayDatepicker(that.ui.visualSearch, callback); }, 0);
-										break;
-									case 'End Date' :
-										setTimeout(function () { XAUtil.displayDatepicker(that.ui.visualSearch, callback); }, 0);
-										break;
-									case 'Today'	:
-										var today = Globalize.format(new Date(),"yyyy/mm/dd");
-										callback([today]);
-										break;*/
-								}     
-			            	
-							}
-				      }
-				};
-			XAUtil.addVisualSearch(searchOpt,serverAttrName, this.collection,pluginAttr);
-		},
-
-		/** on close */
-		onClose: function(){
-		}
-
-	});
-
-	return KnoxTableLayout; 
-});

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/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 a44305d..004f9fa 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
@@ -51,7 +51,9 @@ define(function(require) {
 			selectUsers		: '[data-js="selectUsers"]',
 			addPerms		: 'a[data-js="permissions"]',
 			conditionsTags	: '[class=tags1]',
-			delegatedAdmin	: 'input[data-js="delegatedAdmin"]'
+			delegatedAdmin	: 'input[data-js="delegatedAdmin"]',
+			addPermissionsSpan : '.add-permissions',
+			addConditionsSpan : '.add-conditions',
 		},
 		events : {
 			'click [data-action="delete"]'	: 'evDelete',
@@ -74,6 +76,7 @@ define(function(require) {
 			this.createDropDown(this.ui.selectGroups, this.groupList, true);
 			this.createDropDown(this.ui.selectUsers, this.userList, false);
 			//groups or users select2 dropdown change vent 
+			
 			this.dropDownChange(this.ui.selectGroups);
 			this.dropDownChange(this.ui.selectUsers);
 			//render permissions and policy conditions
@@ -236,6 +239,8 @@ define(function(require) {
 					if(_.isNull(values) || _.isEmpty(values)){
 						$(this).empty();
 						that.model.unset('accesses');
+						that.ui.addPermissionsSpan.find('i').attr('class', 'icon-plus');
+						that.ui.addPermissionsSpan.attr('title','add');
 						return;
 					}
 					if(_.contains(values,"-1")){
@@ -247,7 +252,7 @@ define(function(require) {
 						if(!_.isUndefined(id)){
 							var obj = _.findWhere(srcData,{'value' : id});
 							permTypeArr.push({permType : obj.value});
-							return "<span class='label label-inverse'>" + obj.text + "</span>";
+							return "<span class='label label-info'>" + obj.text + "</span>";
 						}
 					});
 					var perms = []
@@ -269,26 +274,37 @@ define(function(require) {
 						that.model.set('accesses', that.accessItems);
 					
 					$(this).html(valArr.join(" "));
+					that.ui.addPermissionsSpan.find('i').attr('class', 'icon-pencil');
+					that.ui.addPermissionsSpan.attr('title','edit');
 				},
 			}).on('click', function(e) {
 				e.stopPropagation();
 				e.preventDefault();
-				var selectAll = true;
-				var checklist = that.$('.editable-checklist').find('input[type="checkbox"]')
-				_.each(checklist,function(checkbox){ if($(checkbox).val() != -1 && !$(checkbox).is(':checked')) selectAll = false;})
-				if(selectAll){
-					that.$('.editable-checklist').find('input[type="checkbox"][value="-1"]').prop('checked',true)
-				}
-				//for selectAll functionality
-				that.$('input[type="checkbox"][value="-1"]').click(function(e){
-					var checkboxlist =$(this).closest('.editable-checklist').find('input[type="checkbox"][value!=-1]')
-					$(this).is(':checked') ? checkboxlist.prop('checked',true) : checkboxlist.prop('checked',false); 
-					
-				});
-				
+				that.clickOnPermissions(that);
+			});
+			that.ui.addPermissionsSpan.click(function(e) {
+				e.stopPropagation();
+				that.$('a[data-js="permissions"]').editable('toggle');
+				that.clickOnPermissions(that);
 			});
 			
 		},
+		clickOnPermissions : function(that) {
+			var selectAll = true;
+			var checklist = that.$('.editable-checklist').find('input[type="checkbox"]')
+			_.each(checklist,function(checkbox){ if($(checkbox).val() != -1 && !$(checkbox).is(':checked')) selectAll = false;})
+			if(selectAll){
+				that.$('.editable-checklist').find('input[type="checkbox"][value="-1"]').prop('checked',true)
+			}else{
+				that.$('.editable-checklist').find('input[type="checkbox"][value="-1"]').prop('checked',false)
+			}
+			//for selectAll functionality
+			that.$('input[type="checkbox"][value="-1"]').click(function(e){
+				var checkboxlist =$(this).closest('.editable-checklist').find('input[type="checkbox"][value!=-1]')
+				$(this).is(':checked') ? checkboxlist.prop('checked',true) : checkboxlist.prop('checked',false); 
+				
+			});
+		},
 		renderPolicyCondtion : function() {
 			var that = this;
 			
@@ -317,13 +333,22 @@ define(function(require) {
 							});
 							var cond = _.map(value, function(val, name) {return {'type' : name, 'value' :val};});
 							that.model.set('conditions', cond);
-							$(this).html(html); 
+							$(this).html(html);
+							that.ui.addConditionsSpan.find('i').attr('class', 'icon-pencil');
+							that.ui.addConditionsSpan.attr('title','edit');
 						}else{
 							that.model.unset('conditions');
 							$(this).empty();
+							that.ui.addConditionsSpan.find('i').attr('class', 'icon-plus');
+							that.ui.addConditionsSpan.attr('title','add');
 						}
 					}
 				});
+				that.ui.addConditionsSpan.click(function(e) {
+					e.stopPropagation();
+					that.$('#policyConditions').editable('toggle');
+				});
+				
 			}
 		},
 		getSelectdValues : function($select, typeGroup){

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
index 1407614..7c40ade 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
@@ -73,7 +73,7 @@ define(function(require){
 			var events = {};
 			events['click ' + this.ui.btnSave]		= 'onSave';
 			events['click ' + this.ui.btnCancel]	= 'onCancel';
-//			events['click ' + this.ui.btnDelete]	= 'onDelete';
+			events['click ' + this.ui.btnDelete]	= 'onDelete';
 			
 			return events;
 		},
@@ -161,6 +161,32 @@ define(function(require){
 			App.appRouter.navigate("#!/service/"+this.rangerService.id+"/policies",{trigger: true});
 
 		},
+		onDelete :function(){
+			var that = this;
+			XAUtil.confirmPopup({
+				//msg :localize.tt('msg.confirmDelete'),
+				msg :'Are you sure want to delete ?',
+				callback : function(){
+					XAUtil.blockUI();
+					that.model.destroy({
+						success: function(model, response) {
+							XAUtil.blockUI('unblock');
+							XAUtil.allowNavigation();
+							XAUtil.notifySuccess('Success', localization.tt('msg.policyDeleteMsg'));
+							App.appRouter.navigate("#!/service/"+that.rangerService.id+"/policies",{trigger: true});
+						},
+						error: function (model, response, options) {
+							XAUtil.blockUI('unblock');
+							if ( response && response.responseJSON && response.responseJSON.msgDesc){
+								    XAUtil.notifyError('Error', response.responseJSON.msgDesc);
+							    }else
+							    	XAUtil.notifyError('Error', 'Error deleting Policy!');
+							    console.log("error");
+						}
+					});
+				}
+			});
+		},
 		/** on close */
 		onClose: function(){
 			XAUtil.allowNavigation();

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/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 5726dd1..de14a37 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
@@ -33,6 +33,7 @@ define(function(require){
 	var localization	= require('utils/XALangSupport');
 	var vFolderInfo = require('views/folders/FolderInfo');
 	var RangerServiceDef	= require('models/RangerServiceDef');
+	var RangerPolicy 		= require('models/RangerPolicy');
 	var RangerPolicyTableLayoutTmpl = require('hbs!tmpl/policies/RangerPolicyTableLayout_tmpl');
 
 	require('backgrid-filter');
@@ -59,7 +60,7 @@ define(function(require){
 		},
         
     	breadCrumbs : function(){
-    		return [XALinks.get('RepositoryManager'),XALinks.get('ManagePolicies',{model : this.rangerService})];
+    		return [XALinks.get('ServiceManager'),XALinks.get('ManagePolicies',{model : this.rangerService})];
 //    		return [];
    		},        
 
@@ -79,7 +80,7 @@ define(function(require){
 		/** ui events hash */
 		events: function() {
 			var events = {};
-//			events['click ' + this.ui.btnDeletePolicy]  = 'onDelete';
+			events['click ' + this.ui.btnDeletePolicy]  = 'onDelete';
 			events['click ' + this.ui.btnShowMore]  = 'onShowMore';
 			events['click ' + this.ui.btnShowLess]  = 'onShowLess';
 			
@@ -125,8 +126,6 @@ define(function(require){
 //			this.initializePlugins();
 //			this.addVisualSearch();
 			this.renderTable();
-			//TODO REMOVE
-			this.rTableList.$el.find('th[class="renderable table"]').removeClass('table')
 			
 //			XAUtil.highlightDisabledPolicy(this);
 		},
@@ -186,8 +185,39 @@ define(function(require){
 					drag : false,
 					sortable : false
 				},
+				policyItems : {
+					reName : 'groupName',
+					cell	: Backgrid.HtmlCell.extend({className: 'cellWidth-1'}),
+					label : localization.tt("lbl.group"),
+					formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+						fromRaw: function (rawValue, model) {
+							if(!_.isUndefined(rawValue))
+								return XAUtil.showGroupsOrUsersForPolicy(rawValue, model);
+							else 
+								return '--';
+						}
+					}),
+					editable : false,
+					sortable : false
+				},
+				//Hack for backgrid plugin doesn't allow to have same column name 
+				guid : {
+					reName : 'userName',
+					cell	: Backgrid.HtmlCell.extend({className: 'cellWidth-1'}),
+					label : localization.tt("lbl.users"),
+					formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+						fromRaw: function (rawValue, model) {
+							if(!_.isUndefined(rawValue))
+								return XAUtil.showGroupsOrUsersForPolicy(model.get('policyItems'), model, false);
+							else 
+								return '--';
+						}
+					}),
+					editable : false,
+					sortable : false
+				},
 			};
-			_.each(this.rangerServiceDefModel.get('resources'), function(obj){
+			/*_.each(this.rangerServiceDefModel.get('resources'), function(obj){
 				if(!_.isUndefined(obj) && !_.isNull(obj))
 					 cols[obj.name]={
 							cell : "html",
@@ -202,14 +232,28 @@ define(function(require){
 							})
 						};
 
-			});
+			});*/
+			cols['permissions'] = {
+				cell :  "html",
+				label : localization.tt("lbl.action"),
+				formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+					fromRaw: function (rawValue,model) {
+						return '<a href="#!/service/'+that.rangerService.id+'/policies/'+model.id+'/edit" class="btn btn-mini" title="Edit"><i class="icon-edit icon-large" /></a>\
+								<a href="javascript:void(0);" data-name ="deletePolicy" data-id="'+model.id+'"  class="btn btn-mini btn-danger" title="Delete"><i class="icon-trash icon-large" /></a>';
+						//You can use rawValue to custom your html, you can change this value using the name parameter.
+					}
+				}),
+				editable: false,
+				sortable : false
+
+			};
 			return this.collection.constructor.getTableCols(cols, this.collection);
 		},
 		onDelete :function(e){
 			var that = this;
-			var VXResource = require('models/VXResource');
+			
 			var obj = this.collection.get($(e.currentTarget).data('id'));
-			var model = new VXResource(obj.attributes);
+			var model = new RangerPolicy(obj.attributes);
 			model.collection = this.collection;
 			XAUtil.confirmPopup({
 				//msg :localize.tt('msg.confirmDelete'),
@@ -220,7 +264,6 @@ define(function(require){
 						success: function(model, response) {
 							XAUtil.blockUI('unblock');
 							that.collection.remove(model.get('id'));
-							$(that.rFolderInfo.el).hide();
 							XAUtil.notifySuccess('Success', localization.tt('msg.policyDeleteMsg'));
 							if(that.collection.length ==  0){
 								that.renderTable();
@@ -240,16 +283,28 @@ define(function(require){
 			});
 		},
 		onShowMore : function(e){
-			var id = $(e.currentTarget).attr('policy-group-id');
-			this.rTableList.$el.find('[policy-group-id="'+id+'"]').show();
-			$('[data-id="showLess"][policy-group-id="'+id+'"]').show();
-			$('[data-id="showMore"][policy-group-id="'+id+'"]').hide();
+			var attrName = 'policy-groups-id';
+			var id = $(e.currentTarget).attr(attrName);
+			if(_.isUndefined(id)){
+				id = $(e.currentTarget).attr('policy-users-id');
+				attrName = 'policy-users-id';
+			}   
+			var $td = $(e.currentTarget).parents('td');
+			$td.find('['+attrName+'="'+id+'"]').show();
+			$td.find('[data-id="showLess"]['+attrName+'="'+id+'"]').show();
+			$td.find('[data-id="showMore"]['+attrName+'="'+id+'"]').hide();
 		},
 		onShowLess : function(e){
-			var id = $(e.currentTarget).attr('policy-group-id');
-			this.rTableList.$el.find('[policy-group-id="'+id+'"]').slice(4).hide();
-			$('[data-id="showLess"][policy-group-id="'+id+'"]').hide();
-			$('[data-id="showMore"][policy-group-id="'+id+'"]').show();
+			var attrName = 'policy-groups-id';
+			var id = $(e.currentTarget).attr(attrName);
+			if(_.isUndefined(id)){
+				id = $(e.currentTarget).attr('policy-users-id');
+				attrName = 'policy-users-id';
+			}
+			var $td = $(e.currentTarget).parents('td');
+			$td.find('['+attrName+'="'+id+'"]').slice(4).hide();
+			$td.find('[data-id="showLess"]['+attrName+'="'+id+'"]').hide();
+			$td.find('[data-id="showMore"]['+attrName+'="'+id+'"]').show();
 		},
 		addVisualSearch : function(){
 			var that = this;

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/policy/PolicyCreate.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policy/PolicyCreate.js b/security-admin/src/main/webapp/scripts/views/policy/PolicyCreate.js
deleted file mode 100644
index 27b2032..0000000
--- a/security-admin/src/main/webapp/scripts/views/policy/PolicyCreate.js
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * 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.
- */
-
- 
-/* 
- * Policy create view
- */
-
-define(function(require){
-    'use strict';
-
-	var Backbone		= require('backbone');
-	var App				= require('App');
-	var XAEnums			= require('utils/XAEnums');
-	var XAUtil			= require('utils/XAUtils');
-	var XALinks 		= require('modules/XALinks');
-	var localization	= require('utils/XALangSupport');
-	
-	var PolicycreateTmpl = require('hbs!tmpl/hdfs/PolicyCreate_tmpl');
-	var PolicyForm		= require('views/policy/PolicyForm');
-	var VXResourceList	= require('collections/VXResourceList');
-
-	var PolicyCreate = Backbone.Marionette.Layout.extend(
-	/** @lends PolicyCreate */
-	{
-		_viewName : 'PolicyCreate',
-		
-    	template: PolicycreateTmpl,
-    	templateHelpers : function(){
-    		return {
-    			editPolicy : this.editPolicy
-    		};
-    	},
-    	breadCrumbs :function(){
-	    	
-    		if(this.model.isNew())
-    			return [XALinks.get('RepositoryManager'),XALinks.get('ManagePolicies',{model : this.assetModel}),XALinks.get('PolicyCreate')];
-    		else
-    			return [XALinks.get('RepositoryManager'),XALinks.get('ManagePolicies',{model : this.assetModel}),XALinks.get('PolicyEdit')];
-    	} ,        
-
-		/** Layout sub regions */
-    	regions: {
-			'rForm' :'div[data-id="r_form"]'
-		},
-
-    	/** ui selector cache */
-    	ui: {
-			'btnSave'	: '[data-id="save"]',
-			'btnCancel' : '[data-id="cancel"]',
-			'btnDelete' : '[data-id="delete"]',
-			'policyDisabledAlert' : '[data-id="policyDisabledAlert"]' 
-		},
-
-		/** ui events hash */
-		events: function() {
-			var events = {};
-			events['click ' + this.ui.btnSave]		= 'onSave';
-			events['click ' + this.ui.btnCancel]	= 'onCancel';
-			events['click ' + this.ui.btnDelete]	= 'onDelete';
-			
-			return events;
-		},
-
-    	/**
-		* intialize a new PolicyCreate Layout 
-		* @constructs
-		*/
-		initialize: function(options) {
-			var that = this;
-			console.log("initialized a PolicyCreate Layout");
-
-			_.extend(this, _.pick(options, 'assetModel'));
-			
-			that.form = new PolicyForm({
-				template : require('hbs!tmpl/hdfs/PolicyForm_tmpl'),
-				model : this.model,
-				assetModel : this.assetModel
-			});
-
-			this.editPolicy = this.model.has('id') ? true : false;
-			this.bindEvents();
-			this.params = {};
-		},
-
-		/** 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() {
-			XAUtil.showAlerForDisabledPolicy(this);
-			this.rForm.show(this.form);
-			this.rForm.$el.dirtyFields();
-			XAUtil.preventNavigation(localization.tt('dialogMsg.preventNavPolicyForm'),this.rForm.$el);
-			this.initializePlugins();
-		},
-
-		/** all post render plugin initialization */
-		initializePlugins: function(){
-		},
-		popupCallBack : function(msg,validateObj){
-			var that = this;
-			XAUtil.alertPopup({
-				msg :msg,
-				callback : function(){
-				//	if(validateObj.auditLoggin)
-				//		that.savePolicy();
-				}
-			});
-		},
-		onSave: function(){
-			var valid = false;
-			var errors = this.form.commit({validate : false});
-			if(! _.isEmpty(errors)){
-				return;
-			}
-			var validateObj = this.form.formValidation();
-			valid = (validateObj.groupSet && validateObj.permSet) || (validateObj.userSet && validateObj.userPerm);
-			if(!valid){
-				if(validateObj.groupSet && (!validateObj.permSet)){
-					this.popupCallBack(localization.tt('msg.addGroupPermission'),validateObj);
-				}else if((!validateObj.groupSet) && (validateObj.permSet)) {
-					this.popupCallBack(localization.tt('msg.addGroup'),validateObj);
-						
-				}else if(validateObj.userSet && (!validateObj.userPerm)){
-					this.popupCallBack(localization.tt('msg.addUserPermission'),validateObj);
-				}else if((!validateObj.userSet) && (validateObj.userPerm)) {
-					this.popupCallBack(localization.tt('msg.addUser'),validateObj);
-						
-				}else if((!validateObj.auditLoggin) && (!validateObj.groupPermSet)){
-					XAUtil.alertPopup({
-						msg :localization.tt('msg.yourAuditLogginIsOff'),
-						callback : function(){
-							/*if(!that.model.isNew()){
-								that.model.destroy({success: function(model, response) {
-									XAUtil.notifySuccess('Success', localization.tt('msg.policyDeleteMsg'));
-									App.appRouter.navigate("#!/hdfs/"+that.assetModel.id+"/policies",{trigger: true});
-								}});
-							}else{
-								XAUtil.notifyError('Error', localization.tt('msg.policyNotAddedMsg'));
-								App.appRouter.navigate("#!/hdfs/"+that.assetModel.id+"/policies",{trigger: true});
-							}*/
-						}
-					});
-				}else{
-					this.savePolicy();
-				}
-			}else{
-				if(validateObj.groupSet && (!validateObj.permSet)){
-					this.popupCallBack(localization.tt('msg.addGroupPermission'),validateObj);
-				}else if((!validateObj.groupSet) && (validateObj.permSet)) {
-					this.popupCallBack(localization.tt('msg.addGroup'),validateObj);
-						
-				}else if(validateObj.userSet && (!validateObj.userPerm)){
-					this.popupCallBack(localization.tt('msg.addUserPermission'),validateObj);
-				}else if((!validateObj.userSet) && (validateObj.userPerm)) {
-					this.popupCallBack(localization.tt('msg.addUser'),validateObj);
-						
-				}else
-					this.savePolicy();
-			}
-			
-		},
-		savePolicy : function(){
-			var that = this;
-			this.form.beforeSave();
-			this.saveMethod();
-		},
-		saveMethod : function(){
-			var that = this;
-			XAUtil.blockUI();
-			this.model.save({},{
-				wait: true,
-				success: function () {
-					XAUtil.blockUI('unblock');
-					var msg = that.editPolicy ? 'Policy updated successfully' :'Policy created successfully';
-					XAUtil.notifySuccess('Success', msg);
-					XAUtil.allowNavigation();
-					if(that.editPolicy){
-						App.appRouter.navigate("#!/hdfs/"+that.assetModel.id+"/policies",{trigger: true});
-						return;
-					}
-					
-					App.appRouter.navigate("#!/hdfs/"+that.assetModel.id+"/policies",{trigger: true});
-					
-					var view = require('views/hdfs/HDFSTableLayout');
-					var resourceListForAsset = new VXResourceList([],{
-						   queryParams : {
-							   'assetId' : that.assetModel.id 
-						   }
-					   });
-					resourceListForAsset.fetch({
-						cache : true,
-						'data' : {
-				//			'resourceType':XAEnums.AssetType.ASSET_HDFS.value,
-							'assetId' :that.assetModel.id
-						}
-					}).done(function(){
-						var newColl = resourceListForAsset;
-						resourceListForAsset.getLastPage({
-							cache : false,
-							data  : {
-			//					'resourceType' : XAEnums.AssetType.ASSET_HDFS.value,
-								'assetId' : that.assetModel.id
-							}
-						}).done(function(){
-							var model = newColl.get(that.model.id);
-							if(model){
-								model.trigger("model:highlightBackgridRow");
-							}
-						});
-						
-						App.rContent.show(new view({
-							collection : resourceListForAsset,
-							assetModel : that.assetModel
-						}));
-					});
-					
-					console.log("success");
-				},
-				error: function (model, response, options) {
-					    XAUtil.blockUI('unblock');
-					    if ( response && response.responseJSON && response.responseJSON.msgDesc){
-						if( response.responseJSON.messageList && response.responseJSON.messageList.length > 0 && !_.isUndefined(response.responseJSON.messageList[0].fieldName)){
-						    if(response.responseJSON.messageList[0].fieldName == "parentPermission"){
-							XAUtil.confirmPopup({
-							    msg :response.responseJSON.msgDesc,
-							    callback : function(){
-								that.model.set('checkParentPermission',XAEnums.BooleanValue.BOOL_FALSE.value);
-								that.saveMethod();
-							    }
-							});
-						    }else{
-							that.form.fields.name.setError(response.responseJSON.msgDesc);
-							XAUtil.scrollToField(that.form.fields.name.$el);
-							//XAUtil.notifyError('Error', response.responseJSON.msgDesc);
-						    }
-						}else{
-						    //that.form.fields.name.setError(response.responseJSON.msgDesc);
-						    //XAUtil.scrollToField(that.form.fields.name.$el);
-						    XAUtil.notifyError('Error', response.responseJSON.msgDesc);
-						}
-					    }else
-						XAUtil.notifyError('Error', 'Error creating Policy!');
-					    console.log("error");
-				}
-			});
-		},
-		onDelete :function(){
-			var that = this;
-			XAUtil.confirmPopup({
-				//msg :localize.tt('msg.confirmDelete'),
-				msg :'Are you sure want to delete ?',
-				callback : function(){
-					XAUtil.blockUI();
-					that.model.destroy({
-							success: function(model, response) {
-								XAUtil.blockUI('unblock');
-								XAUtil.allowNavigation();
-								XAUtil.notifySuccess('Success', localization.tt('msg.policyDeleteMsg'));
-								App.appRouter.navigate("#!/hdfs/"+that.assetModel.id+"/policies",{trigger: true});
-							},
-							error: function (model, response, options) {
-								XAUtil.blockUI('unblock');
-								if ( response && response.responseJSON && response.responseJSON.msgDesc){
-									    XAUtil.notifyError('Error', response.responseJSON.msgDesc);
-								    }else
-								    	XAUtil.notifyError('Error', 'Error deleting Policy!');
-								    console.log("error");
-							}
-					});
-					
-				}
-			});
-		},
-		onCancel : function(){
-			XAUtil.allowNavigation();
-			App.appRouter.navigate("#!/hdfs/"+this.assetModel.id+"/policies",{trigger: true});
-
-		},
-		/** on close */
-		onClose: function(){
-			XAUtil.allowNavigation();
-		}
-
-	});
-
-	return PolicyCreate;
-});

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/policy/PolicyForm.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policy/PolicyForm.js b/security-admin/src/main/webapp/scripts/views/policy/PolicyForm.js
deleted file mode 100644
index 1ad8ca1..0000000
--- a/security-admin/src/main/webapp/scripts/views/policy/PolicyForm.js
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * 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 localization	= require('utils/XALangSupport');
-	var XAUtil			= require('utils/XAUtils');
-    
-	var VXAuditMap		= require('models/VXAuditMap');
-	var VXPermMap		= require('models/VXPermMap');
-	var VXPermMapList	= require('collections/VXPermMapList');
-	var VXGroupList		= require('collections/VXGroupList');
-	var VXAuditMapList	= require('collections/VXAuditMapList');
-	var VXUserList		= require('collections/VXUserList');
-	var FormInputItemList = require('views/common/FormInputItemList');
-	var UserPermissionList = require('views/common/UserPermissionList');
-
-	require('backbone-forms.list');
-	require('backbone-forms.templates');
-	require('backbone-forms');
-	require('backbone-forms.XAOverrides');
-	require('jquery-ui');
-	require('tag-it');
-
-	var PolicyForm = Backbone.Form.extend(
-	/** @lends PolicyForm */
-	{
-		_viewName : 'PolicyForm',
-
-    	/**
-		* intialize a new PolicyForm Form View 
-		* @constructs
-		*/
-		initialize: function(options) {
-			console.log("initialized a PolicyForm Form View");
-    		Backbone.Form.prototype.initialize.call(this, options);
-
-			_.extend(this, _.pick(options,'assetModel'));
-			this.initializeCollection();
-			this.bindEvents();
-		},
-
-		initializeCollection: function(){
-			this.permMapList = this.model.isNew() ? new VXPermMapList() : this.model.get('permMapList');
-			this.auditList = this.model.isNew() ? new VXAuditMapList() : this.model.get('auditList');
-			
-			//this.userList.fetch();
-			
-
-			/*If the model passed to the fn is new return an empty collection
-			 * otherwise return a collection that has models like 
-			 * {
-			 * 	groupId : 5,
-			 * 	permissionList : [4,3]
-			 * }
-			 * The formInputList will be passed to the forminputitemlist view.
-			 */
-
-			this.formInputList 		= XAUtil.makeCollForGroupPermission(this.model);
-			this.userPermInputList  = XAUtil.makeCollForUserPermission(this.model);
-
-		},
-		/** all events binding here */
-		bindEvents : function(){
-			this.on('_vAuditListToggle:change', function(form, fieldEditor){
-    			this.evAuditChange(form, fieldEditor);
-    		});
-			this.on('isRecursive:change', function(form, fieldEditor){
-    			this.evRecursiveChange(form, fieldEditor);
-    		});
-			this.on('resourceStatus:change', function(form, fieldEditor){
-    			this.evResourceStatusChange(form, fieldEditor);
-    		});
-		},
-
-		/** fields for the form
-		*/
-		fields: ['name', 'description', '_vAuditListToggle', 'isEncrypt','isRecursive'],
-		schema :{
-			policyName : {
-				   type 		: 'Text',
-				   title		: localization.tt("lbl.policyName"),
-//				   validators  	: [{'type' :'required'}]
-				   editorAttrs 	:{ maxlength: 255},
-			},
-			name : {
-			   type 		: 'Text',
-			   title		: localization.tt("lbl.resourcePath") +' *',
-			   validators  	: [{'type' :'required'},
-				   function checkPath(resourcePaths, formValues) {
-					   var errorPath=[];
-					   _.each(resourcePaths.split(','),function(path){
-						   if(!(/^(\/(|[a-zA-Z0-9*?_/\.\-\\])*)$/i).test(path)){
-							   if(!_.isEmpty(path)){
-								   errorPath.push(path);
-							   }
-							   return;
-						   }
-					   });
-					   if(!_.isEmpty(errorPath))
-						   return {
-							   type: 'name',
-							   message: 'Please enter valid resource path : '+errorPath.join(',')
-						   };
-				   }
-				] 
-			},
-			isRecursive : {
-				type		: 'Switch',
-				title		: localization.tt('lbl.includesAllPathsRecursively'),
-				switchOn	: false,
-				onText 		: 'YES',
-				offText		: 'NO'
-			},
-			description : { 
-				type		: 'TextArea',
-				title		: localization.tt("lbl.description"), 
-			//	validators	: [/^[A-Za-z ,.'-]+$/i],
-				template	:_.template('<div class="altField" data-editor></div>')
-			},
-			_vAuditListToggle : {
-				type		: 'Switch',
-				title		: localization.tt("lbl.auditLogging"),
-				listType	: 'VNameValue',
-				switchOn	: true
-			},
-			isEncrypt : {
-				type		: 'Switch',
-				title		: localization.tt("lbl.encrypted"),
-				switchOn	: false,
-				fieldAttrs : {style : 'display:none;'}
-			},
-			isEnabled : {
-				type		: 'Switch',
-				title		: localization.tt("lbl.policyStatus"),
-				onText		: 'enabled',
-				offText		: 'disabled',
-				width		: '80',
-				switchOn	: true
-			},
-			permMapList : {
-				getValue : function(){
-					console.log(this);
-				}
-			},
-			userIdList : {
-				getValue : function(){
-					console.log("userIdList : "+this);
-				}
-			},
-			resourceStatus : {
-				type		: 'Switch',
-				title		: localization.tt("lbl.policyStatus"),
-				onText		: 'enabled',
-				offText		: 'disabled',
-				width		: '85',
-				switchOn	: true
-			}
-		},
-		/** on render callback */
-		render: function(options) {
-			var that = this;
-			 Backbone.Form.prototype.render.call(this, options);
-
-			this.initializePlugins();
-			this.renderCustomFields();
-			if(!this.model.isNew()){
-				this.setUpSwitches();
-			}
-			if(this.model.isNew() && this.fields._vAuditListToggle.editor.getValue() == 1){
-				this.model.set('auditList', new VXAuditMapList(new VXAuditMap({
-					'auditType' : XAEnums.XAAuditType.XA_AUDIT_TYPE_ALL.value,//fieldEditor.getValue()//
-					'resourceId' :this.model.get('id')
-					
-				})));
-			}
-		},
-		formValidation : function(){
-			var groupSet = false,permSet = false,auditStatus= false,encryptStatus= false,groupPermSet = false,
-							userSet=false,userPerm = false,isUsers =false;
-			console.log('validation called..');
-			var breakFlag =false;
-			this.formInputList.each(function(m){
-				if(m.has('groupId') ||  m.has('_vPermList')){
-					if(! breakFlag){
-						groupSet = m.has('groupId') ? true : false ; 
-						if(!m.has('_vPermList')){
-							permSet = false;
-						}else
-							permSet = true;
-						if(groupSet && permSet)
-							groupPermSet = true;
-						else
-							breakFlag=true;
-					}
-				}
-			});
-			breakFlag = false;
-			
-			this.userPermInputList.each(function(m){
-					if(! breakFlag){
-						userSet = m.has('userId') || m.has('userName') ? true : false ; 
-						if(!m.has('_vPermList')){
-							userPerm = false;
-						}else
-							userPerm = true;
-						if(userSet && userPerm)
-							isUsers = true;
-						else
-							breakFlag=true;
-					}
-			});
-			auditStatus = this.fields._vAuditListToggle.editor.getValue();
-			encryptStatus = this.fields.isEncrypt.editor.getValue();
-			var auditLoggin = (auditStatus == XAEnums.BooleanValue.BOOL_TRUE.value) ? true : false;
-			var encrypted = (encryptStatus == XAEnums.BooleanValue.BOOL_TRUE.value) ? true : false;
-
-			return {groupPermSet: groupPermSet , groupSet : groupSet,permSet : permSet,auditLoggin :auditLoggin,encrypted : encrypted,
-				userSet : userSet,userPerm:userPerm,isUsers:isUsers};
-		},
-		setUpSwitches :function(){
-			var that = this;
-			var encryptStatus = false,auditStatus = false,recursiveStatus = false;
-			auditStatus = this.model.has('auditList') ? true : false; 
-			this.fields._vAuditListToggle.editor.setValue(auditStatus);
-			
-			_.each(_.toArray(XAEnums.BooleanValue),function(m){
-				if(parseInt(that.model.get('isEncrypt')) == m.value)
-					encryptStatus =  (m.label == XAEnums.BooleanValue.BOOL_TRUE.label) ? true : false;
-				if(parseInt(that.model.get('isRecursive')) == m.value)
-					recursiveStatus =  (m.label == XAEnums.BooleanValue.BOOL_TRUE.label) ? true : false;
-			});
-			this.fields.isEncrypt.editor.setValue(encryptStatus);
-			this.fields.isRecursive.editor.setValue(recursiveStatus);
-			if(parseInt(this.model.get('resourceStatus')) != XAEnums.BooleanValue.BOOL_TRUE.value)
-				this.fields.resourceStatus.editor.setValue(false);
-		},
-		/** all custom field rendering */
-		renderCustomFields: function(){
-			var that = this;
-			this.groupList = new VXGroupList();
-			var params = {sortBy : 'name'};
-			this.groupList.setPageSize(100,{fetch:false});
-			this.groupList.fetch({
-					cache :true,
-					data : params
-				}).done(function(){
-					that.$('[data-customfields="groupPerms"]').html(new FormInputItemList({
-						collection : that.formInputList,
-						groupList  : that.groupList,
-						model : that.model,
-						policyType 	: XAEnums.AssetType.ASSET_HDFS.value
-					}).render().el);
-			});
-			
-			this.userList = new VXUserList();
-			var params = {sortBy : 'name'};
-			this.userList.setPageSize(100,{fetch:false});
-			this.userList.fetch({
-					cache :true,
-					data: params
-				}).done(function(){
-					that.$('[data-customfields="userPerms"]').html(new UserPermissionList({
-						collection : that.userPermInputList,
-						model : that.model,
-						userList : that.userList,
-						policyType 	: XAEnums.AssetType.ASSET_HDFS.value
-					}).render().el);
-			});
-		},
-	
-		beforeSave : function(){
-			//TODO FIXME remove the hard coding
-			var that = this;
-			this.model.set('assetId', this.assetModel.id);
-			var permMapList = new VXPermMapList();
-			
-			this.formInputList.each(function(m){
-				if(!_.isUndefined(m.get('groupId'))){
-					var uniqueID = _.uniqueId(new Date()+':');
-					_.each(m.get('groupId').split(","),function(groupId){
-						_.each(m.get('_vPermList'), function(perm){
-							var params = {
-									//groupId: m.get('groupId'),
-						//			id : perm.id,
-									groupId: groupId,
-									permFor : XAEnums.XAPermForType.XA_PERM_FOR_GROUP.value,
-									permType : perm.permType,
-									permGroup : uniqueID
-							};
-							//TODO FIXME remove the hardcoding
-							if(parseInt(groupId) == perm.groupId)
-								params = $.extend(params, {id : perm.id});
-							permMapList.add(new VXPermMap(params));
-						}, this);
-					});
-				}
-			}, this);
-			
-			this.userPermInputList.each(function(m){
-				if(!_.isUndefined(m.get('userId'))){
-					var uniqueID = _.uniqueId(new Date()+':');
-					_.each(m.get('userId').split(","),function(userId){
-						_.each(m.get('_vPermList'), function(perm){
-							var params = {
-									//groupId: m.get('groupId'),
-							//		id : perm.id,
-									userId: userId,
-									permFor : XAEnums.XAPermForType.XA_PERM_FOR_USER.value,
-									permType : perm.permType,
-									permGroup : uniqueID
-							};
-							if(parseInt(userId) == perm.userId)
-								params = $.extend(params, {id : perm.id});
-							//TODO FIXME remove the hardcoding
-							permMapList.add(new VXPermMap(params));
-						}, this);
-					});
-				}
-			}, this);
-			
-			if(!_.isUndefined(this.model.get('name')) && _.isUndefined(this.model.get('name').split(','))){
-				this.model.set('name', _.unique(this.model.get('name').split(',')).join());
-			}
-			this.model.set('permMapList', permMapList);
-			//this.model.set('_vPermMapList', permMapList);
-			this.model.unset('userIdList');
-			this.model.set('resourceType',XAEnums.ResourceType.RESOURCE_PATH.value);
-			if(this.model.get('resourceStatus') != XAEnums.BooleanValue.BOOL_TRUE.value){
-				this.model.set('resourceStatus', XAEnums.ActiveStatus.STATUS_DISABLED.value);
-			}
-			
-			
-		},
-		/** all post render plugin initialization */
-		initializePlugins: function(){
-			var that= this;	
-			function split( val ) {
-				return val.split( /,\s*/ );
-			}
-			function extractLast( term ) {
-				return split( term ).pop();
-			}
-
-			this.fields.name.editor.$el.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({
-				autocomplete : {
-					cache: false,
-					source: function( request, response ) {
-						var p = $.getJSON( "service/assets/hdfs/resources", {
-							dataSourceName: that.assetModel.get('name'),
-							baseDirectory: extractLast( request.term )
-						}).done(function(data){
-							if(data.vXStrings){
-								response(data.vXStrings);
-							} else {
-								response();
-							}
-
-						}).error(function(){
-							response();
-
-						});
-						setTimeout(function(){ 
-							p.abort();
-							console.log('connection timeout for resource path request...!!');
-						}, 7000);
-					},
-					open : function(){
-						$(this).removeClass('working');
-					},
-					search: function() {
-						if(!_.isUndefined(this.value) && _.contains(this.value,',')){ 
-							_.each(this.value.split(',') , function(tag){
-								that.fields.name.editor.$el.tagit("createTag", tag);
-							});
-				        	return false;
-				        }	
-						var term = extractLast( this.value );
-						$(this).addClass('working');
-						if ( term.length < 1 ) {
-							return false;
-						}
-					},
-					focus: function(event, ui) {
-						var terms = split( this.value );
-						terms.pop();
-						terms.push( ui.item.value );
-						this.value = terms.join( ", " );
-						return false;
-					},
-					select: function( event, ui ) {
-						var terms = split( this.value );
-						terms.pop();
-						terms.push( ui.item.value );
-						terms.push( "" );
-						this.value = terms.join( ", " );
-						return false;
-					}
-					
-				},
-				beforeTagAdded: function(event, ui) {
-			        // do something special
-					that.fields.name.$el.removeClass('error');
-		        	that.fields.name.$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('/'));
-			        	that.fields.name.$el.addClass('error');
-			        	that.fields.name.$el.find('.help-inline').html('Please enter valid resource path : ' + ui.tagLabel);
-			        	return false;
-			        }
-//			        this.value = tags;
-			        /*if(_.contains(ui.tagLabel,','))
-			        	tags = ui.tagLabel.split(',');
-			        	this.value = tags;*/
-					}
-			});
-			/*this.fields.name.editor.$el.tagit({
-				beforeTagAdded: function(event, ui) {
-		        // do something special
-				var tags =  [];
-		        console.log(ui.tag);
-		        if(_.contains(ui.tagLabel,','))
-		        	tags = ui.tagLabel.split(',');
-		        	this.value = tags;
-				}
-			});*/
-			
-		},
-
-		evAuditChange : function(form, fieldEditor){
-			XAUtil.checkDirtyFieldForToggle(fieldEditor);
-			if(fieldEditor.getValue() == 1){
-				this.model.set('auditList', new VXAuditMapList(new VXAuditMap({
-					'auditType' : XAEnums.XAAuditType.XA_AUDIT_TYPE_ALL.value,//fieldEditor.getValue()//
-					'resourceId' :this.model.get('id')
-					
-				})));
-			} else {
-				var validation  = this.formValidation();
-				if(validation.groupPermSet || validation.isUsers)
-					this.model.unset('auditList');
-				else{
-					XAUtil.alertPopup({
-						msg :localization.tt("msg.policyNotHavingPerm"),
-						callback : function(){
-							fieldEditor.setValue('ON');
-						}
-					});
-				}
-			}
-			console.log(fieldEditor); 
-		},
-		evRecursiveChange : function(form, fieldEditor){
-			XAUtil.checkDirtyFieldForToggle(fieldEditor);
-		},
-		evResourceStatusChange : function(form, fieldEditor){
-			XAUtil.checkDirtyFieldForToggle(fieldEditor);
-		}
-	});
-
-	return PolicyForm;
-});

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/security-admin/src/main/webapp/scripts/views/policymanager/PolicyManagerLayout.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policymanager/PolicyManagerLayout.js b/security-admin/src/main/webapp/scripts/views/policymanager/PolicyManagerLayout.js
deleted file mode 100644
index e3ba907..0000000
--- a/security-admin/src/main/webapp/scripts/views/policymanager/PolicyManagerLayout.js
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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 XALinks 			= require('modules/XALinks');
-	var XAEnums 			= require('utils/XAEnums');
-	var XAUtil				= require('utils/XAUtils');
-	var SessionMgr 			= require('mgrs/SessionMgr');
-	
-	var PolicymanagerlayoutTmpl = require('hbs!tmpl/common/PolicyManagerLayout_tmpl');
-	return Backbone.Marionette.Layout.extend(
-	/** @lends PolicyManagerLayout */
-	{
-		_viewName : name,
-		
-    	template: PolicymanagerlayoutTmpl,
-
-		templateHelpers: function(){
-			var groupedCol = this.collection.groupBy('assetType');
-			return {
-				hdfsList : groupedCol[XAEnums.AssetType.ASSET_HDFS.value],
-				hiveList : groupedCol[XAEnums.AssetType.ASSET_HIVE.value],
-				hbaseList: groupedCol[XAEnums.AssetType.ASSET_HBASE.value],
-				knoxList : groupedCol[XAEnums.AssetType.ASSET_KNOX.value],
-				stormList: groupedCol[XAEnums.AssetType.ASSET_STORM.value],
-				hdfsVal  : XAEnums.AssetType.ASSET_HDFS.value,
-				hiveVal  : XAEnums.AssetType.ASSET_HIVE.value,
-				hbaseVal : XAEnums.AssetType.ASSET_HBASE.value,
-				knoxVal  : XAEnums.AssetType.ASSET_KNOX.value,
-				stormVal  : XAEnums.AssetType.ASSET_STORM.value,
-				assetCreateHref : XALinks.get('AssetCreate').href,
-				isSysAdmin : SessionMgr.isSystemAdmin()
-			};
-		},
-    	breadCrumbs :[XALinks.get('RepositoryManager')],
-
-		/** Layout sub regions */
-    	regions: {},
-
-    	/** ui selector cache */
-    	ui: {},
-
-		/** ui events hash */
-		events : function(){
-			var events = {};
-			events['click .deleteRep']		= 'onDeleteRepository';
-			return events;
-		},
-    	/**
-		* intialize a new PolicyManagerLayout Layout 
-		* @constructs
-		*/
-		initialize: function(options) {
-			console.log("initialized a PolicyManagerLayout Layout");
-
-			_.extend(this, _.pick(options, 'collection'));
-			this.bindEvents();
-		},
-
-		/** all events binding here */
-		bindEvents : function(){
-			/*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/
-			this.listenTo(this.collection, "sync", this.render, this);
-			this.listenTo(this.collection, "request", function(){
-				this.$('[data-id="r_tableSpinner"]').removeClass('display-none').addClass('loading');
-			}, this);
-		},
-
-		/** on render callback */
-		onRender: function() {
-			this.$('[data-id="r_tableSpinner"]').removeClass('loading').addClass('display-none');
-			this.initializePlugins();
-		},
-
-		/** all post render plugin initialization */
-		initializePlugins: function(){
-		},
-		onDeleteRepository : function(e){
-			var that = this;
-			var model = this.collection.get($(e.currentTarget).data('id'));
-			if(model){
-				model = new this.collection.model(model.attributes);
-				XAUtil.confirmPopup({
-					msg :'Are you sure want to delete ?',
-					callback : function(){
-						XAUtil.blockUI();
-						model.destroy({success: function(model, response) {
-							XAUtil.blockUI('unblock');
-							that.collection.remove(model.get('id'));
-							XAUtil.notifySuccess('Success', 'Repository deleted successfully');
-							that.render();
-						}});
-					}
-				});
-			}
-		},
-		/** on close */
-		onClose: function(){
-		}
-
-	});
-});

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/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 0c29c2c..525418d 100644
--- a/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js
@@ -28,6 +28,7 @@ define(function(require){
 	var XAUtil				= require('utils/XAUtils');
 	var SessionMgr 			= require('mgrs/SessionMgr');
 	var RangerServiceList 	= require('collections/RangerServiceList');
+	var RangerService 	= require('models/RangerService');
 	
 	var ServicemanagerlayoutTmpl = require('hbs!tmpl/common/ServiceManagerLayout_tmpl');
 	return Backbone.Marionette.Layout.extend(
@@ -39,24 +40,26 @@ define(function(require){
 
 		templateHelpers: function(){
 			var groupedServices = this.services.groupBy("type");
-
 			return {
 				isSysAdmin : SessionMgr.isSystemAdmin(),
 				serviceDefs : this.collection.models,
 				services : groupedServices
 			};
 		},
-    	breadCrumbs :[XALinks.get('RepositoryManager')],
+    	breadCrumbs :[XALinks.get('ServiceManager')],
 
 		/** Layout sub regions */
     	regions: {},
 
     	/** ui selector cache */
-    	ui: {},
+    	ui: {
+    		'btnDelete' : '.deleteRepo',
+    	},
 
 		/** ui events hash */
 		events : function(){
 			var events = {};
+			events['click ' + this.ui.btnDelete]	= 'onDelete';
 			return events;
 		},
     	/**
@@ -85,7 +88,6 @@ define(function(require){
 			this.$('[data-id="r_tableSpinner"]').removeClass('loading').addClass('display-none');
 			this.initializePlugins();
 		},
-
 		/** all post render plugin initialization */
 		initializePlugins: function(){
 
@@ -98,6 +100,25 @@ define(function(require){
 			});
 
 		},
+		onDelete : function(e){
+			var that = this;
+			var model = this.services.get($(e.currentTarget).data('id'));
+			if(model){
+				model = new RangerService(model.attributes);
+				XAUtil.confirmPopup({
+					msg :'Are you sure want to delete ?',
+					callback : function(){
+						XAUtil.blockUI();
+						model.destroy({success: function(model, response) {
+							XAUtil.blockUI('unblock');
+							that.services.remove(model.get('id'));
+							XAUtil.notifySuccess('Success', 'Service deleted successfully');
+							that.render();
+						}});
+					}
+				});
+			}
+		},
 		/** on close */
 		onClose: function(){
 		}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/286acf6d/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 d37a2db..b4dd88b 100644
--- a/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
+++ b/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
@@ -72,7 +72,7 @@ define(function(require){
 			var events = {};
 			events['click ' + this.ui.btnSave]		= 'onSave';
 			events['click ' + this.ui.btnCancel]	= 'onCancel';
-//			events['click ' + this.ui.btnDelete]	= 'onDelete';
+			events['click ' + this.ui.btnDelete]	= 'onDelete';
 //			events['click ' + this.ui.btnTestConn]	= 'onTestConnection';
 			return events;
 		},
@@ -156,7 +156,7 @@ define(function(require){
 				success: function () {
 					XAUtil.blockUI('unblock');
 					XAUtil.allowNavigation();
-					var msg = that.editService ? 'Repository updated successfully' :'Repository created successfully';
+					var msg = that.editService ? 'Service updated successfully' :'Service created successfully';
 					XAUtil.notifySuccess('Success', msg);
 					
 					if(that.editService){
@@ -201,15 +201,16 @@ define(function(require){
 						success: function(model, response) {
 							XAUtil.blockUI('unblock');
 							XAUtil.allowNavigation();
-							XAUtil.notifySuccess('Success', 'Repository delete successfully');
+							XAUtil.notifySuccess('Success', 'Service delete successfully');
 							App.appRouter.navigate("#!/policymanager",{trigger: true});
 						},
 						error: function (model, response, options) {
 							XAUtil.blockUI('unblock');
 							if ( response && response.responseJSON && response.responseJSON.msgDesc){
 									XAUtil.notifyError('Error', response.responseJSON.msgDesc);
-							}else
+							}else{
 								XAUtil.notifyError('Error', 'Error occured while deleting service!');
+							}
 						}
 					});