diff --git a/go.mod b/go.mod index a03cb379..b8aa8148 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/rs/xid v1.5.0 github.com/rs/zerolog v1.31.0 github.com/sftpgo/sdk v0.1.6-0.20231105181545-b44c8058fc25 - github.com/shirou/gopsutil/v3 v3.23.11 + github.com/shirou/gopsutil/v3 v3.23.12 github.com/spf13/afero v1.11.0 github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.18.2 diff --git a/go.sum b/go.sum index 9952ffbc..e054f882 100644 --- a/go.sum +++ b/go.sum @@ -356,8 +356,8 @@ github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/sftpgo/sdk v0.1.6-0.20231105181545-b44c8058fc25 h1:R8cTb41ZX5WSYw8q8ufTKQfOvXh7aLQWqdnteDY/96U= github.com/sftpgo/sdk v0.1.6-0.20231105181545-b44c8058fc25/go.mod h1:6s/PFoLUd7FXG3wGlrdVhrA0SJOwri2h9kzTph/2oiU= -github.com/shirou/gopsutil/v3 v3.23.11 h1:i3jP9NjCPUz7FiZKxlMnODZkdSIp2gnzfrvsu9CuWEQ= -github.com/shirou/gopsutil/v3 v3.23.11/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= +github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4= +github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= diff --git a/internal/httpd/webadmin.go b/internal/httpd/webadmin.go index c7804842..742f6130 100644 --- a/internal/httpd/webadmin.go +++ b/internal/httpd/webadmin.go @@ -42,7 +42,6 @@ import ( "github.com/drakkan/sftpgo/v2/internal/plugin" "github.com/drakkan/sftpgo/v2/internal/smtp" "github.com/drakkan/sftpgo/v2/internal/util" - "github.com/drakkan/sftpgo/v2/internal/version" "github.com/drakkan/sftpgo/v2/internal/vfs" ) @@ -160,21 +159,6 @@ type basePage struct { FolderQuotaScanURL string StatusURL string MaintenanceURL string - UsersTitle string - AdminsTitle string - ConnectionsTitle string - FoldersTitle string - GroupsTitle string - EventRulesTitle string - EventActionsTitle string - RolesTitle string - StatusTitle string - MaintenanceTitle string - DefenderTitle string - IPListsTitle string - EventsTitle string - ConfigsTitle string - Version string CSRFToken string IsEventManagerPage bool IsIPManagerPage bool @@ -182,7 +166,7 @@ type basePage struct { HasDefender bool HasSearcher bool HasExternalLogin bool - LoggedAdmin *dataprovider.Admin + LoggedUser *dataprovider.Admin Branding UIBranding } @@ -416,7 +400,7 @@ type userTemplateFields struct { func loadAdminTemplates(templatesPath string) { usersPaths := []string{ - filepath.Join(templatesPath, templateCommonDir, templateCommonCSS), + filepath.Join(templatesPath, templateCommonDir, templateCommonBase), filepath.Join(templatesPath, templateAdminDir, templateBase), filepath.Join(templatesPath, templateAdminDir, templateUsers), } @@ -730,22 +714,7 @@ func (s *httpdServer) getBasePageData(title, currentURL string, r *http.Request) StatusURL: webStatusPath, FolderQuotaScanURL: webScanVFolderPath, MaintenanceURL: webMaintenancePath, - UsersTitle: pageUsersTitle, - AdminsTitle: pageAdminsTitle, - ConnectionsTitle: pageConnectionsTitle, - FoldersTitle: pageFoldersTitle, - GroupsTitle: pageGroupsTitle, - EventRulesTitle: pageEventRulesTitle, - EventActionsTitle: pageEventActionsTitle, - RolesTitle: pageRolesTitle, - StatusTitle: pageStatusTitle, - MaintenanceTitle: pageMaintenanceTitle, - DefenderTitle: pageDefenderTitle, - IPListsTitle: pageIPListsTitle, - EventsTitle: pageEventsTitle, - ConfigsTitle: pageConfigsTitle, - Version: version.GetAsString(), - LoggedAdmin: getAdminFromToken(r), + LoggedUser: getAdminFromToken(r), IsEventManagerPage: isEventManagerResource(currentURL), IsIPManagerPage: isIPListsResource(currentURL), IsServerManagerPage: isServerManagerResource(currentURL), @@ -859,7 +828,7 @@ func (s *httpdServer) renderMFAPage(w http.ResponseWriter, r *http.Request) { SaveTOTPURL: webAdminTOTPSavePath, RecCodesURL: webAdminRecoveryCodesPath, } - admin, err := dataprovider.AdminExists(data.LoggedAdmin.Username) + admin, err := dataprovider.AdminExists(data.LoggedUser.Username) if err != nil { s.renderInternalServerErrorPage(w, r, err) return @@ -873,7 +842,7 @@ func (s *httpdServer) renderProfilePage(w http.ResponseWriter, r *http.Request, basePage: s.getBasePageData(pageProfileTitle, webAdminProfilePath, r), Error: error, } - admin, err := dataprovider.AdminExists(data.LoggedAdmin.Username) + admin, err := dataprovider.AdminExists(data.LoggedUser.Username) if err != nil { s.renderInternalServerErrorPage(w, r, err) return @@ -1015,7 +984,7 @@ func (s *httpdServer) renderUserPage(w http.ResponseWriter, r *http.Request, use } } var roles []dataprovider.Role - if basePage.LoggedAdmin.Role == "" { + if basePage.LoggedUser.Role == "" { var err error roles, err = s.getWebRoles(w, r, 10, true) if err != nil { @@ -1049,7 +1018,7 @@ func (s *httpdServer) renderUserPage(w http.ResponseWriter, r *http.Request, use Filesystem: user.FsConfig, IsUserPage: true, IsGroupPage: false, - IsHidden: basePage.LoggedAdmin.Filters.Preferences.HideFilesystem(), + IsHidden: basePage.LoggedUser.Filters.Preferences.HideFilesystem(), HasUsersBaseDir: dataprovider.HasUsersBaseDir(), DirPath: user.HomeDir, }, diff --git a/static/locales/en/translation.json b/static/locales/en/translation.json index eba031b4..1980e51d 100644 --- a/static/locales/en/translation.json +++ b/static/locales/en/translation.json @@ -27,7 +27,24 @@ "error429": "Too Many Requests", "error500": "Internal Server Error", "errorPDF": "Unable to show PDF file", - "error_editor": "Cannot open file editor" + "error_editor": "Cannot open file editor", + "users": "Users", + "groups": "Groups", + "folders": "Virtual folders", + "connections": "Active sessions", + "event_manager": "Event Manager", + "event_rules": "Rules", + "event_actions": "Actions", + "ip_manager": "IP Manager", + "ip_lists": "IP Lists", + "defender": "Auto Block List", + "admins": "Admins", + "roles": "Roles", + "server_manager": "Server Manager", + "configs": "Configurations", + "logs": "Logs", + "maintenance": "Maintenance", + "status": "Status" }, "setup": { "desc": "To start using SFTPGo you need to create an administrator user", @@ -370,6 +387,7 @@ "required": "Password change is required. Set a new password to continue using your account" }, "user": { + "view_manage": "View and manage users", "username_reserved": "The specified username is reserved", "username_invalid": "The specified username is not valid, the following characters are allowed: a-zA-Z0-9-_.~", "home_required": "The home directory is mandatory", diff --git a/static/locales/it/translation.json b/static/locales/it/translation.json index a021db27..2859d2ba 100644 --- a/static/locales/it/translation.json +++ b/static/locales/it/translation.json @@ -27,7 +27,24 @@ "error429": "Troppe richieste", "error500": "Errore interno del server", "errorPDF": "Impossibile mostrare il file PDF", - "error_editor": "Impossibile aprire l'editor di file" + "error_editor": "Impossibile aprire l'editor di file", + "users": "Utenti", + "groups": "Gruppi", + "folders": "Cartelle virtuali", + "connections": "Sessioni attive", + "event_manager": "Gestione eventi", + "event_rules": "Regole", + "event_actions": "Azioni", + "ip_manager": "Gestione IP", + "ip_lists": "Liste IP", + "defender": "Blocchi automatici", + "admins": "Amministratori", + "roles": "Ruoli", + "server_manager": "Gestione server", + "configs": "Configurazioni", + "logs": "Registro eventi", + "maintenance": "Manutenzione", + "status": "Stato" }, "setup": { "desc": "Per iniziare a utilizzare SFTPGo devi creare un utente amministratore", @@ -370,6 +387,7 @@ "required": "È richiesta la modifica della password. Imposta una nuova password per continuare a utilizzare il tuo account" }, "user": { + "view_manage": "Visualizza e gestisci utenti", "username_reserved": "Il nome utente specificato è riservato", "username_invalid": "Il nome utente specificato non è valido, sono consentiti i seguenti caratteri: a-zA-Z0-9-_.~", "home_required": "La directory principale è obbligatoria", diff --git a/templates/common/base.html b/templates/common/base.html index 9535e043..d12f4026 100644 --- a/templates/common/base.html +++ b/templates/common/base.html @@ -182,7 +182,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). expirationTime: 7 * 24 * 60 * 60 * 1000, // 7 days defaultVersion: '{{.Version}}' }, { - loadPath: '{{.StaticURL}}/locales/{{"{{lng}}"}}/{{"{{ns}}"}}.json' + loadPath: '{{.StaticURL}}/locales/{{"{{lng}}"}}/{{"{{ns}}"}}.json?_='+new Date().getTime().toString() } ] } diff --git a/templates/webadmin/base.html b/templates/webadmin/base.html index 47a34bac..f639cb8c 100644 --- a/templates/webadmin/base.html +++ b/templates/webadmin/base.html @@ -1,345 +1,286 @@ -{{define "base"}} - - - - - - - - - - - - {{.Branding.Name}} - {{template "title" .}} - - - - - - - - - - {{- range .Branding.DefaultCSS}} - - {{- end}} - - {{block "extra_css" .}}{{end}} - - {{range .Branding.ExtraCSS}} - - {{end}} - - - - - - -
- - {{if .LoggedAdmin.Username}} - - - - {{end}} - - -
- - -
- - {{if .LoggedAdmin.Username}} - - - - {{end}} - - -
- - {{template "page_body" .}} - -
- - -
- - {{if .LoggedAdmin.Username}} - -
-
- -
-
- - {{end}} - -
- - +{{- define "navitems"}} +{{- block "additionalnavitems" .}}{{- end}} +{{- template "theme-switcher"}} +
+
+ + + +
- + +
+{{- end}} - - - +{{- define "sidebaritems"}} +{{- if .LoggedUser.HasPermission "view_users"}} + @@ -109,9 +109,9 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
- + - Add + Add
diff --git a/templates/webclient/share.html b/templates/webclient/share.html index bb310a9f..2dc31060 100644 --- a/templates/webclient/share.html +++ b/templates/webclient/share.html @@ -61,7 +61,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). name="path" value="{{$val}}" />
- @@ -70,7 +70,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). - Delete + Delete
@@ -83,7 +83,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). name="path" value="" />
- @@ -92,7 +92,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). - Delete + Delete
@@ -102,9 +102,9 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
- + - Add + Add
diff --git a/templates/webclient/shares.html b/templates/webclient/shares.html index 47e44790..d0b3a609 100644 --- a/templates/webclient/shares.html +++ b/templates/webclient/shares.html @@ -13,15 +13,13 @@ This WebUI is allowed for use only within the SFTPGo product and therefore cannot be used in derivative works/products without an explicit grant from the SFTPGo Team (support@sftpgo.com). --> -{{template "base" .}} +{{- template "base" .}} {{- define "extra_css"}} {{- end}} - -{{define "page_body"}} - +{{- define "page_body"}}

View and manage shares

@@ -29,23 +27,22 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
- Loading... + Loading...
-
+
-
- - @@ -372,7 +369,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). stateDuration: 0, stateLoadParams: function (settings, data) { if (data.search.search){ - const filterSearch = document.querySelector('[data-share-table-filter="search"]'); + const filterSearch = document.querySelector('[data-table-filter="search"]'); filterSearch.value = data.search.search; } }, @@ -405,7 +402,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). } var handleSearchDatatable = function () { - const filterSearch = document.querySelector('[data-share-table-filter="search"]'); + const filterSearch = document.querySelector('[data-table-filter="search"]'); filterSearch.addEventListener('keyup', function (e) { dt.rows().deselect(); dt.search(e.target.value, true, false).draw();