Ver código fonte

WebClient: propose to add files for empty dirs

Signed-off-by: Nicola Murino <[email protected]>
Nicola Murino 1 ano atrás
pai
commit
e35e07acdb

+ 1 - 1
pkgs/build.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-NFPM_VERSION=2.35.0
+NFPM_VERSION=2.35.1
 NFPM_ARCH=${NFPM_ARCH:-amd64}
 if [ -z ${SFTPGO_VERSION} ]
 then

+ 2 - 2
static/locales/en/translation.json

@@ -78,7 +78,6 @@
         "invalid_token": "Invalid permissions",
         "confirm_logout": "Are you sure you want to sign out?",
         "wait": "Please wait...",
-        "or": "or",
         "ok": "OK",
         "none": "None",
         "cancel": "No, back",
@@ -224,6 +223,7 @@
             "text": "Upload Files",
             "success": "Files uploaded successfully",
             "message": "Drop files here or click to upload.",
+            "message_empty": "This directory is empty. $t(fs.upload.message)",
             "err_generic": "Error uploading files",
             "err_403": "$t(fs.upload.err_generic). $t(fs.err_403)",
             "err_429": "$t(fs.upload.err_generic). $t(fs.err_429)"
@@ -287,7 +287,7 @@
         "save_err": "Failed to save configuration",
         "auth_code_required": "The authentication code is required",
         "no_protocol": "Please select at least a protocol",
-        "required_protocols": "The security policy configured for your account requires two-factor authentication for the following protocols: {{val}}",
+        "required_protocols": "Unable to disable two-factor authentication. The security policy configured for your account requires two-factor authentication for the following protocols: {{val}}",
         "recovery_codes_generate": "Generate new recovery codes",
         "recovery_codes_view": "View recovery codes"
     },

+ 2 - 2
static/locales/it/translation.json

@@ -78,7 +78,6 @@
         "invalid_token": "Permessi non validi",
         "confirm_logout": "Sei sicuro di volerti disconnettere?",
         "wait": "Attendere prego...",
-        "or": "o",
         "ok": "OK",
         "none": "Nessuna",
         "cancel": "No, indietro",
@@ -224,6 +223,7 @@
             "text": "Carica file",
             "success": "File caricati correttamente",
             "message": "Rilascia i file qui o fai clic per caricarli.",
+            "message_empty": "Questa cartella è vuota. $t(fs.upload.message)",
             "err_generic": "Errore caricamento file",
             "err_403": "$t(fs.upload.err_generic). $t(fs.err_403)",
             "err_429": "$t(fs.upload.err_generic). $t(fs.err_429)"
@@ -287,7 +287,7 @@
         "save_err": "Impossibile salvare la configurazione",
         "auth_code_required": "Il codice di autenticazione è obbligatorio",
         "no_protocol": "Seleziona almeno un protocollo",
-        "required_protocols": "La politica di sicurezza configurata per il tuo account richiede l'autenticazione a due fattori per i seguenti protocolli: {{val}}",
+        "required_protocols": "Impossibile disabilitare l'autenticazione a due fattori. La politica di sicurezza configurata per il tuo account richiede l'autenticazione a due fattori per i seguenti protocolli: {{val}}",
         "recovery_codes_generate": "Genera nuovi codici di ripristino",
         "recovery_codes_view": "Visualizza codici di ripristino"
     },

+ 70 - 17
templates/webclient/files.html

@@ -145,24 +145,47 @@ explicit grant from the SFTPGo Team ([email protected]).
         <div class="new_folder_divider py-2 d-none">
             <hr>
         </div>
-        <table id="file_manager_list" class="table align-middle table-row-dashed fs-6 gy-5">
-            <thead>
-                <tr class="text-start text-muted fw-bold fs-6 gs-0 text-gray-500">
-                    <th class="w-10px pe-2">
-                        <div class="form-check form-check-sm form-check-custom form-check-solid me-3">
-                            <input id="select_checkbox" class="form-check-input" type="checkbox"/>
+        <div id="upload_files_empty_container" class="d-none mt-10">
+            <form id="upload_files_empty_form" action="{{.FilesURL}}?path={{.CurrentDir}}" method="POST" enctype="multipart/form-data">
+                <div class="fv-row">
+                    <div class="dropzone" id="upload_files_empty">
+                        <div class="dz-message needsclick align-items-center">
+                            <i class="ki-duotone ki-file-up fs-3x text-primary">
+                                <span class="path1"></span>
+                                <span class="path2"></span>
+                            </i>
+                            <div class="ms-4">
+                                <h3 data-i18n="fs.upload.message_empty" class="fs-5 fw-bold text-gray-900 mb-1"></h3>
+                                <!-- <span class="fs-7 fw-semibold text-gray-500">Upload up to 30 files</span> -->
+                            </div>
                         </div>
-                    </th>
-                    <th></th>
-                    <th data-i18n="general.name" class="min-w-250px">Name</th>
-					<th data-i18n="general.size" class="min-w-10px">Size</th>
-					<th data-i18n="general.last_modified" class="min-w-125px">Last Modified</th>
-					<th class="w-125px"></th>
-                </tr>
-            </thead>
-            <tbody id="file_manager_list_body" class="text-gray-700 fw-semibold">
-            </tbody>
-        </table>
+                    </div>
+                </div>
+            </form>
+            <div class="d-flex justify-content-end mt-5">
+                <button data-i18n="general.submit" type="button" id="upload_files_empty_button" class="btn btn-primary">Submit</button>
+            </div>
+        </div>
+        <div id="file_manager_list_container">
+            <table id="file_manager_list" class="table align-middle table-row-dashed fs-6 gy-5">
+                <thead>
+                    <tr class="text-start text-muted fw-bold fs-6 gs-0 text-gray-500">
+                        <th class="w-10px pe-2">
+                            <div class="form-check form-check-sm form-check-custom form-check-solid me-3">
+                                <input id="select_checkbox" class="form-check-input" type="checkbox" />
+                            </div>
+                        </th>
+                        <th></th>
+                        <th data-i18n="general.name" class="min-w-250px">Name</th>
+                        <th data-i18n="general.size" class="min-w-10px">Size</th>
+                        <th data-i18n="general.last_modified" class="min-w-125px">Last Modified</th>
+                        <th class="w-125px"></th>
+                    </tr>
+                </thead>
+                <tbody id="file_manager_list_body" class="text-gray-700 fw-semibold">
+                </tbody>
+            </table>
+        </div>
     </div>
 </div>
 
@@ -720,6 +743,15 @@ explicit grant from the SFTPGo Team ([email protected]).
             //table = dt.$;
 
             dt.on('draw', function () {
+                //{{- if .CanAddFiles}}
+                if (dt.rows().count() === 0) {
+                    $('#file_manager_list_container').addClass("d-none");
+                    $('#upload_files_empty_container').removeClass("d-none");
+                    return;
+                }
+                $('#upload_files_empty_container').addClass("d-none");
+                $('#file_manager_list_container').removeClass("d-none");
+                //{{- end}}
                 lightbox.reload();
                 KTMenu.createInstances();
 
@@ -1690,6 +1722,27 @@ explicit grant from the SFTPGo Team ([email protected]).
             file.previewElement.querySelector(".dz-progress").style.display = 'none';
         });
 
+        var dropzoneEmpty =  new Dropzone("#upload_files_empty", {
+            url: "{{.FilesURL}}?path={{.CurrentDir}}",
+            paramName: "filenames",
+            maxFiles: 250,
+            maxFilesize: null,
+            autoQueue: false,
+            addRemoveLinks: true,
+            autoProcessQueue: false,
+            filesizeBase: 1000,
+            init: function() {
+                var dropzoneEmpty = this;
+                $("#upload_files_empty_button").click(function(){
+                   uploadFiles(dropzoneEmpty.getAcceptedFiles());
+                });
+            }
+        });
+
+        dropzoneEmpty.on("addedfile", file => {
+            file.previewElement.querySelector(".dz-progress").style.display = 'none';
+        });
+
         $('#modal_video_player').on('hide.bs.modal', function () {
             $("#video_player").get(0).pause();
             if (playerKeepAlive != null) {

+ 1 - 4
templates/webclient/login.html

@@ -70,10 +70,7 @@ explicit grant from the SFTPGo Team ([email protected]).
 								</button>
 								{{- end}}
 								{{- if .OpenIDLoginURL}}
-								{{- if not .FormDisabled}}
-								<div data-i18n="general.or" class="text-center text-muted text-uppercase fw-bold mb-5">or</div>
-								{{- end}}
-								<a href="{{.OpenIDLoginURL}}" class="btn btn-flex btn-outline flex-center btn-active-color-primary bg-state-light btn-lg w-100 mb-5">
+								<a href="{{.OpenIDLoginURL}}" class="btn btn-flex btn-outline flex-center {{if .FormDisabled}}btn-primary{{else}}btn-active-color-primary bg-state-light{{end}} btn-lg w-100 my-5">
 									<img alt="Logo" src="{{.StaticURL}}/img/openid-logo.png" class="h-20px me-3" />
 									<span data-i18n="login.signin_openid">Sign in with OpenID</span>
 								</a>