You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2018/03/22 13:53:01 UTC
ranger git commit: RANGER-2030: Improvement to UI updates to
accommodate policy effective dates.
Repository: ranger
Updated Branches:
refs/heads/master 97b927f93 -> d2073e774
RANGER-2030: Improvement to UI updates to accommodate policy effective dates.
Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/d2073e77
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/d2073e77
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/d2073e77
Branch: refs/heads/master
Commit: d2073e774f458079d9e92a610fec2ae22d63cf12
Parents: 97b927f
Author: ni3galave <ni...@gmail.com>
Authored: Thu Mar 22 18:07:14 2018 +0530
Committer: pradeep <pr...@apache.org>
Committed: Thu Mar 22 19:22:13 2018 +0530
----------------------------------------------------------------------
.../src/main/webapp/scripts/utils/XAUtils.js | 12 ++++--
.../scripts/views/policies/PolicyTimeList.js | 15 ++++++--
.../views/policies/RangerPolicyCreate.js | 6 +--
.../scripts/views/policies/RangerPolicyForm.js | 20 ++++++++--
.../views/policies/RangerPolicyTableLayout.js | 39 ++++++++++++--------
security-admin/src/main/webapp/styles/xa.css | 11 ++++++
.../policies/RangerPolicyCreate_tmpl.html | 4 +-
7 files changed, 75 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ranger/blob/d2073e77/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 9e17951..8a0302d 100644
--- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js
+++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js
@@ -1389,10 +1389,16 @@ define(function(require) {
XAUtils.isAuditorOrKMSAuditor = function(SessionMgr){
return (SessionMgr.isAuditor() || SessionMgr.isKMSAuditor()) ? true : false ;
};
- XAUtils.policyExpierd = function(model){
- return _.some(model.get('validitySchedules') , function(m){
+ XAUtils.isPolicyExpierd = function(model){
+ return !_.some(model.get('validitySchedules') , function(m){
+ if(!m.endTime){
+ return true;
+ } else if(_.isEmpty(m.timeZone)){
return new Date().valueOf() > new Date(m.endTime).valueOf() ? false : true;
-
+ }else{
+ return new Date(new Date().toLocaleString('en-US', { timeZone: m.timeZone }).valueOf()).valueOf() >
+ new Date(m.endTime.toLocaleString('en-US', { timeZone: m.timeZone }).valueOf()).valueOf() ? false : true;
+ }
});
};
return XAUtils;
http://git-wip-us.apache.org/repos/asf/ranger/blob/d2073e77/security-admin/src/main/webapp/scripts/views/policies/PolicyTimeList.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policies/PolicyTimeList.js b/security-admin/src/main/webapp/scripts/views/policies/PolicyTimeList.js
index 0d88072..74b9b4d 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/PolicyTimeList.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/PolicyTimeList.js
@@ -58,9 +58,14 @@ define(function(require) {
onRender : function() {
var that = this;
- var startTime = this.$el.find(this.ui.startTime).datetimepicker({autoclose:true}),
- endTime = this.$el.find(this.ui.endTime).datetimepicker({autoclose:true});;
-
+ var startTime = this.$el.find(this.ui.startTime).datetimepicker({
+ autoclose: true,
+ minuteStep: 1,
+ }),
+ endTime = this.$el.find(this.ui.endTime).datetimepicker({
+ autoclose: true,
+ minuteStep: 1
+ });
startTime.on('changeDate', function(ev){
that.$el.find(that.ui.endTime).datetimepicker('setStartDate', ev.date);
});
@@ -99,6 +104,7 @@ define(function(require) {
evDelete : function(){
var that = this;
this.collection.remove(this.model);
+ $('[data-js="policyTimeBtn"]').addClass('dirtyField');
},
});
@@ -134,6 +140,7 @@ define(function(require) {
this.bind("ok", this.onSave);
},
onRender : function(){
+ XAUtil.preventNavigation(localization.tt('dialogMsg.preventNavPolicyForm'),this.$el);
},
addNew : function(){
var that =this;
@@ -141,7 +148,7 @@ define(function(require) {
this.collection.add(new Backbone.Model());
},
onSave: function (modal) {
- var self = this
+ var self = this;
if(! _.isUndefined(this.collection.models)){
var error = _.some(this.collection.models, function(m){
var startTime = new Date(m.get('startTime')), endTime = new Date(m.get('endTime'));
http://git-wip-us.apache.org/repos/asf/ranger/blob/d2073e77/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 1b82128..4158309 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyCreate.js
@@ -55,10 +55,10 @@ define(function(require){
infoMsg = localization.tt('msg.rowFilterPolicyInfoMsg'), displayClass = 'show';
}
if(this.editPolicy && !_.isEmpty(this.model.get('validitySchedules'))){
- if(XAUtil.policyExpierd(this.model)){
- expiredClass = 'hide';
- }else{
+ if(XAUtil.isPolicyExpierd(this.model)){
policyTimeStatus = localization.tt('msg.policyExpired'), expiredClass = 'show';
+ }else{
+ expiredClass = 'hide';
}
}
return {
http://git-wip-us.apache.org/repos/asf/ranger/blob/d2073e77/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 6d511e1..1c3dc85 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js
@@ -149,9 +149,13 @@ define(function(require){
setPolicyValidityTime : function(){
var that = this;
this.$el.find(this.ui.policyTimeBtn).on('click', function(e){
- var view = new vPolicyTimeList({
- collection: that.model.has('validitySchedules') ? new Backbone.Collection(that.model.get('validitySchedules')) : new Backbone.Collection(),
- model : that.model
+ var policyDirtyField = that.model.has('validitySchedules') ? new Backbone.Collection(that.model.get('validitySchedules')) : new Backbone.Collection();
+ policyDirtyField.on('change',function(){
+ that.$el.find('[data-js="policyTimeBtn"]').addClass('dirtyField');
+ });
+ var view = new vPolicyTimeList({
+ collection: policyDirtyField,
+ model : that.model
});
var modal = new Backbone.BootstrapModal({
content : view,
@@ -167,9 +171,17 @@ define(function(require){
}).open();
modal.$el.addClass('modal-policy-time');
+ $('body').addClass('hideBodyScroll')
//To prevent modal being close by click out of modal
- modal.$el.find('.cancel, .close, .ok').on('click', function(e){
+ modal.$el.find('.cancel, .close').on('click', function(e){
modal._preventClose = false;
+ $('body').removeClass('hideBodyScroll');
+ $('[data-js="policyTimeBtn"]').addClass('dirtyField');
+ $(".datetimepicker").remove();
+ });
+ modal.$el.find('.ok').on('click', function(e){
+ modal._preventClose = false;
+ $('body').removeClass('hideBodyScroll');
});
modal.on('shown', function(a){
this.preventClose();
http://git-wip-us.apache.org/repos/asf/ranger/blob/d2073e77/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 b849799..1afd92e 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
@@ -101,10 +101,7 @@ define(function(require){
*/
initialize: function(options) {
console.log("initialized a RangerPolicyTableLayout Layout");
-
_.extend(this, _.pick(options,'rangerService'));
-
-
this.bindEvents();
this.initializeServiceDef();
},
@@ -203,19 +200,32 @@ define(function(require){
var that = this;
var cols = {
id : {
- cell : 'html',
+ cell : 'html',
label : localization.tt("lbl.policyId"),
- formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+ formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue, model) {
- if(!_.isEmpty(model.attributes.validitySchedules) && !XAUtil.policyExpierd(model)){
- return '<div class="" style="position: relative; text-align: center;">\
- <!--<i class="icon-exclamation-sign backgrigModelId" title="Policy expired"></i>-->\
- <a class="" href="#!/service/'+that.rangerService.id+'/policies/'+model.id+'/edit">'+model.id+'</a>\
- </div>';
+ if(XAUtil.isAuditorOrKMSAuditor(SessionMgr)){
+ if(!_.isEmpty(model.get('validitySchedules')) && XAUtil.isPolicyExpierd(model)){
+ return '<div class="expiredIconPosition">\
+ <i class="icon-exclamation-sign backgrigModelId" title="Policy expired"></i>\
+ '+model.id+'\
+ </div>';
+ }else{
+ return '<div class="expiredIconPosition">\
+ '+model.id+'\
+ </div>';
+ }
}else{
- return '<div class="" style="position: relative; text-align: center;">\
- <a class="" href="#!/service/'+that.rangerService.id+'/policies/'+model.id+'/edit">'+model.id+'</a>\
- </div>';
+ if(!_.isEmpty(model.get('validitySchedules')) && XAUtil.isPolicyExpierd(model)){
+ return '<div class="expiredIconPosition">\
+ <i class="icon-exclamation-sign backgrigModelId" title="Policy expired"></i>\
+ <a class="" href="#!/service/'+that.rangerService.id+'/policies/'+model.id+'/edit">'+model.id+'</a>\
+ </div>';
+ }else{
+ return '<div class="expiredIconPosition">\
+ <a class="" href="#!/service/'+that.rangerService.id+'/policies/'+model.id+'/edit">'+model.id+'</a>\
+ </div>';
+ }
}
}
}),
@@ -317,9 +327,6 @@ define(function(require){
sortable : false
};
- if(XAUtil.isAuditorOrKMSAuditor(SessionMgr)){
- cols.id.cell = 'string';
- }
return this.collection.constructor.getTableCols(cols, this.collection);
},
onDelete :function(e){
http://git-wip-us.apache.org/repos/asf/ranger/blob/d2073e77/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 ebb6284..0ea0ac2 100644
--- a/security-admin/src/main/webapp/styles/xa.css
+++ b/security-admin/src/main/webapp/styles/xa.css
@@ -2333,3 +2333,14 @@ textarea:read-only{
top: 3px;
color:#bd362f;
}
+.hideBodyScroll{
+ overflow : hidden;
+}
+.datetimepicker-minutes{
+ overflow-y: scroll !important;
+ height: 210px !important;
+}
+.expiredIconPosition{
+ position: relative;
+ text-align: center;
+}
http://git-wip-us.apache.org/repos/asf/ranger/blob/d2073e77/security-admin/src/main/webapp/templates/policies/RangerPolicyCreate_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/policies/RangerPolicyCreate_tmpl.html b/security-admin/src/main/webapp/templates/policies/RangerPolicyCreate_tmpl.html
index e85faa8..0151e7c 100644
--- a/security-admin/src/main/webapp/templates/policies/RangerPolicyCreate_tmpl.html
+++ b/security-admin/src/main/webapp/templates/policies/RangerPolicyCreate_tmpl.html
@@ -28,10 +28,10 @@
<button type="button" class="close" data-dismiss="alert">×</button>
<i class="icon-info-sign searchInfoUserAccess padding-right-10"></i>{{{infoMsg}}}
</div>
- <!-- <div class="alert alert-danger {{expiredClass}}" data-id="policyInfoAlert">
+ <div class="alert alert-danger {{expiredClass}}" data-id="policyInfoAlert">
<button type="button" class="close" data-dismiss="alert">×</button>
<i class="icon-time icon-3 padding-right-10 timeClock"></i>{{{policyTimeStatus}}}
- </div> -->
+ </div>
<div data-id="r_form"></div>
<div class="form-actions form-policy">
{{#if editPolicy}}