This is an automated email from the ASF dual-hosted git repository. mehul pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ranger.git
commit ba52fa43f245236de94bc36c49f2cd7c5e655f9a Author: Nitin Galave <[email protected]> AuthorDate: Mon Dec 9 16:58:39 2019 +0530 RANGER-2655: Ranger-UI-improvement Signed-off-by: Mehul Parikh <[email protected]> --- .../main/webapp/scripts/controllers/Controller.js | 20 ++- .../scripts/model_bases/UserPermissionBase.js | 2 +- .../src/main/webapp/scripts/modules/XALinks.js | 2 +- .../src/main/webapp/scripts/routers/Router.js | 2 +- .../src/main/webapp/scripts/utils/XAUtils.js | 128 ++++++++++++-- .../webapp/scripts/views/kms/KMSTableLayout.js | 4 +- .../views/permissions/ModulePermissionCreate.js | 6 +- .../views/permissions/ModulePermsTableLayout.js | 46 +++-- .../views/policies/RangerPolicyTableLayout.js | 76 +++++---- .../scripts/views/policymanager/ServiceLayout.js | 10 ++ .../webapp/scripts/views/reports/AuditLayout.js | 161 ++++++++++++------ .../webapp/scripts/views/users/UserTableLayout.js | 187 +++++++++++---------- .../main/webapp/templates/common/TopNav_tmpl.html | 2 +- 13 files changed, 429 insertions(+), 217 deletions(-) diff --git a/security-admin/src/main/webapp/scripts/controllers/Controller.js b/security-admin/src/main/webapp/scripts/controllers/Controller.js index 072323a..99b69a4 100755 --- a/security-admin/src/main/webapp/scripts/controllers/Controller.js +++ b/security-admin/src/main/webapp/scripts/controllers/Controller.js @@ -118,7 +118,8 @@ define(function(require) { var userList = new VXUserList(); App.rContent.show(new view({ collection : userList, - tab :tab + tab : tab.split('?')[0], + urlQueryParams : tab.indexOf("?") !== -1 ? tab.substring(tab.indexOf("?") + 1) : undefined, })); }, userCreateAction : function(){ @@ -304,7 +305,7 @@ define(function(require) { })); }); }, - + policyManageAction : function(serviceId,policyType){ MAppState.set({ 'currentTab' : XAGlobals.AppTabs.AccessManager.value }); var XAUtil = require('utils/XAUtils'); @@ -313,7 +314,7 @@ define(function(require) { var RangerPolicyList = require('collections/RangerPolicyList'); var rangerPolicyList = new RangerPolicyList(); - rangerPolicyList.queryParams['policyType'] = policyType; + rangerPolicyList.queryParams['policyType'] = policyType.split("?")[0]; if(_.isNaN(parseInt(serviceId))){ var rangerService = new RangerService(); rangerService.url = XAUtil.getServiceByName(serviceId); @@ -326,7 +327,8 @@ define(function(require) { }).done( function() { App.rContent.show(new view({ rangerService : rangerService, - collection : rangerPolicyList + collection : rangerPolicyList, + urlQueryParams : policyType.indexOf("?") !== -1 ? policyType.substring(policyType.indexOf("?") + 1) : undefined, })); }); }, @@ -385,13 +387,14 @@ define(function(require) { }); }, /************PERMISSIONS LISTING *****************************************/ - modulePermissionsAction :function(){ + modulePermissionsAction :function(argument){ MAppState.set({ 'currentTab' : XAGlobals.AppTabs.Settings.value }); var view = require('views/permissions/ModulePermsTableLayout'); var ModulePermissionList = require('collections/VXModuleDefList'); App.rContent.show(new view({ - collection : new ModulePermissionList() + collection : new ModulePermissionList(), + urlQueryParams : argument.indexOf("?") !== -1 ? argument.substring(argument.indexOf("?") + 1) : undefined, })); }, @@ -428,8 +431,9 @@ define(function(require) { var KmsKeyList = require('collections/VXKmsKeyList'); App.rContent.show(new view({ collection : new KmsKeyList(), - kmsServiceName : kmsServiceName, - kmsManagePage : kmsManagePage + kmsServiceName : kmsServiceName.split("?")[0], + kmsManagePage : kmsManagePage, + urlQueryParams : kmsServiceName.indexOf("?") !== -1 ? kmsServiceName.substring(kmsServiceName.indexOf("?") + 1) : undefined, })); }, kmsKeyCreateAction : function(kmsServiceName){ diff --git a/security-admin/src/main/webapp/scripts/model_bases/UserPermissionBase.js b/security-admin/src/main/webapp/scripts/model_bases/UserPermissionBase.js index 3751362..5599de5 100644 --- a/security-admin/src/main/webapp/scripts/model_bases/UserPermissionBase.js +++ b/security-admin/src/main/webapp/scripts/model_bases/UserPermissionBase.js @@ -27,7 +27,7 @@ define(function(require){ var UserPermissionBase = XABaseModel.extend( /** @lends UserPermissionBase.prototype */ { - urlRoot: XAGlobals.baseURL + 'permissions', + urlRoot: XAGlobals.baseURL + 'permissions/models', defaults: {}, diff --git a/security-admin/src/main/webapp/scripts/modules/XALinks.js b/security-admin/src/main/webapp/scripts/modules/XALinks.js index 5420f11..bc0c57f 100755 --- a/security-admin/src/main/webapp/scripts/modules/XALinks.js +++ b/security-admin/src/main/webapp/scripts/modules/XALinks.js @@ -264,7 +264,7 @@ define(function(require) { }; }, ModulePermissions :{ - href : '#!/permissions', + href : '#!/permissions/models', text : 'h.permissions', title: 'h.permissions' }, diff --git a/security-admin/src/main/webapp/scripts/routers/Router.js b/security-admin/src/main/webapp/scripts/routers/Router.js index b9ea66b..14f4916 100644 --- a/security-admin/src/main/webapp/scripts/routers/Router.js +++ b/security-admin/src/main/webapp/scripts/routers/Router.js @@ -63,7 +63,7 @@ function(Backbone, Marionette, localization, MAppState, XAUtil){ "!/service/:serviceId/policies/:id/edit" : "RangerPolicyEditAction", /************PERMISSIONS VIEWS *****************************************/ - "!/permissions" : "modulePermissionsAction", + "!/permissions/:models" : "modulePermissionsAction", "!/permissions/:id/edit" : "modulePermissionEditAction", /************ KMS ***************************/ diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js b/security-admin/src/main/webapp/scripts/utils/XAUtils.js index f0e0be0..5ec258f 100644 --- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js +++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js @@ -763,29 +763,44 @@ define(function(require) { pluginAttr) { var visualSearch, that = this; var supportMultipleItems = pluginAttr.supportMultipleItems || false; - var multipleFacet = serverAttrName.filter(function(elem) { + var multipleFacet = serverAttrName.filter(function(elem) { return elem['addMultiple']; }).map(function(elem) { return elem.text; }); var search = function(searchCollection, collection) { - var params = {}; + var params = {}, urlParams = {}; if($('.popover')){ $('.popover').remove(); } searchCollection.each(function(m) { - var serverParamName = _.findWhere(serverAttrName, { - text : m.attributes.category - }); - var extraParam = {}; - if (_.has(serverParamName, 'multiple') - && serverParamName.multiple) { - extraParam[serverParamName.label] = XAUtils - .enumLabelToValue(serverParamName.optionsArr, m - .get('value')); - ; - $.extend(params, extraParam); - } else { + //For url params + if(_.has(urlParams, m.get('category'))) { + var oldValue = urlParams[m.get('category')], newValue = m.get('value'); + if (Array.isArray(oldValue)) { + // if it's a list, append to the end + oldValue.push(newValue); + } else { + // convert to a list + urlParams[m.get('category')] = [oldValue, newValue]; + } + } else { + urlParams[m.get('category')] = m.get('value') + } + var serverParamName = _.findWhere(serverAttrName, { + text : m.attributes.category + }); + // pass label in url params + // if(_.isUndefined(serverParamName)) { + // var serverParamName = _.findWhere(serverAttrName, { + // label : m.attributes.category + // }); + // } + var extraParam = {}; + if (serverParamName && _.has(serverParamName, 'multiple') && serverParamName.multiple) { + extraParam[serverParamName.label] = XAUtils.enumLabelToValue(serverParamName.optionsArr, m.get('value')); + $.extend(params, extraParam); + } else { if (!_.isUndefined(serverParamName)) { var oldValue = params[serverParamName.label]; var newValue = m.get('value'); @@ -806,6 +821,16 @@ define(function(require) { }); collection.queryParams = $.extend(collection.queryParams, params); collection.state.currentPage = collection.state.firstPage; + //Add urlLabel to URL + var urlLabelParam = {}; + _.map(urlParams, function(attr, key) { + _.filter(serverAttrName, function(val) { + if(val.text === key) { + return urlLabelParam[val.urlLabel] = attr + } + }) + }) + XAUtils.changeParamToUrlFragment(urlLabelParam, collection.modelName); collection.fetch({ reset : true, cache : false, @@ -1743,5 +1768,80 @@ define(function(require) { return "/service/plugins/services/name/" + name }; + //Add visual search query parameter to URL + XAUtils.changeParamToUrlFragment = function(obj, modelName) { + var App = require('App'); + var baseUrlFregment = Backbone.history.fragment.split('?')[0], + str = []; + for (var p in obj) { + if (obj.hasOwnProperty(p)) { + if(_.isArray(obj[p])) { + _.each(obj[p], function(val) { + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(val)); + }) + } else { + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + } + } + } + if(App.vZone && App.vZone.vZoneName && !_.isEmpty(App.vZone.vZoneName) && !obj.hasOwnProperty("securityZone") && + modelName && (modelName === "RangerServiceDef" || modelName === "RangerPolicy")) { + str.push(encodeURIComponent("securityZone")+"="+ encodeURIComponent(App.vZone.vZoneName)); + } + if( _.isEmpty(str)) { + Backbone.history.navigate(baseUrlFregment , false); + } else { + Backbone.history.navigate(baseUrlFregment+"?"+str.join("&") , false); + } + } + + //convert URL to object params + XAUtils.changeUrlToSearchQuery = function(query) { + var query_string = {}; + var vars = query.split("&"); + for (var i=0;i<vars.length;i++) { + var pair = vars[i].split("="); + pair[0] = decodeURIComponent(pair[0]); + pair[1] = decodeURIComponent(pair[1]); + // If first entry with this name + if (typeof query_string[pair[0]] === "undefined") { + query_string[pair[0]] = pair[1]; + // If second entry with this name + } else if (typeof query_string[pair[0]] === "string") { + var arr = [ query_string[pair[0]], pair[1] ]; + query_string[pair[0]] = arr; + // If third or later entry with this name + } else { + query_string[pair[0]].push(pair[1]); + } + } + return query_string; + } + + //convert URL to visual search query parameter + XAUtils.changeUrlToVSSearchQuery = function(urlQuery) { + return '"'+decodeURIComponent(urlQuery.replace(/"/g, '\\"').replace(/&/g, '""').replace(/=/g, '":"'))+'"' + } + + //Return key from serverAttrName for vsSearch + XAUtils.filterKeyForVSQuery = function(list, key) { + var value = _.filter(list, function(m) { + return m.urlLabel === key + }) + if(_.isEmpty(value) || _.isUndefined(value)) { + value = _.filter(list, function(m) { + return m.text === key + }) + } + return value[0].text + } + + //convert string to Camel Case + XAUtils.stringToCamelCase = function(str) { + return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) { + return index == 0 ? word.toLowerCase() : word.toUpperCase(); + }).replace(/\s+/g, ''); + } + return XAUtils; }); \ No newline at end of file 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 d6521c6..4954b74 100755 --- a/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/kms/KMSTableLayout.js @@ -77,7 +77,7 @@ define(function(require){ */ initialize: function(options) { console.log("initialized a KmsTableLayout Layout"); - _.extend(this, _.pick(options, 'tab','kmsServiceName','kmsManagePage')); + _.extend(this, _.pick(options, 'tab','kmsServiceName','kmsManagePage', 'urlQueryParams')); this.showKeyList = true; this.isKnownKmsServicePage = this.kmsManagePage == 'new' ? false : true; this.initializeKMSServices(); @@ -248,7 +248,7 @@ define(function(require){ placeholder = localization.tt('h.searchForKeys'); coll = this.collection; searchOpt = ['Key Name']; - serverAttrName = [ {text : "Key Name", label :"name"}]; + serverAttrName = [ {text : "Key Name", label :"name", urlLabel : "keyName"}]; } var query = (!_.isUndefined(coll.VSQuery)) ? coll.VSQuery : ''; var pluginAttr = { 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 2a66312..0a3def9 100644 --- a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionCreate.js +++ b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermissionCreate.js @@ -72,7 +72,7 @@ define(function(require){ initialize: function(options) { console.log("initialized a ModulePermissionCreate Layout"); - _.extend(this, _.pick(options)); + _.extend(this, _.pick(options, 'urlQueryParams')); this.editMode = this.model.has('id') ? true : false; this.bindEvents(); }, @@ -118,7 +118,7 @@ define(function(require){ XAUtil.allowNavigation(); var msg = that.editMode ? 'Module Permissions updated successfully' :'Module Permissions created successfully'; XAUtil.notifySuccess('Success', msg); - App.appRouter.navigate("#!/permissions",{trigger: true}); + App.appRouter.navigate("#!/permissions/models",{trigger: true}); }, error : function(model,resp){ XAUtil.blockUI('unblock'); @@ -132,7 +132,7 @@ define(function(require){ }, onCancel : function(){ XAUtil.allowNavigation(); - App.appRouter.navigate("#!/permissions",{trigger: true}); + App.appRouter.navigate("#!/permissions/models",{trigger: true}); }, /** on close */ 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 9db72a7..798fe79 100644 --- a/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/permissions/ModulePermsTableLayout.js @@ -81,7 +81,7 @@ define(function(require){ initialize: function(options) { console.log("initialized a ModulePermsTableLayout Layout"); - _.extend(this, _.pick(options)); + _.extend(this, _.pick(options, 'urlQueryParams')); this.bindEvents(); }, @@ -97,9 +97,11 @@ define(function(require){ /** on render callback */ onRender: function() { //this.initializePlugins(); - this.addVisualSearch(); this.renderTable(); - this.initializeModulePerms(); + this.addVisualSearch(); + if(_.isUndefined(this.urlQueryParams)) { + this.initializeModulePerms(); + } }, /** all post render plugin initialization */ initializePlugins: function(){ @@ -220,20 +222,30 @@ define(function(require){ $td.find('[data-id="showMore"]['+attrName+'="'+id+'"]').parents('div[data-id="groupsDiv"]').removeClass('set-height-groups'); }, addVisualSearch : function(){ - var that = this; - 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) { - } - } - } - }; + var that = this, query = ''; + var searchOpt = ['Module Name','Group Name','User Name']; + var serverAttrName = [{text : "Module Name", label :"module", urlLabel : "moduleName"}, + {text : "Group Name", label :"groupName", urlLabel : "groupName"}, + {text : "User Name", label :"userName", urlLabel : "userName"} + ]; + if(!_.isUndefined(this.urlQueryParams)) { + var urlQueryParams = XAUtil.changeUrlToSearchQuery(this.urlQueryParams); + _.map(urlQueryParams, function(val , key) { + query += '"'+XAUtil.filterKeyForVSQuery(serverAttrName, key)+'":"'+val+'"'; + }); + // query += XAUtil.changeUrlToVSSearchQuery(this.urlQueryParams); + } + var pluginAttr = { + placeholder :localization.tt('h.searchForPermissions'), + container : this.ui.visualSearch, + query : query, + callbacks : { + valueMatches :function(facet, searchTerm, callback) { + switch (facet) { + } + } + } + }; window.vs = XAUtil.addVisualSearch(searchOpt,serverAttrName, this.collection,pluginAttr); }, getActiveStatusNVList : function() { 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 1209c6d..4ee9487 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js @@ -111,12 +111,32 @@ define(function(require){ */ initialize: function(options) { console.log("initialized a RangerPolicyTableLayout Layout"); - _.extend(this, _.pick(options,'rangerService')); + _.extend(this, _.pick(options,'rangerService', 'urlQueryParams')); this.bindEvents(); this.initializeServiceDef(); + if(_.isUndefined(App.vZone)) { + App.vZone = {}; + } + if(App.vZone && App.vZone.vZoneName && !_.isEmpty(App.vZone.vZoneName)) { + XAUtil.changeParamToUrlFragment({"securityZone" : App.vZone.vZoneName}, this.collection.modelName); + } + if (!_.isUndefined(this.urlQueryParams)) { + var searchFregment = XAUtil.changeUrlToSearchQuery(decodeURIComponent(this.urlQueryParams)); + if(_.has(searchFregment, 'securityZone')) { + App.vZone.vZoneName = searchFregment['securityZone']; + searchFregment = _.omit(searchFregment, 'securityZone'); + if(_.isEmpty(searchFregment)) { + this.urlQueryParams = ''; + } else { + this.urlQueryParams = $.param(searchFregment); + } + } else { + App.vZone.vZoneName = ""; + } + } }, - /** all events binding here */ + /** all events binding here */ bindEvents : function(){ //this.listenTo(this.collection, "sync", this.render, this); }, @@ -137,16 +157,18 @@ define(function(require){ if(!_.isUndefined(App.vZone) && App.vZone.vZoneName){ this.collection.queryParams['zoneName'] = App.vZone.vZoneName; } - this.collection.fetch({ - cache : false, - }); }, /** on render callback */ onRender: function() { this.setTabForPolicyListing(); - this.addVisualSearch(); this.renderTable(); this.initializePolicies(); + this.addVisualSearch(); + if(_.isUndefined(this.urlQueryParams) || _.isEmpty(this.urlQueryParams)) { + this.collection.fetch ({ + cache : false, + }) + } XAUtil.searchInfoPopover(this.searchInfoArray , this.ui.iconSearchInfo , 'bottom'); }, @@ -428,7 +450,7 @@ define(function(require){ addVisualSearch : function(){ - var that = this, resources = this.rangerServiceDefModel.get('resources'); + var that = this, resources = this.rangerServiceDefModel.get('resources'), query = ''; var policyType = this.collection.queryParams['policyType']; if(XAUtil.isMaskingPolicy(policyType) ){ if(!_.isEmpty(this.rangerServiceDefModel.get('dataMaskDef').resources)){ @@ -446,11 +468,11 @@ define(function(require){ var searchOpt = ['Policy Name','Group Name','User Name','Status', 'Policy Label'];//,'Start Date','End Date','Today']; searchOpt = _.union(searchOpt, _.map(resourceSearchOpt, function(opt){ return opt.label })) - var serverAttrName = [{text : "Group Name", label :"group", info:localization.tt('h.groupNameMsg')}, - {text : "Policy Name", label :"policyNamePartial", info :localization.tt('msg.policyNameMsg')}, - {text : "Status", info : localization.tt('msg.statusMsg') , label :"isEnabled",'multiple' : true, 'optionsArr' : PolicyStatusValue}, - {text : "User Name", label :"user" , info :localization.tt('h.userMsg')}, - {text : "Policy Label", label :"policyLabelsPartial" , info :localization.tt('h.policyLabelsinfo')}, + var serverAttrName = [{text : "Group Name", label :"group", info:localization.tt('h.groupNameMsg'), urlLabel : 'groupName'}, + {text : "Policy Name", label :"policyNamePartial", info :localization.tt('msg.policyNameMsg'), urlLabel : 'policyName'}, + {text : "Status", info : localization.tt('msg.statusMsg') , label :"isEnabled",'multiple' : true, 'optionsArr' : PolicyStatusValue, urlLabel : 'status'}, + {text : "User Name", label :"user" , info :localization.tt('h.userMsg'), urlLabel : 'userName'}, + {text : "Policy Label", label :"policyLabelsPartial" , info :localization.tt('h.policyLabelsinfo'), urlLabel : 'policyLabel'}, ]; // {text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'}, // {text : 'Today',label :'today'}]; @@ -471,15 +493,23 @@ define(function(require){ 'text': opt.label, 'label': 'resource:'+ opt.name, 'info' : info[opt.name], + 'urlLabel' : XAUtil.stringToCamelCase(opt.label.toLowerCase()), }; }); serverAttrName = _.union(serverAttrName, serverRsrcAttrName) this.searchInfoArray = serverAttrName; + if(!_.isUndefined(this.urlQueryParams)) { + var urlQueryParams = XAUtil.changeUrlToSearchQuery(this.urlQueryParams); + _.map(urlQueryParams, function(val , key) { + query += '"'+XAUtil.filterKeyForVSQuery(serverAttrName, key)+'":"'+val+'"'; + }); + // query += XAUtil.changeUrlToVSSearchQuery(this.urlQueryParams); + } var pluginAttr = { - placeholder :localization.tt('h.searchForPolicy'), - container : this.ui.visualSearch, - query : '', - callbacks : { + placeholder :localization.tt('h.searchForPolicy'), + container : this.ui.visualSearch, + query : query, + callbacks : { valueMatches :function(facet, searchTerm, callback) { switch (facet) { case 'Status': @@ -487,21 +517,7 @@ define(function(require){ break; case 'Policy Type': callback(that.getNameOfPolicyTypeNVList()); -// callback(XAUtil.enumToSelectLabelValuePairs(XAEnums.PolicyType)); break; - /* case 'Audit Status': - callback(XAUtil.enumToSelectLabelValuePairs(XAEnums.AuthType)); - break; - case 'Start Date' : - setTimeout(function () { XAUtil.displayDatepicker(that.ui.visualSearch, callback); }, 0); - break; - case 'End Date' : - setTimeout(function () { XAUtil.displayDatepicker(that.ui.visualSearch, callback); }, 0); - break; - case 'Today' : - var today = Globalize.format(new Date(),"yyyy/mm/dd"); - callback([today]); - break;*/ } } 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 d190686..de81182 100644 --- a/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js +++ b/security-admin/src/main/webapp/scripts/views/policymanager/ServiceLayout.js @@ -111,6 +111,13 @@ define(function(require){ vZoneName: "" } } + if(this.type && this.type.split('?')[1]) { + var searchFregment = XAUtil.changeUrlToSearchQuery(decodeURIComponent(this.type.substring(this.type.indexOf("?") + 1))); + console.log(searchFregment); + if(_.has(searchFregment, 'securityZone')) { + App.vZone.vZoneName = searchFregment['securityZone']; + } + } }, /** all events binding here */ @@ -313,8 +320,11 @@ define(function(require){ App.vZone.vZoneName = e.val; if(e.added){ App.vZone.vZoneId = e.added.zoneId; + XAUtil.changeParamToUrlFragment({"securityZone" : e.val}, that.collection.modelName); } else { App.vZone.vZoneId = null; + //for url change on UI + XAUtil.changeParamToUrlFragment(); } var rBreadcrumbsText = !_.isEmpty(App.vZone.vZoneName) ? 'Service Manager : ' + App.vZone.vZoneName + ' zone' : 'Service Manager'; App.rBreadcrumbs.currentView.breadcrumb[0].text = rBreadcrumbsText; 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 b0cb508..7345f5a 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js +++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js @@ -126,16 +126,35 @@ define(function(require) { console.log("initialized a AuditLayout Layout"); _.extend(this, _.pick(options, 'accessAuditList','tab')); + var that = this; this.bindEvents(); - this.currentTab = '#'+this.tab; + this.currentTab = '#'+this.tab.split('?')[0]; var date = new Date().toString(); this.timezone = date.replace(/^.*GMT.*\(/, "").replace(/\)$/, ""); this.initializeServiceDefColl(); if(_.isUndefined(App.vsHistory)){ - var startDateModel = new Backbone.Model({'category':'Start Date', value:Globalize.format(new Date(),"MM/dd/yyyy")}); - App.vsHistory = {'bigData':[startDateModel], 'admin':[], 'loginSession':[], 'plugin':[],'pluginStatus':[], 'userSync': []}; + App.vsHistory = {'bigData':[], 'admin':[], 'loginSession':[], 'agent':[],'pluginStatus':[], 'userSync': []}; } - }, + //Add url params to vsHistory + if(!_.isUndefined(this.tab.split('?')[1])) { + App.vsHistory[that.tab.split('?')[0]] = []; + var searchFregment = XAUtils.changeUrlToSearchQuery(decodeURIComponent(this.tab.substring(this.tab.indexOf("?") + 1))); + _.map (searchFregment, function(val, key) { + if (_.isArray(val)) { + _.map(val, function (v) { + App.vsHistory[that.tab.split('?')[0]].push(new Backbone.Model( {'category': key, 'value' : v})); + }) + } else { + App.vsHistory[that.tab.split('?')[0]].push(new Backbone.Model( {'category': key, 'value' : val})); + } + } ) + } + //if url params are not present then set a default value in Audit assecc vsHistory + if(_.isEmpty(App.vsHistory.bigData)){ + var startDateModel = new Backbone.Model({'category':'startDate', value:Globalize.format(new Date(),"MM/dd/yyyy")}); + App.vsHistory['bigData'].push(startDateModel); + } + }, /** all events binding here */ bindEvents : function() { @@ -219,7 +238,10 @@ define(function(require) { var that = this, tab; tab = !_.isUndefined(e) ? $(e.currentTarget).attr('href') : this.currentTab; this.$el.parents('body').find('.datepicker').remove(); - switch (tab) { + if (!_.isUndefined(e)) { + Backbone.history.navigate("!/reports/audit/"+ tab.slice(1), false) + } + switch (tab) { case "#bigData": this.currentTab = '#bigData'; //Remove empty search values on tab changes for visual search. @@ -272,12 +294,12 @@ define(function(require) { break; case "#agent": this.currentTab = '#agent'; - App.vsHistory.plugin = XAUtils.removeEmptySearchValue(App.vsHistory.plugin); + App.vsHistory.agent = XAUtils.removeEmptySearchValue(App.vsHistory.agent); this.policyExportAuditList = new VXPolicyExportAuditList(); var params = { priAcctId : 1 }; that.renderAgentTable(); this.policyExportAuditList.setSorting('createDate',1); - if(_.isEmpty(App.vsHistory.plugin)){ + if(_.isEmpty(App.vsHistory.agent)){ this.policyExportAuditList.fetch({ cache : false, data :params @@ -337,18 +359,25 @@ define(function(require) { var that = this , query = ''; var serverListForRepoType = this.serviceDefList.map(function(serviceDef){ return {'label' : serviceDef.get('name').toUpperCase(), 'value' : serviceDef.get('id')}; }) var serviceUser = [{'label' : 'True' , 'value' : true},{'label' : 'False' , 'value' : false}] - var serverAttrName = [{text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'}, - {text : 'Application',label : 'agentId'}, - {text : 'User',label :'requestUser', 'addMultiple': true}, - {text : 'Exclude User',label :'excludeUser', 'addMultiple': true}, - {text : 'Resource Name',label :'resourcePath'}, - {text : 'Service Name',label :'repoName'},{text : 'Policy ID',label :'policyId'}, - {text : 'Service Type',label :'repoType','multiple' : true, 'optionsArr' : serverListForRepoType}, - {text : 'Result',label :'accessResult', 'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.AccessResult)}, - {text : 'Access Type',label :'accessType'},{text : 'Access Enforcer',label :'aclEnforcer'}, - {text : 'Client IP',label :'clientIP'},{text : 'Tags',label :'tags'}, - {text : 'Resource Type',label : 'resourceType'},{text : 'Cluster Name',label : 'cluster'}, - {text : 'Zone Name',label : 'zoneName'},{text : localization.tt("lbl.agentHost"), label :"agentHost"}]; + var serverAttrName = [{text : 'Start Date', label :'startDate', urlLabel : 'startDate'}, + {text : 'End Date', label :'endDate', urlLabel : 'endDate'}, + {text : 'Application', label : 'agentId', urlLabel : 'application'}, + {text : 'User', label :'requestUser', 'addMultiple': true, urlLabel : 'user'}, + {text : 'Exclude User', label :'excludeUser', 'addMultiple': true, urlLabel : 'excludeUser'}, + {text : 'Resource Name',label :'resourcePath', urlLabel : 'resourceName'}, + {text : 'Service Name', label :'repoName', urlLabel : 'serviceName'}, + {text : 'Policy ID', label :'policyId', urlLabel : 'policyID'}, + {text : 'Service Type',label :'repoType','multiple' : true, 'optionsArr' : serverListForRepoType, urlLabel : 'serviceType'}, + {text : 'Result', label :'accessResult', 'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.AccessResult), urlLabel : 'result'}, + {text : 'Access Type', label :'accessType', urlLabel : 'accessType'}, + {text : 'Access Enforcer',label :'aclEnforcer', urlLabel : 'accessEnforcer'}, + {text : 'Client IP',label :'clientIP', urlLabel : 'clientIP'}, + {text : 'Tags',label :'tags', urlLabel : 'tags'}, + {text : 'Resource Type',label : 'resourceType', urlLabel : 'resourceType'}, + {text : 'Cluster Name',label : 'cluster', urlLabel : 'clusterName'}, + {text : 'Zone Name',label : 'zoneName', urlLabel : 'zoneName'}, + {text : localization.tt("lbl.agentHost"), label :"agentHost", urlLabel : 'agentHost'} + ]; var searchOpt = ['Resource Type','Start Date','End Date','Application','User','Service Name','Service Type','Resource Name','Access Type','Result','Access Enforcer', 'Client IP','Tags','Cluster Name', 'Zone Name', 'Exclude User', localization.tt("lbl.agentHost")];//,'Policy ID' this.clearVisualSearch(this.accessAuditList, serverAttrName); @@ -372,10 +401,12 @@ define(function(require) { XAUtils.searchInfoPopover(this.searchInfoArr , this.ui.iconSearchInfo , 'bottom'); //Set query(search filter values in query) if(_.isEmpty(App.vsHistory.bigData)){ - query = '"Start Date": "'+Globalize.format(new Date(),"MM/dd/yyyy")+'"'; - App.vsHistory.bigData.push(new Backbone.Model({'category':'Start Date', value:Globalize.format(new Date(),"MM/dd/yyyy")})); + query = '"startDate": "'+Globalize.format(new Date(),"MM/dd/yyyy")+'"'; + App.vsHistory.bigData.push(new Backbone.Model({'category':'startDate', value:Globalize.format(new Date(),"MM/dd/yyyy")})); }else{ - _.map(App.vsHistory.bigData, function(a){ query += '"'+a.get('category')+'":"'+a.get('value')+'"'; }); + _.map(App.vsHistory.bigData, function(a) { + query += '"'+XAUtils.filterKeyForVSQuery(serverAttrName, a.get('category'))+'":"'+a.get('value')+'"'; + }); } var pluginAttr = { placeholder :localization.tt('h.searchForYourAccessAudit'), @@ -474,10 +505,13 @@ define(function(require) { addSearchForAdminTab : function(){ var that = this; var searchOpt = ["Audit Type", "User", "Actions", "Session ID", "Start Date", "End Date"]; - var serverAttrName = [{text : "Audit Type", label :"objectClassType",'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.ClassTypes)}, - {text : "User", label :"owner"}, {text : "Session ID", label :"sessionId"}, - {text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'}, - {text : "Actions", label :"action",'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAGlobals.ActionType)},]; + var serverAttrName = [{text : "Audit Type", label :"objectClassType",'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.ClassTypes), urlLabel : 'auditType'}, + {text : "User", label :"owner", urlLabel : 'user'}, + {text : "Session ID", label :"sessionId", urlLabel : 'sessionId'}, + {text : 'Start Date',label :'startDate', urlLabel : 'startDate'}, + {text : 'End Date',label :'endDate', urlLabel : 'endDate'}, + {text : "Actions", label :"action",'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAGlobals.ActionType), urlLabel : 'actions'} + ]; var auditList = [],query = '', actionTypeList = []; _.each(XAEnums.ClassTypes, function(obj){ @@ -495,12 +529,14 @@ define(function(require) { } }) if(!_.isUndefined(App.sessionId)){ - App.vsHistory.admin = [] ; + App.vsHistory.admin = [] ; query = '"Session ID": "'+App.sessionId+'"'; - App.vsHistory.admin.push(new Backbone.Model({'category':'Session ID', value:App.sessionId})); + App.vsHistory.admin.push(new Backbone.Model({'category':'Session ID', value:App.sessionId})); delete App.sessionId; - }else{ - _.map(App.vsHistory.admin, function(a){ query += '"'+a.get('category')+'":"'+a.get('value')+'"'; }); + }else{ + _.map(App.vsHistory.admin, function(a) { + query += '"'+XAUtils.filterKeyForVSQuery(serverAttrName, a.get('category'))+'":"'+a.get('value')+'"'; + }); } var pluginAttr = { placeholder :localization.tt('h.searchForYourAccessLog'), @@ -544,13 +580,18 @@ define(function(require) { addSearchForLoginSessionTab : function(){ var that = this , query = '' ; var searchOpt = ["Session ID", "Login ID", "Result", "Login Type", "IP", "User Agent", "Start Date","End Date"]; - var serverAttrName = [{text : "Session ID", label :"id"}, {text : "Login ID", label :"loginId"}, - {text : "Result", label :"authStatus",'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.AuthStatus)}, - {text : "Login Type", label :"authType",'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.AuthType)}, - {text : "IP", label :"requestIP"},{text :"User Agent", label :"requestUserAgent"}, - {text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'} ]; - - _.map(App.vsHistory.loginSession, function(m){ query += '"'+m.get('category')+'":"'+m.get('value')+'"'; }); + var serverAttrName = [{text : "Session ID", label :"id", urlLabel : 'sessionID'}, + {text : "Login ID", label :"loginId", urlLabel : 'loginID'}, + {text : "Result", label :"authStatus",'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.AuthStatus), urlLabel : 'result'}, + {text : "Login Type", label :"authType",'multiple' : true, 'optionsArr' : XAUtils.enumToSelectLabelValuePairs(XAEnums.AuthType), urlLabel : 'loginType'}, + {text : "IP", label :"requestIP", urlLabel : 'requestIP'}, + {text :"User Agent", label :"requestUserAgent", urlLabel : 'userAgent'}, + {text : 'Start Date',label :'startDate', urlLabel : 'startDate'}, + {text : 'End Date',label :'endDate', urlLabel : 'endDate'} + ]; + _.map(App.vsHistory.loginSession, function(m) { + query += '"'+XAUtils.filterKeyForVSQuery(serverAttrName, m.get('category'))+'":"'+m.get('value')+'"'; + }); var pluginAttr = { placeholder :localization.tt('h.searchForYourLoginSession'), container : this.ui.visualSearch, @@ -600,12 +641,17 @@ define(function(require) { addSearchForAgentTab : function(){ var that = this , query = ''; var searchOpt = ["Service Name", "Plugin ID", "Plugin IP", "Http Response Code", "Start Date","End Date", "Cluster Name"]; - var serverAttrName = [{text : "Plugin ID", label :"agentId"}, {text : "Plugin IP", label :"clientIP"}, - {text : "Service Name", label :"repositoryName"},{text : "Http Response Code", label :"httpRetCode"}, - {text : "Export Date", label :"createDate"}, - {text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'}, - {text : 'Cluster Name',label :'cluster'}]; - _.map(App.vsHistory.plugin, function(m){ query += '"'+m.get('category')+'":"'+m.get('value')+'"'; }); + var serverAttrName = [{text : "Plugin ID", label :"agentId", urlLabel : 'pluginID'}, + {text : "Plugin IP", label :"clientIP", urlLabel : 'pluginIP'}, + {text : "Service Name", label :"repositoryName", urlLabel : 'serviceName'}, + {text : "Http Response Code", label :"httpRetCode", urlLabel : 'httpResponseCode'}, + {text : "Export Date", label :"createDate", urlLabel : 'exportDate'}, + {text : 'Start Date',label :'startDate', urlLabel : 'startDate'}, + {text : 'End Date',label :'endDate', urlLabel : 'endDate'}, + {text : 'Cluster Name',label :'cluster', urlLabel : 'clusterName'}]; + _.map(App.vsHistory.agent, function(m) { + query += '"'+XAUtils.filterKeyForVSQuery(serverAttrName, m.get('category'))+'":"'+m.get('value')+'"'; + }); var pluginAttr = { placeholder :localization.tt('h.searchForYourAgent'), container : this.ui.visualSearch, @@ -646,16 +692,21 @@ define(function(require) { } }; this.visualSearch = XAUtils.addVisualSearch(searchOpt,serverAttrName, this.policyExportAuditList, pluginAttr); - this.setEventsToFacets(this.visualSearch, App.vsHistory.plugin); + this.setEventsToFacets(this.visualSearch, App.vsHistory.agent); }, addSearchForPluginStatusTab : function(){ var that = this , query = ''; var searchOpt = [localization.tt("lbl.serviceName"), localization.tt("lbl.serviceType"),localization.tt("lbl.applicationType"), localization.tt("lbl.agentIp"), localization.tt("lbl.hostName"), localization.tt("lbl.clusterName")]; - var serverAttrName = [{text : localization.tt("lbl.serviceName"), label :"serviceName"},{text : localization.tt("lbl.applicationType"), label :"pluginAppType"}, - {text : localization.tt("lbl.agentIp"), label :"pluginIpAddress"}, {text : localization.tt("lbl.hostName"), label :"pluginHostName"}, - {text : localization.tt("lbl.serviceType"), label :"serviceType"}, {text : localization.tt("lbl.clusterName"),label :'clusterName'}]; - _.map(App.vsHistory.pluginStatus, function(m){ query += '"'+m.get('category')+'":"'+m.get('value')+'"'; }); + var serverAttrName = [{text : localization.tt("lbl.serviceName"), label :"serviceName", urlLabel : 'serviceName'}, + {text : localization.tt("lbl.applicationType"), label :"pluginAppType", urlLabel : 'applicationType'}, + {text : localization.tt("lbl.agentIp"), label :"pluginIpAddress", urlLabel : 'agentIp'}, + {text : localization.tt("lbl.hostName"), label :"pluginHostName", urlLabel : 'hostName'}, + {text : localization.tt("lbl.serviceType"), label :"serviceType", urlLabel : 'serviceType'}, + {text : localization.tt("lbl.clusterName"),label :'clusterName', urlLabel : 'clusterName'}]; + _.map(App.vsHistory.pluginStatus, function(m) { + query += '"'+XAUtils.filterKeyForVSQuery(serverAttrName, m.get('category'))+'":"'+m.get('value')+'"'; + }); var pluginAttr = { placeholder : localization.tt('msg.searchForPluginStatus'), container : this.ui.visualSearch, @@ -712,13 +763,17 @@ define(function(require) { addSearchForUserSyncTab : function(){ var that = this , query = ''; var searchOpt = [localization.tt("lbl.userName"), localization.tt("lbl.syncSource"), localization.tt("lbl.startDate"), localization.tt("lbl.endDate")]; - var serverAttrName = [{text : localization.tt("lbl.userName"), label :"userName"},{text : localization.tt("lbl.syncSource"), label :"syncSource"}, - {text : 'Start Date',label :'startDate'},{text : 'End Date',label :'endDate'}]; + var serverAttrName = [{text : localization.tt("lbl.userName"), label :"userName", urlLabel : 'userName'}, + {text : localization.tt("lbl.syncSource"), label :"syncSource", urlLabel : 'syncSource'}, + {text : 'Start Date',label :'startDate', urlLabel : 'startDate'}, + {text : 'End Date',label :'endDate', urlLabel : 'endDate'}]; if(_.isEmpty(App.vsHistory.userSync)){ - query = '"Start Date": "'+Globalize.format(new Date(),"MM/dd/yyyy")+'"'; - App.vsHistory.userSync.push(new Backbone.Model({'category':'Start Date', value:Globalize.format(new Date(),"MM/dd/yyyy")})); + query = '"startDate": "'+Globalize.format(new Date(),"MM/dd/yyyy")+'"'; + App.vsHistory.userSync.push(new Backbone.Model({'category':'startDate', value:Globalize.format(new Date(),"MM/dd/yyyy")})); }else{ - _.map(App.vsHistory.userSync, function(a){ query += '"'+a.get('category')+'":"'+a.get('value')+'"'; }); + _.map(App.vsHistory.userSync, function(a) { + query += '"'+XAUtils.filterKeyForVSQuery(serverAttrName, a.get('category'))+'":"'+a.get('value')+'"'; + }); } var pluginAttr = { placeholder : localization.tt('msg.searchForUserSync'), diff --git a/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js b/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js index 4050849..d1f421f 100755 --- a/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js @@ -92,7 +92,7 @@ define(function(require){ initialize: function(options) { console.log("initialized a UserTableLayout Layout"); - _.extend(this, _.pick(options, 'groupList','tab', 'roleList')); + _.extend(this, _.pick(options, 'groupList','tab', 'roleList', 'urlQueryParams')); this.showUsers = this.tab == 'usertab' ? true : false; this.showGroups = this.tab == 'grouptab' ? true : false; this.chgFlags = []; @@ -117,18 +117,11 @@ define(function(require){ /** on render callback */ onRender: function() { this.initializePlugins(); - if(this.tab == 'grouptab'){ - this.renderGroupTab(); - } else if(this.tab == 'usertab'){ - this.renderUserTab(); - } else{ - this.renderRoleTab(); - } + this.renderTable(); this.bindEventToColl(this.collection); this.bindEventToColl(this.groupList); this.bindEventToColl(this.roleList); - this.addVisualSearch(); - }, + }, bindEventToColl : function(coll){ if(_.isUndefined(coll)) return; this.listenTo(coll, "sync reset", function(){ @@ -149,21 +142,30 @@ define(function(require){ }, onTabChange : function(e){ var that = this; - this.chgFlags = []; - this.showUsers = $(e.currentTarget).attr('href') == '#users' ? true : false; - this.showGroups = $(e.currentTarget).attr('href') == '#groups' ? true : false; - if(this.showUsers){ - this.renderUserTab(); - this.addVisualSearch(); - } else if(this.showGroups){ - this.renderGroupTab(); - this.addVisualSearch(); - }else{ - this.renderRoleTab(); - this.addVisualSearch(); - } + if (!_.isUndefined(e)) { + var nav = e.currentTarget.hash === "#users" ? "#!/users/usertab" : (e.currentTarget.hash === "#groups" ? + "#!/users/grouptab" : "#!/users/roletab"); + App.appRouter.navigate(nav,{trigger: false}); + this.showUsers = $(e.currentTarget).attr('href') == '#users' ? true : false; + this.showGroups = $(e.currentTarget).attr('href') == '#groups' ? true : false; + this.urlQueryParams = ''; + } + this.renderTable(); + this.chgFlags = []; $(this.rUserDetail.el).hide(); }, + + renderTable : function() { + // this.addVisualSearch(); + if(this.showUsers){ + this.renderUserTab(); + } else if(this.showGroups){ + this.renderGroupTab(); + } else { + this.renderRoleTab(); + } + }, + onVisibilityChange : function(e){ var that = this; var status = $(e.currentTarget).attr('data-id') == 'visible' ? true : false; @@ -237,13 +239,18 @@ define(function(require){ var that = this; this.ui.addNewRoles.hide(); this.ui.hideShowVisibility.show(); - if(_.isUndefined(this.collection)){ + if(_.isUndefined(this.collection) || _.isUndefined(this.urlQueryParams) || _.isEmpty(this.urlQueryParams)){ this.collection = new VXUserList(); - } + } this.collection.selectNone(); this.renderUserListTable(); - _.extend(this.collection.queryParams, XAUtil.getUserDataParams()) - this.collection.fetch({ + _.extend(this.collection.queryParams, XAUtil.getUserDataParams()); + this.ui.addNewGroup.hide(); + this.ui.addNewUser.show(); + this.$('.wrap-header').text('User List'); + this.addVisualSearch(); + if (_.isUndefined(this.urlQueryParams) || _.isEmpty(this.urlQueryParams)) { + this.collection.fetch({ reset: true, cache: false }).done(function(userList){ @@ -259,24 +266,28 @@ define(function(require){ _.last(userList.models).trigger("model:highlightUserGroupTableRow"); } } - if(!_.isString(that.ui.addNewGroup)){ - that.ui.addNewGroup.hide(); - that.ui.addNewUser.show(); - } - that.$('.wrap-header').text('User List'); that.checkRoleKeyAdmin(); }); + } }, renderGroupTab : function(){ var that = this; - this.ui.addNewRoles.hide(); - this.ui.hideShowVisibility.show(); - if(_.isUndefined(this.groupList)){ + this.ui.addNewRoles.hide(); + this.ui.hideShowVisibility.show(); + if(_.isUndefined(this.groupList) || _.isUndefined(this.urlQueryParams) || _.isEmpty(this.urlQueryParams)){ this.groupList = new VXGroupList(); } this.groupList.selectNone(); this.renderGroupListTable(); - this.groupList.fetch({ + this.addVisualSearch(); + this.ui.addNewUser.hide(); + this.ui.addNewGroup.show(); + this.$('.wrap-header').text('Group List'); + this.$('ul').find('[data-js="groups"]').addClass('active'); + this.$('ul').find('[data-js="users"]').removeClass(); + this.$('ul').find('[data-js="roles"]').removeClass(); + if (_.isUndefined(this.urlQueryParams) || _.isEmpty(this.urlQueryParams)) { + this.groupList.fetch({ reset:true, cache: false, }).done(function(groupList){ @@ -292,46 +303,44 @@ define(function(require){ } App.usersGroupsListing={}; } - that.ui.addNewUser.hide(); - that.ui.addNewGroup.show(); - that.$('.wrap-header').text('Group List'); - that.$('ul').find('[data-js="groups"]').addClass('active'); - that.$('ul').find('[data-js="users"]').removeClass(); that.checkRoleKeyAdmin(); }); + } }, renderRoleTab : function(){ var that = this; this.ui.hideShowVisibility.hide(); - if(_.isUndefined(this.roleList)){ + if(_.isUndefined(this.roleList) || _.isUndefined(this.urlQueryParams) || _.isEmpty(this.urlQueryParams)){ this.roleList = new VXRoleList(); } + this.ui.addNewUser.hide(); + this.ui.addNewGroup.hide(); + this.ui.addNewRoles.show(); + this.$('.wrap-header').text('Role List'); + this.$('ul').find('[data-js="roles"]').addClass('active'); + this.$('ul').find('[data-js="users"]').removeClass(); + this.$('ul').find('[data-js="groups"]').removeClass(); this.renderRoleListTable(); - this.roleList.fetch({ - reset:true, - cache: false, - }).done(function(roleList){ - if(App.usersGroupsListing && !_.isEmpty(App.usersGroupsListing) && App.usersGroupsListing.showLastPage){ - if(roleList.state.totalRecords > roleList.state.pageSize){ - that.roleList.getLastPage({ - cache : false, - }).done(function(m){ - (_.last(m.models)).trigger("model:highlightUserGroupTableRow"); - }); - }else{ - (_.last(roleList.models)).trigger("model:highlightUserGroupTableRow"); - } - App.usersGroupsListing={}; - } - that.ui.addNewUser.hide(); - that.ui.addNewGroup.hide(); - that.ui.addNewRoles.show(); - that.$('.wrap-header').text('Role List'); - that.$('ul').find('[data-js="roles"]').addClass('active'); - that.$('ul').find('[data-js="users"]').removeClass(); - that.$('ul').find('[data-js="groups"]').removeClass(); - // that.checkRoleKeyAdmin(); - }); + this.addVisualSearch(); + if(_.isUndefined(this.urlQueryParams) || _.isEmpty(this.urlQueryParams)) { + this.roleList.fetch({ + reset:true, + cache: false, + }).done(function(roleList){ + if(App.usersGroupsListing && !_.isEmpty(App.usersGroupsListing) && App.usersGroupsListing.showLastPage){ + if(roleList.state.totalRecords > roleList.state.pageSize){ + that.roleList.getLastPage({ + cache : false, + }).done(function(m){ + (_.last(m.models)).trigger("model:highlightUserGroupTableRow"); + }); + }else{ + (_.last(roleList.models)).trigger("model:highlightUserGroupTableRow"); + } + App.usersGroupsListing={}; + } + }); + } }, renderUserListTable : function(){ var that = this; @@ -961,37 +970,43 @@ define(function(require){ coll = this.collection; searchOpt = ['User Name','Email Address','Visibility', 'Role','User Source','User Status'];//,'Start Date','End Date','Today']; var userRoleList = _.map(XAEnums.UserRoles,function(obj,key){return {label:obj.label,value:key};}); - serverAttrName = [ {text : "User Name", label :"name"}, - {text : "Email Address", label :"emailAddress"}, - {text : "Role", label :"userRole", 'multiple' : true, 'optionsArr' : userRoleList}, - {text : "Visibility", label :"isVisible", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.VisibilityStatus)}, - {text : "User Source", label :"userSource", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.UserTypes)}, - {text : "User Status", label :"status", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.ActiveStatus)}, - ]; + serverAttrName = [{text : "User Name", label :"name", urlLabel : "userName"}, + {text : "Email Address", label :"emailAddress", urlLabel : "emailAddress"}, + {text : "Role", label :"userRole", 'multiple' : true, 'optionsArr' : userRoleList, urlLabel : "role"}, + {text : "Visibility", label :"isVisible", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.VisibilityStatus), urlLabel : "visibility"}, + {text : "User Source", label :"userSource", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.UserTypes), urlLabel : "userSource"}, + {text : "User Status", label :"status", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.ActiveStatus), urlLabel : "userStatus"}, + ]; } else if(this.showGroups){ placeholder = localization.tt('h.searchForYourGroup'); coll = this.groupList; searchOpt = ['Group Name','Group Source', 'Visibility'];//,'Start Date','End Date','Today']; - serverAttrName = [{text : "Group Name", label :"name"}, - {text : "Visibility", label :"isVisible", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.VisibilityStatus)}, - {text : "Group Source", label :"groupSource", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.GroupTypes)},]; - + serverAttrName = [{text : "Group Name", label :"name", urlLabel : "groupName"}, + {text : "Visibility", label :"isVisible", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.VisibilityStatus), urlLabel : "visibility"}, + {text : "Group Source", label :"groupSource", 'multiple' : true, 'optionsArr' : XAUtil.enumToSelectLabelValuePairs(XAEnums.GroupTypes), urlLabel : "groupSource"} + ]; } else{ placeholder = localization.tt('h.searchForYourRole'); coll = this.roleList; searchOpt = ['Role Name','User Name', 'Group Name', /*Role ID*/];//,'Start Date','End Date','Today']; - serverAttrName = [{text : "Role Name", label :"roleName"}, - {text : "User Name", label :"userName"}, - {text : "Group Name", label :"groupName"}, - // {text : "Role ID", label : "roleId"} - ]; - } - var query = (!_.isUndefined(coll.VSQuery)) ? coll.VSQuery : ''; + serverAttrName = [{text : "Role Name", label :"roleName", urlLabel : "roleName"}, + {text : "User Name", label :"userName", urlLabel : "userName"}, + {text : "Group Name", label :"groupName", urlLabel : "groupName"}, + ]; + } + var query = ''; + if(!_.isUndefined(this.urlQueryParams) && !_.isEmpty(this.urlQueryParams)) { + var urlQueryParams = XAUtil.changeUrlToSearchQuery(this.urlQueryParams); + _.map(urlQueryParams, function(val , key) { + query += '"'+XAUtil.filterKeyForVSQuery(serverAttrName, key)+'":"'+val+'"'; + }); + // query += XAUtil.changeUrlToVSSearchQuery(this.urlQueryParams); + } var pluginAttr = { placeholder :placeholder, container : this.ui.visualSearch, query : query, - callbacks : { + callbacks : { valueMatches :function(facet, searchTerm, callback) { switch (facet) { case 'Role': 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 8ed90aa..cfb5eac 100644 --- a/security-admin/src/main/webapp/templates/common/TopNav_tmpl.html +++ b/security-admin/src/main/webapp/templates/common/TopNav_tmpl.html @@ -61,7 +61,7 @@ <li><a href="#!/users/usertab"><i class="icon-group"></i>{{tt 'h.usersOrGroupsOrRoles'}}</a></li> {{/hasAccessToTab}} {{#if showPermissionTab}} - <li><a href="#!/permissions"><i class="icon-file-alt"></i> {{tt 'h.permissions'}}</a></li> + <li><a href="#!/permissions/models"><i class="icon-file-alt"></i> {{tt 'h.permissions'}}</a></li> {{/if}} </ul> </li>
