http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/common/UserPermissionList.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/common/UserPermissionList.js b/security-admin/src/main/webapp/scripts/views/common/UserPermissionList.js index fce1963..58da18c 100644 --- a/security-admin/src/main/webapp/scripts/views/common/UserPermissionList.js +++ b/security-admin/src/main/webapp/scripts/views/common/UserPermissionList.js @@ -23,12 +23,13 @@ define(function(require) { 'use strict'; - var Backbone = require('backbone'); - var App = require('App'); - var XAEnums = require('utils/XAEnums'); + 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'); + var VXUser = require('models/VXUser'); + require('bootstrap-editable'); var UserPermissionItem = Backbone.Marionette.ItemView.extend({ @@ -59,9 +60,10 @@ define(function(require) { initialize : function(options) { _.extend(this, _.pick(options, 'userList','policyType')); - //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) @@ -86,17 +88,19 @@ define(function(require) { this.$el.find('input[data-id="' + p.permType + '"]').attr('checked', 'checked'); },this); } - if(this.policyType == XAEnums.AssetType.ASSET_STORM.value) + 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'))) + + if(!_.isUndefined(this.model.get('userId'))){ userIdList = this.model.get('userId').split(','); + } XAUtil.checkDirtyField(userIdList, e.val, $(e.currentTarget)); }, toggleAddButton : function(e){ @@ -112,7 +116,7 @@ define(function(require) { $('[data-action="addUser"]').hide(); if(!_.isUndefined(e.removed)) $('[data-action="addUser"]').show(); - }else{ + } else { $('[data-action="addUser"]').show(); } }, @@ -123,6 +127,7 @@ define(function(require) { }, evClickTD : function(e){ 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); @@ -131,43 +136,26 @@ define(function(require) { if(!_.isUndefined(curPerm)){ var perms = []; if(this.model.has('_vPermList')){ - if(_.isArray(this.model.get('_vPermList'))) + if(_.isArray(this.model.get('_vPermList'))){ perms = this.model.get('_vPermList'); - else + } else { perms.push(this.model.get('_vPermList')); + } } - - /* permMapList = [ {id: 18, groupId : 1, permType :5}, {id: 18, groupId : 1, permType :4}, {id: 18, groupId : 2, permType :5} ] - [1] => [ {id: 18, groupId : 1, permType :5}, {id: 19, groupId : 1, permType :4} ] - [2] => [ {id: 20, groupId : 2, permType :5} ] - { groupId : 1, - _vPermList : [ { id: 18, permType : 5 }, { id: 19, permType : 4 } ] - } - this.model => { groupId : 2, - _vPermList : [ { id: 20, permType : 5 }, { permType : 6 } ] - } - - */ - -// perms = this.model.has('_vPermList') ? this.model.get('_vPermList'): []; - if($el.find('input[type="checkbox"]').is(':checked')){ perms.push({permType : curPerm}); + if(curPerm == XAEnums.XAPermType.XA_PERM_TYPE_ADMIN.value){ $el.parent().find('input[type="checkbox"]:not(:checked)[data-id!="'+curPerm+'"]').map(function(){ perms.push({ permType :$(this).data('id')}); - // return { permType :$(this).data('id')}; }); - // this.model.set('_vPermList', perms); $el.parent().find('input[type="checkbox"]').prop('checked',true); } } else { perms = _.reject(perms,function(el) { return el.permType == curPerm; }); - - //perms = _.without(perms, curPerm); - } + this.checkDirtyFieldForCheckBox(perms); if(!_.isEmpty(perms)){ this.model.set('_vPermList', perms); @@ -215,15 +203,6 @@ define(function(require) { 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", @@ -233,22 +212,14 @@ define(function(require) { }, 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)) + 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}; } @@ -268,19 +239,20 @@ define(function(require) { 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) + 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{ + } else { that.model.unset('userId'); that.model.unset('userName'); } @@ -288,34 +260,38 @@ define(function(require) { } if(!_.isUndefined(e.added)){ - that.model.set('userId', e.currentTarget.value); + that.model.set('userId', e.currentTarget.value); } }); }, 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'))) + if(!_.isEmpty(this.ui.selectUsers.select2('val'))){ selectedVals = this.ui.selectUsers.select2('val'); + } vals.push.apply(vals , selectedVals); vals = $.unique(vals); return vals; }, evIPAddress :function(e){ - if(!_.isEmpty($(e.currentTarget).val())) + if(!_.isEmpty($(e.currentTarget).val())){ this.model.set('ipAddress',$(e.currentTarget).val().split(',')); - else + } else { this.model.unset('ipAddress'); + } }, 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', @@ -325,9 +301,8 @@ define(function(require) { $(this).html(''); return; } - if(!_.isArray(idList)) - idList = [idList]; -// that.checkDirtyFieldForGroup(values); + if(!_.isArray(idList)) idList = [idList]; + var permTypeArr = []; var valArr = _.map(idList, function(id){ if(!(parseInt(id) <= 0) && (!_.isNaN(parseInt(id)))){ @@ -340,8 +315,8 @@ define(function(require) { 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); - + + that.model.set('_vPermList', permTypeArr); $(this).html(valArr.join(" ")); }, }); @@ -356,7 +331,6 @@ define(function(require) { }); }); }, - }); @@ -364,17 +338,14 @@ define(function(require) { return Backbone.Marionette.CompositeView.extend({ _msvName : 'UserPermissionList', template : require('hbs!tmpl/common/UserPermissionList'), - //tagName : 'ul', - //className : 'timeline-container', templateHelpers :function(){ + return { permHeaders : XAUtil.getPermHeaders(this.policyType,false) }; }, getItemView : function(item){ - if(!item){ - return; - } + if(!item){ return; } return UserPermissionItem; }, itemViewContainer : ".js-formInput", @@ -390,12 +361,10 @@ define(function(require) { }, initialize : function(options) { _.extend(this, _.pick(options, 'userList','policyType')); - //this.listenTo(this.collection, 'removeAddBtn', this.render, this); - /*if(options.model.isNew()) - this.collection.add(new Backbone.Model());*/ - if(this.collection.length == 0) + + if(this.collection.length == 0){ this.collection.add(new Backbone.Model()); - + } }, onRender : function(){ //console.log("onRender of ArtifactFormNoteList called"); @@ -414,12 +383,11 @@ define(function(require) { userIds.push.apply(userIds,temp); } }); - if(userIds.length == this.userList.length) + if(userIds.length == this.userList.length){ this.$('button[data-action="addUser"]').hide(); - else + } else { this.$('button[data-action="addUser"]').show(); + } } - }); - });
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/common/XABackgrid.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/common/XABackgrid.js b/security-admin/src/main/webapp/scripts/views/common/XABackgrid.js index d9cc832..6c95390 100644 --- a/security-admin/src/main/webapp/scripts/views/common/XABackgrid.js +++ b/security-admin/src/main/webapp/scripts/views/common/XABackgrid.js @@ -78,10 +78,7 @@ define(function(require){ var $clearButton = this.clearButton(); var searchTerms = this.searchBox().val(); - // if(e.which === XAGlobals.keys.ENTER_KEY ){ - if(!e.shiftKey) - this.search(); - // } + if(!e.shiftKey) this.search(); if (searchTerms) { $clearButton.show(); @@ -179,10 +176,7 @@ define(function(require){ var $clearButton = this.clearButton(); var searchTerms = this.searchBox().val(); - // if(e.which === XAGlobals.keys.ENTER_KEY ){ - if(!e.shiftKey) - this.search(); - // } + if(!e.shiftKey) this.search(); if (searchTerms) { $clearButton.show(); @@ -281,7 +275,6 @@ define(function(require){ this.$el.find('select').on('click',function(e){ that.search(e.currentTarget.value); }); - //this.delegateEvents(); return this; }, @@ -307,15 +300,7 @@ define(function(require){ collection.fetch({data: data, reset: true}); } - /*clear: function (e) { - if (e) e.preventDefault(); - this.searchBox().val(null); - this.collection.fetch({reset: true}); - }*/ - }); - - var HeaderRow = Backgrid.Row.extend({ @@ -391,6 +376,5 @@ define(function(require){ }); - return XAHeader; }); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js b/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js index 12bd6d7..ae81b86 100644 --- a/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/common/XATableLayout.js @@ -48,7 +48,7 @@ define(function(require){ 'rPagination' : 'div[data-id="r_pagination"]' }, - // /** ui selector cache */ + /** ui selector cache */ ui: {}, gridOpts : { @@ -122,11 +122,9 @@ define(function(require){ this.listenTo(this.collection, "sync reset", this.showHidePager); this.listenTo(this.collection, 'request', function(){ -// $(this.rTableSpinner.el).addClass('loading'); this.$el.find(this.rTableSpinner.el).addClass('loading'); },this); this.listenTo(this.collection, 'sync error', function(){ -// $(this.rTableSpinner.el).removeClass('loading'); this.$el.find(this.rTableSpinner.el).removeClass('loading'); },this); }, @@ -158,11 +156,6 @@ define(function(require){ renderTable : function(){ var that = this; this.rTableList.show(new Backgrid.Grid(this.gridOpts)); - - /*this.rTableSpinner.show(new Spinner({ - collection: this.collection - }));*/ - }, renderPagination : function(){ this.rPagination.show(new Backgrid.Extension.Paginator({ @@ -175,7 +168,6 @@ define(function(require){ showHidePager : function(){ if(this.collection.state && this.collection.state.totalRecords > XAGlobals.settings.PAGE_SIZE) { this.$el.find(this.rPagination.el).show() - //$(this.rPagination.el).show(); } else { this.$el.find(this.rPagination.el).hide(); } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/folders/FolderInfo.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/folders/FolderInfo.js b/security-admin/src/main/webapp/scripts/views/folders/FolderInfo.js deleted file mode 100644 index 18ef7e2..0000000 --- a/security-admin/src/main/webapp/scripts/views/folders/FolderInfo.js +++ /dev/null @@ -1,173 +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 Communicator = require('communicator'); - - var XAUtil = require('utils/XAUtils'); - var XAEnums = require('utils/XAEnums'); - var VXPermMapList = require('collections/VXPermMapList'); - var FolderInfo_tmpl = require('hbs!tmpl/folders/FolderInfo_tmpl'); - var KnoxInfo_tmpl = require('hbs!tmpl/knox/KnoxInfo_tmpl'); - - var FolderInfo = Backbone.Marionette.ItemView.extend( - /** @lends FolderInfo */ - { - _viewName : FolderInfo, - - template: FolderInfo_tmpl, - templateHelpers :function(){ - - var hiveModel = this.model.get('assetType') == XAEnums.AssetType.ASSET_HIVE.value ? true : false; - var hbaseModel = this.model.get('assetType') == XAEnums.AssetType.ASSET_HBASE.value ? true : false; - var hiveOrHbaseModel = hiveModel || hbaseModel; - return { - groupPermListArr: this.getGroupPermListArr(), - userPermListArr : this.getUserPermListArr(), - hdfsModel : this.model.get('assetType') == XAEnums.AssetType.ASSET_HDFS.value ? true : false, - hiveOrHbaseModel: hiveOrHbaseModel, - - }; - }, - /** ui selector cache */ - ui: {}, - - /** ui events hash */ - events: function() { - var events = {}; - //events['change ' + this.ui.input] = 'onInputChange'; - return events; - }, - - /** - * intialize a new FolderInfo ItemView - * @constructs - */ - initialize: function(options) { - console.log("initialized a FolderInfo ItemView"); - - _.extend(this, _.pick(options, '')); - //this.model.set('permMapList',new VXPermMapList(this.model.attributes.permMapList)) - this.bindEvents(); - this.getTemplateForView(); - }, - - /** all events binding here */ - bindEvents : function(){ - /*this.listenTo(this.model, "change:foo", this.modelChanged, this);*/ - /*this.listenTo(communicator.vent,'someView:someEvent', this.someEventHandler, this)'*/ - }, - - /** on render callback */ - onRender: function() { - this.initializePlugins(); - }, - - /** all post render plugin initialization */ - initializePlugins: function(){ - }, - getTemplateForView : function(){ - if(this.model.get('assetType') == XAEnums.AssetType.ASSET_KNOX.value){ - this.template = KnoxInfo_tmpl; - } - }, - getGroupPermListArr : function(){ - var groupList = []; - var perm=[],permListArr =[]; - if(!_.isUndefined(this.model.attributes.permMapList)){ - if(_.isArray(this.model.attributes.permMapList)){ - groupList = new VXPermMapList(this.model.attributes.permMapList); - groupList = groupList.groupBy('groupId'); - }else{ - groupList = this.model.attributes.permMapList.groupBy('groupId'); - } - - _.each(groupList,function(val,prop){ - var groups = groupList[prop]; - var permTypeArr =[],name ='',ipAddressArr =[]; - groups = _.sortBy(groups, function (m) {return m.get('permType');}); - _.each(groups,function(gprop){ - var permVal = _.pick(gprop.attributes,'permType').permType; - var label = XAUtil.enumValueToLabel(XAEnums.XAPermType,permVal); - permTypeArr.push(label); - name = _.pick(gprop.attributes,'groupName').groupName; - if(!_.isUndefined(gprop.get('ipAddress'))) - ipAddressArr.push(gprop.get('ipAddress')) - - }); - if(name != undefined){ - var ipAddress = _.uniq(ipAddressArr).toString(); - permListArr.push({ - name :name, - permType :permTypeArr.toString(), - ipAddress :_.isEmpty(ipAddress) ? "--" : ipAddress - }); - } - - }); - } - return permListArr; - }, - getUserPermListArr : function(){ - var userList = []; - var perm=[],permListArr =[]; - if(!_.isUndefined(this.model.attributes.permMapList)){ - if(_.isArray(this.model.attributes.permMapList)){ - userList = new VXPermMapList(this.model.attributes.permMapList); - userList = userList.groupBy('userId'); - }else{ - userList = this.model.attributes.permMapList.groupBy('userId'); - } - //var userList = this.model.attributes.permMapList.groupBy('userId'); - _.each(userList,function(val,prop){ - var users = userList[prop]; - users = _.sortBy(users, function (m) {return m.get('permType');}); - var permTypeArr =[],name ='', ipAddressArr =[]; - _.each(users,function(gprop){ - var permVal = _.pick(gprop.attributes,'permType').permType; - var label = XAUtil.enumValueToLabel(XAEnums.XAPermType,permVal); - permTypeArr.push(label); - name = _.pick(gprop.attributes,'userName').userName; - if(!_.isUndefined(gprop.get('ipAddress'))) - ipAddressArr.push(gprop.get('ipAddress')) - }); - if(name != undefined){ - var ipAddress = _.uniq(ipAddressArr).toString(); - permListArr.push({ name :name, - permType :permTypeArr.toString(), - ipAddress :_.isEmpty(ipAddress) ? "--" : ipAddress - }); - } - - }); - } - return permListArr; - }, - /** on close */ - onClose: function(){ - } - - }); - - return FolderInfo; -}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js b/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js index 52990dd..a5d0d82 100755 --- a/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js @@ -40,7 +40,6 @@ define(function(require){ template: KmsTablelayoutTmpl, templateHelpers : function(){ -// return { kmsServiceName : this.kmsServiceName }; }, breadCrumbs :[XALinks.get('KmsManage')], /** Layout sub regions */ @@ -78,10 +77,8 @@ define(function(require){ this.showKeyList = true; this.isKnownKmsServicePage = this.kmsManagePage == 'new' ? false : true; this.initializeKMSServices(); - if(this.isKnownKmsServicePage){ - this.getKeysForKmsService(); - } this.bindEvents(); + this.defaultsCollstate = this.collection.state; }, /** all events binding here */ @@ -99,16 +96,19 @@ define(function(require){ }); }, getKeysForKmsService : function() { + var that = this; this.collection.queryParams['provider'] = this.kmsServiceName; this.collection.fetch({ cache : false, reset :true, - error : function(model,resp){ + error : function(collection,resp){ var errorMsg = 'Error getting key list!!'; if(!_.isUndefined(resp) && !_.isUndefined(resp.responseJSON) && !_.isUndefined(resp.responseJSON.msgDesc)){ errorMsg = resp.responseJSON.msgDesc; } XAUtil.notifyError('Error', errorMsg); + collection.state = that.defaultsCollstate; + collection.reset(); } }); }, @@ -128,13 +128,19 @@ define(function(require){ } this.setupKmsServiceAutoComplete(); this.addVisualSearch(); + //Showing pagination even if No Key found + if(!this.isKnownKmsServicePage){ + this.collection.reset(); + } + if(this.isKnownKmsServicePage){ + this.getKeysForKmsService(); + } }, onTabChange : function(e){ var that = this; this.showKeyList = $(e.currentTarget).attr('href') == '#keys' ? true : false; if(this.showKeyList){ this.renderKeyTab(); -// this.addVisualSearch(); } }, renderKeyTab : function(){ @@ -152,19 +158,16 @@ define(function(require){ emptyText : 'No Key found!' } })); - }, getColumns : function(){ var that = this; var cols = { - name : { label : localization.tt("lbl.keyName"), cell :'string', editable:false, sortable:false, - }, cipher : { label : localization.tt("lbl.cipher"), @@ -206,12 +209,10 @@ define(function(require){ drag : false, editable:false, sortable:false, -// sortType: 'toggle', -// direction: 'descending', formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { if(!_.isUndefined(rawValue)) - return Globalize.format(new Date(rawValue), "MM/dd/yyyy hh:mm:ss tt"); + return Globalize.format(new Date(rawValue), "MM/dd/yyyy hh:mm:ss tt"); } }) }, @@ -227,7 +228,6 @@ define(function(require){ }), editable: false, sortable : false - } }; @@ -252,7 +252,6 @@ define(function(require){ valueMatches :function(facet, searchTerm, callback) { switch (facet) { } - } } }; @@ -263,6 +262,7 @@ define(function(require){ }, setupKmsServiceAutoComplete : function(serviceName){ var that = this, arr = []; + this.ui.selectServiceName.select2({ maximumSelectionSize : 1, closeOnSelect : true, @@ -275,13 +275,13 @@ define(function(require){ url: "service/plugins/services", dataType: 'json', data: function (term, page) { - return {name : term, 'serviceType' : 'kms'}; + return { name : term, 'serviceType' : 'kms' }; }, results: function (data, page) { var results = [],selectedVals = []; if(data.resultSize != "0"){ results = data.services.map(function(m, i){ return {id : m.name, text: m.name}; }); - return {results : results}; + return { results : results }; } return { results : results }; } @@ -296,7 +296,7 @@ define(function(require){ return 'No service found.'; } }) - .on('select2-focus', XAUtil.select2Focus) + //.on('select2-focus', XAUtil.select2Focus) .on('change',function(e) { that.kmsServiceName = (e.currentTarget.value) that.ui.addNewKey.attr('disabled',false); @@ -311,12 +311,12 @@ define(function(require){ var obj = this.collection.get($(e.currentTarget).data('id')); var model = new KmsKey(obj.attributes); model.collection = this.collection; - var url = model.urlRoot+"/"+model.get('name')+"?provider="+ this.kmsServiceName; + var url = model.urlRoot +"/"+model.get('name') +"?provider="+ this.kmsServiceName; + XAUtil.confirmPopup({ msg :'Are you sure want to delete ?', callback : function(){ XAUtil.blockUI(); - model.destroy({ 'url' : url, 'success': function(model, response) { @@ -343,7 +343,7 @@ define(function(require){ var obj = this.collection.get($(e.currentTarget).data('id')); var model = new KmsKey({ 'name' : obj.attributes.name }); model.collection = this.collection; - var url = model.urlRoot+"?provider="+ this.kmsServiceName; + var url = model.urlRoot + "?provider=" + this.kmsServiceName; XAUtil.confirmPopup({ msg :'Are you sure want to rollover ?', callback : function(){ @@ -363,7 +363,7 @@ define(function(require){ var errorMsg = 'Error rollovering key!'; XAUtil.blockUI('unblock'); if(!_.isUndefined(resp) && !_.isUndefined(resp.responseJSON) && !_.isUndefined(resp.responseJSON.msgDesc)){ - errorMsg = resp.responseJSON.msgDesc; + errorMsg = resp.responseJSON.msgDesc; } XAUtil.notifyError('Error', errorMsg); } @@ -379,4 +379,4 @@ define(function(require){ }); return KmsTableLayout; -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/kms/KmsKeyCreate.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/kms/KmsKeyCreate.js b/security-admin/src/main/webapp/scripts/views/kms/KmsKeyCreate.js index 0bc62b6..38cb03f 100644 --- a/security-admin/src/main/webapp/scripts/views/kms/KmsKeyCreate.js +++ b/security-admin/src/main/webapp/scripts/views/kms/KmsKeyCreate.js @@ -34,7 +34,6 @@ define(function(require){ var KmsKeyCreateTmpl= require('hbs!tmpl/kms/KmsKeyCreate_tmpl'); var RKmsKeyForm = require('views/kms/KmsKeyForm'); -// var RangerServiceDef = require('models/RangerServiceDef'); var KmsKeyCreate = Backbone.Marionette.Layout.extend( /** @lends KmsKeyCreate */ @@ -49,8 +48,9 @@ define(function(require){ }, breadCrumbs :function(){ var opts = { 'kmsService' : this.kmsService, 'kmsServiceDefModel' : this.kmsServiceDefModel } - if(this.model.isNew()) + if(this.model.isNew()){ return [XALinks.get('KmsManage',opts), XALinks.get('KmsServiceForKey', opts), XALinks.get('KmsKeyCreate')]; + } } , /** Layout sub regions */ @@ -110,9 +110,7 @@ define(function(require){ onSave: function(){ var that =this ; var errors = this.form.commit({validate : false}); - if(! _.isEmpty(errors)){ - return; - } + if(! _.isEmpty(errors)) return; var options = { url : this.model.urlRoot+"?provider="+ this.kmsServiceName, success: function () { @@ -125,12 +123,14 @@ define(function(require){ error : function (model, resp, options) { XAUtil.blockUI('unblock'); var errorMsg = 'Error creating Key!'; - if(!_.isUndefined(resp) && !_.isUndefined(resp.responseJSON) && !_.isUndefined(resp.responseJSON.msgDesc)){ + if(!_.isUndefined(resp) && !_.isUndefined(resp.responseJSON) + && !_.isUndefined(resp.responseJSON.msgDesc)){ errorMsg = resp.responseJSON.msgDesc; } XAUtil.notifyError('Error', errorMsg); } } + //to check model is new or not options.type = (this.model.has('versions')) ? 'PUT' : 'POST'; this.form.beforeSave(); @@ -145,7 +145,6 @@ define(function(require){ var that = this; var url = this.model.urlRoot+"?provider="+ this.kmsServiceName; XAUtil.confirmPopup({ - //msg :localize.tt('msg.confirmDelete'), msg :'Are you sure want to delete ?', callback : function(){ XAUtil.blockUI(); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/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 index 3e03d80..02b879d 100644 --- a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionCreate.js +++ b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionCreate.js @@ -38,25 +38,23 @@ define(function(require){ { _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"]' - }, + template: ModulePermissionCreateTmpl, + breadCrumbs :function(){ + return this.model.isNew() ? [XALinks.get('ModulePermissions')] + : [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() { @@ -94,34 +92,33 @@ define(function(require){ 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); + 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(); @@ -142,14 +139,14 @@ define(function(require){ var msg = that.editMode ? 'Module Permissions updated successfully' :'Module Permissions created successfully'; XAUtil.notifySuccess('Success', msg); App.appRouter.navigate("#!/permissions",{trigger: true}); - } , + }, error : function(model,resp){ XAUtil.blockUI('unblock'); if(!_.isUndefined(resp.responseJSON) && !_.isUndefined(resp.responseJSON.msgDesc)){ XAUtil.notifyError('Error',resp.responseJSON.msgDesc); - }else + } else { XAUtil.notifyError('Error', "Error occurred while creating/updating module permissions."); - + } } }); }, http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/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 index 497a4a2..14509e1 100644 --- a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionForm.js +++ b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionForm.js @@ -46,9 +46,6 @@ define(function(require) { _viewName : 'ModulePermissionForm', template : require('hbs!tmpl/permissions/ModulePermissionForm_tmpl'), templateHelpers :function(){ - return { - - }; }, templateData : function(){ return { 'id' : this.model.id, 'permHeaders' : this.getPermHeaders() }; @@ -106,10 +103,6 @@ define(function(require) { var that = this; Backbone.Form.prototype.render.call(this, options); - if(!this.model.isNew()){ - //this.setUpSwitches(); - } - }, setupFieldsforEditModule : function(){ var groupsNVList=[],usersNVList =[]; @@ -135,19 +128,18 @@ define(function(require) { getPlugginAttr :function(autocomplete, options){ var that = this; if(!autocomplete) - return{tags : true,width :'220px',multiple: true,minimumInputLength: 1}; + 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]}); - }); + data.push({id: elem[options.idKey], text: elem[options.textKey]}); + }); callback(data); }, createSearchChoice: function(term, data) { @@ -170,16 +162,22 @@ define(function(require) { cache: false, data: function (term, page) { //To be checked - return {name : term, isVisible : XAEnums.VisibilityStatus.STATUS_VISIBLE.value}; -// return {loginId : term}; + return { name : term, isVisible : XAEnums.VisibilityStatus.STATUS_VISIBLE.value }; }, results: function (data, page) { var results = []; + var results = [], selectedVals = []; + //Get selected values of groups/users dropdown + selectedVals = that.getSelectedValues(options); if(data.resultSize != "0"){ - if(!_.isUndefined(data.vXGroups)) + if(!_.isUndefined(data.vXGroups)){ results = data.vXGroups.map(function(m, i){ return {id : m.id+"", text: m.name}; }); - else if(!_.isUndefined(data.vXUsers)) + } else if(!_.isUndefined(data.vXUsers)){ 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}; }, @@ -199,16 +197,23 @@ define(function(require) { 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"; - } + return options.textKey == 'groupName' ? 'No group found.' : 'No user found.'; } }; } }, + + getSelectedValues : function(options){ + var vals = [],selectedVals = []; + var type = options.textKey == 'groupName' ? 'selectGroups' : 'selectUsers'; + var $select = this.$('[name="'+type+'"]'); + if(!_.isEmpty($select.select2('data'))){ + selectedVals = _.map($select.select2('data'),function(obj){ return obj.text; }); + } + vals.push.apply(vals , selectedVals); + vals = $.unique(vals); + return vals; + }, beforeSaveModulePermissions : function(){ if(this.model.get('module') != ''){ var groupValStr = this.fields.selectGroups.getValue(); @@ -234,7 +239,7 @@ define(function(require) { //Look for equals if(_.isEqual(selectedIdList,modelPerms)) { //No changes in Selected Users - }else{ + } else { //look for new values - //loop through each new element and check if it has any non matching ids @@ -261,7 +266,7 @@ define(function(require) { } } - }else{ + } else { //Remove permissions from all objects which earlier had permission _.each(options.permList, function(perm){ perm.isAllowed = 0; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/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 index 18d7c4c..c8ce659 100644 --- a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js @@ -27,10 +27,10 @@ define(function(require){ var XAGlobals = require('utils/XAGlobals'); var SessionMgr = require('mgrs/SessionMgr'); var XAUtil = require('utils/XAUtils'); + var localization = require('utils/XALangSupport'); 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'); @@ -44,25 +44,22 @@ define(function(require){ { _viewName : 'ModulePermsTableLayout', - template: ModulePermsTableLayoutTmpl, + template: ModulePermsTableLayoutTmpl, templateHelpers : function(){ - return { - //rangerService:this.rangerService - }; }, - breadCrumbs : function(){ - return [XALinks.get('ModulePermissions')]; + breadCrumbs : function(){ + return [XALinks.get('ModulePermissions')]; }, /** Layout sub regions */ - regions: { + regions: { 'rTableList' : 'div[data-id="r_table"]', }, - // /** ui selector cache */ - ui: { + /** ui selector cache */ + ui: { 'btnShowMore' : '[data-id="showMore"]', 'btnShowLess' : '[data-id="showLess"]', 'visualSearch' : '.visual_search' @@ -77,13 +74,14 @@ define(function(require){ return events; }, - /** + /** * intialize a new RangerPolicyTableLayout Layout * @constructs */ initialize: function(options) { console.log("initialized a ModulePermsTableLayout Layout"); - //_.extend(this, _.pick(options)); + + _.extend(this, _.pick(options)); this.bindEvents(); }, @@ -95,10 +93,16 @@ define(function(require){ //this.initializePlugins(); this.addVisualSearch(); this.renderTable(); + this.initializeModulePerms(); }, /** all post render plugin initialization */ initializePlugins: function(){ }, + initializeModulePerms : function(){ + this.collection.fetch({ + cache : false, + }); + }, renderTable : function(){ var that = this; this.rTableList.show(new XATableLayout({ @@ -148,10 +152,9 @@ define(function(require){ 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 '--'; + return !_.isUndefined(rawValue) ? + XAUtil.showGroupsOrUsers(rawValue, model, 'users') + : '--'; } }), editable : false, @@ -200,12 +203,8 @@ define(function(require){ }, 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, @@ -213,17 +212,7 @@ define(function(require){ 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;*/ } - } } }; @@ -234,6 +223,7 @@ define(function(require){ 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 */ http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js index b392248..b5a3c7f 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js +++ b/security-admin/src/main/webapp/scripts/views/policies/PermissionList.js @@ -35,8 +35,8 @@ define(function(require) { var VXUserList = require('collections/VXUserList'); require('bootstrap-editable'); - var FormInputItem = Backbone.Marionette.ItemView.extend({ - _msvName : 'FormInputItem', + var PermissionItem = Backbone.Marionette.ItemView.extend({ + _msvName : 'PermissionItem', template : require('hbs!tmpl/policies/PermissionItem'), tagName : 'tr', templateHelpers : function(){ @@ -442,7 +442,7 @@ define(function(require) { return Backbone.Marionette.CompositeView.extend({ - _msvName : 'FormInputItemList', + _msvName : 'PermissionItemList', template : require('hbs!tmpl/policies/PermissionList'), templateHelpers :function(){ return { @@ -453,7 +453,7 @@ define(function(require) { if(!item){ return; } - return FormInputItem; + return PermissionItem; }, itemViewContainer : ".js-formInput", itemViewOptions : function() { @@ -476,14 +476,11 @@ define(function(require) { this.collection.add(new Backbone.Model()); }, onRender : function(){ -// this.toggleAddButton(); }, addNew : function(){ var that =this; -// if(this.groupList.length > this.collection.length && (this.userList.length > this.collection.length)){ - this.collection.add(new Backbone.Model()); -// this.toggleAddButton(); -// } + this.collection.add(new Backbone.Model()); + }, toggleAddButton : function(){ var groupNames=[], userNames=[]; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/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 9a6b92f..621edf6 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js @@ -31,7 +31,6 @@ define(function(require){ var XABackgrid = require('views/common/XABackgrid'); var XATableLayout = require('views/common/XATableLayout'); var localization = require('utils/XALangSupport'); - var vFolderInfo = require('views/folders/FolderInfo'); var RangerService = require('models/RangerService'); var RangerServiceDef = require('models/RangerServiceDef'); var RangerPolicy = require('models/RangerPolicy'); @@ -122,12 +121,18 @@ define(function(require){ async : false }) }, + initializePolicies : function(){ + this.collection.url = XAUtil.getServicePoliciesURL(this.rangerService.id); + this.collection.fetch({ + cache : false, + }); + }, /** on render callback */ onRender: function() { // this.initializePlugins(); this.addVisualSearch(); this.renderTable(); - + this.initializePolicies(); // XAUtil.highlightDisabledPolicy(this); }, @@ -319,7 +324,7 @@ define(function(require){ var searchOpt = ['Policy Name','Group Name','User Name','Status'];//,'Start Date','End Date','Today']; searchOpt = _.union(searchOpt, resourceSearchOpt) - var serverAttrName = [{text : "Policy Name", label :"policyName"},{text : "Group Name", label :"group"}, + var serverAttrName = [{text : "Policy Name", label :"policyNamePartial"},{text : "Group Name", label :"group"}, {text : "User Name", label :"user"}, {text : "Status", label :"isEnabled"}]; // {text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'}, // {text : 'Today',label :'today'}]; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js b/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js index 040cda7..50f773c 100644 --- a/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js +++ b/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js @@ -28,7 +28,7 @@ define(function(require){ var XAUtil = require('utils/XAUtils'); var SessionMgr = require('mgrs/SessionMgr'); var RangerServiceList = require('collections/RangerServiceList'); - var RangerService = require('models/RangerService'); + var RangerService = require('models/RangerService'); var ServicemanagerlayoutTmpl = require('hbs!tmpl/common/ServiceManagerLayout_tmpl'); return Backbone.Marionette.Layout.extend( @@ -39,11 +39,10 @@ define(function(require){ template: ServicemanagerlayoutTmpl, templateHelpers: function(){ - var groupedServices = this.services.groupBy("type"); return { - operation : SessionMgr.isSystemAdmin() || SessionMgr.isKeyAdmin(), + operation : SessionMgr.isSystemAdmin() || SessionMgr.isKeyAdmin(), serviceDefs : this.collection.models, - services : groupedServices + services : this.services.groupBy("type") }; }, breadCrumbs :[XALinks.get('ServiceManager')], http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js index b3147ee..d3c684c 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js +++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js @@ -105,7 +105,6 @@ define(function(require) { console.log("initialized a AuditLayout Layout"); _.extend(this, _.pick(options, 'accessAuditList','tab')); - // this.initializePolling(); this.bindEvents(); this.currentTab = '#'+this.tab; var date = new Date().toString(); @@ -119,20 +118,13 @@ define(function(require) { //this.listenTo(this.collection, "change:foo", this.render, this); }, initializeCollection : function(){ - this.collection.fetch({ reset : true, cache : false }); }, - initializePolling : function(){ - this.timerId = setInterval(function(){ -// that.onRefresh(this.accessAuditList); - console.log('polling collection..'); - },XAGlobals.settings.AUDIT_REPORT_POLLING); - }, initializeServiceDefColl : function() { - this.serviceDefList = new RangerServiceDefList(); + this.serviceDefList = new RangerServiceDefList(); this.serviceDefList.fetch({ cache : false, async:false @@ -146,15 +138,15 @@ define(function(require) { this.onTabChange(); this.ui.tab.find('li[class="active"]').removeClass(); this.ui.tab.find('[href="'+this.currentTab+'"]').parent().addClass('active'); - - }else{ + } else { this.renderBigDataTable(); this.addSearchForBigDataTab(); this.modifyTableForSubcolumns(); } }, - displayDatepicker : function ($el, callback) { - var input = $el.find('.search_facet.is_editing input.search_facet_input'); + displayDatepicker : function ($el, callback) { + var input = $el.find('.search_facet.is_editing input.search_facet_input'); + input.datepicker({ autoclose : true, dateFormat: 'yy-mm-dd' @@ -168,7 +160,7 @@ define(function(require) { input.datepicker("destroy"); }); input.datepicker('show'); - }, + }, modifyTableForSubcolumns : function(){ this.$el.find('[data-id="r_tableList"] table thead').prepend('<tr>\ <th class="renderable pid"></th>\ @@ -185,17 +177,17 @@ define(function(require) { }, renderDateFields : function(){ var that = this; + this.ui.startDate.datepicker({ autoclose : true - //language : $.cookie().lang }).on('changeDate', function(ev) { that.ui.endDate.datepicker('setStartDate', ev.date); }).on('keydown',function(){ return false; }); + this.ui.endDate.datepicker({ autoclose : true - //language : $.cookie().lang }).on('changeDate', function(ev) { that.ui.startDate.datepicker('setEndDate', ev.date); }).on('keydown',function(){ @@ -204,60 +196,60 @@ define(function(require) { }, onTabChange : function(e){ var that = this, tab; - if(!_.isUndefined(e)) - tab = $(e.currentTarget).attr('href'); - else - tab = this.currentTab; + tab = !_.isUndefined(e) ? $(e.currentTarget).attr('href') : this.currentTab; this.$el.parents('body').find('.datepicker').remove(); switch (tab) { - case "#bigData": - this.currentTab = '#bigData'; - this.ui.visualSearch.show(); - this.ui.visualSearch.parents('.well').show(); - this.renderBigDataTable(); - this.modifyTableForSubcolumns(); - if(this.accessAuditList.length <= 0){ - this.accessAuditList.fetch({ - cache : false + case "#bigData": + this.currentTab = '#bigData'; + this.ui.visualSearch.show(); + this.ui.visualSearch.parents('.well').show(); + this.renderBigDataTable(); + this.modifyTableForSubcolumns(); + if(this.accessAuditList.length <= 0){ + this.accessAuditList.fetch({ + cache : false + }); + } + this.addSearchForBigDataTab(); + this.listenTo(this.accessAuditList, "request", that.updateLastRefresh); + break; + case "#admin": + this.currentTab = '#admin'; + this.trxLogList = new VXTrxLogList(); + this.renderAdminTable(); + if(_.isUndefined(App.sessionId)){ + this.trxLogList.fetch({ + cache : false + }); + } + this.addSearchForAdminTab(); + this.listenTo(this.trxLogList, "request", that.updateLastRefresh); + break; + case "#loginSession": + this.currentTab = '#loginSession'; + this.authSessionList = new VXAuthSession(); + this.renderLoginSessionTable(); + //Setting SortBy as id and sortType as desc = 1 + this.authSessionList.setSorting('id',1); + this.authSessionList.fetch({ + cache:false, }); - } - this.addSearchForBigDataTab(); - break; - case "#admin": - this.currentTab = '#admin'; - this.trxLogList = new VXTrxLogList(); - this.renderAdminTable(); - if(_.isUndefined(App.sessionId)){ - this.trxLogList.fetch({ - cache : false + this.addSearchForLoginSessionTab(); + this.listenTo(this.authSessionList, "request", that.updateLastRefresh) + break; + case "#agent": + this.currentTab = '#agent'; + this.policyExportAuditList = new VXPolicyExportAuditList(); + var params = { priAcctId : 1 }; + that.renderAgentTable(); + this.policyExportAuditList.setSorting('createDate',1); + this.policyExportAuditList.fetch({ + cache : false, + data :params }); - } - this.addSearchForAdminTab(); - - break; - case "#loginSession": - this.currentTab = '#loginSession'; - this.authSessionList = new VXAuthSession(); - this.renderLoginSessionTable(); - //Setting SortBy as id and sortType as desc = 1 - this.authSessionList.setSorting('id',1); - this.authSessionList.fetch({ - cache:false, - }); - this.addSearchForLoginSessionTab(); - break; - case "#agent": - this.currentTab = '#agent'; - this.policyExportAuditList = new VXPolicyExportAuditList(); - var params = { priAcctId : 1 }; - that.renderAgentTable(); - this.policyExportAuditList.setSorting('createDate',1); - this.policyExportAuditList.fetch({ - cache : false, - data :params - }); - this.addSearchForAgentTab(); - break; + this.addSearchForAgentTab(); + this.listenTo(this.policyExportAuditList, "request", that.updateLastRefresh); + break; } var lastUpdateTime = Globalize.format(new Date(), "MM/dd/yyyy hh:mm:ss tt"); that.ui.lastUpdateTimeLabel.html(lastUpdateTime); @@ -287,12 +279,12 @@ define(function(require) { valueMatches : function(facet, searchTerm, callback) { var auditList = []; _.each(XAEnums.ClassTypes, function(obj){ - if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) + if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) auditList.push({label :obj.label, value :obj.value+''}); }); @@ -331,7 +323,6 @@ define(function(require) { callback([today]); break; } - } } }; @@ -352,12 +343,12 @@ define(function(require) { var auditList = [],query = ''; _.each(XAEnums.ClassTypes, function(obj){ - if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) + if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) auditList.push({label :obj.label, value :obj.label+''}); }); if(!_.isUndefined(App.sessionId)){ @@ -563,7 +554,7 @@ define(function(require) { userName :self.model.get('owner'), action : action }); - }else{ + } else { var view = new vOperationDiffDetail({ collection : fullTrxLogListForTrxId, classType : self.model.get('objectClassType'), @@ -585,9 +576,6 @@ define(function(require) { modal.$el.addClass('modal-diff').attr('tabindex',-1); modal.$el.find('.cancel').hide(); }); - - - } }); this.ui.tableList.addClass("clickable"); @@ -605,15 +593,14 @@ define(function(require) { getAdminTableColumns : function(){ var auditList = []; _.each(XAEnums.ClassTypes, function(obj){ - if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) || - (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) + if((obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) + || (obj.value == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value)) auditList.push({text :obj.label, id :obj.value}); }); - console.log(auditList); var cols = { operation : { label : localization.tt("lbl.operation"), @@ -629,7 +616,7 @@ define(function(require) { label = XAUtils.enumValueToLabel(XAEnums.ClassTypes,rawValue), html = ''; if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value || rawValue == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) html = 'Service '+action+'d '+'<b>'+name+'</b>'; - if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value|| rawValue == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) + if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value || rawValue == XAEnums.ClassTypes.CLASS_TYPE_RANGER_POLICY.value) html = 'Policy '+action+'d '+'<b>'+name+'</b>'; if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_USER.value) html = 'User '+action+'d '+'<b>'+name+'</b>'; @@ -670,7 +657,6 @@ define(function(require) { cell: "String", click : false, drag : false, - //sortable:false, editable:false, sortType: 'toggle', direction: 'descending', @@ -690,14 +676,16 @@ define(function(require) { formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue) { var html = ''; - if(rawValue =='create') + if(rawValue =='create'){ html = '<label class="label label-success">'+rawValue+'</label>'; - else if(rawValue == 'update') + } else if(rawValue == 'update'){ html = '<label class="label label-yellow">'+rawValue+'</label>'; - else if(rawValue == 'delete') + }else if(rawValue == 'delete'){ html = '<label class="label label-important">'+rawValue+'</label>'; - else + } else { html = '<label class="label">'+rawValue+'</label>'; + } + return html; } }) @@ -791,19 +779,10 @@ define(function(require) { if(rawValue == -1){ return '--'; } - /*var rangerService = new RangerService(); - rangerService.urlRoot += '/name/'+model.get('repoName'); - rangerService.fetch({ - cache : false, - async : false - });*/ - -// if (SessionMgr.isKeyAdmin()) { - var serviceDef = that.serviceDefList.findWhere({'id' : model.get('repoType')}) - if(_.isUndefined(serviceDef)){ - return rawValue; - } -// } + var serviceDef = that.serviceDefList.findWhere({'id' : model.get('repoType')}); + if(_.isUndefined(serviceDef)){ + return rawValue; + } var href = 'javascript:void(0)'; return '<a href="'+href+'" title="'+rawValue+'">'+rawValue+'</a>'; } @@ -831,7 +810,6 @@ define(function(require) { cell: "String", click : false, drag : false, - // sortable:false, editable:false }, repoName : { @@ -875,7 +853,6 @@ define(function(require) { cell: "html", click : false, drag : false, - // sortable:false, editable:false, formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue) { @@ -883,10 +860,11 @@ define(function(require) { _.each(_.toArray(XAEnums.AccessResult),function(m){ if(parseInt(rawValue) == m.value){ label= m.label; - if(m.value == XAEnums.AccessResult.ACCESS_RESULT_ALLOWED.value) + if(m.value == XAEnums.AccessResult.ACCESS_RESULT_ALLOWED.value){ html = '<label class="label label-success">'+label+'</label>'; - else + } else { html = '<label class="label label-important">'+label+'</label>'; + } } }); return html; @@ -944,7 +922,7 @@ define(function(require) { if(obj.value != XAEnums.AuthType.AUTH_TYPE_UNKNOWN.value) authTypeList.push({text :obj.label, id :obj.value}); }); - console.log(authStatusList); + var cols = { id : { label : localization.tt("lbl.sessionId"), @@ -952,7 +930,6 @@ define(function(require) { href: function(model){ return '#!/reports/audit/loginSession/id/'+model.get('id'); }, -// sortable:false, editable:false, sortType: 'toggle', direction: 'descending' @@ -972,12 +949,13 @@ define(function(require) { _.each(_.toArray(XAEnums.AuthStatus),function(m){ if(parseInt(rawValue) == m.value){ label= m.label; - if(m.value == 1) + if(m.value == 1){ html = '<label class="label label-success">'+label+'</label>'; - else if(m.value == 2) + } else if(m.value == 2){ html = '<label class="label label-important">'+label+'</label>'; - else + } else { html = '<label class="label">'+label+'</label>'; + } } }); return html; @@ -1026,7 +1004,6 @@ define(function(require) { authTime : { label : localization.tt("lbl.loginTime")+ ' ( '+this.timezone+' )', cell: "String", - // sortable:false, editable:false, formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { @@ -1097,11 +1074,8 @@ define(function(require) { formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { var html = rawValue; - if(rawValue > 400) - html = '<label class="label btn-danger">'+rawValue+'</label>'; - else - html = '<label class="label btn-success">'+rawValue+'</label>'; - return html; + return (rawValue > 400) ? '<label class="label btn-danger">'+rawValue+'</label>' + : '<label class="label btn-success">'+rawValue+'</label>'; } }) }, @@ -1129,6 +1103,7 @@ define(function(require) { coll = this.authSessionList; break; case "#agent": + //TODO params = { 'priAcctId' : 1 }; coll = this.policyExportAuditList; break; @@ -1144,25 +1119,21 @@ define(function(require) { } }); - - }, onSearch : function(e){ this.setCurrentTabCollection(); - var resourceName= this.ui.resourceName.val(); - var startDate = this.ui.startDate.val(); - var endDate = this.ui.endDate.val(); - var params = { 'startDate' : startDate , 'endDate' : endDate }; + var resourceName= this.ui.resourceName.val(), + startDate = this.ui.startDate.val(), + endDate = this.ui.endDate.val(), + params = { 'startDate' : startDate , 'endDate' : endDate }; //After every search we need goto to first page $.extend(this.collection.queryParams,params); //collection.fetch({data: data, reset: true}); this.collection.state.currentPage = this.collection.state.firstPage; - this.collection.fetch({ reset : true, - cache : false - //data : params, + cache : false, }); }, setCurrentTabCollection : function(){ @@ -1188,13 +1159,12 @@ define(function(require) { }); }, - /* - * onChangeRepository : function(){ this.onSearch(); }, - */ /** all post render plugin initialization */ initializePlugins : function() { }, - + updateLastRefresh : function(){ + this.ui.lastUpdateTimeLabel.html(Globalize.format(new Date(), "MM/dd/yyyy hh:mm:ss tt")); + }, /** on close */ onClose : function() { clearInterval(this.timerId); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js b/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js index 8f0f67e..6f1069d 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js +++ b/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js @@ -35,9 +35,6 @@ define(function(require){ template: LoginSessionDetail_tmpl, templateHelpers :function(){ - - return { - }; }, /** ui selector cache */ ui: { http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js b/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js index 1b66728..a214394 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js +++ b/security-admin/src/main/webapp/scripts/views/reports/OperationDiffDetail.js @@ -27,9 +27,9 @@ define(function(require){ var PolicyOperationDiff_tmpl = require('hbs!tmpl/reports/PolicyOperationDiff_tmpl'); var PolicyUpdateOperationDiff_tmpl = require('hbs!tmpl/reports/PolicyUpdateOperationDiff_tmpl'); var PolicyDeleteUpdateOperationDiff_tmpl = require('hbs!tmpl/reports/PolicyDeleteOperationDiff_tmpl'); - var KnoxPolicyOperationDiff_tmpl = require('hbs!tmpl/reports/KnoxPolicyOperationDiff_tmpl'); - var KnoxPolicyUpdateOperationDiff_tmpl = require('hbs!tmpl/reports/KnoxPolicyUpdateOperationDiff_tmpl'); - var KnoxPolicyDeleteUpdateOperationDiff_tmpl = require('hbs!tmpl/reports/KnoxPolicyDeleteOperationDiff_tmpl'); + var KnoxPolicyOperationDiff_tmpl = require('hbs!tmpl/reports/KnoxPolicyOperationDiff_tmpl'); + var KnoxPolicyUpdateOperationDiff_tmpl = require('hbs!tmpl/reports/KnoxPolicyUpdateOperationDiff_tmpl'); + var KnoxPolicyDeleteUpdateOperationDiff_tmpl= require('hbs!tmpl/reports/KnoxPolicyDeleteOperationDiff_tmpl'); var AssetOperationDiff_tmpl = require('hbs!tmpl/reports/AssetOperationDiff_tmpl'); var AssetUpdateOperationDiff_tmpl = require('hbs!tmpl/reports/AssetUpdateOperationDiff_tmpl'); var UserOperationDiff_tmpl = require('hbs!tmpl/reports/UserOperationDiff_tmpl'); @@ -55,7 +55,9 @@ define(function(require){ if(this.templateType == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value){ obj = $.extend(obj, { newConnConfig : this.newConnConfig, - previousConnConfig : this.previousConnConfig + previousConnConfig : this.previousConnConfig, + isNewConnConfig : _.isEmpty(this.newConnConfig) ? false : true, + isPreviousConnConfig: _.isEmpty(this.previousConnConfig) ? false : true }); } if(this.templateType == XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value){ @@ -76,7 +78,6 @@ define(function(require){ newGroupList : this.newGroupList, previousGroupList : this.previousGroupList, isGroup : this.isGroup - }); } @@ -109,7 +110,6 @@ define(function(require){ _.extend(this, _.pick(options, 'classType','objectName','objectId','objectCreatedDate','action','userName')); this.bindEvents(); - //this.initializeDiffOperation(); this.getTemplateForView(); }, @@ -126,7 +126,6 @@ define(function(require){ //remove last comma from Perms _.each(this.ui.diff.find('ol li'),function(m){ var text = $(m).text().replace(/,(?=[^,]*$)/, ''); - //$(m).text(text); $(m).find('span').last().remove(); }); _.each(this.ui.policyDiff.find('ol li'),function(m){ @@ -140,9 +139,9 @@ define(function(require){ this.templateType=XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value; if(this.action == 'create'){ this.template = AssetOperationDiff_tmpl; - }else if(this.action == 'update'){ + } else if(this.action == 'update'){ this.template = AssetUpdateOperationDiff_tmpl; - }else{ + } else { this.template = AssetOperationDiff_tmpl; } this.assetDiffOperation(); @@ -151,9 +150,9 @@ define(function(require){ this.templateType=XAEnums.ClassTypes.CLASS_TYPE_XA_RESOURCE.value; if(this.action == 'create'){ this.template = PolicyOperationDiff_tmpl; - }else if(this.action == 'update'){ + } else if(this.action == 'update'){ this.template = PolicyUpdateOperationDiff_tmpl; - }else{ + } else{ this.template = PolicyDeleteUpdateOperationDiff_tmpl; } this.resourceDiffOperation(); @@ -163,9 +162,9 @@ define(function(require){ || this.classType == XAEnums.ClassTypes.CLASS_TYPE_PASSWORD_CHANGE.value){ if(this.action == 'create' || this.action == 'delete'){ this.template = UserOperationDiff_tmpl; - }else if(this.action == 'update' || this.action == "password change"){ + } else if(this.action == 'update' || this.action == "password change"){ this.template = UserUpdateOperationDiff_tmpl; - }else{ + } else{ this.template = UserOperationDiff_tmpl; } this.userDiffOperation(); @@ -174,14 +173,11 @@ define(function(require){ if(this.classType == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value){ if(this.action == 'create'){ this.template = GroupOperationDiff_tmpl; - //this.groupDiffOperation(); - }else if(this.action == 'update'){ + } else if(this.action == 'update'){ this.template = GroupUpdateOperationDiff_tmpl; - }else{ + } else{ this.template = GroupOperationDiff_tmpl; } - //this.template=GroupUpdateOperationDiff_tmpl; - // this.groupDiffOperation(); this.templateType = XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value; } }, @@ -202,7 +198,13 @@ define(function(require){ if(this.action == 'create' || this.action == 'delete'){ this.newConnConfig = this.removeUnwantedFromObject(this.newConnConfig); this.previousConnConfig = this.removeUnwantedFromObject(this.previousConnConfig); + }else{ + var tmp = this.newConnConfig, tmp1 = {};; + _.each(tmp,function(val, name){ tmp1[name] = ""; }) + _.each(this.previousConnConfig,function(val, name){ tmp1[name]=val; }); + this.previousConnConfig = tmp1; } + }, resourceDiffOperation : function(){ var that = this, modelColl = []; @@ -210,8 +212,7 @@ define(function(require){ this.userList = [],this.groupList = []; this.collection.each(function(m){ var attrName = m.get('attributeName'), type = 'permType'; - if(attrName == "IP Address") - type = 'ipAddress'; + if(attrName == "IP Address") type = 'ipAddress'; if(m.get('attributeName') == 'Permission Type' || m.get('attributeName') == "IP Address"){ if(m.get('parentObjectClassType') == XAEnums.ClassTypes.CLASS_TYPE_XA_GROUP.value){ if(m.get('action') != 'delete'){ @@ -231,8 +232,7 @@ define(function(require){ } if($.inArray(m.get('parentObjectName'),that.groupList) < 0) that.groupList.push(m.get('parentObjectName')); - } - else{ + } else { if(m.get('action') != 'delete'){ if(m.get('action') == 'create'){ var obj = {userName : m.get('parentObjectName')}; @@ -255,11 +255,12 @@ define(function(require){ } modelColl.push(m); - }else if(m.get('attributeName') == 'Repository Type'){ - if(m.get('action') != 'delete') + } else if(m.get('attributeName') == 'Repository Type'){ + if(m.get('action') != 'delete'){ that.repositoryType = m.get('newValue'); - else + } else { that.repositoryType = m.get('previousValue'); + } modelColl.push(m); if(that.repositoryType == XAEnums.AssetType.ASSET_KNOX.label && m.get('action') == "create")//XAEnums.AssetType.ASSET_KNOX.value) that.template = KnoxPolicyOperationDiff_tmpl; @@ -267,15 +268,16 @@ define(function(require){ that.template = KnoxPolicyUpdateOperationDiff_tmpl; if(that.repositoryType == XAEnums.AssetType.ASSET_KNOX.label && m.get('action') == "delete") that.template = KnoxPolicyDeleteUpdateOperationDiff_tmpl; - }else if(m.get('attributeName') == 'Policy Name'){ - if(m.get('action') != 'delete') + } else if(m.get('attributeName') == 'Policy Name'){ + if(m.get('action') != 'delete'){ that.policyName = m.get('newValue'); - else + } else { that.policyName = m.get('previousValue'); + } if(m.get('newValue') == m.get('previousValue')) modelColl.push(m); } - + if(_.isUndefined(m.get('attributeName'))) modelColl.push(m); }); @@ -346,7 +348,7 @@ define(function(require){ if(m.get('action') == 'delete' || m.get('action') == 'update') that.previousGroupList.push(m.get('parentObjectName')); modelArr.push(m); - }else if(m.get('attributeName') == 'User Role'){ + } else if(m.get('attributeName') == 'User Role'){ var newRole = m.get('newValue').replace(/[[\]]/g,''); var prevRole = m.get('previousValue').replace(/[[\]]/g,''); if( newRole == "ROLE_USER") @@ -361,13 +363,14 @@ define(function(require){ m.set('previousValue',XAEnums.UserRoles.ROLE_SYS_ADMIN.label) else if(prevRole == "ROLE_KEY_ADMIN") m.set('previousValue',XAEnums.UserRoles.ROLE_KEY_ADMIN.label) - }else{ + } else { if(!m.has('attributeName')) modelArr.push(m); } }); - if(!_.isEmpty(this.newGroupList) || !_.isEmpty(this.previousGroupList)) + if(!_.isEmpty(this.newGroupList) || !_.isEmpty(this.previousGroupList)){ this.isGroup = true; + } this.collection.remove(modelArr); }, groupDiffOperation : function(){ http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js b/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js index ceb8898..52550b6 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js +++ b/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js @@ -82,7 +82,6 @@ define(function(require){ _.extend(this, _.pick(options, 'classType','objectName','objectId','objectCreatedDate','action','userName','policyId')); this.bindEvents(); - //this.initializeDiffOperation(); this.initializeServiceDef(); this.getTemplateForView(); @@ -260,7 +259,6 @@ define(function(require){ } if(this.action == "update"){ _.each(resources,function(val, key){ -// console.log(oldResources) if(val != oldResources[key]) this.collection.add({'attributeName':key, 'newValue':val.toString(),'previousValue': oldResources[key],type : "Policy Resources"}); }, this) @@ -341,8 +339,6 @@ define(function(require){ this.newPermList.push({}) } } - console.log(this.oldPermList) - console.log(this.newPermList) }, /** all post render plugin initialization */ initializePlugins: function(){ http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js b/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js index b1ed454..1002516 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js +++ b/security-admin/src/main/webapp/scripts/views/reports/UserAccessLayout.js @@ -78,13 +78,8 @@ define(function(require) {'use strict'; /** ui events hash */ events : function() { var events = {}; - //events['change ' + this.ui.input] = 'onInputChange'; events['click ' + this.ui.searchBtn] = 'onSearch'; - //events["'change ' "+ this.ui.userName +"','" + this.ui.userGroup+"'"] = 'onSearch'; - //events['change ' + this.ui.userName+ ','+this.ui.userGroup+ ',' +this.ui.resourceName] = 'onSearch'; events['click .autoText'] = 'autocompleteFilter'; - - //events['keydown ' + this.ui.userGroup] = 'groupKeyDown'; events['click .gotoLink'] = 'gotoTable'; events['click ' + this.ui.btnShowMore] = 'onShowMore'; events['click ' + this.ui.btnShowLess] = 'onShowLess'; @@ -101,7 +96,6 @@ define(function(require) {'use strict'; console.log("initialized a UserAccessLayout Layout"); _.extend(this, _.pick(options, 'groupList','userList')); this.bindEvents(); - }, initializeRequiredData : function() { this.policyCollList = []; @@ -116,7 +110,6 @@ define(function(require) {'use strict'; }, initializeServiceDef : function() { this.serviceDefList = new RangerServiceDefList(); -// this.serviceDefList.queryParams.sortBy = 'id'; this.serviceDefList.fetch({ cache : false, async:false @@ -138,34 +131,18 @@ define(function(require) {'use strict'; this.renderTable(obj.collName, obj.serviceDefName); this.getResourceLists(obj.collName,obj.serviceDefName); },this); + this.$el.find('[data-js="policyName"]').focus(); }, getResourceLists: function(collName, serviceDefName){ var that = this, coll = this[collName]; coll.queryParams.serviceType = serviceDefName; - /* if(!_.isUndefined(params)){ - _.each(params,function(val, attr){ - if(!_.isUndefined(val) && !_.isEmpty(val)) - coll.queryParams[attr] = val; - }); - }*/ coll.fetch({ cache : false, reset: true, async:false, }).done(function(){ -// console.log(coll); coll.trigger('sync') -// if(coll.queryParams.assetType == XAEnums.AssetType.ASSET_STORM.value){ -// var totalRecords=0; -// _.each(that.resourceList, function( list ){ totalRecords += list.state.totalRecords; }); - /*that.$('[data-js="searchResult"]').html('Total '+totalRecords+' records found.'); - that.$('[data-js="hdfsSearchResult"]').html(that.hdfsResourceList.state.totalRecords +' records found.'); - that.$('[data-js="hiveSearchResult"]').html(that.hiveResourceList.state.totalRecords +' records found.'); - that.$('[data-js="hbaseSearchResult"]').html(that.hbaseResourceList.state.totalRecords +' records found.'); - that.$('[data-js="knoxSearchResult"]').html(that.knoxResourceList.state.totalRecords +' records found.'); - that.$('[data-js="stormSearchResult"]').html(that.stormResourceList.state.totalRecords +' records found.');*/ -// } XAUtil.blockUI('unblock'); }); @@ -271,14 +248,6 @@ define(function(require) {'use strict'; }, /** on render callback */ setupGroupAutoComplete : function(){ - //tags : true, - /*width :'220px', - multiple: true, - minimumInputLength: 1, - data :this.groupList.map(function(m) { - //console.log(m); - return {id : m.id,text : m.get('name')}; - }),*/ this.groupArr = this.groupList.map(function(m){ return { id : m.get('name') , text : m.get('name')}; }); @@ -293,8 +262,6 @@ define(function(require) {'use strict'; // tags : this.groupArr, initSelection : function (element, callback) { var data = []; - console.log(that.groupList); - $(element.val().split(",")).each(function () { var obj = _.findWhere(that.groupArr,{id:this}); data.push({id: obj.text, text: obj.text}); @@ -329,7 +296,7 @@ define(function(require) {'use strict'; formatNoMatches: function(result){ return 'No group found.'; } - }).on('select2-focus', XAUtil.select2Focus); + })//.on('select2-focus', XAUtil.select2Focus); }, setupUserAutoComplete : function(){ var that = this; @@ -384,7 +351,7 @@ define(function(require) {'use strict'; return 'No user found.'; } - }).on('select2-focus', XAUtil.select2Focus); + })//.on('select2-focus', XAUtil.select2Focus); }, /** all post render plugin initialization */ initializePlugins : function() { @@ -395,6 +362,7 @@ define(function(require) {'use strict'; if (wrap.hasClass('wrap') && ! wrap.hasClass('non-collapsible')) $(this).append('<a href="#" class="wrap-collapse pull-right">hide <i class="icon-caret-up"></i></a>').append('<a href="#" class="wrap-expand pull-right" style="display: none">show <i class="icon-caret-down"></i></a>'); }); + // Collapse wrap $(document).on("click", "a.wrap-collapse", function() { var self = $(this).hide(100, 'linear'); @@ -413,7 +381,6 @@ define(function(require) {'use strict'; }); this.ui.resourceName.bind( "keydown", function( event ) { - if ( event.keyCode === $.ui.keyCode.ENTER ) { that.onSearch(); } @@ -422,7 +389,6 @@ define(function(require) {'use strict'; }, onSearch : function(e){ var that = this, type; - // XAUtil.blockUI(); //Get search values var groups = (this.ui.userGroup.is(':visible')) ? this.ui.userGroup.select2('val'):undefined; var users = (this.ui.userName.is(':visible')) ? this.ui.userName.select2('val'):undefined; @@ -459,7 +425,6 @@ define(function(require) {'use strict'; this.setupUserAutoComplete(); $button.text('Username'); } - //this.onSearch(); }, gotoTable : function(e){ var that = this, elem = $(e.currentTarget),pos; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/082d0f28/security-admin/src/main/webapp/scripts/views/service/ConfigurationList.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/service/ConfigurationList.js b/security-admin/src/main/webapp/scripts/views/service/ConfigurationList.js index 598db83..dcc85ab 100644 --- a/security-admin/src/main/webapp/scripts/views/service/ConfigurationList.js +++ b/security-admin/src/main/webapp/scripts/views/service/ConfigurationList.js @@ -91,13 +91,11 @@ define(function(require) { }, initialize : function(options) { _.extend(this, _.pick(options, 'fieldLabel')); -// this.listenTo(this.groupList, 'sync', this.render, this); - if(this.collection.length == 0) - this.collection.add(new Backbone.Model()); + if(this.collection.length == 0){ + this.collection.add(new Backbone.Model()); + } }, onRender : function(){ -// this.$('table').hide(); - }, addNew : function(){ var that =this;
