ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pengjian...@apache.org
Subject ranger git commit: RANGER-2153 Supply the function of reverting policy history version.
Date Wed, 01 Aug 2018 07:13:45 GMT
Repository: ranger
Updated Branches:
  refs/heads/master 9fd6acf41 -> ee806ca5f


RANGER-2153 Supply the function of reverting policy history version.

Signed-off-by: pengjianhua <35573597@qq.com>


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

Branch: refs/heads/master
Commit: ee806ca5fedd868e6e2788566926a0c42b6def16
Parents: 9fd6acf
Author: 洪一帆6186000050 <hong.yifan@zte.com.cn>
Authored: Fri Jul 27 14:28:24 2018 +0800
Committer: pengjianhua <35573597@qq.com>
Committed: Wed Aug 1 15:13:31 2018 +0800

----------------------------------------------------------------------
 .../scripts/views/policies/RangerPolicyRO.js    | 27 ++++++++++++++++++++
 .../views/policies/RangerPolicyTableLayout.js   |  3 +++
 2 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/ee806ca5/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js
index a0b46fd..1e3554f 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyRO.js
@@ -30,6 +30,7 @@ define(function(require) {
 
 	var RangerPolicyROTmpl = require('hbs!tmpl/policies/RangerPolicyRO_tmpl');
 	var RangerService = require('models/RangerService');
+	var RangerPolicy		= require('models/RangerPolicy');
 
 	var RangerPolicyRO = Backbone.Marionette.Layout.extend({
 		_viewName: 'RangerPolicyRO',
@@ -268,6 +269,7 @@ define(function(require) {
 			this.render();
 			var verEl = $(e.currentTarget).parent();
 			verEl.find('text').text('Version '+this.policy.get('version'));
+			var reverEl = verEl.next('#revert');
 			var prevEl = verEl.find('#preVer'),
 				nextEl = verEl.find('#nextVer');
 			if(this.policy.get('version')>1){
@@ -278,11 +280,36 @@ define(function(require) {
 			var policyVerIndexAt = this.policyVersionList.indexOf(this.policy.get('version').toString());
 			if(!_.isUndefined(this.policyVersionList[++policyVerIndexAt])){
 				nextEl.addClass('active');
+				reverEl.css('display','');
 			}else{
 				nextEl.removeClass('active');
+				reverEl.css('display','none');
 			}
 		},
 
+		revert : function(e){
+			e.preventDefault();
+			var policyId = this.policy.attributes.id;
+			var rangerPolicy = new RangerPolicy({id : policyId});
+			rangerPolicy.attributes = this.policy.attributes;
+			rangerPolicy.save({}, {
+				wait: true,
+				success: function() {
+					XAUtil.blockUI('unblock');
+					XAUtil.notifySuccess('Success', 'Policy reverted successfully.');
+					location.reload();
+				},
+				error: function(model, response, options) {
+					XAUtil.blockUI('unblock');
+					if(response && response.responseJSON && response.responseJSON.msgDesc)
{
+						XAUtil.showErrorMsg(response.responseJSON.msgDesc);
+					} else {
+						XAUtil.notifyError('Error', 'Error reverting policy.');
+					}
+				}
+			});
+		},
+
 		/** on close */
 		onClose: function() {}
 	});

http://git-wip-us.apache.org/repos/asf/ranger/blob/ee806ca5/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 206bb96..83253e4 100644
--- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js
@@ -202,6 +202,9 @@ define(function(require){
 				policyVerEl.append('<i id="nextVer" class="icon-chevron-right ' + (!_.isUndefined(policyVersionList[++policyVerIndexAt])
? 'active' : '') + '"></i>').find('#nextVer').click(function(e) {
 					view.nextVer(e);
 				});
+				policyVerEl.after('<a id="revert" href="#" class="btn btn-primary" style="display:none;">Revert</a>').next('#revert').click(function(e){
+					view.revert(e);
+				});
 				modal.$el.find('.cancel').hide();
 			});
 		},


Mime
View raw message