]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blobdiff - frontend/index.html
Add access token ui and rest api
[perso/Immae/Projets/Nodejs/Surfer.git] / frontend / index.html
index 0ef1bf53a7ebb8d3bc4cce49e00bfc6aed426905..20154da6a77229223d711d829c3a30f1b284ceea 100644 (file)
@@ -6,15 +6,15 @@
 
     <link rel="icon" type="image/png" href="/_admin/img/logo.png">
 
-    <link rel="stylesheet" href="/_admin/css/theme-chalk.css">
+    <link rel="stylesheet" href="/_admin/css/theme-chalk_2.11.1.css">
     <link rel="stylesheet" href="/_admin/css/style.css">
 
     <script src="/_admin/js/jquery-1.12.1.min.js"></script>
-    <script src="/_admin/js/vue.js"></script>
-    <script src="/_admin/js/element-ui.js"></script>
+    <script src="/_admin/js/vue.min.js"></script>
+    <script src="/_admin/js/element-ui_2.11.1.min.js"></script>
+    <script src="/_admin/js/element-ui_en_2.11.1.min.js"></script>
     <script src="/_admin/js/filesize.min.js"></script>
     <script src="/_admin/js/superagent.js"></script>
-    <script src="/_admin/js/sorttable.js"></script>
 
 </head>
 <body>
 <div id="app" @drop="drop" @dragover="dragOver">
 
 <el-container>
-  <input type="file" ref="upload" style="display: none" id="uploadInput" multiple/>
+  <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>
-      <el-form-item label="Username"><el-input v-model="loginData.username" required autofocus></el-input></el-form-item>
-      <el-form-item label="Password"><el-input v-model="loginData.password" type="password" required></el-input></el-form-item>
+      <el-form-item label="Username"><el-input v-model="loginData.username" id="loginUsernameInput" required autofocus :disabled="loginData.busy"></el-input></el-form-item>
+      <el-form-item label="Password"><el-input v-model="loginData.password" id="loginPasswordInput" type="password" required :disabled="loginData.busy"></el-input></el-form-item>
       <input type="submit" @click="onLogin" v-show="false"/>
     </el-form>
     <span slot="footer" class="dialog-footer">
-      <el-button type="primary" @click="onLogin"><i class="el-icon-loading" v-show="busy"></i><span v-show="!busy">Login</span></el-button>
+      <el-button type="primary" @click="onLogin" id="loginSubmitButton"><i class="el-icon-loading" v-show="loginData.busy"></i><span v-show="!loginData.busy">Login</span></el-button>
     </span>
   </el-dialog>
 
+  <el-dialog title="Access Tokens" :visible.sync="accessTokensDialogVisible" width="30%">
+    Tokens can be used with the surfer <a href="https://www.npmjs.com/package/cloudron-surfer" target="_blank">cli tool</a> or using the Api directly.
+    They are shared between all users.
+    <br/>
+    <br/>
+    <div>
+      <div v-for="accessToken in accessTokens">
+        <el-input suffix-icon="el-icon-copy-document" v-model="accessToken" class="access-token-input" @focus="onCopyAccessToken" size="small"></el-input>
+        <el-button icon="el-icon-delete" type="danger" size="small" @click="onDeleteAccessToken(accessToken)"></el-button>
+      </div>
+    </div>
+    <br/>
+    <el-button @click="onCreateAccessToken()" size="small" type="primary">Create Access Token</el-button>
+  </el-dialog>
+
   <el-header>
     <el-row type="flex" justify="space-between">
       <div style="padding: 7px;">
       </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">
-          <el-button size="small" icon="el-icon-more"></el-button>
+        <el-dropdown @command="onOptionsMenu" :hide-on-click="false" trigger="click">
+          <el-button size="small" icon="el-icon-more" id="burgerMenuButton"></el-button>
           <el-dropdown-menu slot="dropdown">
             <el-dropdown-item disabled>Public Folder Listing</el-dropdown-item>
             <el-dropdown-item command="folderListing">
-              <el-switch v-model="folderListingEnabled" active-text="Enabled" inactive-text="Disabled">
-            </el-switch>
+              <el-switch v-model="folderListingEnabled" active-text="Enabled" inactive-text="Disabled"></el-switch>
             </el-dropdown-item>
+            <el-dropdown-item disabled divided>WebDAV Endpoint</el-dropdown-item>
+            <el-dropdown-item><a href="/_webdav/" target="_blank">{{ origin }}/_webdav/</a></el-dropdown-item>
+            <el-dropdown-item command="apiAccess" divided><i class="el-icon-connection"></i> Access Tokens</el-dropdown-item>
             <el-dropdown-item command="about" divided><i class="el-icon-info"></i> About</el-dropdown-item>
-            <el-dropdown-item command="logout"><i class="el-icon-circle-close"></i> Logout</el-dropdown-item>
+            <el-dropdown-item command="logout" id="logoutButton"><i class="el-icon-circle-close"></i> Logout</el-dropdown-item>
           </el-dropdown-menu>
         </el-dropdown>
       </div>
         <el-table :data="entries" style="max-width: 1280px;width: 100%" height="100%" empty-text="Folder is emtpy" :default-sort="{ prop: 'filePath', order: 'descending' }" @row-click="open">
           <el-table-column prop="previewUrl" label="Type" width="100px" sortable>
             <template slot-scope="scope">
-              <img v-bind:src="scope.row.previewUrl" height="48px" width="48px"/>
+              <img v-bind:src="scope.row.previewUrl" height="48px" width="48px" style="object-fit: cover;"/>
+            </template>
+          </el-table-column>
+          <el-table-column prop="filePath" label="Name" sortable>
+            <template slot-scope="scope">
+              <el-input v-on:keyup.native.enter="onRenameSubmit(scope.row)" v-on:keyup.native.esc="onRenameEnd(scope.row)" @blur="onRenameEnd(scope.row)" v-model="scope.row.filePathNew" :id="'filePathRenameInputId-' + scope.$index" v-show="scope.row.rename"></el-input>
+              <span v-show="!scope.row.rename">{{ scope.row.filePath }}</span>
             </template>
           </el-table-column>
-          <el-table-column prop="filePath" label="Name" sortable></el-table-column>
           <el-table-column prop="size" label="Size" width="150px" sortable :formatter="prettyFileSize"></el-table-column>
           <el-table-column prop="mtime" label="Modified" width="150px" sortable :formatter="prettyDate"></el-table-column>
           <el-table-column label="Actions" align="right" width="200px" class-name="list-actions">
             <template slot-scope="scope">
-              <el-button size="small" icon="el-icon-download" circle v-show="scope.row.isFile" @click.stop="onDownload(scope.row)"></el-button>
-              <el-button size="small" icon="el-icon-edit" circle @click.stop="onRename(scope.row)"></el-button>
-              <el-button size="small" icon="el-icon-delete" circle @click.stop="onDelete(scope.row)"></el-button>
+              <el-button size="small" icon="el-icon-edit" circle v-show="!scope.row.rename" @click.stop="onRename(scope.row, scope)"></el-button>
+              <el-button size="small" icon="el-icon-download" circle v-show="!scope.row.rename && scope.row.isFile" @click.stop="onDownload(scope.row)"></el-button>
+              <el-button size="small" icon="el-icon-delete" circle v-show="!scope.row.rename" @click.stop="onDelete(scope.row)"></el-button>
             </template>
           </el-table-column>
         </el-table>
 
   </el-main>
   <el-footer v-show="uploadStatus.busy">
-    <el-row>
+    <el-row v-if="uploadStatus.uploadListCount">
+      <center><i class="el-icon-loading"></i> Fetching file information for upload <el-badge class="mark" :value="uploadStatus.uploadListCount"/></center>
+    </el-row>
+    <el-row v-else>
       <el-col :span="4">
-        Uploading files ({{ uploadStatus.done }} / {{ uploadStatus.count }})
+        Uploading {{ uploadStatus.count }} files ({{ Math.round(uploadStatus.done/1000/1000) }}MB / {{ Math.round(uploadStatus.size/1000/1000) }}MB)
       </el-col>
       <el-col :span="20">
         <el-progress :text-inside="true" :stroke-width="18" :percentage="uploadStatus.percentDone"></el-progress>