From caa1d70aaba81c38122721b78a8579414a3ed65b Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sun, 28 Jan 2024 10:22:16 +0100 Subject: [PATCH] WebUI: add a base template for info messages Signed-off-by: Nicola Murino --- internal/dataprovider/iplist.go | 2 +- internal/util/i18n.go | 2 +- templates/common/base.html | 10 ++++++++++ templates/common/changepassword.html | 17 ++--------------- templates/webadmin/admin.html | 6 +++--- templates/webadmin/configs.html | 6 +++--- templates/webadmin/fsconfig.html | 4 ++-- templates/webadmin/group.html | 6 ++---- templates/webadmin/mfa.html | 12 ++++++++---- templates/webadmin/user.html | 8 +++----- templates/webclient/mfa.html | 12 ++++++++---- 11 files changed, 43 insertions(+), 42 deletions(-) diff --git a/internal/dataprovider/iplist.go b/internal/dataprovider/iplist.go index 16c68b1b..739ef472 100644 --- a/internal/dataprovider/iplist.go +++ b/internal/dataprovider/iplist.go @@ -214,7 +214,7 @@ func (e *IPListEntry) validate() error { // parse as IP parsed, err := netip.ParseAddr(e.IPOrNet) if err != nil { - return util.NewI18nError(util.NewValidationError(fmt.Sprintf("invalid IP %q", e.IPOrNet)), util.I18nErrorIpInvalid) + return util.NewI18nError(util.NewValidationError(fmt.Sprintf("invalid IP %q", e.IPOrNet)), util.I18nErrorIPInvalid) } if parsed.Is4() { e.IPOrNet += "/32" diff --git a/internal/util/i18n.go b/internal/util/i18n.go index 340973fd..b0c8865a 100644 --- a/internal/util/i18n.go +++ b/internal/util/i18n.go @@ -224,7 +224,7 @@ const ( I18nErrorAdminSelfPerms = "admin.self_permissions" I18nErrorAdminSelfDisable = "admin.self_disable" I18nErrorAdminSelfRole = "admin.self_role" - I18nErrorIpInvalid = "ip_list.ip_invalid" + I18nErrorIPInvalid = "ip_list.ip_invalid" I18nErrorNetInvalid = "ip_list.net_invalid" I18nFTPTLSDisabled = "status.tls_disabled" I18nFTPTLSExplicit = "status.tls_explicit" diff --git a/templates/common/base.html b/templates/common/base.html index 54005e8e..78b4778f 100644 --- a/templates/common/base.html +++ b/templates/common/base.html @@ -726,6 +726,16 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). {{- end}} +{{- define "infomsg"}} +
+
+
+ +
+
+
+{{- end}} + {{- define "base"}} diff --git a/templates/common/changepassword.html b/templates/common/changepassword.html index a5d1d058..5a94385a 100644 --- a/templates/common/changepassword.html +++ b/templates/common/changepassword.html @@ -21,24 +21,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).

Change password

-
- - - - -
-
-
- - -
-
-
-
+ {{template "infomsg" "change_pwd.info"}} {{- template "errmsg" .Error}}
-
+
diff --git a/templates/webadmin/admin.html b/templates/webadmin/admin.html index 0d8bd22e..40faf278 100644 --- a/templates/webadmin/admin.html +++ b/templates/webadmin/admin.html @@ -69,7 +69,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).

Role

-

+ {{template "infomsg" "admin.role_help"}}
@@ -92,7 +92,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-

+ {{template "infomsg" "admin.users_groups_help"}}
{{range $idx, $val := .Admin.Groups}} @@ -181,7 +181,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).

User page preferences

-

+ {{template "infomsg" "admin.user_page_pref_help"}}
diff --git a/templates/webadmin/configs.html b/templates/webadmin/configs.html index 8ed32d8d..c97ad940 100644 --- a/templates/webadmin/configs.html +++ b/templates/webadmin/configs.html @@ -31,7 +31,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-

+ {{template "infomsg" "sftp.help"}}
@@ -126,7 +126,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-

+ {{template "infomsg" "acme.help"}} @@ -195,7 +195,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-

+ {{template "infomsg" "smtp.help"}} diff --git a/templates/webadmin/fsconfig.html b/templates/webadmin/fsconfig.html index 258f8133..931d07b6 100644 --- a/templates/webadmin/fsconfig.html +++ b/templates/webadmin/fsconfig.html @@ -412,7 +412,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
- +
@@ -517,7 +517,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-

+ {{template "infomsg" "filters.directory_patterns_help"}}
{{- range $idx, $pattern := .GetFlatFilePatterns -}} diff --git a/templates/webadmin/group.html b/templates/webadmin/group.html index d2a78e77..6d2cdfc6 100644 --- a/templates/webadmin/group.html +++ b/templates/webadmin/group.html @@ -47,9 +47,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-

- Quota size/files -1 means included within user quota, 0 unlimited. Don't set -1 for shared folders. You can use MB/GB/TB suffix. Without suffix we assume bytes -

+ {{template "infomsg" "user.virtual_folders_help"}}
{{- range $idx, $val := .Group.VirtualFolders}} @@ -158,7 +156,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-

+ {{template "infomsg" "filters.directory_permissions_help"}}
{{- range $idx, $dirPerms := .Group.GetPermissions -}} diff --git a/templates/webadmin/mfa.html b/templates/webadmin/mfa.html index 89a38e59..f8bde85b 100644 --- a/templates/webadmin/mfa.html +++ b/templates/webadmin/mfa.html @@ -116,10 +116,14 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-
-

Recovery codes are a set of one time use codes that can be used in place of the authentication code to login to the web UI. You can use them if you lose access to your phone to login to your account and disable or regenerate two-factor configuration.

-

To keep your account secure, don't share or distribute your recovery codes. We recommend saving them with a secure password manager.

-

If you generate new recovery codes, you automatically invalidate old ones.

+
+
+
+

Recovery codes are a set of one time use codes that can be used in place of the authentication code to login to the web UI. You can use them if you lose access to your phone to login to your account and disable or regenerate two-factor configuration.

+

To keep your account secure, don't share or distribute your recovery codes. We recommend saving them with a secure password manager.

+

If you generate new recovery codes, you automatically invalidate old ones.

+
+
-

+ {{template "infomsg" "user.groups_help"}}
@@ -264,9 +264,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-

- Quota size/files -1 means included within user quota, 0 unlimited. Don't set -1 for shared folders. You can use MB/GB/TB suffix. Without suffix we assume bytes -

+ {{template "infomsg" "user.virtual_folders_help"}}
{{- range $idx, $val := .User.VirtualFolders}} @@ -445,7 +443,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-

+ {{template "infomsg" "filters.directory_permissions_help"}}
{{- range $idx, $dirPerms := .User.GetSubDirPermissions -}} diff --git a/templates/webclient/mfa.html b/templates/webclient/mfa.html index 452f8c66..6a8ea801 100644 --- a/templates/webclient/mfa.html +++ b/templates/webclient/mfa.html @@ -132,10 +132,14 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
-
-

Recovery codes are a set of one time use codes that can be used in place of the authentication code to login to the web UI. You can use them if you lose access to your phone to login to your account and disable or regenerate two-factor configuration.

-

To keep your account secure, don't share or distribute your recovery codes. We recommend saving them with a secure password manager.

-

If you generate new recovery codes, you automatically invalidate old ones.

+
+
+
+

Recovery codes are a set of one time use codes that can be used in place of the authentication code to login to the web UI. You can use them if you lose access to your phone to login to your account and disable or regenerate two-factor configuration.

+

To keep your account secure, don't share or distribute your recovery codes. We recommend saving them with a secure password manager.

+

If you generate new recovery codes, you automatically invalidate old ones.

+
+