]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blobdiff - frontend/js/app.js
Do not error if a user tries to upload a file without a type
[perso/Immae/Projets/Nodejs/Surfer.git] / frontend / js / app.js
index 92dc1defd6b804183a2140583fe6a0ac77140e0c..dce3a602e43f42e8e487318d5b4c46977374be4d 100644 (file)
@@ -136,7 +136,10 @@ function uploadFiles(files) {
     app.uploadStatus.percentDone = 0;
 
     asyncForEach(files, function (file, callback) {
-        var path = encode(sanitize(app.path + '/' + file.name));
+        // do not handle directories (file.type is empty in such a case)
+        if (file.type === '') return callback();
+
+        var path = encode(sanitize(app.path + '/' + (file.webkitRelativePath || file.name)));
 
         var formData = new FormData();
         formData.append('file', file);
@@ -164,10 +167,13 @@ function uploadFiles(files) {
 }
 
 function dragOver(event) {
+    event.stopPropagation();
     event.preventDefault();
+    event.dataTransfer.dropEffect = 'copy';
 }
 
 function drop(event) {
+    event.stopPropagation();
     event.preventDefault();
     uploadFiles(event.dataTransfer.files || []);
 }
@@ -275,9 +281,7 @@ var app = new Vue({
 
                     refresh();
                 });
-            }).catch(function () {
-                console.log('delete error:', arguments);
-            });
+            }).catch(function () {});
         },
         onRename: function (entry) {
             var that = this;
@@ -294,9 +298,7 @@ var app = new Vue({
 
                     refresh();
                 });
-            }).catch(function (error) {
-                that.$message.error(error.message);
-            });
+            }).catch(function () {});
         },
         onNewFolder: function () {
             var that = this;
@@ -314,9 +316,7 @@ var app = new Vue({
 
                     refresh();
                 });
-            }).catch(function (error) {
-                that.$message.error(error.message);
-            });
+            }).catch(function () {});
         },
         prettyDate: function (row, column, cellValue, index) {
             var date = new Date(cellValue),