diff --git a/internal/httpd/webadmin.go b/internal/httpd/webadmin.go index 57cf771a..fd1cd3bd 100644 --- a/internal/httpd/webadmin.go +++ b/internal/httpd/webadmin.go @@ -428,7 +428,7 @@ func loadAdminTemplates(templatesPath string) { filepath.Join(templatesPath, templateAdminDir, templateFolders), } folderPaths := []string{ - filepath.Join(templatesPath, templateCommonDir, templateCommonCSS), + filepath.Join(templatesPath, templateCommonDir, templateCommonBase), filepath.Join(templatesPath, templateAdminDir, templateBase), filepath.Join(templatesPath, templateAdminDir, templateFsConfig), filepath.Join(templatesPath, templateAdminDir, templateFolder), @@ -1171,13 +1171,13 @@ func (s *httpdServer) renderFolderPage(w http.ResponseWriter, r *http.Request, f var title, currentURL string switch mode { case folderPageModeAdd: - title = "Add a new folder" + title = util.I18nAddFolderTitle currentURL = webFolderPath case folderPageModeUpdate: - title = "Update folder" + title = util.I18nUpdateFolderTitle currentURL = fmt.Sprintf("%v/%v", webFolderPath, url.PathEscape(folder.Name)) case folderPageModeTemplate: - title = "Folder template" + title = util.I18nTemplateFolderTitle currentURL = webTemplateFolder } folder.FsConfig.RedactedSecret = redactedSecret @@ -1201,6 +1201,11 @@ func (s *httpdServer) renderFolderPage(w http.ResponseWriter, r *http.Request, f func getFoldersForTemplate(r *http.Request) []string { var res []string + for k := range r.Form { + if hasPrefixAndSuffix(k, "template_folders[", "][tpl_foldername]") { + r.Form.Add("tpl_foldername", r.Form.Get(k)) + } + } folderNames := r.Form["tpl_foldername"] folders := make(map[string]bool) for _, name := range folderNames { @@ -1958,11 +1963,17 @@ func getQuotaLimits(r *http.Request) (int64, int, error) { func updateRepeaterFormFields(r *http.Request) { for k := range r.Form { if hasPrefixAndSuffix(k, "public_keys[", "][public_key]") { - r.Form.Add("public_keys", r.Form.Get(k)) + key := r.Form.Get(k) + if strings.TrimSpace(key) != "" { + r.Form.Add("public_keys", key) + } continue } if hasPrefixAndSuffix(k, "tls_certs[", "][tls_cert]") { - r.Form.Add("tls_certs", strings.TrimSpace(r.Form.Get(k))) + cert := strings.TrimSpace(r.Form.Get(k)) + if cert != "" { + r.Form.Add("tls_certs", cert) + } continue } if hasPrefixAndSuffix(k, "virtual_folders[", "][vfolder_path]") { diff --git a/internal/util/i18n.go b/internal/util/i18n.go index c427f264..885c4505 100644 --- a/internal/util/i18n.go +++ b/internal/util/i18n.go @@ -186,6 +186,9 @@ const ( I18nAddGroupTitle = "title.add_group" I18nUpdateGroupTitle = "title.update_group" I18nErrorInvalidTLSCert = "user.tls_cert_invalid" + I18nAddFolderTitle = "title.add_folder" + I18nUpdateFolderTitle = "title.update_folder" + I18nTemplateFolderTitle = "title.template_folder" ) // NewI18nError returns a I18nError wrappring the provided error diff --git a/static/locales/en/translation.json b/static/locales/en/translation.json index 6cbc99f1..80cca890 100644 --- a/static/locales/en/translation.json +++ b/static/locales/en/translation.json @@ -49,7 +49,10 @@ "update_user": "Update user", "template_user": "User template", "add_group": "Add group", - "update_group": "Update group" + "update_group": "Update group", + "add_folder": "Add virtual folder", + "update_folder": "Update virtual folder", + "template_folder": "Virtual folder template" }, "setup": { "desc": "To start using SFTPGo you need to create an administrator user", @@ -207,7 +210,8 @@ "global_settings": "Global settings", "mandatory_encryption": "Mandatory encryption", "name_invalid": "The specified username is not valid, the following characters are allowed: a-zA-Z0-9-_.~", - "associations": "Associations" + "associations": "Associations", + "template_placeholders": "The following placeholders are supported" }, "fs": { "view_file": "View file \"{{- path}}\"", @@ -470,7 +474,12 @@ "expires_in_help": "Account expiration as number of days from the creation. 0 means no expiration", "tls_certs": "TLS certificates", "tls_cert_help": "Paste your PEM encoded TLS certificate here", - "tls_cert_invalid": "Invalid TLS certificate" + "tls_cert_invalid": "Invalid TLS certificate", + "template_title": "Create one or more new users from this template", + "template_username_placeholder": "replaced with the specified username", + "template_password_placeholder": "replaced with the specified password", + "template_help1": "Placeholders will be replaced in paths and credentials of the configured storage backend.", + "template_help2": "The generated users can be saved or exported. Exported users can be imported from the \"Maintenance\" section of this SFTPGo instance or another." }, "group": { "view_manage": "View and manage groups", @@ -483,7 +492,13 @@ "quota_size": "Quota size", "quota_size_help": "0 means no limit. You can use MB/GB/TB suffix", "quota_files": "Quota files", - "associations_summary": "Users: {{users}}. Groups: {{groups}}" + "associations_summary": "Users: {{users}}. Groups: {{groups}}", + "template_title": "Create one or more new virtual folders from this template", + "template_name_placeholder": "replaced with the name of the specified virtual folder", + "template_help": "The generated virtual folders can be saved or exported. Exported folders can be imported from the \"Maintenance\" section of this SFTPGo instance or another.", + "name": "Virtual folder name", + "submit_generate": "Generate and save folders", + "submit_export": "Generate and export folder" }, "storage": { "title": "File system", diff --git a/static/locales/it/translation.json b/static/locales/it/translation.json index 5fc70a25..c334f08b 100644 --- a/static/locales/it/translation.json +++ b/static/locales/it/translation.json @@ -49,7 +49,10 @@ "update_user": "Aggiorna utente", "template_user": "Modello utente", "add_group": "Aggiungi gruppo", - "update_group": "Aggiorna gruppo" + "update_group": "Aggiorna gruppo", + "add_folder": "Aggiungi cartella virtuale", + "update_folder": "Aggiorna cartella virtuale", + "template_folder": "Modello cartella virtuale" }, "setup": { "desc": "Per iniziare a utilizzare SFTPGo devi creare un utente amministratore", @@ -207,7 +210,8 @@ "global_settings": "Impostazioni globali", "mandatory_encryption": "Crittografia obbligatoria", "name_invalid": "Il nome specificato non è valido, sono consentiti i seguenti caratteri: a-zA-Z0-9-_.~", - "associations": "Associazioni" + "associations": "Associazioni", + "template_placeholders": "Sono supportati i seguenti segnaposto" }, "fs": { "view_file": "Visualizza file \"{{- path}}\"", @@ -470,7 +474,12 @@ "expires_in_help": "Scadenza dell'account espressa in numero di giorni dalla creazione. 0 significa nessuna scadenza", "tls_certs": "Certificati TLS", "tls_cert_help": "Incolla qui il tuo certificato TLS codificato PEM", - "tls_cert_invalid": "Certificato TLS non valido" + "tls_cert_invalid": "Certificato TLS non valido", + "template_title": "Crea uno o più nuovi utenti da questo modello", + "template_username_placeholder": "sostituito con il nome utente specificato", + "template_password_placeholder": "sostituito con la password specificata", + "template_help1": "I segnaposto verranno sostituiti nei percorsi e nelle credenziali del backend di archiviazione configurato.", + "template_help2": "Gli utenti generati possono essere salvati o esportati. Gli utenti esportati possono essere importati dalla sezione \"Manutenzione\" di questa istanza SFTPGo o di un'altra." }, "group": { "view_manage": "Visualizza e gestisci gruppi", @@ -483,7 +492,13 @@ "quota_size": "Quota (dimensione)", "quota_size_help": "0 significa nessun limite. E' possibile utilizzare il suffisso MB/GB/TB", "quota_files": "Quota (numero file)", - "associations_summary": "Utenti: {{users}}. Gruppi: {{groups}}" + "associations_summary": "Utenti: {{users}}. Gruppi: {{groups}}", + "template_title": "Crea una o più nuove cartelle virtuali da questo modello", + "template_name_placeholder": "sostituito con il nome della cartella virtuale specificata", + "template_help": "Le cartelle virtuali generate possono essere salvate o esportate. Le cartelle esportate possono essere importate dalla sezione \"Manutenzione\" di questa istanza SFTPGo o di un'altra.", + "name": "Nome cartella virtuale", + "submit_generate": "Genera e salva cartelle", + "submit_export": "Genera e esporta cartelle" }, "storage": { "title": "File system", diff --git a/templates/webadmin/folder.html b/templates/webadmin/folder.html index c867a026..5beeeb1c 100644 --- a/templates/webadmin/folder.html +++ b/templates/webadmin/folder.html @@ -1,149 +1,168 @@ {{template "base" .}} -{{define "title"}}{{.Title}}{{end}} - -{{define "extra_css"}} - -{{end}} - -{{define "page_body"}} -
The following placeholders are supported
+The generated folders can be saved or exported. Exported folders can be imported from the "Maintenance" section of this SFTPGo instance or another.
+