aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnjali Walsatwar <anjali.walsatwar@huawei.com>2018-04-18 07:58:22 +0530
committerAnjali Walsatwar <anjali.walsatwar@huawei.com>2018-04-18 07:58:22 +0530
commitbee3e9d43fba11fb37bd8ba590c76203e585505d (patch)
treebe4e842d9ff86ec9205115dc5b27335be410899d
parent7df584b2b5a8059a6230d757e4b33092de13faba (diff)
validation for file type selection
Issue-ID: VNFSDK-243 Change-Id: Ib831eb9733a51408c73363702dd7032502f24710 Signed-off-by: Anjali Walsatwar <anjali.walsatwar@huawei.com>
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js10
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/common/locale/locale-en.json2
2 files changed, 10 insertions, 2 deletions
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"