validation for file type selection 59/43459/1
authorAnjali Walsatwar <anjali.walsatwar@huawei.com>
Wed, 18 Apr 2018 02:28:22 +0000 (07:58 +0530)
committerAnjali Walsatwar <anjali.walsatwar@huawei.com>
Wed, 18 Apr 2018 02:28:22 +0000 (07:58 +0530)
Issue-ID: VNFSDK-243

Change-Id: Ib831eb9733a51408c73363702dd7032502f24710
Signed-off-by: Anjali Walsatwar <anjali.walsatwar@huawei.com>
vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js
vnfmarket/src/main/webapp/vnfmarket/common/locale/locale-en.json

index 3f64841..43137a5 100644 (file)
         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];
+                    }
                 });
             });
         }
index d086b9a..f82b567 100644 (file)
@@ -57,7 +57,7 @@
                                "fields": {\r
                                        "fileUpload": {\r
                                                "label": "Select File",\r
-                                               "noFileSelected": "No file selected"\r
+                                               "noFileSelected": "No file selected (Select .csar file)"\r
                                        },\r
                                        "shortDescription": {\r
                                                "placeholder": "Short Description"\r