RANGER-274: UI updates to fix 404 error page after deleting a servicfixese

Signed-off-by: Madhan Neethiraj <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/e2075ffa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/e2075ffa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/e2075ffa

Branch: refs/heads/master
Commit: e2075ffa93d727c49f04d3ce937a87bd6b966cbe
Parents: b6728b7
Author: Gautam Borad <[email protected]>
Authored: Tue Sep 29 16:28:06 2015 +0530
Committer: Madhan Neethiraj <[email protected]>
Committed: Tue Sep 29 08:53:52 2015 -0700

----------------------------------------------------------------------
 .../src/main/webapp/scripts/utils/XAUtils.js    | 22 ++++++----
 .../views/policies/RangerPolicyCreate.js        | 43 ++++++++++++--------
 .../scripts/views/policies/RangerPolicyForm.js  | 26 ++++++------
 .../views/reports/PlugableServiceDiffDetail.js  | 19 ++-------
 .../scripts/views/service/ServiceCreate.js      | 19 ++++-----
 .../scripts/views/users/UserTableLayout.js      |  4 +-
 security-admin/src/main/webapp/styles/xa.css    |  1 -
 7 files changed, 68 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e2075ffa/security-admin/src/main/webapp/scripts/utils/XAUtils.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js 
b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
index 83eeff8..4265e1e 100644
--- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
+++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
@@ -466,14 +466,19 @@ define(function(require) {
                        return '--';
        };
        XAUtils.showGroupsOrUsersForPolicy = function(rawValue, model, 
showGroups) {
-               var showMoreLess = false, groupArr = [];
+               var showMoreLess = false, groupArr = [], items = [];
+               var itemList = 
['policyItems','allowExceptions','denyPolicyItems','denyExceptions']
                var type = _.isUndefined(showGroups) ? 'groups' : 'users';
-               if (!_.isArray(rawValue) && !_.isUndefined(rawValue[type]))
-                       return '--';
-               _.each(rawValue, function(perm) {
+               _.each(itemList, function(item){
+                   if(!_.isUndefined(model.get(item)) && 
!_.isEmpty(model.get(item))) {
+                       items =_.union(items,  model.get(item))
+                   }
+               });
+               _.each(items, function(perm) {
                        groupArr = _.union(groupArr, perm[type])
                });
-
+               if (_.isEmpty(items))
+                       return '--';
                var newGroupArr = _.map(groupArr, function(name, i) {
                        if (i >= 4) {
                                return '<span class="label label-info 
float-left-margin-2" policy-' + type
@@ -1030,11 +1035,14 @@ define(function(require) {
                        if(_.isEmpty(vXPortalUser.attributes)){
                                return controller;
                        }
-                       var denyControllerActions = [];
-                       var denyModulesObj = [];
+                       var denyControllerActions = [], denyModulesObj = [];
                        var userModuleNames = 
_.pluck(vXPortalUser.get('userPermList'),'moduleName');
                        //TODO Temporary fix for tag based policies : need to 
come from server
                        userModuleNames.push('Tag Based Policies')
+                       //add by default permission module to admin user
+                       if (SessionMgr.isSystemAdmin()){
+                               userModuleNames.push('Permissions')
+                       }
                        var groupModuleNames = 
_.pluck(vXPortalUser.get('groupPermissions'), 'moduleName');
                        var moduleNames = _.union(userModuleNames, 
groupModuleNames);
                        

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e2075ffa/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js 
b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
index a5f0bcd..cc11cef 100644
--- 
a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
+++ 
b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
@@ -133,12 +133,28 @@ define(function(require){
                        });
                },
                onSave: function(){
-                       var that = this, valid = false;
                        var errors = this.form.commit({validate : false});
                        if(! _.isEmpty(errors)){
                                return;
                        }
-                       var validateObj = this.form.formValidation();
+                       //validate policyItems in the policy
+                       var validateObj1 = 
this.form.formValidation(this.form.formInputList);
+                       if(!this.validatePolicyItem(validateObj1)) return;
+                       var     validateObj2 = 
this.form.formValidation(this.form.formInputAllowExceptionList);
+                       if(!this.validatePolicyItem(validateObj2)) return;
+                       var     validateObj3 = 
this.form.formValidation(this.form.formInputDenyList);
+                       if(!this.validatePolicyItem(validateObj3)) return;
+                       var     validateObj4 = 
this.form.formValidation(this.form.formInputDenyExceptionList);
+                       if(!this.validatePolicyItem(validateObj4)) return;
+                       if((!validateObj1.auditLoggin) && 
!(validateObj1.groupPermSet || validateObj2.groupPermSet 
+                                                                               
|| validateObj3.groupPermSet || validateObj4.groupPermSet)){
+                               XAUtil.alertPopup({ msg 
:localization.tt('msg.yourAuditLogginIsOff') });
+                               return;
+                       }
+                       this.savePolicy();
+               },
+               validatePolicyItem : function(validateObj){
+                       var that = this, valid = false;
                        valid = (validateObj.groupSet && validateObj.permSet) 
|| (validateObj.userSet && validateObj.userPerm);
                        if(!valid){
                                if((!validateObj.groupSet && 
!validateObj.userSet) && (validateObj.condSet)) {
@@ -157,22 +173,11 @@ define(function(require){
                                        
this.popupCallBack(localization.tt('msg.addUser'),validateObj);
                                                
                                }else if((!validateObj.auditLoggin) && 
(!validateObj.groupPermSet)){
-                                       XAUtil.alertPopup({
-                                               msg 
:localization.tt('msg.yourAuditLogginIsOff'),
-                                               callback : function(){
-                                                       
/*if(!that.model.isNew()){
-                                                               
that.model.destroy({success: function(model, response) {
-                                                                       
XAUtil.notifySuccess('Success', localization.tt('msg.policyDeleteMsg'));
-                                                                       
App.appRouter.navigate("#!/hdfs/"+that.assetModel.id+"/policies",{trigger: 
true});
-                                                               }});
-                                                       }else{
-                                                               
XAUtil.notifyError('Error', localization.tt('msg.policyNotAddedMsg'));
-                                                               
App.appRouter.navigate("#!/hdfs/"+that.assetModel.id+"/policies",{trigger: 
true});
-                                                       }*/
-                                               }
-                                       });
+                                       return true;
+//                                     XAUtil.alertPopup({ msg 
:localization.tt('msg.yourAuditLogginIsOff') });
                                }else{
-                                       this.savePolicy();
+//                                     this.savePolicy();
+                                       return true;
                                }
                        }else{
                                if(validateObj.groupSet && 
(!validateObj.permSet)){
@@ -186,9 +191,11 @@ define(function(require){
                                        
this.popupCallBack(localization.tt('msg.addUser'),validateObj);
                                                
                                }else{
-                                       this.savePolicy();
+//                                     this.savePolicy();
+                                       return true;
                                }
                        }
+                       return false;
                },
                savePolicy : function(){
                        var that = this;

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e2075ffa/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js 
b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
index 55c3651..5ef56f8 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
@@ -348,20 +348,20 @@ define(function(require){
                                        if(!_.isUndefined(m.get('userName')) && 
!_.isNull(m.get('userName'))){
                                                
policyItem.set("users",m.get("userName").split(','));
                                        }
-                                       
if(!_.isUndefined(m.get('delegateAdmin'))){
-                                               
policyItem.set("delegateAdmin",m.get("delegateAdmin"));
-                                       }
-                                       
-                                       var RangerPolicyItemAccessList = 
Backbone.Collection.extend();
-                                       var rangerPlcItemAccessList = new 
RangerPolicyItemAccessList(m.get('accesses'));
-                                       policyItem.set('accesses', 
rangerPlcItemAccessList)
-                                       
-                                       if(!_.isUndefined(m.get('conditions'))){
+                                       if(!(_.isUndefined(m.get('conditions')) 
&& _.isEmpty(m.get('conditions')))){
                                                var 
RangerPolicyItemConditionList = Backbone.Collection.extend();
                                                var rPolicyItemCondList = new 
RangerPolicyItemConditionList(m.get('conditions'))
                                                policyItem.set('conditions', 
rPolicyItemCondList)
                                        }
-                                       policyItemList.add(policyItem)
+                                       if(!_.isUndefined(m.get('accesses')) && 
!_.isUndefined(m.get('delegateAdmin'))){
+                                               
policyItem.set("delegateAdmin",m.get("delegateAdmin"));
+                                       }
+                                       if(!_.isUndefined(m.get('accesses'))){
+                                               var RangerPolicyItemAccessList 
= Backbone.Collection.extend();
+                                               var rangerPlcItemAccessList = 
new RangerPolicyItemAccessList(m.get('accesses'));
+                                               policyItem.set('accesses', 
rangerPlcItemAccessList)
+                                               policyItemList.add(policyItem)
+                                       }
                                        
                                }
                        }, this);
@@ -587,11 +587,11 @@ define(function(require){
                                };
                        return JSON.stringify(context);
                },
-               formValidation : function(){
+               formValidation : function(coll){
                        var groupSet = false,permSet = false,groupPermSet = 
false,
                        userSet=false, userPerm = false, userPermSet 
=false,breakFlag =false, condSet = false;
                        console.log('validation called..');
-                       this.formInputList.each(function(m){
+                       coll.each(function(m){
                                if(_.isEmpty(m.attributes)) return;
                                if(m.has('groupName') || m.has('userName') || 
m.has('accesses') ){
                                        if(! breakFlag){
@@ -609,7 +609,7 @@ define(function(require){
                                                }
                                        }
                                }
-                               if(m.has('conditions')){
+                               if(m.has('conditions') && 
!_.isEmpty(m.get('conditions'))){
                                        condSet = m.has('conditions') ? true : 
false;
                                }
                        });

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e2075ffa/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..b65dff4 100644
--- 
a/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js
+++ 
b/security-admin/src/main/webapp/scripts/views/reports/PlugableServiceDiffDetail.js
@@ -88,18 +88,7 @@ define(function(require){
                        
                },
                initializeServiceDef : function(){
-                       var url;
-                       /*if(this.action == 'update'){
-                               var rangerPolicy = new 
RangerPolicy({'id':this.objectId})
-                               rangerPolicy.fetch({
-                                       cache : false,
-                                       async : false
-                               })
-                               this.policyName = rangerPolicy.get('name');
-                               url = 
XAUtils.getRangerServiceByName(rangerPolicy.get('service'))
-                       }else{
-                       }*/
-                       var policyName = 
this.collection.findWhere({'attributeName':'Policy Name'});
+                       var url, policyName = 
this.collection.findWhere({'attributeName':'Policy Name'});
                        if(this.action == 'create'){
                                this.policyName = policyName.get('newValue');
                        }else if(this.action == 'delete'){
@@ -108,9 +97,9 @@ define(function(require){
                        if(!_.isUndefined(this.collection.models[0]) ){
                                this.policyName = 
_.isUndefined(this.policyName) ? this.collection.models[0].get('objectName') : 
this.policyName;
                                if(this.action != 'delete'){
-                                       url = 
XAUtils.getRangerServiceByName(this.collection.models[0].get('parentObjectName'))
-                                       var rangerService = new RangerService()
-                                       rangerService.url = url;
+//                                     url = 
XAUtils.getRangerServiceByName(this.collection.models[0].get('parentObjectName'))
+                                       var rangerService = new RangerService({ 
'id' : this.collection.models[0].get('parentObjectId') })
+//                                     rangerService.url = url;
                                        rangerService.fetch({
                                                cache : false,
                                                async : false

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e2075ffa/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js 
b/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
index 7488cc5..79d6187 100644
--- a/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
+++ b/security-admin/src/main/webapp/scripts/views/service/ServiceCreate.js
@@ -154,12 +154,7 @@ define(function(require){
                                        XAUtil.allowNavigation();
                                        var msg = that.editService ? 'Service 
updated successfully' :'Service created successfully';
                                        XAUtil.notifySuccess('Success', msg);
-                                       
-                                       
if(XAEnums.ServiceType.SERVICE_TAG.label == that.model.get('type')){
-                                               
App.appRouter.navigate("#!/policymanager/tag",{trigger: true});
-                                               return;
-                                       }
-                                       
App.appRouter.navigate("#!/policymanager/resource",{trigger: true});
+                                       that.gotoResourceOrTagTab()
                                },
                                error: function (model, response, options) {
                                        XAUtil.blockUI('unblock');
@@ -185,7 +180,7 @@ define(function(require){
                                                        
XAUtil.blockUI('unblock');
                                                        
XAUtil.allowNavigation();
                                                        
XAUtil.notifySuccess('Success', 'Service delete successfully');
-                                                       
App.appRouter.navigate("#!/policymanager",{trigger: true});
+                                                       
that.gotoResourceOrTagTab()
                                                },
                                                error: function (model, 
response, options) {
                                                        
XAUtil.blockUI('unblock');
@@ -255,14 +250,16 @@ define(function(require){
                                        }       
                                });
                },
-               onCancel : function(){
-                       XAUtil.allowNavigation();
-                       if(XAEnums.ServiceType.SERVICE_TAG.label == 
this.rangerServiceDefModel.get('name')){
+               gotoResourceOrTagTab : function(){
+                       if(XAEnums.ServiceType.SERVICE_TAG.label == 
this.model.get('type')){
                                
App.appRouter.navigate("#!/policymanager/tag",{trigger: true});
                                return;
                        }
                        
App.appRouter.navigate("#!/policymanager/resource",{trigger: true});
-//                     App.appRouter.navigate("#!/policymanager",{trigger: 
true});
+               },
+               onCancel : function(){
+                       XAUtil.allowNavigation();
+                       this.gotoResourceOrTagTab();
                },
                /** on close */
                onClose: function(){

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e2075ffa/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js
----------------------------------------------------------------------
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 2ade868..aeb8608 100644
--- a/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/users/UserTableLayout.js
@@ -501,7 +501,9 @@ define(function(require){
                                          valueMatches :function(facet, 
searchTerm, callback) {
                                                                switch (facet) {
                                                                        case 
'Role':
-                                                                               
callback(XAUtil.hackForVSLabelValuePairs(XAEnums.UserRoles));
+                                                                               
var roles = XAUtil.hackForVSLabelValuePairs(XAEnums.UserRoles);
+                                                                               
var label  = SessionMgr.isSystemAdmin() ? 
XAEnums.UserRoles.ROLE_KEY_ADMIN.label : XAEnums.UserRoles.ROLE_SYS_ADMIN.label;
+                                                                               
callback(_.filter(roles, function(o) { return o.label !== label; }));
                                                                                
break;
                                                                        case 
'User Source':
                                                                                
callback(XAUtil.hackForVSLabelValuePairs(XAEnums.UserTypes));

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/e2075ffa/security-admin/src/main/webapp/styles/xa.css
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/styles/xa.css 
b/security-admin/src/main/webapp/styles/xa.css
index d17f947..331cda1 100644
--- a/security-admin/src/main/webapp/styles/xa.css
+++ b/security-admin/src/main/webapp/styles/xa.css
@@ -1903,7 +1903,6 @@ input[type="radio"], input[type="checkbox"] {margin-top: 
0;}
 .table-policy-condition td label {
     min-width: 170px;
 } */
-=======
 .pause-play-close{
        margin-left: -5px;
     margin-top: -2px;

Reply via email to