From: Anjali Walsatwar Date: Wed, 18 Apr 2018 02:28:22 +0000 (+0530) Subject: validation for file type selection X-Git-Tag: v1.1.1~24^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F59%2F43459%2F1;p=vnfsdk%2Frefrepo.git validation for file type selection Issue-ID: VNFSDK-243 Change-Id: Ib831eb9733a51408c73363702dd7032502f24710 Signed-off-by: Anjali Walsatwar --- diff --git a/vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js b/vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js index 3f64841d..43137a5a 100644 --- a/vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js +++ b/vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js @@ -43,7 +43,15 @@ function link(scope, element, attrs) { element.bind("change", function (changeEvent) { scope.$apply(function () { - scope.fileUpload = changeEvent.target.files[0]; + var fileType = changeEvent.target.accept; + var ext = "." + changeEvent.target.value.match(/\.(.+)$/)[1]; + scope.fileUpload = null; + if (typeof fileType == undefined || fileType == "") { + scope.fileUpload = changeEvent.target.files[0]; + } + else if ((Array.isArray(fileType) && fileType.indexOf(ext) > -1) || (fileType == ext)) { + scope.fileUpload = changeEvent.target.files[0]; + } }); }); } diff --git a/vnfmarket/src/main/webapp/vnfmarket/common/locale/locale-en.json b/vnfmarket/src/main/webapp/vnfmarket/common/locale/locale-en.json index d086b9ac..f82b567e 100644 --- a/vnfmarket/src/main/webapp/vnfmarket/common/locale/locale-en.json +++ b/vnfmarket/src/main/webapp/vnfmarket/common/locale/locale-en.json @@ -57,7 +57,7 @@ "fields": { "fileUpload": { "label": "Select File", - "noFileSelected": "No file selected" + "noFileSelected": "No file selected (Select .csar file)" }, "shortDescription": { "placeholder": "Short Description"