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/16 16:52:29 UTC
[1/2] incubator-ranger git commit: RANGER-203: UI: Added dynamic
policy conditions module, updated url path and done some clean up
Repository: incubator-ranger
Updated Branches:
refs/heads/stack 87fffe02e -> e551d589b
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/scripts/views/policies/UserPermList.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policies/UserPermList.js b/security-admin/src/main/webapp/scripts/views/policies/UserPermList.js
deleted file mode 100644
index 6f2e578..0000000
--- a/security-admin/src/main/webapp/scripts/views/policies/UserPermList.js
+++ /dev/null
@@ -1,440 +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 App = require('App');
- var XAEnums = require('utils/XAEnums');
- var XAUtil = require('utils/XAUtils');
- var localization = require('utils/XALangSupport');
- var VXUser = require('models/VXUser');
- require('bootstrap-editable');
-
- var UserPermissionItem = Backbone.Marionette.ItemView.extend({
- _msvName : 'UserPermissionItem',
- template : require('hbs!tmpl/policies/UserPermItem'),
- tagName : 'tr',
- templateHelpers : function(){
-
- return {
- permissions : this.accessTypes,
- policyConditions: this.policyConditions,
-// policyStorm : this.policyType == XAEnums.ServiceType.Service_STORM.value ? true :false,
- isModelNew : !this.model.has('editMode'),
- stormPerms : this.stormPermsIds.length == 14 ? _.union(this.stormPermsIds,[-1]) : this.stormPermsIds
- };
- },
- ui : {
- selectUsers : '[data-js="selectUsers"]',
- tags : '[class=tags]'
- },
- events : {
- 'click [data-action="delete"]' : 'evDelete',
- 'click td' : 'evClickTD',
- 'change [data-js="selectUsers"]': 'evSelectUser',
- 'change input[class="policy-conditions"]' : 'policyCondtionChange'
- },
-
- initialize : function(options) {
- _.extend(this, _.pick(options, 'userList','policyType','accessTypes','policyConditions'));
- //this.subjectList = this.mStudent.getSubjectList();
- this.stormPermsIds = [];
- if(this.policyType == XAEnums.AssetType.ASSET_STORM.value){
- if(this.model.has('editMode') && this.model.get('editMode')){
- this.stormPermsIds = _.map(this.model.get('_vPermList'), function(p){
- if(XAEnums.XAPermType.XA_PERM_TYPE_ADMIN.value != p.permType)
- return p.permType;
- });
- }
- }
- },
-
- onRender : function() {
- var that = this;
-
- this.accessItems = _.map(this.accessTypes, function(perm){
- if(!_.isUndefined(perm))
- return {'type':perm.label,isAllowed : false}
- });
-
- if(this.model.get('userName') != undefined){
- this.ui.selectUsers.val(this.model.get('userName').split(','));
- }
- if(!_.isUndefined(this.model.get('conditions'))){
- _.each(this.model.get('conditions'), function(obj){
- console.log(obj)
- this.$el.find('input[data-js="'+obj.type+'"]').val(obj.value.toString())
- },this);
- }
-
- if(this.model.has('editMode') && this.model.get('editMode')){
- _.each(this.model.get('accesses'), function(p){
- if(p.isAllowed){
- this.$el.find('input[data-name="' + p.type + '"]').attr('checked', 'checked');
- _.each(this.accessItems,function(obj){ if(obj.type == p.type) obj.isAllowed=true;})
- }
- },this);
- }
- if(this.policyType == XAEnums.AssetType.ASSET_STORM.value)
- this.renderStormPerms();
-
- this.createSelectUserDropDown();
- this.userDropDownChange();
-
- },
- checkDirtyFieldForDropDown : function(e){
- //that.model.has('groupId')
- var userIdList =[];
- if(!_.isUndefined(this.model.get('userId')))
- userIdList = this.model.get('userId').split(',');
- XAUtil.checkDirtyField(userIdList, e.val, $(e.currentTarget));
- },
- toggleAddButton : function(e){
- var temp = [];
- this.collection.each(function(m){
- if(!_.isUndefined(m.get('userId'))){
- temp.push.apply(temp, m.get('userId').split(','));
-
- }
- });
- if(!_.isUndefined(e)){
- if( !_.isUndefined(e.added) && ((temp.length + 1) == this.userList.length))
- $('[data-action="addUser"]').hide();
- if(!_.isUndefined(e.removed))
- $('[data-action="addUser"]').show();
- }else{
- $('[data-action="addUser"]').show();
- }
- },
- evDelete : function(){
- var that = this;
- this.collection.remove(this.model);
- this.toggleAddButton();
- },
- evClickTD : function(e){
- var that = this;
- var $el = $(e.currentTarget),permList =[],perms =[];
- if($(e.toElement).is('td')){
- var $checkbox = $el.find('input');
- $checkbox.is(':checked') ? $checkbox.prop('checked',false) : $checkbox.prop('checked',true);
- }
-// var curPerm = $el.find('input').data('id');
- var curPermName = $el.find('input').data('name');
- if(!_.isUndefined(curPermName)){
- var perms = [];
- if(this.model.has('accesses')){
- if(_.isArray(this.model.get('accesses')))
- perms = this.model.get('accesses');
- else
- perms.push(this.model.get('accesses'));
- }
-
-
- if($el.find('input[type="checkbox"]').is(':checked')){
- _.each(that.accessItems, function(obj){ if(obj.type == curPermName) obj.isAllowed = true });
- /*if(curPermName == XAEnums.XAPermType.XA_PERM_TYPE_ADMIN.label){
- $el.parent().find('input[type="checkbox"]:not(:checked)[data-name!="'+curPermName+'"]').map(function(){
- _.each(that.accessItems, function(obj){ if(obj.type == $(this).data('name')) obj.isAllowed = true }, this);
- });
- // this.model.set('_vPermList', perms);
- $el.parent().find('input[type="checkbox"]').prop('checked',true);
- }*/
- } else {
- _.each(that.accessItems, function(obj){ if(obj.type == curPermName ) obj.isAllowed = false }, this);
- }
-// this.checkDirtyFieldForCheckBox(perms);
- if(!_.isEmpty(that.accessItems)){
- this.model.set('accesses', that.accessItems);
- } else {
- this.model.unset('accesses');
- }
- }
- },
- checkDirtyFieldForCheckBox : function(perms){
- var permList = [];
- if(!_.isUndefined(this.model.get('_vPermList')))
- permList = _.map(this.model.attributes._vPermList,function(obj){return obj.permType;});
- perms = _.map(perms,function(obj){return obj.permType;});
- XAUtil.checkDirtyField(permList, perms, this.$el);
- },
- createSelectUserDropDown :function(){
- var that = this;
- if(this.model.has('editMode') && !_.isEmpty(this.ui.selectUsers.val())){
- var temp = this.ui.selectUsers.val().split(",");
- _.each(temp , function(id){
- if(_.isUndefined(that.userList.where({ name : name}))){
- var user = new VXUser({name: name});
- user.fetch({async:false}).done(function(){
- that.userList.add(user);
- });
- }
- });
- }
- this.userArr = this.userList.map(function(m){
- return { id : m.id+"" , text : m.get('name')};
- });
- this.ui.selectUsers.select2({
- closeOnSelect : true,
- placeholder : 'Select User',
- // maximumSelectionSize : 1,
- width :'220px',
- tokenSeparators: [",", " "],
- tags : this.userArr,
- initSelection : function (element, callback) {
- var data = [];
- $(element.val().split(",")).each(function () {
- var obj = _.findWhere(that.userArr,{ text : this });
- data.push({ id : obj.id, text: this });
- });
- callback(data);
- },
- createSearchChoice: function(term, data) {
- /*if ($(data).filter(function() {
- return this.text.localeCompare(term) === 0;
- //return this.value == (term) ? true : false;
- }).length === 0) {
- return {
- id : term,
- text: term
- };
- }*/
- },
- ajax: {
- url: "service/xusers/users",
- dataType: 'json',
- data: function (term, page) {
- return {name : term};
- },
- results: function (data, page) {
- var results = [],selectedVals=[];
- /*if(!_.isEmpty(that.ui.selectUsers.select2('val')))
- selectedVals = that.ui.selectUsers.select2('val');
- selectedVals.push.apply(selectedVals, that.getUsersSelectdValues());
- selectedVals = $.unique(selectedVals);*/
- selectedVals = that.getUsersSelectdValues();
- if(data.resultSize != "0"){
- //if(data.vXUsers.length > 1){
-
- results = data.vXUsers.map(function(m, i){ return {id : m.id+"", text: m.name}; });
- if(!_.isEmpty(selectedVals))
- results = XAUtil.filterResultByIds(results, selectedVals);
- //console.log(results.length);
- return {results : results};
- // }
- // results = [{id : data.vXUsers.id+"", text: data.vXUsers.name}];
- // return {results : results};
- }
- return {results : results};
- }
- },
- formatResult : function(result){
- return result.text;
- },
- formatSelection : function(result){
- return result.text;
- },
- formatNoMatches: function(result){
- return 'No user found.';
- }
-
- }).on('select2-focus', XAUtil.select2Focus);
- },
- userDropDownChange : function(){
- var that = this;
- this.ui.selectUsers.on('change',function(e){
- // console.log(e.currentTarget.value);
- that.checkDirtyFieldForDropDown(e);
- that.toggleAddButton(e);
- var duplicateUsername = false;
- if(e.removed != undefined){
- var gIdArr = [],gNameArr = [];
- gIdArr = _.without(that.model.get('userId').split(','), e.removed.id);
- if(that.model.get('userName') != undefined)
- gNameArr = _.without(that.model.get('userName').split(','), e.removed.text);
- if(!_.isEmpty(gIdArr)){
- that.model.set('userId',gIdArr.join(','));
- that.model.set('userName',gNameArr.join(','));
- }else{
- that.model.unset('userId');
- that.model.unset('userName');
- }
- return;
-
- }
- if(!_.isUndefined(e.added)){
- that.model.set('userId', e.currentTarget.value);
- var userNameList = _.map($(e.currentTarget).select2("data"), function(obj){return obj.text});
- that.model.set('userName',userNameList.toString())
- }
- });
- },
- getUsersSelectdValues : function(){
- var vals = [],selectedVals = [];
- this.collection.each(function(m){
- if(!_.isUndefined(m.get('userId'))){
- vals.push.apply(vals, m.get('userId').split(','));
- }
- });
- if(!_.isEmpty(this.ui.selectUsers.select2('val')))
- selectedVals = this.ui.selectUsers.select2('val');
- vals.push.apply(vals , selectedVals);
- vals = $.unique(vals);
- return vals;
- },
- policyCondtionChange :function(e){
- if(!_.isEmpty($(e.currentTarget).val()) && !_.isEmpty(this.policyConditions)){
- var policyCond = { 'type' : $(e.currentTarget).attr('data-js'), 'value' : $(e.currentTarget).val() } ;
- var conditions = [];
- if(this.model.has('conditions')){
- conditions = this.model.get('conditions')
- }
- conditions.push(policyCond);
- this.model.set('conditions',conditions);
- }
- },
- renderStormPerms :function(){
- var that = this;
- var permArr = _.pick(XAEnums.XAPermType, XAUtil.getStormActions(this.policyType));
- this.stormPerms = _.map(permArr,function(m){return {text:m.label, value:m.value};});
- this.stormPerms.push({'value' : -1, 'text' : 'Select/Deselect All'});
- this.ui.tags.editable({
- placement: 'right',
-// emptytext : 'Please select',
- source: this.stormPerms,
- display: function(idList,srcData) {
- if(_.isEmpty(idList.toString())){
- $(this).html('');
- return;
- }
- if(!_.isArray(idList))
- idList = [idList];
-// that.checkDirtyFieldForGroup(values);
- var permTypeArr = [];
- var valArr = _.map(idList, function(id){
- if(!(parseInt(id) <= 0) && (!_.isNaN(parseInt(id)))){
- var obj = _.findWhere(srcData,{'value' : parseInt(id)});
- permTypeArr.push({permType : obj.value});
- return "<span class='label label-inverse'>" + obj.text + "</span>";
- }
- });
- if(that.model.has('_vPermList')){
- var adminPerm = _.where(that.model.get('_vPermList'),{'permType': XAEnums.XAPermType.XA_PERM_TYPE_ADMIN.value });
- permTypeArr = _.isEmpty(adminPerm) ? permTypeArr : _.union(permTypeArr,adminPerm);
- }
- that.model.set('_vPermList', permTypeArr);
-
- $(this).html(valArr.join(" "));
- },
- });
- this.$('[id^="tags-edit-"]').click(function(e) {
- e.stopPropagation();
- e.preventDefault();
- that.$('#' + $(this).data('editable') ).editable('toggle');
- 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);
-
- });
- });
- },
-
- });
-
-
-
- return Backbone.Marionette.CompositeView.extend({
- _msvName : 'UserPermissionList',
- template : require('hbs!tmpl/common/UserPermissionList'),
- //tagName : 'ul',
- //className : 'timeline-container',
- templateHelpers :function(){
- return {
- permHeaders : this.getPermHeaders()
- };
- },
- getItemView : function(item){
- if(!item){
- return;
- }
- return UserPermissionItem;
- },
- itemViewContainer : ".js-formInput",
- itemViewOptions : function() {
- return {
- 'collection' : this.collection,
- 'userList' : this.userList,
- 'policyType' : this.policyType,
- 'accessTypes' : this.accessTypes,
- 'policyConditions' : this.rangerServiceDefModel.get('policyConditions')
- };
- },
- events : {
- 'click [data-action="addUser"]' : 'addNew'
- },
- initialize : function(options) {
- _.extend(this, _.pick(options, 'userList','policyType','accessTypes','rangerServiceDefModel'));
- //this.listenTo(this.collection, 'removeAddBtn', this.render, this);
- /*if(options.model.isNew())
- this.collection.add(new Backbone.Model());*/
- if(this.collection.length == 0)
- this.collection.add(new Backbone.Model());
-
- },
- onRender : function(){
- //console.log("onRender of ArtifactFormNoteList called");
- this.toggleAddButton();
- },
- addNew : function(){
- var that =this;
- this.collection.add(new Backbone.Model());
- this.toggleAddButton();
- },
- toggleAddButton : function(){
- var userIds=[];
- this.collection.each(function(m){
- if(!_.isUndefined(m.get('userId'))){
- var temp = m.get('userId').split(',');
- userIds.push.apply(userIds,temp);
- }
- });
- if(userIds.length == this.userList.length)
- this.$('button[data-action="addUser"]').hide();
- else
- this.$('button[data-action="addUser"]').show();
- },
- getPermHeaders : function(){
- var permList = _.map(this.accessTypes,function(type){ return type.label});
- if(!_.isEmpty(this.rangerServiceDefModel.get('policyConditions'))){
- _.each(this.rangerServiceDefModel.get('policyConditions'), function(cond){
- if(!_.isNull(cond) && !_.isNull(cond.label)) permList.unshift(cond.label);
- });
- }
- permList.unshift(localization.tt('lbl.selectUser'));
- permList.push("");
- return permList;
- },
-
- });
-
-});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/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 6b7f3ea..d37a2db 100644
--- a/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
+++ b/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
@@ -72,8 +72,8 @@ 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.btnTestConn] = 'onTestConnection';
+// events['click ' + this.ui.btnDelete] = 'onDelete';
+// events['click ' + this.ui.btnTestConn] = 'onTestConnection';
return events;
},
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js b/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
index 24b174c..fc3ddae 100644
--- a/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
+++ b/security-admin/src/main/webapp/scripts/views/service/ServiceForm.js
@@ -22,7 +22,6 @@ define(function(require){
'use strict';
var Backbone = require('backbone');
-
var XAEnums = require('utils/XAEnums');
var localization = require('utils/XALangSupport');
var BackboneFormDataType = require('models/BackboneFormDataType');
@@ -87,25 +86,22 @@ define(function(require){
render: function(options) {
Backbone.Form.prototype.render.call(this, options);
+ this.setupForm();
this.initializePlugins();
this.renderCustomFields();
- /*if(!this.model.isNew())
- this.fields.serviceType.editor.$el.prop('disabled',true);
- else
- this.fields.activeStatus.editor.setValue(XAEnums.ActiveStatus.STATUS_ENABLED.value);
- */
- if(this.model.isNew())
+ },
+ setupForm : function() {
+ if(this.model.isNew()){
this.fields.isEnabled.editor.setValue(XAEnums.ActiveStatus.STATUS_ENABLED.value);
- else{
- //Set isEnabled Status
- if(!_.isUndefined(this.model.get('isEnabled')))
- if(XAEnums.ActiveStatus.STATUS_ENABLED.value == this.model.get('isEnabled'))
- this.fields.isEnabled.editor.setValue(XAEnums.ActiveStatus.STATUS_ENABLED.value);
- else
- this.fields.isEnabled.editor.setValue(XAEnums.ActiveStatus.STATUS_DISABLED.value);
- }
+ }else{
+ //Set isEnabled Status
+ if(XAEnums.ActiveStatus.STATUS_ENABLED.value == this.model.get('isEnabled')){
+ this.fields.isEnabled.editor.setValue(XAEnums.ActiveStatus.STATUS_ENABLED.value);
+ }else{
+ this.fields.isEnabled.editor.setValue(XAEnums.ActiveStatus.STATUS_DISABLED.value);
+ }
+ }
},
-
/** all custom field rendering */
renderCustomFields: function(){
},
@@ -129,21 +125,16 @@ define(function(require){
that.model.unset(obj.name);
}
});
-// this.model.set('configs',JSON.stringify(config));
this.model.set('configs',config);
//Set service type
this.model.set('type',this.rangerServiceDefModel.get('name'))
- /*_.each(XAEnums.AssetType, function(asset){
- if(asset.label.toUpperCase() == this.rangerServiceDefModel.get('name').toUpperCase())
- this.model.set('type',asset.label)
- },this);*/
-//
//Set isEnabled
- if(parseInt(this.model.get('isEnabled')) == XAEnums.ActiveStatus.STATUS_ENABLED.value)
+ if(parseInt(this.model.get('isEnabled')) == XAEnums.ActiveStatus.STATUS_ENABLED.value){
this.model.set('isEnabled',true);
- else
+ }else{
this.model.set('isEnabled',false);
+ }
//Remove unwanted attributes from model
if(!this.model.isNew()){
@@ -152,7 +143,6 @@ define(function(require){
},this);
}
},
-
removeElementFromArr : function(arr ,elem){
var index = $.inArray(elem,arr);
if(index >= 0) arr.splice(index,1);
@@ -161,4 +151,4 @@ define(function(require){
});
return ServiceForm;
-});
\ No newline at end of file
+});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/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 7981486..a6ef7af 100644
--- a/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
+++ b/security-admin/src/main/webapp/templates/common/ServiceManagerLayout_tmpl.html
@@ -38,24 +38,6 @@
</thead>
<tbody>
{{{getServices ../services this}}}
-
- <!-- <tr>
- <td>
- <div>
- <a data-id="{{./this.id}}" href="#!/hdfs/{{./this.id}}/policies">{{./this.attributes.name}}</a>
- {{#if ../isSysAdmin}}
- <div class="pull-right">
- <a data-id="{{./this.id}}" class="btn btn-mini"
- href="#!/asset/{{./this.id}}" title="Edit"><i
- class="icon-edit"></i></a> <a data-id="{{./this.id}}"
- class="deleteRep btn btn-mini btn-danger"
- href="javascript:void(0);" title="Delete"><i
- class="icon-trash"></i></a>
- </div>
- {{/if}}
- </div>
- </td>
- </tr> -->
</tbody>
</table>
<div data-id="r_tableSpinner" class="loading">
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/templates/policies/GroupPermItem.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/GroupPermItem.html b/security-admin/src/main/webapp/templates/policies/GroupPermItem.html
deleted file mode 100644
index fd1de81..0000000
--- a/security-admin/src/main/webapp/templates/policies/GroupPermItem.html
+++ /dev/null
@@ -1,39 +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.
---}}
-<td>
- <input type="text" data-js="selectGroups" />
-</td>
-<td>
- <input type="text" data-js="selectUsers" />
-</td>
-{{#if policyConditions}}
-<td>
- <a href="#" id="policyConditions" data-type="policyConditions" data-original-title="Policy Conditions" ></a>
-</td>
-{{/if}}
-<td>
- <a href="#" data-js="permissions" data-type="checklist" data-title="Select permissions"></a>
-</td>
-<td>
- <input data-js="delegatedAdmin" type="checkbox">
-</td>
-<td>
- <button type="button" class="btn btn-small btn-danger " data-action="delete">
- <i class="icon-remove"></i>
- </button>
-</td>
-
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/templates/policies/GroupPermList.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/GroupPermList.html b/security-admin/src/main/webapp/templates/policies/GroupPermList.html
deleted file mode 100644
index 070b908..0000000
--- a/security-admin/src/main/webapp/templates/policies/GroupPermList.html
+++ /dev/null
@@ -1,42 +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.
---}}
-<div class="control-group">
- <label class="control-label">{{tt 'lbl.permissions'}}</label>
- <div class="controls">
- <table class="table-permission table-condensed">
- <thead>
- <tr>
- {{#each permHeaders}}
- <th>{{./this}}</th>
- {{/each}}
-
- </tr>
- </thead>
- <tbody class="js-formInput">
-
- </tbody>
- </table>
- </div>
-</div>
-<div class="control-group">
- <div class="controls" style="margin-top:-14px">
- <button type="button" class="btn btn-small" data-action="addGroup" title="Add">
- <!-- {{tt 'btn.add'}} -->
- <i class="icon-plus"></i>
- </button>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/templates/policies/PermissionItem.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/PermissionItem.html b/security-admin/src/main/webapp/templates/policies/PermissionItem.html
new file mode 100644
index 0000000..e1a7166
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/policies/PermissionItem.html
@@ -0,0 +1,39 @@
+{{!--
+ 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.
+--}}
+<td>
+ <input type="text" data-js="selectGroups" />
+</td>
+<td>
+ <input type="text" data-js="selectUsers" />
+</td>
+{{#if policyConditions}}
+<td>
+ <a href="#" id="policyConditions" data-type="policyConditions" data-original-title="Policy Conditions" title="add/edit conditions"></a>
+</td>
+{{/if}}
+<td>
+ <a href="#" data-js="permissions" data-type="checklist" data-title="Select permissions" title="add/edit permissions"></a>
+</td>
+<td>
+ <input data-js="delegatedAdmin" type="checkbox">
+</td>
+<td>
+ <button type="button" class="btn btn-small btn-danger " data-action="delete">
+ <i class="icon-remove"></i>
+ </button>
+</td>
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/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
new file mode 100644
index 0000000..070b908
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/policies/PermissionList.html
@@ -0,0 +1,42 @@
+{{!--
+ 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.
+--}}
+<div class="control-group">
+ <label class="control-label">{{tt 'lbl.permissions'}}</label>
+ <div class="controls">
+ <table class="table-permission table-condensed">
+ <thead>
+ <tr>
+ {{#each permHeaders}}
+ <th>{{./this}}</th>
+ {{/each}}
+
+ </tr>
+ </thead>
+ <tbody class="js-formInput">
+
+ </tbody>
+ </table>
+ </div>
+</div>
+<div class="control-group">
+ <div class="controls" style="margin-top:-14px">
+ <button type="button" class="btn btn-small" data-action="addGroup" title="Add">
+ <!-- {{tt 'btn.add'}} -->
+ <i class="icon-plus"></i>
+ </button>
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/templates/policies/RangerPolicyCreate_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/RangerPolicyCreate_tmpl.html b/security-admin/src/main/webapp/templates/policies/RangerPolicyCreate_tmpl.html
new file mode 100644
index 0000000..eab1c22
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/policies/RangerPolicyCreate_tmpl.html
@@ -0,0 +1,48 @@
+{{!--
+ 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.
+--}}
+{{#if editPolicy}}
+ <h4> {{tt 'h.editPolicy'}}</h4>
+{{else}}
+ <h4> {{tt 'h.createPolicy'}} </h4>
+{{/if}}
+<div class="wrap non-collapsible ">
+<div class="alert alert-danger" data-id="policyDisabledAlert" style="display:none;">
+ <button type="button" class="close" data-dismiss="alert">×</button>
+ <strong>Warning !</strong> {{tt 'msg.policyDisabledMsg'}}
+</div>
+ <div data-id="r_form"></div>
+ <div class="form-actions form-policy" class="row-fluid">
+ {{#if editPolicy}}
+ <button type="submit" data-id="save" class="btn btn-spinner btn-primary">
+ <span>Save</span>
+ <i class="icon-spinner icon-spin"></i>
+ </button>
+ {{else}}
+ <button type="submit" data-id="save" class="btn btn-spinner btn-primary">
+ <span>Add</span>
+ <i class="icon-spinner icon-spin"></i>
+ </button>
+ {{/if}}
+ <button type="button" data-id="cancel" class="btn btn-inverse">
+ Cancel
+ </button>
+ {{#if editPolicy}}
+ <button type="button" data-id="delete" class="btn btn-danger" ><!-- style="margin-left: 27%;" -->Delete</button>
+ {{/if}}
+ </div>
+</div>
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
index 157e9e1..d4df1fa 100644
--- a/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
+++ b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html
@@ -19,19 +19,7 @@
<p class="formHeader">
Policy Details :
</p>
- <!--ul id="name1"></ul-->
- <!--div class="control-group field-name">
- <label class="control-label" for="name2">Resource Path(new impl) *</label>
- <div class="controls">
- <input type="text" class="select2-input" id="name2" style="width: 250px;">
- </div>
- </div-->
- <!-- <div class="" data-fields="policyName" style="float:left"></div>
- <div class="" data-editors="resourceStatus" style="float:left"></div> -->
- <div class="clearfix"></div>
<b data-fieldsets class="policy-form"></b>
- <!-- <div class="" data-fields="name"></div>
- -->
</fieldset>
<fieldset>
<p class="formHeader">
@@ -46,5 +34,4 @@
</div>
</div>
</fieldset>
-</form>
-
+</form>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/templates/policies/UserPermItem.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/UserPermItem.html b/security-admin/src/main/webapp/templates/policies/UserPermItem.html
deleted file mode 100644
index 09304f4..0000000
--- a/security-admin/src/main/webapp/templates/policies/UserPermItem.html
+++ /dev/null
@@ -1,53 +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.
---}}
-<td>
- <input type="text" data-js="selectUsers" />
-</td>
-{{#each policyConditions}}
- {{#if this.name}}
- <td>
- <input type="text" data-js="{{this.name}}" placeholder="{{this.label}}" class="policy-conditions"/>
- </td>
- {{/if}}
-{{/each}}
-
-{{#if policyStorm}}
-<td>
- <span class="tags" id="tags-editable-1" data-toggle="manual" data-type="checklist"
- data-value="{{stormPerms}}" data-original-title="Select Actions">
- </span>
- <a href="#" id="tags-edit-1" data-editable="tags-editable-1" class="" style="margin-left:10px;">
- {{#if isModelNew}}
- <i class="icon-plus" title="Add"></i>
- {{else}}
- <i class="icon-pencil" title="Edit"></i>
- {{/if}}
- </a>
-</td>
-{{/if}}
-{{#each permissions}}
- <td style="cursor:pointer;">
- <input data-name="{{./this.label}}" type="checkbox">
- </td>
-{{/each}}
-
-<td>
- <button type="button" class="btn btn-small btn-danger " data-action="delete">
- <i class="icon-remove"></i>
- </button>
-</td>
-
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/templates/policies/UserPermList.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/UserPermList.html b/security-admin/src/main/webapp/templates/policies/UserPermList.html
deleted file mode 100644
index 797ae21..0000000
--- a/security-admin/src/main/webapp/templates/policies/UserPermList.html
+++ /dev/null
@@ -1,42 +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.
---}}
-<div class="control-group">
- <label class="control-label">{{tt 'lbl.userPermissions'}}</label>
- <div class="controls">
- <table class="table-permission table-condensed">
- <thead>
- <tr>
- {{#each permHeaders}}
- <th>{{./this}}</th>
- {{/each}}
-
- </tr>
- </thead>
- <tbody class="js-formInput">
-
- </tbody>
- </table>
- </div>
-</div>
-<div class="control-group">
- <div class="controls" style="margin-top:-14px">
- <button type="button" class="btn btn-small" data-action="addUser" title="Add">
- <!-- {{tt 'btn.add'}} -->
- <i class="icon-plus"></i>
- </button>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/templates/service/ServiceForm_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/service/ServiceForm_tmpl.html b/security-admin/src/main/webapp/templates/service/ServiceForm_tmpl.html
index 0a52755..e0f7f4d 100644
--- a/security-admin/src/main/webapp/templates/service/ServiceForm_tmpl.html
+++ b/security-admin/src/main/webapp/templates/service/ServiceForm_tmpl.html
@@ -22,12 +22,9 @@
<div class="serviceDetail" data-fields={{serviceDetail}}></div>
</fieldset>
<fieldset class="configProp">
- <!-- <b data-fieldsets></b> -->
<p class="formHeader">
Config Properties :
</p>
- <!-- div class="" data-fields="_vPassword"></div-->
- <!-- div class="" data-fields="pair"></div-->
<div class="serviceConfig" data-fields={{serviceConfig}}></div>
</fieldset>
<div>
@@ -41,6 +38,4 @@
</div>
</div>
</div>
-
-</form>
-
+</form>
\ No newline at end of file
[2/2] incubator-ranger git commit: RANGER-203: UI: Added dynamic
policy conditions module, updated url path and done some clean up
Posted by ma...@apache.org.
RANGER-203: UI: Added dynamic policy conditions module, updated url path and done some clean up
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/e551d589
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/e551d589
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/e551d589
Branch: refs/heads/stack
Commit: e551d589bcaf04324d5dcf53bbb83b06c8e572f5
Parents: 87fffe0
Author: Gautam Borad <gb...@gmail.com>
Authored: Fri Jan 16 07:51:50 2015 -0800
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Fri Jan 16 07:51:50 2015 -0800
----------------------------------------------------------------------
.../plugin/store/ServiceStoreFactory.java | 2 +-
.../bower/x-editable/js/bootstrap-editable.js | 2 +-
.../webapp/scripts/controllers/Controller.js | 391 +--------------
.../scripts/models/BackboneFormDataType.js | 2 +-
.../src/main/webapp/scripts/routers/Router.js | 35 --
.../src/main/webapp/scripts/utils/XAUtils.js | 10 +
.../scripts/views/policies/GroupPermList.js | 476 -------------------
.../scripts/views/policies/PermissionList.js | 473 ++++++++++++++++++
.../views/policies/RangerPolicyCreate.js | 167 +------
.../scripts/views/policies/RangerPolicyForm.js | 103 ++--
.../views/policies/RangerPolicyTableLayout.js | 156 +-----
.../scripts/views/policies/UserPermList.js | 440 -----------------
.../scripts/views/service/ServiceCreate.js | 4 +-
.../webapp/scripts/views/service/ServiceForm.js | 42 +-
.../common/ServiceManagerLayout_tmpl.html | 18 -
.../templates/policies/GroupPermItem.html | 39 --
.../templates/policies/GroupPermList.html | 42 --
.../templates/policies/PermissionItem.html | 39 ++
.../templates/policies/PermissionList.html | 42 ++
.../policies/RangerPolicyCreate_tmpl.html | 48 ++
.../policies/RangerPolicyForm_tmpl.html | 15 +-
.../webapp/templates/policies/UserPermItem.html | 53 ---
.../webapp/templates/policies/UserPermList.html | 42 --
.../templates/service/ServiceForm_tmpl.html | 7 +-
24 files changed, 691 insertions(+), 1957 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceStoreFactory.java
----------------------------------------------------------------------
diff --git a/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceStoreFactory.java b/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceStoreFactory.java
index a2af931..949792b 100644
--- a/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceStoreFactory.java
+++ b/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceStoreFactory.java
@@ -68,7 +68,7 @@ public class ServiceStoreFactory {
if(useFileStore) {
serviceStore = new ServiceFileStore(); // TODO: configurable store implementation
} else {
- RangerRESTClient restClient = new RangerRESTClient("http://172.18.145.30:6080", "");
+ RangerRESTClient restClient = new RangerRESTClient("http://localhost:6080", "");
restClient.setBasicAuthInfo("admin", "admin");
serviceStore = new ServiceRESTStore(restClient);
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/libs/bower/x-editable/js/bootstrap-editable.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/libs/bower/x-editable/js/bootstrap-editable.js b/security-admin/src/main/webapp/libs/bower/x-editable/js/bootstrap-editable.js
index fe2ae73..86d34da 100644
--- a/security-admin/src/main/webapp/libs/bower/x-editable/js/bootstrap-editable.js
+++ b/security-admin/src/main/webapp/libs/bower/x-editable/js/bootstrap-editable.js
@@ -610,7 +610,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
'</form>';
//loading div
- $.fn.editableform.loading = '<div class="editableform-loading"></div>';
+ $.fn.editableform.loading = '<div class="loading"></div>';
//buttons
$.fn.editableform.buttons = '<button type="submit" class="editable-submit">ok</button>'+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/scripts/controllers/Controller.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/controllers/Controller.js b/security-admin/src/main/webapp/scripts/controllers/Controller.js
index b58a632..f056d15 100644
--- a/security-admin/src/main/webapp/scripts/controllers/Controller.js
+++ b/security-admin/src/main/webapp/scripts/controllers/Controller.js
@@ -73,381 +73,6 @@ define(function(require) {
});
},
- hdfsManageAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/hdfs/HDFSTableLayout');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
- var resourceListForAsset = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- var assetModel = new VXAsset({id:assetId});
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- collection : resourceListForAsset,
- assetModel : assetModel
- }));
- resourceListForAsset.fetch({
-// cache : true
- });
- });
- },
-
- policyCreateAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
-
- var view = require('views/policy/PolicyCreate');
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
-
- var assetModel = new VXAsset({id:assetId});
- var resource = new VXResource();
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
-
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- },
-
- policyEditAction :function(){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/policy/PolicyCreate');
- App.rContent.show(new view({
- }));
- },
-
- policyViewAction :function(assetId,id){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
-
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
- var view = require('views/policy/PolicyCreate');
-
- var resource = new VXResource({id : id });
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
-
- var assetModel = new VXAsset({id:assetId});
- resource.fetch({
-// cache:true
- }).done(function(){
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- });
- },
- //************** Policy Related ( HIVE )*********************/
- hiveManageAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/hive/HiveTableLayout');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
- var resourceListForAsset = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- var assetModel = new VXAsset({id:assetId});
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- collection : resourceListForAsset,
- assetModel : assetModel
- }));
- resourceListForAsset.fetch({
-// cache : true
- });
- });
- },
- hivePolicyCreateAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/hive/HivePolicyCreate');
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
-
- var assetModel = new VXAsset({id:assetId});
- var resource = new VXResource();
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- },
- hivePolicyEditAction :function(assetId,id){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
- var view = require('views/hive/HivePolicyCreate');
- var resource = new VXResource({id : id });
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- var assetModel = new VXAsset({id:assetId});
- resource.fetch({
-// cache:true
- }).done(function(){
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- });
- },
-
- //************** Policy Related ( KNOX )*********************/
- knoxManageAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/knox/KnoxTableLayout');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
-
- var resourceListForAsset = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- var assetModel = new VXAsset({id:assetId});
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- collection :resourceListForAsset,
- assetModel : assetModel
- }));
- resourceListForAsset.fetch({
-// cache : true
- });
- });
- },
- knoxPolicyCreateAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/knox/KnoxPolicyCreate');
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
-
- var assetModel = new VXAsset({id:assetId});
- var resource = new VXResource();
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- },
- knoxPolicyEditAction :function(assetId,id){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
- var view = require('views/knox/KnoxPolicyCreate');
- var resource = new VXResource({id : id });
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- var assetModel = new VXAsset({id:assetId});
- resource.fetch({
-// cache:true
- }).done(function(){
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- });
- },
- //************** Policy Related ( STORM )*********************/
- stormManageAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/storm/StormTableLayout');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
-
- var resourceListForAsset = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- var assetModel = new VXAsset({id:assetId});
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- collection :resourceListForAsset,
- assetModel : assetModel
- }));
- resourceListForAsset.fetch({
-// cache : true
- });
- });
- },
- stormPolicyCreateAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/storm/StormPolicyCreate');
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
-
- var assetModel = new VXAsset({id:assetId});
- var resource = new VXResource();
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- },
- stormPolicyEditAction :function(assetId,id){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
- var view = require('views/storm/StormPolicyCreate');
- var resource = new VXResource({id : id });
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- var assetModel = new VXAsset({id:assetId});
- resource.fetch({
-// cache:true
- }).done(function(){
- assetModel.fetch({cache : true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- });
- },
- //************** Asset Related ( Repository )*********************/
- assetCreateAction :function(assetType){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/asset/AssetCreate');
- var VXAsset = require('models/VXAsset');
- App.rContent.show(new view({
- model : new VXAsset().set('assetType',assetType)
- }));
- },
-
- assetEditAction :function(id){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/asset/AssetCreate');
- var VXAsset = require('models/VXAsset');
-
- var model = new VXAsset({id : id });
- model.fetch({cache:true}).done(function(){
- App.rContent.show(new view({
- model : model
- }));
- });
- },
- //************** Policy Related ( HBASE)*********************/
- hbaseManageAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/hbase/HbaseTableLayout');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
- var resourceListForAsset = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- var assetModel = new VXAsset({id:assetId});
- assetModel.fetch({cache:true}).done(function(){
- App.rContent.show(new view({
- collection : resourceListForAsset,
- assetModel : assetModel
- }));
- resourceListForAsset.fetch({
-// cache : true
- });
- });
-
- },
- hbasePolicyCreateAction :function(assetId){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var view = require('views/hbase/HbasePolicyCreate');
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
- var resource = new VXResource();
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- var assetModel = new VXAsset({id:assetId});
- assetModel.fetch({cache:true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- },
- hbasePolicyEditAction :function(assetId,id){
- MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
- var VXResource = require('models/VXResource');
- var VXResourceList = require('collections/VXResourceList');
- var VXAsset = require('models/VXAsset');
- var view = require('views/hbase/HbasePolicyCreate');
- var resource = new VXResource({id : id });
- var assetModel = new VXAsset({id:assetId});
-
- resource.collection = new VXResourceList([],{
- queryParams : {
- 'assetId' : assetId
- }
- });
- resource.fetch({
-// cache:true
- }).done(function(){
- assetModel.fetch({cache:true}).done(function(){
- App.rContent.show(new view({
- model : resource,
- assetModel : assetModel
- }));
- });
- });
- },
-
//************** Analytics(reports) Related *********************/
userAccessReportAction : function(){
MAppState.set({ 'currentTab' : XAGlobals.AppTabs.Analytics.value });
@@ -646,14 +271,11 @@ define(function(require) {
var rangerServiceDefModel = new RangerServiceDef({id:serviceTypeId});
var rangerServiceModel = new RangerService();
-// rangerServiceDefModel.fetch({
-// cache:true
-// }).done(function(){
- App.rContent.show(new view({
- model : rangerServiceModel,
- serviceTypeId : serviceTypeId
- }));
-// });
+
+ App.rContent.show(new view({
+ model : rangerServiceModel,
+ serviceTypeId : serviceTypeId
+ }));
},
serviceEditAction :function(serviceTypeId, serviceId){
MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
@@ -676,6 +298,7 @@ define(function(require) {
policyManageAction :function(serviceId){
MAppState.set({ 'currentTab' : XAGlobals.AppTabs.PolicyManager.value });
+ var XAUtil = require('utils/XAUtils');
var view = require('views/policies/RangerPolicyTableLayout');
var RangerService = require('models/RangerService');
var RangerPolicyList = require('collections/RangerPolicyList');
@@ -687,7 +310,7 @@ define(function(require) {
'serviceId' : serviceId
}
});*/
- rangerPolicyList.url = "service/plugins/policies/service/"+serviceId
+ rangerPolicyList.url = XAUtil.getServicePoliciesURL(serviceId);
rangerService.fetch({
cache : false,
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/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 7b02ef9..b8c8bb2 100644
--- a/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js
+++ b/security-admin/src/main/webapp/scripts/models/BackboneFormDataType.js
@@ -33,7 +33,7 @@ define(function(require) {
case 'string':
if(!_.isUndefined(v.lookupSupported) && v.lookupSupported ){
formObj.type = 'Select2Remote';
- formObj.pluginAttr = form.getPlugginAttr(false),
+ formObj.pluginAttr = _.isUndefined(v.url) ? form.getPlugginAttr(false) : form.getPlugginAttr(true, v.url),
formObj.editorAttrs = {'data-placeholder': v.label },
formObj.options = function(callback, editor){
callback();
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/scripts/routers/Router.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/routers/Router.js b/security-admin/src/main/webapp/scripts/routers/Router.js
index 3cafdae..cda8ea3 100644
--- a/security-admin/src/main/webapp/scripts/routers/Router.js
+++ b/security-admin/src/main/webapp/scripts/routers/Router.js
@@ -30,40 +30,6 @@ function(Backbone){
"" : "serviceManagerAction",//"dashboardAction",
"!/policymanager" : "serviceManagerAction",
- /* HDFS related */
- "!/hdfs" : "hdfsManageAction",
- "!/hdfs/:id/policies" : "hdfsManageAction",
- "!/policy/:assetId/create" : "policyCreateAction",
- "!/policy/:id/edit" : "policyEditAction",
- "!/hdfs/:assetId/policy/:id": "policyViewAction",
-
- /****** Hive related **********************/
- "!/hive" : "hiveManageAction",
- "!/hive/:id/policies" : "hiveManageAction",
- "!/hive/:assetId/policy/create" : "hivePolicyCreateAction",
- "!/hive/:assetId/policy/:id" : "hivePolicyEditAction",
-
- /****** HBASE related **********************/
- "!/hbase" : "hbaseManageAction",
- "!/hbase/:id/policies" : "hbaseManageAction",
- "!/hbase/:assetId/policy/create": "hbasePolicyCreateAction",
- "!/hbase/:assetId/policy/:id" : "hbasePolicyEditAction",
-
- /****** KNOX related ************************/
- "!/knox/:id/policies" : "knoxManageAction",
- "!/knox/:assetId/policy/create" : "knoxPolicyCreateAction",
- "!/knox/:assetId/policy/:id" : "knoxPolicyEditAction",
-
- /****** STORM related ************************/
- "!/storm/:id/policies" : "stormManageAction",
- "!/storm/:assetId/policy/create": "stormPolicyCreateAction",
- "!/storm/:assetId/policy/:id" : "stormPolicyEditAction",
-
- /****** Asset related **********************/
- "!/asset" : "policyManagerAction",
- "!/asset/create/:assetType" : "assetCreateAction",
- "!/asset/:id" : "assetEditAction",
-
/****** Analytics Report related **********************/
"!/reports/userAccess" : "userAccessReportAction",
@@ -82,7 +48,6 @@ function(Backbone){
"!/group/:id" : "groupEditAction",
/************GENERIC UI *****************************************/
- /****** Service related **********************/
"!/service/:serviceType/create" : "serviceCreateAction",
"!/service/:serviceType/edit/:id" : "serviceEditAction",
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/scripts/utils/XAUtils.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
index 24850a7..4ff308f 100644
--- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
+++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
@@ -707,5 +707,15 @@ define(function(require) {
});
$.fn.editabletypes.policyConditions = PolicyConditions;
};
+ XAUtils.capitaliseFirstLetter = function (string){
+ return string.charAt(0).toUpperCase() + string.slice(1);
+ };
+ XAUtils.getServicePoliciesURL = function(serviceId) {
+ return "service/plugins/policies/service/"+serviceId;
+ };
+ XAUtils.getRangerServiceDef = function(name) {
+ return "service/plugins/definitions/name/"+name;
+ };
+
return XAUtils;
});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/security-admin/src/main/webapp/scripts/views/policies/GroupPermList.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policies/GroupPermList.js b/security-admin/src/main/webapp/scripts/views/policies/GroupPermList.js
deleted file mode 100644
index 3fe0a6e..0000000
--- a/security-admin/src/main/webapp/scripts/views/policies/GroupPermList.js
+++ /dev/null
@@ -1,476 +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 App = require('App');
- var XAEnums = require('utils/XAEnums');
- var XAUtil = require('utils/XAUtils');
- var localization = require('utils/XALangSupport');
- var VXGroup = require('models/VXGroup');
- require('bootstrap-editable');
-
- var FormInputItem = Backbone.Marionette.ItemView.extend({
- _msvName : 'FormInputItem',
- template : require('hbs!tmpl/policies/GroupPermItem'),
- tagName : 'tr',
- templateHelpers : function(){
-
- return {
- permissions : this.accessTypes,
- policyConditions: this.policyConditions,
- isModelNew : !this.model.has('editMode'),
- perms : this.permsIds.length == 14 ? _.union(this.permsIds,[-1]) : this.permsIds,
- };
- },
- ui : {
- selectGroups : '[data-js="selectGroups"]',
- selectUsers : '[data-js="selectUsers"]',
- addPerms : 'a[data-js="permissions"]',
- conditionsTags : '[class=tags1]',
- delegatedAdmin : 'input[data-js="delegatedAdmin"]'
- },
- events : {
- 'click [data-action="delete"]' : 'evDelete',
- 'click td' : 'evClickTD',
- 'change [data-js="selectGroups"]': 'evSelectGroup',
- 'change [data-js="selectUsers"]': 'evSelectUser',
- 'change input[class="policy-conditions"]' : 'policyCondtionChange'
- },
-
- initialize : function(options) {
- _.extend(this, _.pick(options, 'groupList','policyType','accessTypes','policyConditions','userList'));
- this.setupPermissionsAndConditions();
-
- },
-
- onRender : function() {
- this.setupFormForEditMode();
-
- this.createDropDown(this.ui.selectGroups, this.groupList, true);
- this.createDropDown(this.ui.selectUsers, this.userList, false);
- this.dropDownChange(this.ui.selectGroups);
- this.dropDownChange(this.ui.selectUsers);
-
- this.renderPerms();
- this.renderPolicyCondtion();
- },
- setupFormForEditMode : function() {
- this.accessItems = _.map(this.accessTypes, function(perm){
- if(!_.isUndefined(perm))
- return {'type':perm.label,isAllowed : false}
- });
- if(this.model.has('editMode') && this.model.get('editMode')){
- if(!_.isUndefined(this.model.get('groupName')) && !_.isNull(this.model.get('groupName'))){
- this.ui.selectGroups.val(this.model.get('groupName').split(','));
- }
- if(!_.isUndefined(this.model.get('userName')) && !_.isNull(this.model.get('userName'))){
- this.ui.selectUsers.val(this.model.get('userName').split(','));
- }
-
- if(!_.isUndefined(this.model.get('conditions'))){
- _.each(this.model.get('conditions'), function(obj){
- this.$el.find('input[data-js="'+obj.type+'"]').val(obj.value.toString())
- },this);
- }
- _.each(this.model.get('accesses'), function(p){
- if(p.isAllowed){
- this.$el.find('input[data-name="' + p.type + '"]').attr('checked', 'checked');
- _.each(this.accessItems,function(obj){ if(obj.type == p.type) obj.isAllowed=true;})
- }
- },this);
-
- if(!_.isUndefined(this.model.get('delegateAdmin')) && this.model.get('delegateAdmin')){
- this.ui.delegatedAdmin.attr('checked', 'checked');
- }
- }
- },
- setupPermissionsAndConditions : function() {
- var that = this;
- this.permsIds = [], this.conditions = {};
- //Set Permissions obj
- if( this.model.has('editMode') && this.model.get('editMode')){
- _.each(this.model.get('accesses'), function(p){
- if(p.isAllowed){
- var access = _.find(that.accessTypes,function(obj){if(obj.label == p.type) return obj});
- this.permsIds.push(access.name);
- }
-
- }, this);
- //Set PolicyCondtion Obj to show in edit mode
- _.each(this.model.get('conditions'), function(p){
- this.conditions[p.type] = p.value;
- }, this);
- }
- },
- dropDownChange : function($select){
- var that = this;
- $select.on('change',function(e){
- // console.log(e.currentTarget.value);
- var name = ($(e.currentTarget).attr('data-js') == that.ui.selectGroups.attr('data-js')) ? 'group': 'user';
- that.checkDirtyFieldForDropDown(e);
-
- that.toggleAddButton(e);
- if(e.removed != undefined){
- var gNameArr = [];
- if(that.model.get(name+'Name') != undefined)
- gNameArr = _.without(that.model.get(name+'Name').split(','), e.removed.text);
- if(!_.isEmpty(gNameArr)){
- that.model.set(name+'Name',gNameArr.join(','));
- }else{
- that.model.unset(name+'Name');
- }
- return;
- }
- if(!_.isUndefined(e.added)){
- var nameList = _.map($(e.currentTarget).select2("data"), function(obj){return obj.text});
- that.model.set(name+'Name',nameList.toString());
- }
- });
- },
- createDropDown :function($select, list, typeGroup){
- var that = this;
- var placeholder = (typeGroup) ? 'Select Group' : 'Select User';
- var url = (typeGroup) ? "service/xusers/groups" : "service/xusers/users";
- if(this.model.has('editMode') && !_.isEmpty($select.val())){
- var temp = $select.val().split(",");
- _.each(temp , function(name){
- if(_.isUndefined(list.where({ name : name}))){
- var model;
- model = typeGroup ? new VXGroup({name: name}) : new VXUser({name: name});
- model.fetch({async:false}).done(function(){
- list.add(model);
- });
- }
- });
- }
- var tags = list.map(function(m){
- return { id : m.id+"" , text : m.get('name')};
- });
- $select.select2({
- closeOnSelect : true,
- placeholder : placeholder,
- // maximumSelectionSize : 1,
- width :'220px',
- tokenSeparators: [",", " "],
- tags : tags,
- initSelection : function (element, callback) {
- var data = [];
- console.log(list);
-
- $(element.val().split(",")).each(function () {
- var obj = _.findWhere(tags,{text:this});
- data.push({id: obj.id, 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: url,
- dataType: 'json',
- data: function (term, page) {
- return {name : term};
- },
- results: function (data, page) {
- var results = [] , selectedVals = [];
- /*if(!_.isEmpty(that.ui.selectGroups.select2('val')))
- selectedVals = that.ui.selectGroups.select2('val');*/
- selectedVals = that.getGroupSelectdValues($select, typeGroup);
- if(data.resultSize != "0"){
- //if(data.vXGroups.length > 1){
- if(typeGroup)
- results = data.vXGroups.map(function(m, i){ return {id : m.id+"", text: m.name}; });
- else
- results = data.vXUsers.map(function(m, i){ return {id : m.id+"", text: m.name}; });
- if(!_.isEmpty(selectedVals))
- results = XAUtil.filterResultByText(results, selectedVals);
- // console.log(results.length);
- return {results : results};
- //}
- // results = [{id : data.vXGroups.id+"", text: data.vXGroups.name}];
- // return {results : results};
- }
- return {results : results};
- }
- },
- formatResult : function(result){
- return result.text;
- },
- formatSelection : function(result){
- return result.text;
- },
- formatNoMatches: function(result){
- return 'No group found.';
- }
- }).on('select2-focus', XAUtil.select2Focus);
- },
- renderPerms :function(){
- var that = this;
-// var permArr = _.pick(XAEnums.XAPermType, XAUtil.getStormActions(this.policyType));
- this.perms = _.map(this.accessTypes,function(m){return {text:m.label, value:m.name};});
- this.perms.push({'value' : -1, 'text' : 'Select/Deselect All'});
- this.ui.addPerms.editable({
- emptytext : 'Add Permissions',
- source: this.perms,
- value : this.permsIds,
- display: function(values,srcData) {
- if(_.isNull(values) || _.isEmpty(values)){
- $(this).empty();
- that.model.unset('accesses');
- return;
- }
- if(_.contains(values,"-1")){
- values = _.without(values,"-1")
- }
-// that.checkDirtyFieldForGroup(values);
- var permTypeArr = [];
- var valArr = _.map(values, function(id){
- if(!_.isUndefined(id)){
- var obj = _.findWhere(srcData,{'value' : id});
- permTypeArr.push({permType : obj.value});
- return "<span class='label label-inverse'>" + obj.text + "</span>";
- }
- });
- var perms = []
- if(that.model.has('accesses')){
- perms = that.model.get('accesses');
- }
- _.each(that.accessTypes, function(obj) {
- if(_.contains(values, obj.name)){
- var type = obj.label
- _.each(that.accessItems, function(item){ if(item.type == type) item.isAllowed = true });
- }
- });
- // Save data to model
-
- if(!_.isEmpty(that.accessItems))
- that.model.set('accesses', that.accessItems);
-
- $(this).html(valArr.join(" "));
- },
- }).on('click', function(e) {
- e.stopPropagation();
- e.preventDefault();
- 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;
- if(this.policyConditions.length > 0){
- var tmpl = _.map(this.policyConditions,function(obj){
- return '<div class="editable-address margin-bottom-5"><label style="display:block !important;"><span>'+obj.label+' : </span></label><input type="text" name="'+obj.name+'" ></div>'
- });
- XAUtil.customXEditableForPolicyCond(tmpl.join(''));
- this.$('#policyConditions').editable({
- emptytext : 'Add Conditions',
- value : this.conditions,
- display: function(value) {
- var continue_ = false, i = 0;
- if(!value) {
- $(this).empty();
- return;
- } // End if
- _.each(value, function(val, name){ if(!_.isEmpty(val)) continue_ = true; });
- if(continue_){
- var html = _.map(value, function(val,name) {
- var label = (i%2 == 0) ? 'label label-inverse' : 'label';
- i++;
- return _.isEmpty(val) ? '' : '<span class="'+label+'">'+name+' : '+ val + '</span>';
- });
- var cond = _.map(value, function(val, name) {return {'type' : name, 'value' :val};});
- that.model.set('conditions', cond);
- $(this).html(html);
- }else{
- that.model.unset('conditions');
- $(this).empty();
- }
- } // End display option
- }); // End editable()
- }
- },
- getGroupSelectdValues : function($select, typeGroup){
- var vals = [],selectedVals = [];
- var name = typeGroup ? 'group' : 'user';
- this.collection.each(function(m){
- if(!_.isUndefined(m.get(name+'Name')) && !_.isNull(m.get(name+'Name'))){
- vals.push.apply(vals, m.get(name+'Name').split(','));
- }
- });
- if(!_.isEmpty($select.select2('val')))
- selectedVals = $select.select2('val');
- vals.push.apply(vals , selectedVals);
- vals = $.unique(vals);
- return vals;
- },
- evDelete : function(){
- var that = this;
- this.collection.remove(this.model);
- this.toggleAddButton();
- },
- evClickTD : function(e){
- var $el = $(e.currentTarget);
- //Set Delegated Admin value
- if(!_.isUndefined($el.find('input').data('js'))){
- this.model.set('delegateAdmin',$el.find('input').is(':checked'))
- return;
- }
- },
- checkDirtyFieldForCheckBox : function(perms){
- var permList = [];
- if(!_.isUndefined(this.model.get('_vPermList')))
- permList = _.map(this.model.attributes._vPermList,function(obj){return obj.permType;});
- perms = _.map(perms,function(obj){return obj.permType;});
- XAUtil.checkDirtyField(permList, perms, this.$el);
- },
- toggleAddButton : function(e){
- var temp = [];
- this.collection.each(function(m){
- if(!_.isUndefined(m.get('groupId'))){
- temp.push.apply(temp, m.get('groupId').split(','));
-
- }
- });
- if(!_.isUndefined(e)){
- if( !_.isUndefined(e.added) && ((temp.length + 1) == this.groupList.length))
- $('[data-action="addGroup"]').hide();
- if(!_.isUndefined(e.removed))
- $('[data-action="addGroup"]').show();
- }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() } ;
- var conditions = [];
- if(this.model.has('conditions')){
- conditions = this.model.get('conditions')
- }
- conditions.push(policyCond);
- this.model.set('conditions',conditions);
- }
-
- },
- checkDirtyFieldForDropDown : function(e){
- //that.model.has('groupId')
- var groupIdList =[];
- if(!_.isUndefined(this.model.get('groupId')))
- groupIdList = this.model.get('groupId').split(',');
- XAUtil.checkDirtyField(groupIdList, e.val, $(e.currentTarget));
- },
- });
-
-
-
- return Backbone.Marionette.CompositeView.extend({
- _msvName : 'FormInputItemList',
- template : require('hbs!tmpl/policies/GroupPermList'),
- //tagName : 'ul',
- //className : 'timeline-container',
- templateHelpers :function(){
- return {
- permHeaders : this.getPermHeaders()
- };
- },
- getItemView : function(item){
- if(!item){
- return;
- }
- return FormInputItem;
- },
- itemViewContainer : ".js-formInput",
- itemViewOptions : function() {
- return {
- 'collection' : this.collection,
- 'groupList' : this.groupList,
- 'userList' : this.userList,
- 'policyType' : this.policyType,
- 'accessTypes' : this.accessTypes,
- 'policyConditions' : this.rangerServiceDefModel.get('policyConditions')
- };
- },
- events : {
- 'click [data-action="addGroup"]' : 'addNew'
- },
- initialize : function(options) {
- _.extend(this, _.pick(options, 'groupList','policyType','accessTypes','rangerServiceDefModel','userList'));
- //this.hiveGroupPerm = _.has(options,'hiveGroupPerm') ? true : false;
- this.listenTo(this.groupList, 'sync', this.render, this);
- if(this.collection.length == 0)
- this.collection.add(new Backbone.Model());
- },
- onRender : function(){
- //console.log("onRender of ArtifactFormNoteList called");
- this.toggleAddButton();
- },
- addNew : function(){
- var that =this;
- if(this.groupList.length > this.collection.length){
- this.collection.add(new Backbone.Model());
- this.toggleAddButton();
- }
- },
- toggleAddButton : function(){
- var groupIds=[];
- this.collection.each(function(m){
- if(!_.isUndefined(m.get('groupId'))){
- var temp = m.get('groupId').split(',');
- groupIds.push.apply(groupIds,temp);
- }
- });
- if(groupIds.length == this.groupList.length)
- this.$('button[data-action="addGroup"]').hide();
- else
- this.$('button[data-action="addGroup"]').show();
- },
- getPermHeaders : function(){
- var permList = [];//_.map(this.accessTypes,function(type){ return type.label});
-
- permList.unshift(localization.tt('lbl.delegatedAdmin'));
- permList.unshift(localization.tt('lbl.permissions'));
- if(!_.isEmpty(this.rangerServiceDefModel.get('policyConditions'))){
- permList.unshift(localization.tt('h.policyCondition'));
- }
- permList.unshift(localization.tt('lbl.selectUser'));
- permList.unshift(localization.tt('lbl.selectGroup'));
- permList.push("");
- return permList;
- },
- });
-
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/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
new file mode 100644
index 0000000..a44305d
--- /dev/null
+++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js
@@ -0,0 +1,473 @@
+/*
+ * 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 App = require('App');
+ var XAEnums = require('utils/XAEnums');
+ var XAUtil = require('utils/XAUtils');
+ var localization = require('utils/XALangSupport');
+ var VXGroup = require('models/VXGroup');
+ var VXGroupList = require('collections/VXGroupList');
+ var VXUserList = require('collections/VXUserList');
+ require('bootstrap-editable');
+
+ var FormInputItem = Backbone.Marionette.ItemView.extend({
+ _msvName : 'FormInputItem',
+ template : require('hbs!tmpl/policies/PermissionItem'),
+ tagName : 'tr',
+ templateHelpers : function(){
+
+ return {
+ permissions : this.accessTypes,
+ policyConditions: this.policyConditions,
+ isModelNew : !this.model.has('editMode'),
+ perms : this.permsIds.length == 14 ? _.union(this.permsIds,[-1]) : this.permsIds,
+ };
+ },
+ ui : {
+ selectGroups : '[data-js="selectGroups"]',
+ selectUsers : '[data-js="selectUsers"]',
+ addPerms : 'a[data-js="permissions"]',
+ conditionsTags : '[class=tags1]',
+ delegatedAdmin : 'input[data-js="delegatedAdmin"]'
+ },
+ events : {
+ 'click [data-action="delete"]' : 'evDelete',
+ 'click td' : 'evClickTD',
+ 'change [data-js="selectGroups"]': 'evSelectGroup',
+ 'change [data-js="selectUsers"]': 'evSelectUser',
+ 'change input[class="policy-conditions"]' : 'policyCondtionChange'
+ },
+
+ initialize : function(options) {
+ _.extend(this, _.pick(options, 'groupList','policyType','accessTypes','policyConditions','userList'));
+ this.setupPermissionsAndConditions();
+
+ },
+
+ onRender : function() {
+ //To setup permissions for edit mode
+ this.setupFormForEditMode();
+ //create select2 dropdown for groups and users
+ 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
+ this.renderPerms();
+ this.renderPolicyCondtion();
+ },
+ setupFormForEditMode : function() {
+ this.accessItems = _.map(this.accessTypes, function(perm){
+ if(!_.isUndefined(perm))
+ return {'type':perm.label,isAllowed : false}
+ });
+ if(this.model.has('editMode') && this.model.get('editMode')){
+ if(!_.isUndefined(this.model.get('groupName')) && !_.isNull(this.model.get('groupName'))){
+ this.ui.selectGroups.val(this.model.get('groupName').split(','));
+ }
+ if(!_.isUndefined(this.model.get('userName')) && !_.isNull(this.model.get('userName'))){
+ this.ui.selectUsers.val(this.model.get('userName').split(','));
+ }
+
+ if(!_.isUndefined(this.model.get('conditions'))){
+ _.each(this.model.get('conditions'), function(obj){
+ this.$el.find('input[data-js="'+obj.type+'"]').val(obj.value.toString())
+ },this);
+ }
+ _.each(this.model.get('accesses'), function(p){
+ if(p.isAllowed){
+ this.$el.find('input[data-name="' + p.type + '"]').attr('checked', 'checked');
+ _.each(this.accessItems,function(obj){ if(obj.type == p.type) obj.isAllowed=true;})
+ }
+ },this);
+
+ if(!_.isUndefined(this.model.get('delegateAdmin')) && this.model.get('delegateAdmin')){
+ this.ui.delegatedAdmin.attr('checked', 'checked');
+ }
+ }
+ },
+ setupPermissionsAndConditions : function() {
+ var that = this;
+ this.permsIds = [], this.conditions = {};
+ //Set Permissions obj
+ if( this.model.has('editMode') && this.model.get('editMode')){
+ _.each(this.model.get('accesses'), function(p){
+ if(p.isAllowed){
+ var access = _.find(that.accessTypes,function(obj){if(obj.label == p.type) return obj});
+ this.permsIds.push(access.name);
+ }
+
+ }, this);
+ //Set PolicyCondtion Obj to show in edit mode
+ _.each(this.model.get('conditions'), function(p){
+ this.conditions[p.type] = p.value;
+ }, this);
+ }
+ },
+ dropDownChange : function($select){
+ var that = this;
+ $select.on('change',function(e){
+ // console.log(e.currentTarget.value);
+ var name = ($(e.currentTarget).attr('data-js') == that.ui.selectGroups.attr('data-js')) ? 'group': 'user';
+ that.checkDirtyFieldForDropDown(e);
+
+ that.toggleAddButton(e);
+ if(e.removed != undefined){
+ var gNameArr = [];
+ if(that.model.get(name+'Name') != undefined)
+ gNameArr = _.without(that.model.get(name+'Name').split(','), e.removed.text);
+ if(!_.isEmpty(gNameArr)){
+ that.model.set(name+'Name',gNameArr.join(','));
+ }else{
+ that.model.unset(name+'Name');
+ }
+ return;
+ }
+ if(!_.isUndefined(e.added)){
+ var nameList = _.map($(e.currentTarget).select2("data"), function(obj){return obj.text});
+ that.model.set(name+'Name',nameList.toString());
+ }
+ });
+ },
+ createDropDown :function($select, list, typeGroup){
+ var that = this;
+ var placeholder = (typeGroup) ? 'Select Group' : 'Select User';
+ var url = (typeGroup) ? "service/xusers/groups" : "service/xusers/users";
+ if(this.model.has('editMode') && !_.isEmpty($select.val())){
+ var temp = $select.val().split(",");
+ _.each(temp , function(name){
+ if(_.isEmpty(list.where({ 'name' : name}))){
+ var coll;
+ coll = typeGroup ? new VXGroupList() : new VXUserList();
+ coll.queryParams['name'] = name;
+ coll.fetch({async:false}).done(function(){
+ list.add(coll.models);
+ });
+ }
+ });
+ }
+ var tags = list.map(function(m){
+ return { id : m.id+"" , text : m.get('name')};
+ });
+ $select.select2({
+ closeOnSelect : true,
+ placeholder : placeholder,
+ // maximumSelectionSize : 1,
+ width :'220px',
+ tokenSeparators: [",", " "],
+ tags : tags,
+ initSelection : function (element, callback) {
+ var data = [];
+ console.log(list);
+
+ $(element.val().split(",")).each(function () {
+ var obj = _.findWhere(tags,{text:this});
+ data.push({id: obj.id, text: this})
+ });
+ callback(data);
+ },
+ ajax: {
+ url: url,
+ dataType: 'json',
+ data: function (term, page) {
+ return {name : term};
+ },
+ results: function (data, page) {
+ var results = [] , selectedVals = [];
+ //Get selected values of groups/users dropdown
+ selectedVals = that.getSelectdValues($select, typeGroup);
+ if(data.resultSize != "0"){
+ if(typeGroup)
+ results = data.vXGroups.map(function(m, i){ return {id : m.id+"", text: m.name}; });
+ else
+ results = data.vXUsers.map(function(m, i){ return {id : m.id+"", text: m.name}; });
+ if(!_.isEmpty(selectedVals))
+ results = XAUtil.filterResultByText(results, selectedVals);
+ return {results : results};
+ }
+ return {results : results};
+ }
+ },
+ formatResult : function(result){
+ return result.text;
+ },
+ formatSelection : function(result){
+ return result.text;
+ },
+ formatNoMatches: function(result){
+ return 'No group found.';
+ }
+ }).on('select2-focus', XAUtil.select2Focus);
+ },
+ renderPerms :function(){
+ var that = this;
+ this.perms = _.map(this.accessTypes,function(m){return {text:m.label, value:m.name};});
+ this.perms.push({'value' : -1, 'text' : 'Select/Deselect All'});
+ //create x-editable for permissions
+ this.ui.addPerms.editable({
+ emptytext : 'Add Permissions',
+ source: this.perms,
+ value : this.permsIds,
+ display: function(values,srcData) {
+ if(_.isNull(values) || _.isEmpty(values)){
+ $(this).empty();
+ that.model.unset('accesses');
+ return;
+ }
+ if(_.contains(values,"-1")){
+ values = _.without(values,"-1")
+ }
+// that.checkDirtyFieldForGroup(values);
+ var permTypeArr = [];
+ var valArr = _.map(values, function(id){
+ if(!_.isUndefined(id)){
+ var obj = _.findWhere(srcData,{'value' : id});
+ permTypeArr.push({permType : obj.value});
+ return "<span class='label label-inverse'>" + obj.text + "</span>";
+ }
+ });
+ var perms = []
+ if(that.model.has('accesses')){
+ perms = that.model.get('accesses');
+ }
+ //reset isAllowed flag in accesssItems to set newly isAllowed
+ _.each(that.accessItems, function(item){ item.isAllowed = false });
+
+ _.each(that.accessTypes, function(obj) {
+ if(_.contains(values, obj.name)){
+ var type = obj.label
+ _.each(that.accessItems, function(item){ if(item.type == type) item.isAllowed = true });
+ }
+ });
+ // Save form data to model
+
+ if(!_.isEmpty(that.accessItems))
+ that.model.set('accesses', that.accessItems);
+
+ $(this).html(valArr.join(" "));
+ },
+ }).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);
+
+ });
+
+ });
+
+ },
+ renderPolicyCondtion : function() {
+ var that = this;
+
+ if(this.policyConditions.length > 0){
+ var tmpl = _.map(this.policyConditions,function(obj){
+ return '<div class="editable-address margin-bottom-5"><label style="display:block !important;"><span>'+obj.label+' : </span></label><input type="text" name="'+obj.name+'" ></div>'
+ });
+ //Create new bootstrap x-editable `policyConditions` dataType for policy conditions
+ XAUtil.customXEditableForPolicyCond(tmpl.join(''));
+ //create x-editable for policy conditions
+ this.$('#policyConditions').editable({
+ emptytext : 'Add Conditions',
+ value : this.conditions,
+ display: function(value) {
+ var continue_ = false, i = 0;
+ if(!value) {
+ $(this).empty();
+ return;
+ }
+ _.each(value, function(val, name){ if(!_.isEmpty(val)) continue_ = true; });
+ if(continue_){
+ var html = _.map(value, function(val,name) {
+ var label = (i%2 == 0) ? 'label label-inverse' : 'label';
+ i++;
+ return _.isEmpty(val) ? '' : '<span class="'+label+'">'+name+' : '+ val + '</span>';
+ });
+ var cond = _.map(value, function(val, name) {return {'type' : name, 'value' :val};});
+ that.model.set('conditions', cond);
+ $(this).html(html);
+ }else{
+ that.model.unset('conditions');
+ $(this).empty();
+ }
+ }
+ });
+ }
+ },
+ getSelectdValues : function($select, typeGroup){
+ var vals = [],selectedVals = [];
+ var name = typeGroup ? 'group' : 'user';
+ this.collection.each(function(m){
+ if(!_.isUndefined(m.get(name+'Name')) && !_.isNull(m.get(name+'Name'))){
+ vals.push.apply(vals, m.get(name+'Name').split(','));
+ }
+ });
+ if(!_.isEmpty($select.select2('val')))
+ selectedVals = $select.select2('val');
+ vals.push.apply(vals , selectedVals);
+ vals = $.unique(vals);
+ return vals;
+ },
+ evDelete : function(){
+ var that = this;
+ this.collection.remove(this.model);
+ this.toggleAddButton();
+ },
+ evClickTD : function(e){
+ var $el = $(e.currentTarget);
+ //Set Delegated Admin value
+ if(!_.isUndefined($el.find('input').data('js'))){
+ this.model.set('delegateAdmin',$el.find('input').is(':checked'))
+ return;
+ }
+ },
+ checkDirtyFieldForCheckBox : function(perms){
+ var permList = [];
+ if(!_.isUndefined(this.model.get('_vPermList')))
+ permList = _.map(this.model.attributes._vPermList,function(obj){return obj.permType;});
+ perms = _.map(perms,function(obj){return obj.permType;});
+ XAUtil.checkDirtyField(permList, perms, this.$el);
+ },
+ toggleAddButton : function(e){
+ var temp = [];
+ this.collection.each(function(m){
+ if(!_.isUndefined(m.get('groupId'))){
+ temp.push.apply(temp, m.get('groupId').split(','));
+ }
+ });
+ if(!_.isUndefined(e)){
+ if( !_.isUndefined(e.added) && ((temp.length + 1) == this.groupList.length))
+ $('[data-action="addGroup"]').hide();
+ if(!_.isUndefined(e.removed))
+ $('[data-action="addGroup"]').show();
+ }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() } ;
+ var conditions = [];
+ if(this.model.has('conditions')){
+ conditions = this.model.get('conditions')
+ }
+ conditions.push(policyCond);
+ this.model.set('conditions',conditions);
+ }
+
+ },
+ checkDirtyFieldForDropDown : function(e){
+ //that.model.has('groupId')
+ var groupIdList =[];
+ if(!_.isUndefined(this.model.get('groupId')))
+ groupIdList = this.model.get('groupId').split(',');
+ XAUtil.checkDirtyField(groupIdList, e.val, $(e.currentTarget));
+ },
+ });
+
+
+
+ return Backbone.Marionette.CompositeView.extend({
+ _msvName : 'FormInputItemList',
+ template : require('hbs!tmpl/policies/PermissionList'),
+ templateHelpers :function(){
+ return {
+ permHeaders : this.getPermHeaders()
+ };
+ },
+ getItemView : function(item){
+ if(!item){
+ return;
+ }
+ return FormInputItem;
+ },
+ itemViewContainer : ".js-formInput",
+ itemViewOptions : function() {
+ return {
+ 'collection' : this.collection,
+ 'groupList' : this.groupList,
+ 'userList' : this.userList,
+ 'policyType' : this.policyType,
+ 'accessTypes' : this.accessTypes,
+ 'policyConditions' : this.rangerServiceDefModel.get('policyConditions')
+ };
+ },
+ events : {
+ 'click [data-action="addGroup"]' : 'addNew'
+ },
+ initialize : function(options) {
+ _.extend(this, _.pick(options, 'groupList','policyType','accessTypes','rangerServiceDefModel','userList'));
+ this.listenTo(this.groupList, 'sync', this.render, this);
+ if(this.collection.length == 0)
+ this.collection.add(new Backbone.Model());
+ },
+ onRender : function(){
+ this.toggleAddButton();
+ },
+ addNew : function(){
+ var that =this;
+ if(this.groupList.length > this.collection.length){
+ this.collection.add(new Backbone.Model());
+ this.toggleAddButton();
+ }
+ },
+ toggleAddButton : function(){
+ var groupIds=[];
+ this.collection.each(function(m){
+ if(!_.isUndefined(m.get('groupId'))){
+ var temp = m.get('groupId').split(',');
+ groupIds.push.apply(groupIds,temp);
+ }
+ });
+ if(groupIds.length == this.groupList.length)
+ this.$('button[data-action="addGroup"]').hide();
+ else
+ this.$('button[data-action="addGroup"]').show();
+ },
+ getPermHeaders : function(){
+ var permList = [];
+ permList.unshift(localization.tt('lbl.delegatedAdmin'));
+ permList.unshift(localization.tt('lbl.permissions'));
+ if(!_.isEmpty(this.rangerServiceDefModel.get('policyConditions'))){
+ permList.unshift(localization.tt('h.policyCondition'));
+ }
+ permList.unshift(localization.tt('lbl.selectUser'));
+ permList.unshift(localization.tt('lbl.selectGroup'));
+ permList.push("");
+ return permList;
+ },
+ });
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/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 fa11698..1407614 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
@@ -32,16 +32,16 @@ define(function(require){
var XALinks = require('modules/XALinks');
var localization = require('utils/XALangSupport');
- var PolicycreateTmpl = require('hbs!tmpl/hdfs/PolicyCreate_tmpl');
+ var RangerPolicycreateTmpl = require('hbs!tmpl/policies/RangerPolicyCreate_tmpl');
var RangerPolicyForm = require('views/policies/RangerPolicyForm');
var RangerServiceDef = require('models/RangerServiceDef');
- var PolicyCreate = Backbone.Marionette.Layout.extend(
- /** @lends PolicyCreate */
+ var RangerPolicyCreate = Backbone.Marionette.Layout.extend(
+ /** @lends RangerPolicyCreate */
{
- _viewName : 'PolicyCreate',
+ _viewName : 'RangerPolicyCreate',
- template: PolicycreateTmpl,
+ template : RangerPolicycreateTmpl,
templateHelpers : function(){
return {
editPolicy : this.editPolicy
@@ -53,7 +53,6 @@ define(function(require){
return [XALinks.get('RepositoryManager'),XALinks.get('ManagePolicies',{model : this.rangerService}),XALinks.get('PolicyCreate')];
else
return [XALinks.get('RepositoryManager'),XALinks.get('ManagePolicies',{model : this.rangerService}),XALinks.get('PolicyEdit')];
-// return [];
} ,
/** Layout sub regions */
@@ -80,12 +79,12 @@ define(function(require){
},
/**
- * intialize a new PolicyCreate Layout
+ * intialize a new RangerPolicyCreate Layout
* @constructs
*/
initialize: function(options) {
var that = this;
- console.log("initialized a PolicyCreate Layout");
+ console.log("initialized a RangerPolicyCreate Layout");
_.extend(this, _.pick(options, 'rangerService'));
this.initializeServiceDef();
@@ -103,7 +102,7 @@ define(function(require){
initializeServiceDef : function(){
this.rangerServiceDefModel = new RangerServiceDef();
- this.rangerServiceDefModel.url = "service/plugins/definitions/name/"+this.rangerService.get('type');
+ this.rangerServiceDefModel.url = XAUtil.getRangerServiceDef(this.rangerService.get('type'));
this.rangerServiceDefModel.fetch({
cache : false,
async : false
@@ -118,26 +117,8 @@ define(function(require){
/** 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 that = this, valid = false;
var errors = this.form.commit({validate : false});
@@ -145,52 +126,6 @@ define(function(require){
return;
}
this.savePolicy();
- /*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;
@@ -200,7 +135,6 @@ define(function(require){
saveMethod : function(){
var that = this;
XAUtil.blockUI();
- this.model.url = "service/plugins/policies";
this.model.save({},{
wait: true,
success: function () {
@@ -212,99 +146,16 @@ define(function(require){
App.appRouter.navigate("#!/service/"+that.rangerService.id+"/policies",{trigger: true});
return;
}
-
App.appRouter.navigate("#!/service/"+that.rangerService.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("#!/service/"+this.rangerService.id+"/policies",{trigger: true});
@@ -317,5 +168,5 @@ define(function(require){
});
- return PolicyCreate;
+ return RangerPolicyCreate;
});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/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 7d35d01..532ed67 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
@@ -33,8 +33,7 @@ define(function(require){
var VXGroupList = require('collections/VXGroupList');
var VXAuditMapList = require('collections/VXAuditMapList');
var VXUserList = require('collections/VXUserList');
- var GroupPermList = require('views/policies/GroupPermList');
- var UserPermList = require('views/policies/UserPermList');
+ var PermissionList = require('views/policies/PermissionList');
var RangerPolicyResource = require('models/RangerPolicyResource');
var BackboneFormDataType = require('models/BackboneFormDataType');
@@ -45,17 +44,17 @@ define(function(require){
require('jquery-ui');
require('tag-it');
- var PolicyForm = Backbone.Form.extend(
- /** @lends PolicyForm */
+ var RangerPolicyForm = Backbone.Form.extend(
+ /** @lends RangerPolicyForm */
{
- _viewName : 'PolicyForm',
+ _viewName : 'RangerPolicyForm',
/**
- * intialize a new PolicyForm Form View
+ * intialize a new RangerPolicyForm Form View
* @constructs
*/
initialize: function(options) {
- console.log("initialized a PolicyForm Form View");
+ console.log("initialized a RangerPolicyForm Form View");
_.extend(this, _.pick(options, 'rangerServiceDefModel', 'rangerService'));
this.setupForm()
Backbone.Form.prototype.initialize.call(this, options);
@@ -63,19 +62,8 @@ define(function(require){
this.initializeCollection();
this.bindEvents();
},
- type : {
- DATABASE : 1,
- TABLE : 2,
- COLUMN : 3,
- VIEW : 4,
- UDF : 5
- },
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.formInputList = XAUtil.makeCollForGroupPermission(this.model);
-
},
/** all events binding here */
bindEvents : function(){
@@ -94,13 +82,17 @@ define(function(require){
*/
fields: ['name', 'description', 'isEnabled', 'isAuditEnabled'],
schema :function(){
+ return this.getSchema();
+ },
+ getSchema : function(){
var attrs = {};
- var that = this;
+ var schemaNames = this.rangerServiceDefModel.get('name') == "hdfs" ? ['description', 'isRecursive', 'isAuditEnabled'] : ['description', 'isAuditEnabled'];
+
var formDataType = new BackboneFormDataType();
attrs = formDataType.getFormElements(this.rangerServiceDefModel.get('resources'),this.rangerServiceDefModel.get('enums'), attrs, this);
-
+
var attr1 = _.pick(_.result(this.model,'schemaBase'), 'name','isEnabled');
- var attr2 = _.pick(_.result(this.model,'schemaBase'),'description', 'isRecursive', 'isAuditEnabled');
+ var attr2 = _.pick(_.result(this.model,'schemaBase'),schemaNames);
return _.extend(attr1,_.extend(attrs,attr2));
},
/** on render callback */
@@ -108,7 +100,7 @@ define(function(require){
var that = this;
Backbone.Form.prototype.render.call(this, options);
-
+ //initialize path plugin for hdfs component : resourcePath
if(!_.isUndefined(this.initilializePathPlugin) && this.initilializePathPlugin){
this.initializePathPlugins();
}
@@ -129,13 +121,18 @@ define(function(require){
},
setupForm : function() {
_.each(this.model.attributes.resources,function(obj,key){
- this.model.set(key, obj.values.toString())
+ this.model.set(key, obj.values.toString());
+ if(!_.isUndefined(obj.isRecursive))
+ this.model.set('isRecursive', obj.isRecursive);
+
},this)
},
setUpSwitches :function(){
var that = this;
this.fields.isAuditEnabled.editor.setValue(this.model.get('isAuditEnabled'));
this.fields.isEnabled.editor.setValue(this.model.get('isEnabled'));
+ if(!_.isUndefined(this.fields.isRecursive))
+ this.fields.isRecursive.editor.setValue(this.model.get('isRecursive'));
},
/** all custom field rendering */
renderCustomFields: function(){
@@ -155,12 +152,12 @@ define(function(require){
cache :true,
data : params
}).done(function(){
- that.$('[data-customfields="groupPerms"]').html(new GroupPermList({
+ that.$('[data-customfields="groupPerms"]').html(new PermissionList({
collection : that.formInputList,
groupList : that.groupList,
userList : that.userList,
- model : that.model,
- accessTypes : accessType,
+ model : that.model,
+ accessTypes: accessType,
rangerServiceDefModel : that.rangerServiceDefModel
}).render().el);
});
@@ -169,7 +166,7 @@ define(function(require){
beforeSave : function(){
var that = this, resources = [];
- this.model.set('service',this.rangerService.get('name'));
+
var resources = {};
_.each(this.rangerServiceDefModel.get('resources'),function(obj){
if(!_.isNull(obj)){
@@ -189,12 +186,13 @@ define(function(require){
var RangerPolicyItem = Backbone.Collection.extend();
var policyItemList = new RangerPolicyItem();
policyItemList = this.setPermissionsToColl(this.formInputList, policyItemList);
- this.model.set('policyItems', policyItemList)
- //Unset attrs which are not needed
+ this.model.set('policyItems', policyItemList)
+ this.model.set('service',this.rangerService.get('name'));
+ /*//Unset attrs which are not needed
_.each(this.model.attributes.resources,function(obj,key){
this.model.unset(key, obj.values.toString())
- },this)
+ },this)*/
},
setPermissionsToColl : function(list, policyItemList) {
@@ -321,25 +319,12 @@ define(function(require){
that.fields[that.pathFieldName].$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;
- }
- });*/
+
},
- getPlugginAttr :function(autocomplete, searchType){
+ getPlugginAttr :function(autocomplete, searchType, lookupURL){
var that =this;
var type = searchType;
if(!autocomplete)
@@ -349,7 +334,6 @@ define(function(require){
return {
closeOnSelect : true,
- //placeholder : 'Select User',
tags:true,
multiple: true,
minimumInputLength: 1,
@@ -372,24 +356,8 @@ define(function(require){
};
}
},
- /*query: function (query) {
- var url = "service/assets/hive/resources";
- var data = _.extend(that.getDataParams(type, query.term));
- //var results = [ {id: query.term, path: query.term}];
-
- $.get(url, data, function (resp) {
- var serverRes = [];
- if(resp.resultSize){
- serverRes = resp.vXStrings.map(function(m, i){ return {id : m.text, path: m.text}; });
- }
- query.callback({results: serverRes});
- }, 'json');
-
- //query.callback({results: results});
- },*/
-
ajax: {
- url: "service/assets/hive/resources",
+ url: lookupURL,
dataType: 'json',
params : {
timeout: 3000
@@ -417,13 +385,6 @@ define(function(require){
resultSize : 0
});
});
- /*$.ajax.error(function(data) {
- console.log("ajax failed");
- return {
- results : []
- };
- });*/
-
}
},
@@ -446,5 +407,5 @@ define(function(require){
},
});
- return PolicyForm;
+ return RangerPolicyForm;
});
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e551d589/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 74e393e..eec4484 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
@@ -39,10 +39,10 @@ define(function(require){
require('backgrid-paginator');
require('bootbox');
- var PolicyTableLayout = Backbone.Marionette.Layout.extend(
- /** @lends PolicyTableLayout */
+ var RangerPolicyTableLayout = Backbone.Marionette.Layout.extend(
+ /** @lends RangerPolicyTableLayout */
{
- _viewName : 'PolicyTableLayout',
+ _viewName : 'RangerPolicyTableLayout',
template: RangerPolicyTableLayoutTmpl,
@@ -79,7 +79,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';
@@ -87,11 +87,11 @@ define(function(require){
},
/**
- * intialize a new PolicyTableLayout Layout
+ * intialize a new RangerPolicyTableLayout Layout
* @constructs
*/
initialize: function(options) {
- console.log("initialized a PolicyTableLayout Layout");
+ console.log("initialized a RangerPolicyTableLayout Layout");
_.extend(this, _.pick(options,'rangerService'));
@@ -157,40 +157,6 @@ define(function(require){
editable: false,
sortable : false
},
- /* database : {
- cell : "html",
- label : localization.tt("lbl.database"),
- editable: false,
- sortable : false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue,model) {
- rawValue = model.get('resources')
- var name=''
- _.each(rawValue, function(obj){
- if(!_.isUndefined(obj.values))
- name += obj.values.toString();
- });
- return name;
- }
- })
- },*/
- /* resources : {
- cell : "html",
- label : localization.tt("lbl.resourcePath"),
- editable: false,
- sortable : false,
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
- fromRaw: function (rawValue) {
- console.log(rawValue)
- var name=''
- _.each(rawValue, function(obj){
- if(!_.isUndefined(obj.values))
- name += obj.values.toString();
- });
- return name;
- }
- })
- },*/
isEnabled:{
label:localization.tt('lbl.status'),
cell :"html",
@@ -217,118 +183,12 @@ define(function(require){
drag : false,
sortable : false
},
- /*isRecursive:{
- label:localization.tt('lbl.includesAllPathsRecursively'),
- 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">YES</label>' : '<label class="label label">NO</label>';
- }
- }),
- click : false,
- drag : false,
- sortable : false
- },
- permMapList : {
- reName : 'groupName',
- cell : Backgrid.HtmlCell.extend({className: 'cellWidth-1'}),
- label : localization.tt("lbl.groups"),
- 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
- },
- isEncrypt:{
- label:localization.tt("lbl.encrypted"),
- cell :"Switch",
- editable:false,
- // canHeaderFilter : true,
- // headerFilterList :[{label : 'ON',value : 1},{label :'OFF' ,value:2}],
- 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 ;
- }
- });
- //You can use rawValue to custom your html, you can change this value using the name parameter.
- return status;
- }
- }),
- click : false,
- drag : false,
- onText : 'ON',
- offText : 'OFF',
- sortable : 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="#!/hdfs/'+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
-
- }
-*/
};
_.each(this.rangerServiceDefModel.get('resources'), function(obj){
if(!_.isUndefined(obj) && !_.isNull(obj))
cols[obj.name]={
cell : "html",
- label : obj.name,
+ label : XAUtil.capitaliseFirstLetter(obj.name),
editable: false,
sortable : false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
@@ -432,5 +292,5 @@ define(function(require){
});
- return PolicyTableLayout;
+ return RangerPolicyTableLayout;
});