WebUI: add a base template for info messages

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2024-01-28 10:22:16 +01:00
parent a275ef17a8
commit caa1d70aab
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF
11 changed files with 43 additions and 42 deletions

View file

@ -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"

View file

@ -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"

View file

@ -726,6 +726,16 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</div>
{{- end}}
{{- define "infomsg"}}
<div class="notice d-flex bg-light-primary rounded border-primary border border-dashed p-4">
<div class="d-flex flex-stack flex-grow-1">
<div class="fs-5 fw-semibold text-break text-wrap text-gray-800">
<span data-i18n="{{.}}"></span>
</div>
</div>
</div>
{{- end}}
{{- define "base"}}
<!DOCTYPE html>
<html lang="en">

View file

@ -21,24 +21,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
<h3 data-i18n="title.change_password" class="card-title section-title">Change password</h3>
</div>
<div class="card-body">
<div class="notice d-flex bg-light-primary rounded border-primary border border-dashed p-6 mb-5">
<i class="ki-duotone ki-shield-tick fs-2tx text-primary me-4">
<span class="path1"></span>
<span class="path2"></span>
</i>
<div class="d-flex flex-stack flex-grow-1 flex-wrap flex-md-nowrap">
<div class="mb-3 mb-md-0">
<div class="fs-6 text-gray-800 fw-semibold pe-7">
<span data-i18n="change_pwd.info">
</span>
</div>
</div>
</div>
</div>
{{template "infomsg" "change_pwd.info"}}
{{- template "errmsg" .Error}}
<form id="change_pwd_form" action="{{.CurrentURL}}" method="POST" autocomplete="off">
<div class="form-group row">
<div class="form-group row mt-10">
<label data-i18n="change_pwd.current" class="col-md-3 col-form-label required">Current password</label>
<div class="col-md-9">
<div class="position-relative" data-password-control="container">

View file

@ -69,7 +69,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
<h3 data-i18n="general.role" class="card-title section-title-inner">Role</h3>
</div>
<div class="card-body">
<p data-i18n="admin.role_help" class="fs-5 fw-semibold mb-4"></p>
{{template "infomsg" "admin.role_help"}}
<div class="form-group row mt-10">
<label for="idRole" data-i18n="general.role" class="col-md-3 col-form-label">Role</label>
<div class="col-md-9">
@ -92,7 +92,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</div>
<div class="card-body">
<div id="groups">
<p class="fs-5 fw-semibold mb-4" data-i18n="admin.users_groups_help"></p>
{{template "infomsg" "admin.users_groups_help"}}
<div class="form-group">
<div data-repeater-list="groups">
{{range $idx, $val := .Admin.Groups}}
@ -181,7 +181,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
<h3 data-i18n="admin.user_page_pref" class="card-title section-title-inner">User page preferences</h3>
</div>
<div class="card-body">
<p data-i18n="admin.user_page_pref_help" class="fs-5 fw-semibold mb-4"></p>
{{template "infomsg" "admin.user_page_pref_help"}}
<div class="form-group row mt-10">
<label for="idUserPageHiddenSections" data-i18n="admin.hide_sections" class="col-md-3 col-form-label">Hide sections</label>

View file

@ -31,7 +31,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</h2>
<div id="accordion_sftp_body" class="accordion-collapse collapse {{if eq .ConfigSection 1}}show{{end}}" aria-labelledby="accordion_header_sftp" data-bs-parent="#accordion_configs">
<div class="accordion-body">
<p data-i18n="sftp.help" class="fs-5 fw-semibold mb-4"></p>
{{template "infomsg" "sftp.help"}}
<form id="configs_sftp_form" action="{{.CurrentURL}}" method="POST" autocomplete="off">
<div class="form-group row mt-10">
@ -126,7 +126,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</h2>
<div id="accordion_acme_body" class="accordion-collapse collapse {{if eq .ConfigSection 2}}show{{end}}" aria-labelledby="accordion_header_acme" data-bs-parent="#accordion_configs">
<div class="accordion-body">
<p data-i18n="acme.help" class="fs-5 fw-semibold mb-4"></p>
{{template "infomsg" "acme.help"}}
<form id="configs_acme_form" action="{{.CurrentURL}}" method="POST" autocomplete="off">
@ -195,7 +195,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</h2>
<div id="accordion_smtp_body" class="accordion-collapse collapse {{if eq .ConfigSection 3}}show{{end}}" aria-labelledby="accordion_header_smtp" data-bs-parent="#accordion_configs">
<div class="accordion-body">
<p data-i18n="smtp.help" class="fs-5 fw-semibold mb-4"></p>
{{template "infomsg" "smtp.help"}}
<form id="configs_smtp_form" action="{{.CurrentURL}}" method="POST" autocomplete="off">

View file

@ -412,7 +412,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</div>
<div class="form-group row mt-10 fsconfig fsconfig-sftpfs">
<label for="idSFTPPrefix" data-i18n="storage.sftp_home_dir" class="col-md-3 col-form-label">Roor directory</label>
<label for="idSFTPPrefix" data-i18n="storage.sftp_home_dir" class="col-md-3 col-form-label">Root directory</label>
<div class="col-md-9">
<input id="idSFTPPrefix" type="text" class="form-control" name="sftp_prefix" value="{{.SFTPConfig.Prefix}}" aria-describedby="idSFTPPrefixHelp"/>
<div id="idSFTPPrefixHelp" class="form-text" data-i18n="storage.sftp_home_help"></div>
@ -517,7 +517,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</div>
<div class="card-body">
<div id="directory_patterns">
<p class="fs-5 fw-semibold mb-4" data-i18n="filters.directory_patterns_help"></p>
{{template "infomsg" "filters.directory_patterns_help"}}
<div class="form-group">
<div data-repeater-list="directory_patterns">
{{- range $idx, $pattern := .GetFlatFilePatterns -}}

View file

@ -47,9 +47,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</div>
<div class="card-body">
<div id="virtual_folders">
<p class="fs-5 fw-semibold mb-4" data-i18n="user.virtual_folders_help">
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
</p>
{{template "infomsg" "user.virtual_folders_help"}}
<div class="form-group">
<div data-repeater-list="virtual_folders">
{{- range $idx, $val := .Group.VirtualFolders}}
@ -158,7 +156,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</div>
<div class="card-body">
<div id="directory_permissions">
<p class="fs-5 fw-semibold mb-4" data-i18n="filters.directory_permissions_help"></p>
{{template "infomsg" "filters.directory_permissions_help"}}
<div class="form-group">
<div data-repeater-list="directory_permissions">
{{- range $idx, $dirPerms := .Group.GetPermissions -}}

View file

@ -116,10 +116,14 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</h2>
<div id="accordion_rec_codes_body" class="accordion-collapse collapse" aria-labelledby="accordion_rec_codes" data-bs-parent="#id_accordion">
<div class="accordion-body">
<div class="fs-5 text-gray-800">
<p data-i18n="2fa.recovery_codes_msg1">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.</p>
<p data-i18n="2fa.recovery_codes_msg2">To keep your account secure, don't share or distribute your recovery codes. We recommend saving them with a secure password manager.</p>
<p data-i18n="2fa.recovery_codes_msg3" class="fs-4 fw-bold">If you generate new recovery codes, you automatically invalidate old ones.</p>
<div class="notice d-flex bg-light-primary rounded border-primary border border-dashed p-6">
<div class="d-flex flex-stack flex-grow-1">
<div class="fs-5 fw-semibold text-break text-wrap text-gray-800">
<p data-i18n="2fa.recovery_codes_msg1">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.</p>
<p data-i18n="2fa.recovery_codes_msg2">To keep your account secure, don't share or distribute your recovery codes. We recommend saving them with a secure password manager.</p>
<p data-i18n="2fa.recovery_codes_msg3" class="fs-4 fw-bold">If you generate new recovery codes, you automatically invalidate old ones.</p>
</div>
</div>
</div>
<div class="d-flex justify-content-end mt-10">
<button type="button" id="generate_recovery_code_btn" class="btn btn-light-primary px-10 me-10">

View file

@ -216,7 +216,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
<h3 data-i18n="title.groups" class="card-title section-title-inner">Groups</h3>
</div>
<div class="card-body">
<p data-i18n="user.groups_help" class="fs-5 fw-semibold mb-4"></p>
{{template "infomsg" "user.groups_help"}}
<div class="form-group row mt-10">
<label for="idPrimaryGroup" data-i18n="user.primary_group" class="col-md-3 col-form-label">Primary group</label>
<div class="col-md-9">
@ -264,9 +264,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</div>
<div class="card-body">
<div id="virtual_folders">
<p class="fs-5 fw-semibold mb-4" data-i18n="user.virtual_folders_help">
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
</p>
{{template "infomsg" "user.virtual_folders_help"}}
<div class="form-group">
<div data-repeater-list="virtual_folders">
{{- range $idx, $val := .User.VirtualFolders}}
@ -445,7 +443,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</div>
<div class="card-body">
<div id="directory_permissions">
<p class="fs-5 fw-semibold mb-4" data-i18n="filters.directory_permissions_help"></p>
{{template "infomsg" "filters.directory_permissions_help"}}
<div class="form-group">
<div data-repeater-list="directory_permissions">
{{- range $idx, $dirPerms := .User.GetSubDirPermissions -}}

View file

@ -132,10 +132,14 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</h2>
<div id="accordion_rec_codes_body" class="accordion-collapse collapse" aria-labelledby="accordion_rec_codes" data-bs-parent="#id_accordion">
<div class="accordion-body">
<div class="fs-5 text-gray-800">
<p data-i18n="2fa.recovery_codes_msg1">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.</p>
<p data-i18n="2fa.recovery_codes_msg2">To keep your account secure, don't share or distribute your recovery codes. We recommend saving them with a secure password manager.</p>
<p data-i18n="2fa.recovery_codes_msg3" class="fs-4 fw-bold">If you generate new recovery codes, you automatically invalidate old ones.</p>
<div class="notice d-flex bg-light-primary rounded border-primary border border-dashed p-6">
<div class="d-flex flex-stack flex-grow-1">
<div class="fs-5 fw-semibold text-break text-wrap text-gray-800">
<p data-i18n="2fa.recovery_codes_msg1">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.</p>
<p data-i18n="2fa.recovery_codes_msg2">To keep your account secure, don't share or distribute your recovery codes. We recommend saving them with a secure password manager.</p>
<p data-i18n="2fa.recovery_codes_msg3" class="fs-4 fw-bold">If you generate new recovery codes, you automatically invalidate old ones.</p>
</div>
</div>
</div>
<div class="d-flex justify-content-end mt-10">
<button type="button" id="generate_recovery_code_btn" class="btn btn-light-primary px-10 me-10">