]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/commitdiff
We cannot have one button/input type for both folders and files for upload
authorJohannes Zellner <johannes@cloudron.io>
Fri, 18 May 2018 19:23:02 +0000 (21:23 +0200)
committerJohannes Zellner <johannes@cloudron.io>
Fri, 18 May 2018 19:23:02 +0000 (21:23 +0200)
frontend/index.html
frontend/js/app.js

index 538d32932afdc3edd077ece1900c24bd2c3ee447..d2b526d15c82c48f9954cf2b42e2761d37748cec 100644 (file)
@@ -21,7 +21,8 @@
 <div id="app" @drop="drop" @dragover="dragOver">
 
 <el-container>
-  <input type="file" ref="upload" style="display: none" id="uploadInput" multiple  webkitdirectory="" directory=""/>
+  <input type="file" ref="upload" style="display: none" multiple/>
+  <input type="file" ref="uploadFolder" style="display: none" multiple webkitdirectory directory/>
 
   <el-dialog title="Login" :visible.sync="ready && !session.valid" width="30%" :close-on-press-escape="false" :show-close="false">
     <el-form :model="loginData" label-position="top" @submit.native.prevent>
@@ -51,7 +52,8 @@
       </div>
       <div align="right" v-show="session.valid">
         <el-button-group>
-          <el-button type="primary" icon="el-icon-upload" size="small" @click="onUpload">Upload</el-button>
+          <el-button type="primary" icon="el-icon-upload2" size="small" @click="onUpload">Upload File</el-button>
+          <el-button type="primary" icon="el-icon-upload" size="small" @click="onUploadFolder">Upload Folder</el-button>
           <el-button type="primary" icon="el-icon-plus" size="small" @click="onNewFolder">New Folder</el-button>
         </el-button-group>
         <el-dropdown @command="onOptionsMenu">
index dce3a602e43f42e8e487318d5b4c46977374be4d..9d7bacaa1cd4887420714d558972aea1aa7ba420 100644 (file)
@@ -256,10 +256,8 @@ var app = new Vue({
             var that = this;
 
             $(this.$refs.upload).on('change', function () {
-
                 // detach event handler
                 $(that.$refs.upload).off('change');
-
                 uploadFiles(that.$refs.upload.files || []);
             });
 
@@ -267,6 +265,19 @@ var app = new Vue({
             this.$refs.upload.value = '';
             this.$refs.upload.click();
         },
+        onUploadFolder: function () {
+            var that = this;
+
+            $(this.$refs.uploadFolder).on('change', function () {
+                // detach event handler
+                $(that.$refs.uploadFolder).off('change');
+                uploadFiles(that.$refs.uploadFolder.files || []);
+            });
+
+            // reset the form first to make the change handler retrigger even on the same file selected
+            this.$refs.uploadFolder.value = '';
+            this.$refs.uploadFolder.click();
+        },
         onDelete: function (entry) {
             var that = this;