This is an automated email from the ASF dual-hosted git repository. ni3galave pushed a commit to branch ranger-1.2 in repository https://gitbox.apache.org/repos/asf/ranger.git
View the commit online: https://github.com/apache/ranger/commit/7d4f6e251ce4c6aa94da6818e71f59d46f0f573f The following commit(s) were added to refs/heads/ranger-1.2 by this push: new 7d4f6e2 RANGER-2509 : Add validation message for Importing non JSON file on import action. 7d4f6e2 is described below commit 7d4f6e251ce4c6aa94da6818e71f59d46f0f573f Author: Nitin Galave <[email protected]> AuthorDate: Fri Nov 15 12:33:02 2019 +0530 RANGER-2509 : Add validation message for Importing non JSON file on import action. --- .../main/webapp/scripts/views/UploadServicePolicy.js | 18 +++++++++--------- .../templates/common/uploadservicepolicy_tmpl.html | 2 -- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/security-admin/src/main/webapp/scripts/views/UploadServicePolicy.js b/security-admin/src/main/webapp/scripts/views/UploadServicePolicy.js index 62a1fcf..70f8ee7 100644 --- a/security-admin/src/main/webapp/scripts/views/UploadServicePolicy.js +++ b/security-admin/src/main/webapp/scripts/views/UploadServicePolicy.js @@ -135,6 +135,10 @@ define(function(require){ } return modal.preventClose(); } + if(this.targetFileObj.type != "application/json" || !(this.targetFileObj.name).match(".json$", "i")) { + this.$el.find('.selectFileValidationMsg').show(); + return modal.preventClose(); + } var that = this, serviceMapping = {}, fileObj = this.targetFileObj, preventModal = false , url =""; if(this.$el.find('input[data-name="override"]').is(':checked')){ url = "service/plugins/policies/importPoliciesFromFile?isOverride=true"; @@ -222,8 +226,7 @@ define(function(require){ this.collection.add(new Backbone.Model()); }, onRender: function() { - this.$el.find('.fileValidation').hide(); - this.$el.find('.selectFileValidationMsg').hide(); + this.$el.find('.selectFileValidationMsg').hide(); if(this.serviceType==undefined){ this.$el.find('.seviceFiled').show(); this.renderComponentSelect(); @@ -270,20 +273,17 @@ define(function(require){ importPolicy : function(e){ var that =this; console.log("uploading...."); - this.$el.find('.selectFile').hide(); this.$el.find('.selectFileValidationMsg').hide(); - this.$el.find('.fileValidation').hide(); this.targetFileObj = e.target.files[0]; if(!_.isUndefined(this.targetFileObj)){ - this.$el.find('.selectFile').html('<i>'+this.targetFileObj.name+'</i><label class="icon icon-remove icon-1x icon-remove-btn" data-id="fileNameClosebtn"></label>').show() + this.$el.find('.selectFile').text(this.targetFileObj.name); + this.$el.find('.selectFile').append('<i></i><label class="icon icon-remove icon-1x icon-remove-btn" data-id="fileNameClosebtn"></label>'); }else{ - this.$el.find('.selectFile').html("No file chosen").show(); + this.$el.find('.selectFile').text("No file chosen"); } }, fileNameClosebtn : function(){ - this.$el.find('.selectFile').hide() - this.$el.find('.selectFile').html("No file chosen").show() - this.$el.find('.fileValidation').hide(); + this.$el.find('.selectFile').text("No file chosen"); this.$el.find('.selectFileValidationMsg').hide(); this.targetFileObj = undefined; this.ui.importFilePolicy.val(''); diff --git a/security-admin/src/main/webapp/templates/common/uploadservicepolicy_tmpl.html b/security-admin/src/main/webapp/templates/common/uploadservicepolicy_tmpl.html index 150a885..3e8caec 100644 --- a/security-admin/src/main/webapp/templates/common/uploadservicepolicy_tmpl.html +++ b/security-admin/src/main/webapp/templates/common/uploadservicepolicy_tmpl.html @@ -33,8 +33,6 @@ language governing permissions and limitations under the License. --}} data-id="source" data-name="override" class="margin-left12"> </label> <div class="selectFile margin-left6">No file chosen</div> - <div class="fileValidation text-color-red margin-left6">Please - Select Json file format</div> <hr> <div class="uploadSet"> <span><b>Specify Service Mapping : </b></span>
