From b18b37042dd327a600ac5057adcff8a1251cddb5 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Mon, 29 Jan 2024 10:49:21 +0100 Subject: [PATCH] WIP new WebAdmin: add missing translations for events page Signed-off-by: Nicola Murino --- go.mod | 4 +-- go.sum | 7 ++-- static/locales/en/translation.json | 13 ++++++++ static/locales/it/translation.json | 13 ++++++++ templates/webadmin/events.html | 51 +++++++++++++++++++++++++++--- 5 files changed, 79 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index eec31b29..e9ef564c 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/eikenb/pipeat v0.0.0-20210730190139-06b3e6902001 github.com/fclairamb/ftpserverlib v0.22.0 github.com/fclairamb/go-log v0.4.1 - github.com/go-acme/lego/v4 v4.14.2 + github.com/go-acme/lego/v4 v4.15.0 github.com/go-chi/chi/v5 v5.0.11 github.com/go-chi/jwtauth/v5 v5.3.0 github.com/go-chi/render v1.0.3 @@ -156,7 +156,7 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/tklauser/go-sysconf v0.3.13 // indirect github.com/tklauser/numcpus v0.7.0 // indirect - github.com/yusufpapurcu/wmi v1.2.3 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect diff --git a/go.sum b/go.sum index fe5ff2e5..d4c27db1 100644 --- a/go.sum +++ b/go.sum @@ -138,8 +138,8 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/go-acme/lego/v4 v4.14.2 h1:/D/jqRgLi8Cbk33sLGtu2pX2jEg3bGJWHyV8kFuUHGM= -github.com/go-acme/lego/v4 v4.14.2/go.mod h1:kBXxbeTg0x9AgaOYjPSwIeJy3Y33zTz+tMD16O4MO6c= +github.com/go-acme/lego/v4 v4.15.0 h1:A7MHEU3b+TDFqhC/HmzMJnzPbyeaYvMZQBbqgvbThhU= +github.com/go-acme/lego/v4 v4.15.0/go.mod h1:eeGhjW4zWT7Ccqa3sY7ayEqFLCAICx+mXgkMHKIkLxg= github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA= github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/jwtauth/v5 v5.3.0 h1:X7RKGks1lrVeIe2omGyz47pNaNjG2YmwlRN5UKhN8qg= @@ -403,8 +403,9 @@ github.com/yl2chen/cidranger v1.0.3-0.20210928021809-d1cb2c52f37a h1:XfF01GyP+0e github.com/yl2chen/cidranger v1.0.3-0.20210928021809-d1cb2c52f37a/go.mod h1:aXb8yZQEWo1XHGMf1qQfnb83GR/EJ2EBlwtUgAaNBoE= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= diff --git a/static/locales/en/translation.json b/static/locales/en/translation.json index 3285ea84..1361df08 100644 --- a/static/locales/en/translation.json +++ b/static/locales/en/translation.json @@ -864,5 +864,18 @@ "path": "Path", "object": "Object", "event": "Event" + }, + "provider_objects": { + "user": "User", + "folder": "Folder", + "group": "Group", + "admin": "Admin", + "api_key": "API key", + "share": "Share", + "event_action": "Action", + "event_rule": "Rule", + "role": "role", + "ip_list_entry": "IP list entry", + "configs": "Configurations" } } \ No newline at end of file diff --git a/static/locales/it/translation.json b/static/locales/it/translation.json index 33458802..1738fc36 100644 --- a/static/locales/it/translation.json +++ b/static/locales/it/translation.json @@ -864,5 +864,18 @@ "path": "Percorso", "object": "Oggetto", "event": "Evento" + }, + "provider_objects": { + "user": "Utente", + "folder": "Cartella virtuale", + "group": "Gruppo", + "admin": "Amministratore", + "api_key": "Chiave API", + "share": "Condivisione", + "event_action": "Azione", + "event_rule": "Regola", + "role": "ruolo", + "ip_list_entry": "Elemento lista IP", + "configs": "Configurazioni" } } \ No newline at end of file diff --git a/templates/webadmin/events.html b/templates/webadmin/events.html index c97f249e..08ac8c4d 100644 --- a/templates/webadmin/events.html +++ b/templates/webadmin/events.html @@ -221,13 +221,17 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). function humanizeMilliseconds(val) { let units = ["d", "h", "m", "s", "ms"]; + let decimalPoints = 1; if (val > 1000){ units = ["d", "h", "m", "s"] } + if (val > 60000){ + decimalPoints = 0; + } return humanizeDuration(val, { language: i18next.resolvedLanguage, fallbacks: ["en"], - maxDecimalPoints: 1, + maxDecimalPoints: decimalPoints, units: units }) } @@ -704,10 +708,49 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). if (!data){ return ""; } - if (row.object_name){ - return escapeHTML(`${data} "${row.object_name}"`); + let message; + switch (data){ + case "user": + message = $.t('provider_objects.user'); + break; + case "folder": + message = $.t('provider_objects.folder'); + break; + case "group": + message = $.t('provider_objects.group'); + break; + case "admin": + message = $.t('provider_objects.admin'); + break; + case "api_key": + message = $.t('provider_objects.api_key'); + break; + case "share": + message = $.t('provider_objects.share'); + break; + case "event_action": + message = $.t('provider_objects.event_action'); + break; + case "event_rule": + message = $.t('provider_objects.event_rule'); + break; + case "role": + message = $.t('provider_objects.role'); + break; + case "ip_list_entry": + message = $.t('provider_objects.ip_list_entry'); + break; + case "configs": + message = $.t('provider_objects.configs'); + break; + default: + console.log("uknown object type: "+data); + return "" } - return escapeHTML(data); + if (row.object_name && data != "configs"){ + return message+= escapeHTML(` "${row.object_name}"`); + } + return message; } return data; }