mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
WIP new WebAdmin: remove some hard coded strings
so they can be localized Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -100,12 +100,9 @@ const (
|
|||||||
templateMaintenance = "maintenance.html"
|
templateMaintenance = "maintenance.html"
|
||||||
templateMFA = "mfa.html"
|
templateMFA = "mfa.html"
|
||||||
templateSetup = "adminsetup.html"
|
templateSetup = "adminsetup.html"
|
||||||
pageUsersTitle = "Users"
|
|
||||||
pageAdminsTitle = "Admins"
|
pageAdminsTitle = "Admins"
|
||||||
pageConnectionsTitle = "Connections"
|
pageConnectionsTitle = "Connections"
|
||||||
pageStatusTitle = "Status"
|
pageStatusTitle = "Status"
|
||||||
pageFoldersTitle = "Folders"
|
|
||||||
pageGroupsTitle = "Groups"
|
|
||||||
pageEventRulesTitle = "Event rules"
|
pageEventRulesTitle = "Event rules"
|
||||||
pageEventActionsTitle = "Event actions"
|
pageEventActionsTitle = "Event actions"
|
||||||
pageRolesTitle = "Roles"
|
pageRolesTitle = "Roles"
|
||||||
@@ -1380,18 +1377,9 @@ func getFilePatternsFromPostField(r *http.Request) []sdk.PatternsFilter {
|
|||||||
|
|
||||||
for idx := range patternPaths {
|
for idx := range patternPaths {
|
||||||
p := patternPaths[idx]
|
p := patternPaths[idx]
|
||||||
filters := ""
|
filters := strings.ReplaceAll(patterns[idx], " ", "")
|
||||||
patternType := ""
|
patternType := patternTypes[idx]
|
||||||
patternPolicy := ""
|
patternPolicy := policies[idx]
|
||||||
if len(patterns) > idx {
|
|
||||||
filters = strings.ReplaceAll(patterns[idx], " ", "")
|
|
||||||
}
|
|
||||||
if len(patternTypes) > idx {
|
|
||||||
patternType = patternTypes[idx]
|
|
||||||
}
|
|
||||||
if len(patternPolicies) > idx {
|
|
||||||
patternPolicy = policies[idx]
|
|
||||||
}
|
|
||||||
if p != "" && filters != "" {
|
if p != "" && filters != "" {
|
||||||
if patternType == "allowed" {
|
if patternType == "allowed" {
|
||||||
allowedPatterns[p] = append(allowedPatterns[p], strings.Split(filters, ",")...)
|
allowedPatterns[p] = append(allowedPatterns[p], strings.Split(filters, ",")...)
|
||||||
@@ -2998,7 +2986,7 @@ func (s *httpdServer) handleGetWebUsers(w http.ResponseWriter, r *http.Request)
|
|||||||
s.renderBadRequestPage(w, r, errors.New("invalid token claims"))
|
s.renderBadRequestPage(w, r, errors.New("invalid token claims"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := s.getBasePageData(pageUsersTitle, webUsersPath, r)
|
data := s.getBasePageData(util.I18nUsersTitle, webUsersPath, r)
|
||||||
renderAdminTemplate(w, templateUsers, data)
|
renderAdminTemplate(w, templateUsers, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3487,7 +3475,7 @@ func (s *httpdServer) handleWebGetFolders(w http.ResponseWriter, r *http.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
data := foldersPage{
|
data := foldersPage{
|
||||||
basePage: s.getBasePageData(pageFoldersTitle, webFoldersPath, r),
|
basePage: s.getBasePageData(util.I18nFoldersTitle, webFoldersPath, r),
|
||||||
Folders: folders,
|
Folders: folders,
|
||||||
}
|
}
|
||||||
renderAdminTemplate(w, templateFolders, data)
|
renderAdminTemplate(w, templateFolders, data)
|
||||||
@@ -3529,7 +3517,7 @@ func getAllGroups(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (s *httpdServer) handleWebGetGroups(w http.ResponseWriter, r *http.Request) {
|
func (s *httpdServer) handleWebGetGroups(w http.ResponseWriter, r *http.Request) {
|
||||||
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
|
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
|
||||||
|
|
||||||
data := s.getBasePageData(pageGroupsTitle, webGroupsPath, r)
|
data := s.getBasePageData(util.I18nGroupsTitle, webGroupsPath, r)
|
||||||
renderAdminTemplate(w, templateGroups, data)
|
renderAdminTemplate(w, templateGroups, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ const (
|
|||||||
I18nShareAddTitle = "title.add_share"
|
I18nShareAddTitle = "title.add_share"
|
||||||
I18nShareUpdateTitle = "title.update_share"
|
I18nShareUpdateTitle = "title.update_share"
|
||||||
I18nProfileTitle = "title.profile"
|
I18nProfileTitle = "title.profile"
|
||||||
|
I18nUsersTitle = "title.users"
|
||||||
|
I18nGroupsTitle = "title.groups"
|
||||||
|
I18nFoldersTitle = "title.folders"
|
||||||
I18nChangePwdTitle = "title.change_password"
|
I18nChangePwdTitle = "title.change_password"
|
||||||
I18n2FATitle = "title.two_factor_auth"
|
I18n2FATitle = "title.two_factor_auth"
|
||||||
I18nEditFileTitle = "title.edit_file"
|
I18nEditFileTitle = "title.edit_file"
|
||||||
|
|||||||
@@ -164,7 +164,8 @@ func (c *HTTPFsConfig) validate() error {
|
|||||||
|
|
||||||
// ValidateAndEncryptCredentials validates the config and encrypts credentials if they are in plain text
|
// ValidateAndEncryptCredentials validates the config and encrypts credentials if they are in plain text
|
||||||
func (c *HTTPFsConfig) ValidateAndEncryptCredentials(additionalData string) error {
|
func (c *HTTPFsConfig) ValidateAndEncryptCredentials(additionalData string) error {
|
||||||
if err := c.validate(); err != nil {
|
err := c.validate()
|
||||||
|
if err != nil {
|
||||||
var errI18n *util.I18nError
|
var errI18n *util.I18nError
|
||||||
errValidation := util.NewValidationError(fmt.Sprintf("could not validate HTTP fs config: %v", err))
|
errValidation := util.NewValidationError(fmt.Sprintf("could not validate HTTP fs config: %v", err))
|
||||||
if errors.As(err, &errI18n) {
|
if errors.As(err, &errI18n) {
|
||||||
|
|||||||
Reference in New Issue
Block a user