Repository: incubator-ranger Updated Branches: refs/heads/master 0711abe23 -> a263431a5
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a263431a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionCreate.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionCreate.js b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionCreate.js new file mode 100644 index 0000000..8a9ff83 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionCreate.js @@ -0,0 +1,199 @@ +/* + * 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 XALinks = require('modules/XALinks'); + var XAUtil = require('utils/XAUtils'); + var XAEnums = require('utils/XAEnums'); + var localization = require('utils/XALangSupport'); + + var ModulePermissionForm = require('views/permissions/ModulePermissionForm'); + var ModulePermsTableLayout = require('views/permissions/ModulePermsTableLayout'); + var VXModuleDefList = require('collections/VXModuleDefList'); + var ModulePermissionCreateTmpl = require('hbs!tmpl/permissions/ModulePermissionCreate_tmpl'); + + var ModulePermissionCreate = Backbone.Marionette.Layout.extend( + /** @lends ModulePermissionCreate */ + { + _viewName : 'ModulePermissionCreate', + + template: ModulePermissionCreateTmpl, + breadCrumbs :function(){ + if(this.model.isNew()) + return [XALinks.get('ModulePermissions')]; + else + return [XALinks.get('ModulePermissions'),XALinks.get('ModulePermissionEdit',this.model)]; + }, + + /** Layout sub regions */ + regions: { + 'rForm' :'div[data-id="r_form"]' + }, + + /** ui selector cache */ + ui: { + 'tab' : '.nav-tabs', + 'btnSave' : '[data-id="save"]', + 'btnCancel' : '[data-id="cancel"]' + }, + + /** ui events hash */ + events: function() { + var events = {}; + events['click ' + this.ui.btnSave] = 'onSave'; + events['click ' + this.ui.btnCancel] = 'onCancel'; + + return events; + }, + + /** + * intialize a new ModulePermissionCreate Layout + * @constructs + */ + initialize: function(options) { + console.log("initialized a ModulePermissionCreate Layout"); + + _.extend(this, _.pick(options)); + this.editMode = this.model.has('id') ? true : false; + this.bindEvents(); + }, + + /** all events binding here */ + bindEvents : function(){ + }, + + /** on render callback */ + onRender: function() { + var that = this; + this.renderForm(); + this.rForm.$el.dirtyFields(); + XAUtil.preventNavigation(localization.tt('dialogMsg.preventNavUserForm'),this.rForm.$el); + }, + /** all post render plugin initialization */ + initializePlugins: function(){ + }, + renderForm : function(){ + var VXGroupList = require('collections/VXGroupList'); + var VXUserList = require('collections/VXUserList'); + var params = {sortBy : 'name'}; + this.userList = new VXUserList(); + this.userList.setPageSize(100,{fetch:true}); + this.userList.fetch({ + cache :false, + data: params, + async : false + }); + this.groupList = new VXGroupList(); + this.groupList.setPageSize(100,{fetch:true}); + this.groupList.fetch({ + cache :false, + data : params, + async : false + }); + var that = this; + this.form = new ModulePermissionForm({ + template : require('hbs!tmpl/permissions/ModulePermissionForm_tmpl'), + model : that.model, + groupList : that.groupList, + userList : that.userList + }); + this.rForm.show(this.form); + }, + onSave: function(){ + + var errors = this.form.commit({validate : false}); + if(! _.isEmpty(errors)){ + this.form.beforeSaveModulePermissions(); + } + this.saveModulePermissions(); + + }, + saveModulePermissions : function(){ + var that = this; + if(!this.form.beforeSaveModulePermissions()){ + return; + } + XAUtil.blockUI(); + this.model.save({},{ + success: function () { + XAUtil.blockUI('unblock'); + XAUtil.allowNavigation(); + var msg = that.editMode ? 'Module Permissions updated successfully' :'Module Permissions created successfully'; + XAUtil.notifySuccess('Success', msg); + if(that.editMode){ + App.appRouter.navigate("#!/permissions",{trigger: true}); + return; + } + App.appRouter.navigate("#!/permissions",{trigger: true}); + + var modulePermissionList = new VXModuleDefList(); + + modulePermissionList.fetch({ + cache:false + }).done(function(){ + var newColl = modulePermissionList; + modulePermissionList.getLastPage({ + cache : false, + success : function(collection, response, options){ + App.rContent.show(new UserTableLayout({ + collection : collection, + })); + newColl = collection; + } + }).done(function(){ + var model = newColl.get(that.model.id); + if(model){ + model.trigger("model:highlightBackgridRow"); + } + }); + + App.rContent.show(new UserTableLayout({ + collection : modulePermissionList + })); + }); + } , + error : function(model,resp){ + XAUtil.blockUI('unblock'); + console.log('error'); + if(!_.isUndefined(resp.responseJSON) && !_.isUndefined(resp.responseJSON.msgDesc)){ + XAUtil.notifyError('Error',resp.responseJSON.msgDesc); + }else + XAUtil.notifyError('Error', "Error occurred while creating/updating module permissions."); + + } + }); + }, + onCancel : function(){ + XAUtil.allowNavigation(); + App.appRouter.navigate("#!/permissions",{trigger: true}); + + }, + /** on close */ + onClose: function(){ + } + + }); + + return ModulePermissionCreate; +}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a263431a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionForm.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionForm.js b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionForm.js new file mode 100644 index 0000000..8984fb9 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionForm.js @@ -0,0 +1,274 @@ +/* + * 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 XALinks = require('modules/XALinks'); + 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'); + var VXModuleDef = require('models/VXModuleDef'); + var VXModuleDefList = require('collections/VXModuleDefList'); + var BackboneFormDataType = require('models/BackboneFormDataType'); + require('bootstrap-editable'); + require('backbone-forms'); + require('backbone-forms.list'); + require('backbone-forms.templates'); + require('backbone-forms.XAOverrides'); + + var ModulePermissionForm = Backbone.Form.extend({ + + _viewName : 'ModulePermissionForm', + template : require('hbs!tmpl/permissions/ModulePermissionForm_tmpl'), + templateHelpers :function(){ + return { + + }; + }, + templateData : function(){ + return { 'id' : this.model.id, 'permHeaders' : this.getPermHeaders() }; + }, + initialize : function(options) { + _.extend(this, _.pick(options, 'groupList','userList')); + if (!this.model.isNew()){ + this.setupFieldsforEditModule(); + } + Backbone.Form.prototype.initialize.call(this, options); + + }, + ui : { + /*selectGroups : 'div[data-fields="selectGroups"]', + selectUsers : 'div[data-fields="selectUsers"]',*/ + }, + events : { + }, + /** fields for the form + */ + fields: ['module', 'selectGroups','selectUsers','isAllowed'], + schema :function(){ + return this.getSchema(); + }, + getSchema : function(){ + var that = this; + return { + module : { + type : 'Text', + title : localization.tt("lbl.moduleName") +' *', + editorAttrs : {'readonly' :'readonly'}, + validation : {'required': true}, + }, + selectGroups : { + type : 'Select2Remote', + editorAttrs : {'placeholder' :'Select Group','tokenSeparators': [",", " "],multiple:true}, + pluginAttr: this.getPlugginAttr(true,{'lookupURL':"service/xusers/groups",'permList':that.model.get('groupPermList'),'idKey':'groupId','textKey':'groupName'}), + title : localization.tt('lbl.selectGroup')+' *' + }, + selectUsers : { + type : 'Select2Remote', + editorAttrs : {'placeholder' :'Select User','tokenSeparators': [",", " "],multiple:true}, + pluginAttr: this.getPlugginAttr(true,{'lookupURL':"service/users",'permList':that.model.get('userPermList'),'idKey':'userId','textKey':'userName'}), + title : localization.tt('lbl.selectUser')+' *', + }, + isAllowed : { + type : 'Checkbox', + editorAttrs : {'checked':'checked',disabled:true}, + title : 'Is Allowed ?' + }, + + } + }, + render: function(options) { + var that = this; + + Backbone.Form.prototype.render.call(this, options); + if(!this.model.isNew()){ + //this.setUpSwitches(); + } + + }, + setupFieldsforEditModule : function(){ + var groupsNVList=[],usersNVList =[]; + groupsNVList = _.map(this.model.get('groupPermList'),function(gPerm){ + return {'id': Number(gPerm.groupId), 'text':gPerm.groupName}; + }); + this.model.set('selectGroups', groupsNVList); + + usersNVList = _.map(this.model.get('userPermList'),function(uPerm){ + return {'id': Number(uPerm.userId), 'text':uPerm.userName}; + }); + this.model.set('selectUsers', usersNVList); + + }, + getPermHeaders : function(){ + var permList = []; + permList.unshift(localization.tt('lbl.allowAccess')); + permList.unshift(localization.tt('lbl.selectUser')); + permList.unshift(localization.tt('lbl.selectGroup')); + permList.push(""); + return permList; + }, + getPlugginAttr :function(autocomplete, options){ + var that = this; + if(!autocomplete) + return{tags : true,width :'220px',multiple: true,minimumInputLength: 1}; + else { + return { + closeOnSelect : true, + multiple: true, + minimumInputLength: 0, + tokenSeparators: [",", " "], + /*tags : modelDefaultTags,*/ + initSelection : function (element, callback) { + var data = []; + _.each(options.permList,function (elem) { + data.push({id: elem[options.idKey], text: elem[options.textKey]}); + }); + 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: options.lookupURL, + type : 'GET', + params : { + timeout: 3000, + contentType: "application/json; charset=utf-8", + }, + cache: false, + data: function (term, page) { + //To be checked + //return {name : term, isVisible : XAEnums.VisibilityStatus.STATUS_VISIBLE.value}; + return {loginId : term}; + }, + results: function (data, page) { + var results = []; + if(data.resultSize != "0"){ + if(!_.isUndefined(data.vXGroups)) + results = data.vXGroups.map(function(m, i){ return {id : m.id+"", text: m.name}; }); + else if(!_.isUndefined(data.vXPortalUsers)) + results = data.vXPortalUsers.map(function(m, i){ return {id : m.id+"", text: m.loginId}; }); + } + return { results : results}; + }, + transport: function (options) { + $.ajax(options).error(function() { + console.log("ajax failed"); + this.success({ + resultSize : 0 + }); + }); + } + }, + formatResult : function(result){ + return result.text; + }, + formatSelection : function(result){ + return result.text; + }, + formatNoMatches : function(term){ + switch (term){ + //case that.type.DATABASE :return localization.tt("msg.enterAlteastOneCharactere"); + //case that.type.TABLE :return localization.tt("msg.enterAlteastOneCharactere"); + //case that.type.COLUMN :return localization.tt("msg.enterAlteastOneCharactere"); + default : return "No Matches found"; + } + } + }; + } + }, + beforeSaveModulePermissions : function(){ + if(this.model.get('module') != ''){ + var groupValStr = this.fields.selectGroups.getValue(); + var userValStr = this.fields.selectUsers.getValue(); + this.compareAndUpdateObj(groupValStr,{'mode':'groups','permList':this.model.get('groupPermList'),'idKey':'groupId','textKey':'groupName'}); + this.compareAndUpdateObj(userValStr,{'mode':'users','permList':this.model.get('userPermList'),'idKey':'userId','textKey':'userName'}); + } + return true; + }, + compareAndUpdateObj: function(objValsStr,options){ + + var selectedVals = (!_.isNull(objValsStr)) ? objValsStr.toString().split(',') : []; + var selectedIdList=[]; + selectedVals = _.each(selectedVals, function(eachVal){ + //Ignoring any non existing Group Name + if(_.isNumber(parseInt(eachVal)) && !_.isNaN(parseInt(eachVal))){ + selectedIdList.push(Number(eachVal)); + } + }); + var modelPermList = options.permList; + var modelPerms = _.unique(_.pluck(options.permList, options.idKey)); + if(!_.isEmpty(selectedIdList)){ + //Look for equals + if(_.isEqual(selectedIdList,modelPerms)) { + //No changes in Selected Users + }else{ + + //look for new values - + //loop through each new element and check if it has any non matching ids + var diff = _.filter(selectedIdList, function(value){ return !_.contains(modelPerms, value); }); + var that = this; + if(!_.isEmpty(diff)){ + //push new elements to model groupPermList + _.each(diff, function(newEl){ + var newObj = {}; + newObj[options.idKey] = newEl; + newObj['moduleId'] = that.model.get('id'); + newObj['isAllowed'] = 1; + options.permList.push(newObj); + }); + } + //Look for removed users/groups + //loop through each model element and check new selected groups is missing from any original list of group ids + var updDiff = _.filter(modelPerms, function(value){ return !_.contains(selectedIdList, value); }); + if(!_.isEmpty(updDiff)){ + _.each(options.permList, function(origElem){ + if(_.contains(updDiff, origElem[options.idKey])) + origElem.isAllowed = 0; + }); + } + } + + }else{ + //Remove permissions from all objects which earlier had permission + _.each(options.permList, function(perm){ + perm.isAllowed = 0; + }); + } + + } + }); + return ModulePermissionForm; +}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a263431a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js new file mode 100644 index 0000000..8f39a98 --- /dev/null +++ b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js @@ -0,0 +1,245 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +define(function(require){ + 'use strict'; + + var Backbone = require('backbone'); + var XAEnums = require('utils/XAEnums'); + var XALinks = require('modules/XALinks'); + var XAGlobals = require('utils/XAGlobals'); + var SessionMgr = require('mgrs/SessionMgr'); + var XAUtil = require('utils/XAUtils'); + + var XABackgrid = require('views/common/XABackgrid'); + var XATableLayout = require('views/common/XATableLayout'); + var localization = require('utils/XALangSupport'); + var RangerServiceDef = require('models/RangerServiceDef'); + var UserPermission = require('models/UserPermission'); + var ModulePermsTableLayoutTmpl = require('hbs!tmpl/permissions/ModulePermsTableLayout_tmpl'); + + require('backgrid-filter'); + require('backgrid-paginator'); + require('bootbox'); + + var ModulePermsTableLayout = Backbone.Marionette.Layout.extend( + /** @lends ModulePermsTableLayout */ + { + _viewName : 'ModulePermsTableLayout', + + template: ModulePermsTableLayoutTmpl, + + templateHelpers : function(){ + return { + //rangerService:this.rangerService + }; + }, + + breadCrumbs : function(){ + return [XALinks.get('ModulePermissions')]; + }, + + /** Layout sub regions */ + regions: { + 'rTableList' : 'div[data-id="r_table"]', + }, + + // /** ui selector cache */ + ui: { + 'btnShowMore' : '[data-id="showMore"]', + 'btnShowLess' : '[data-id="showLess"]', + 'visualSearch' : '.visual_search' + }, + + /** ui events hash */ + events: function() { + var events = {}; + events['click ' + this.ui.btnShowMore] = 'onShowMore'; + events['click ' + this.ui.btnShowLess] = 'onShowLess'; + + return events; + }, + + /** + * intialize a new RangerPolicyTableLayout Layout + * @constructs + */ + initialize: function(options) { + console.log("initialized a ModulePermsTableLayout Layout"); + //_.extend(this, _.pick(options)); + this.bindEvents(); + }, + + /** all events binding here */ + bindEvents : function(){ + }, + /** on render callback */ + onRender: function() { + //this.initializePlugins(); + this.addVisualSearch(); + this.renderTable(); + }, + /** all post render plugin initialization */ + initializePlugins: function(){ + }, + renderTable : function(){ + var that = this; + this.rTableList.show(new XATableLayout({ + columns: this.getColumns(), + collection: this.collection, + includeFilter : false, + gridOpts : { + //row: TableRow, + header : XABackgrid, + emptyText : 'No permissions found!' + }, + })); + }, + + getColumns : function(){ + var that = this; + var cols = { + module : { + cell : "uri", + reName : 'module', + href: function(model){ + return '#!/permissions/'+model.id+'/edit'; + }, + label : localization.tt("lbl.permissions"), + editable: false, + sortable : false + }, + groupPermList : { + reName : 'groupPermList', + cell : Backgrid.HtmlCell.extend({className: 'cellWidth-1'}), + label : localization.tt("lbl.group"), + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function (rawValue, model) { + if(!_.isUndefined(rawValue)){ + return XAUtil.showGroupsOrUsers(rawValue,model,'groups'); + }else{ + return '--'; + } + } + }), + editable : false, + sortable : false + }, + //Hack for backgrid plugin doesn't allow to have same column name + userPermList : { + reName : 'userPermList', + cell : Backgrid.HtmlCell.extend({className: 'cellWidth-1'}), + label : localization.tt("lbl.users"), + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function (rawValue, model) { + if(!_.isUndefined(rawValue)) + return XAUtil.showGroupsOrUsers(rawValue, model, 'users'); + else + return '--'; + } + }), + editable : false, + sortable : false + }, + }; + cols['permissions'] = { + cell : "html", + label : localization.tt("lbl.action"), + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function (rawValue,model) { + return '<a href="#!/permissions/'+model.id+'/edit" class="btn btn-mini" title="Edit"><i class="icon-edit icon-large" /></a>'; + } + }), + editable: false, + sortable : false + + }; + return this.collection.constructor.getTableCols(cols, this.collection); + }, + onShowMore : function(e){ + var attrName = 'policy-groups-id'; + var id = $(e.currentTarget).attr(attrName); + if(_.isUndefined(id)){ + id = $(e.currentTarget).attr('policy-users-id'); + attrName = 'policy-users-id'; + } + var $td = $(e.currentTarget).parents('td'); + $td.find('['+attrName+'="'+id+'"]').show(); + $td.find('[data-id="showLess"]['+attrName+'="'+id+'"]').show(); + $td.find('[data-id="showMore"]['+attrName+'="'+id+'"]').hide(); + }, + onShowLess : function(e){ + var attrName = 'policy-groups-id'; + var id = $(e.currentTarget).attr(attrName); + if(_.isUndefined(id)){ + id = $(e.currentTarget).attr('policy-users-id'); + attrName = 'policy-users-id'; + } + var $td = $(e.currentTarget).parents('td'); + $td.find('['+attrName+'="'+id+'"]').slice(4).hide(); + $td.find('[data-id="showLess"]['+attrName+'="'+id+'"]').hide(); + $td.find('[data-id="showMore"]['+attrName+'="'+id+'"]').show(); + }, + addVisualSearch : function(){ + var that = this; + //var resourceSearchOpt = _.map(this.collection.models, function(resource){ return XAUtil.capitaliseFirstLetter(resource.module) }); + + var searchOpt = ['Module Name','Group Name','User Name']; + + var serverAttrName = [{text : "Module Name", label :"module"},{text : "Group Name", label :"groupName"},{text : "User Name", label :"userName"}]; + + var pluginAttr = { + placeholder :localization.tt('h.searchForPermissions'), + container : this.ui.visualSearch, + query : '', + callbacks : { + valueMatches :function(facet, searchTerm, callback) { + switch (facet) { + /*case 'Module Name': + callback(that.getActiveStatusNVList()); + break; + case 'Group Name': + callback(XAUtil.enumToSelectLabelValuePairs(XAEnums.AuthType)); + break; + case 'User Name' : + setTimeout(function () { XAUtil.displayDatepicker(that.ui.visualSearch, callback); }, 0); + break;*/ + } + + } + } + }; + window.vs = XAUtil.addVisualSearch(searchOpt,serverAttrName, this.collection,pluginAttr); + }, + getActiveStatusNVList : function() { + var activeStatusList = _.filter(XAEnums.ActiveStatus, function(obj){ + if(obj.label != XAEnums.ActiveStatus.STATUS_DELETED.label) + return obj; + }); + return _.map(activeStatusList, function(status) { return { 'label': status.label, 'value': status.label.toLowerCase()}; }) + }, + /** on close */ + onClose: function(){ + } + + }); + + return ModulePermsTableLayout; +}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a263431a/security-admin/src/main/webapp/styles/xa.css ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/styles/xa.css b/security-admin/src/main/webapp/styles/xa.css index 31e2a46..7deda0d 100644 --- a/security-admin/src/main/webapp/styles/xa.css +++ b/security-admin/src/main/webapp/styles/xa.css @@ -1822,4 +1822,7 @@ td.select-row-cell { .ranger-notifications { right: 33px!important; top: 41px!important; -} \ No newline at end of file +}table.table-permission.visible-border tr td:last-child { + border: 1px solid #dddddd; + padding-left: 0; +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a263431a/security-admin/src/main/webapp/templates/common/TopNav_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/common/TopNav_tmpl.html b/security-admin/src/main/webapp/templates/common/TopNav_tmpl.html index 7268074..2bbd349 100644 --- a/security-admin/src/main/webapp/templates/common/TopNav_tmpl.html +++ b/security-admin/src/main/webapp/templates/common/TopNav_tmpl.html @@ -19,21 +19,30 @@ <!-- <li class="active"> <a href="#" id="nav1"><i class="icon-dashboard"></i> {{tt 'h.dashboard'}} </a> </li> --> + {{#hasAccessToTab 'Policy Manager'}} <li > <a href="#!/policymanager" id="nav2"><i class="icon-shield"></i>{{tt 'h.policyManager'}} </a> </li> - {{#isSystemAdmin .}} + {{/hasAccessToTab}} + {{#hasAccessToTab 'Users/Groups'}} <li> <a href="#!/users/usertab" id="nav3"><i class="icon-group"></i> {{tt 'h.usersOrGroups'}} </a> </li> - {{/isSystemAdmin}} + {{/hasAccessToTab}} + {{#hasAccessToTab 'Analytics'}} <li> <a href="#!/reports/userAccess" id="nav7"><i class="icon-beaker"></i> {{tt 'h.analytics'}} </a> </li> - {{#isSystemAdmin .}} + {{/hasAccessToTab}} + {{#hasAccessToTab 'Audit'}} <li> <a href="#!/reports/audit/bigData" id="nav8"><i class=" icon-file-alt"></i> {{tt 'h.audit'}} </a> </li> + {{/hasAccessToTab}} + {{#isSystemAdmin .}} + <li> + <a href="#!/permissions" id="nav8"><i class=" icon-file-alt"></i> {{tt 'h.permissions'}} </a> + </li> {{/isSystemAdmin}} <!-- <li> http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a263431a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js b/security-admin/src/main/webapp/templates/helpers/XAHelpers.js index 537baa3..2058b25 100644 --- a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js +++ b/security-admin/src/main/webapp/templates/helpers/XAHelpers.js @@ -534,6 +534,17 @@ Handlebars.registerHelper('capitaliseLetter', function(str) { return str.toUpperCase(); }); + Handlebars.registerHelper('hasAccessToTab', function(tabName,options) { + var vxPortalUser = SessionMgr.getUserProfile(); + var userModules = _.pluck(vxPortalUser.get('userPermList'), 'moduleName'); + var groupModules = _.pluck(vxPortalUser.get('groupPermissions'), 'moduleName'); + var moduleNames = _.union(userModules,groupModules); + var returnFlag = _.contains(moduleNames, tabName); + if (returnFlag) + return options.fn(this); + else + return options.inverse(this); + }); return HHelpers; }); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a263431a/security-admin/src/main/webapp/templates/permissions/ModulePermissionCreate_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/permissions/ModulePermissionCreate_tmpl.html b/security-admin/src/main/webapp/templates/permissions/ModulePermissionCreate_tmpl.html new file mode 100644 index 0000000..2c9f4d9 --- /dev/null +++ b/security-admin/src/main/webapp/templates/permissions/ModulePermissionCreate_tmpl.html @@ -0,0 +1,28 @@ +{{!-- + 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. +--}} +<h3 class="wrap-header bold">Edit Permission</h3> +<div class="wrap non-collapsible"> +<div data-id="r_form"></div> + <div class="form-actions form-policy"> + <button type="button" data-id="save" class="btn btn-primary"> + Save + </button> + <button type="button" data-id="cancel" class="btn btn-inverse"> + Cancel + </button> + </div> +</div> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a263431a/security-admin/src/main/webapp/templates/permissions/ModulePermissionForm_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/permissions/ModulePermissionForm_tmpl.html b/security-admin/src/main/webapp/templates/permissions/ModulePermissionForm_tmpl.html new file mode 100644 index 0000000..badb615 --- /dev/null +++ b/security-admin/src/main/webapp/templates/permissions/ModulePermissionForm_tmpl.html @@ -0,0 +1,61 @@ +{{!-- + 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. +--}} +<form class="form-horizontal"> + <fieldset> + <p class="formHeader"> Policy Details : </p> + <div class="clearfix"></div> + <b class="policy-form"> + <fieldset> + <div class="control-group field-database"> + <!-- <div class="controls"> --> + <div class="" data-fields="module"></div> + <!-- </div> --> + </div> + </fieldset> + </b> + </fieldset> + <fieldset> + <p class="formHeader"> User and Group Permissions : </p> + <div class="control-group"> + <label class="control-label">{{tt 'lbl.permissions'}}</label> + <div class="controls"> + <table class="table-permission table-condensed visible-border"> + <thead> + <tr> + {{#each permHeaders}} + <th>{{./this}}</th> + {{/each}} + </tr> + </thead> + <tbody class="js-formInput"> + <tr> + <td> + <div data-editors="selectGroups"></div> + </td> + <td> + <div data-editors="selectUsers"></div> + </td> + <td> + <div data-editors="isAllowed"></div> + </td> + </tr> + </tbody> + </table> + </div> + </div> + </fieldset> +</form> http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/a263431a/security-admin/src/main/webapp/templates/permissions/ModulePermsTableLayout_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/permissions/ModulePermsTableLayout_tmpl.html b/security-admin/src/main/webapp/templates/permissions/ModulePermsTableLayout_tmpl.html new file mode 100644 index 0000000..52b36a1 --- /dev/null +++ b/security-admin/src/main/webapp/templates/permissions/ModulePermsTableLayout_tmpl.html @@ -0,0 +1,27 @@ +{{!-- + 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. +--}} +<h3 class="wrap-header bold"> {{tt 'lbl.permissions'}}</h3> +<div class="wrap non-collapsible m-height "> + <div> + <div class="span9"> + <div class="visual_search"></div><br/><br/> + + </div> + <div class="clearfix"></div> + <div data-id="r_table" class="clickable"></div> + </div> +</div>
