From d3ca3e59c015886877e10b9caff8fd2fcfd800bd Mon Sep 17 00:00:00 2001 From: ze0s <43699394+zze0s@users.noreply.github.com> Date: Fri, 22 Sep 2023 22:05:14 +0200 Subject: [PATCH] feat(web): show more app info (#1145) * feat(web): add app info * database type used * application binary path * config path * feat(web): label colors light theme * feat(web): truncate long fields --- internal/http/config.go | 23 +++++++++++++++++++++++ web/src/screens/settings/Application.tsx | 15 +++++++++------ web/src/screens/settings/Logs.tsx | 12 ++++++------ web/src/types/Config.d.ts | 3 +++ 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/internal/http/config.go b/internal/http/config.go index de7024b..5902c49 100644 --- a/internal/http/config.go +++ b/internal/http/config.go @@ -6,6 +6,8 @@ package http import ( "encoding/json" "net/http" + "os" + "path/filepath" "github.com/autobrr/autobrr/internal/config" "github.com/autobrr/autobrr/internal/domain" @@ -15,6 +17,9 @@ import ( ) type configJson struct { + Application string `json:"application"` + ConfigDir string `json:"config_dir"` + Database string `json:"database"` Host string `json:"host"` Port int `json:"port"` LogLevel string `json:"log_level"` @@ -50,6 +55,7 @@ func (h configHandler) Routes(r chi.Router) { func (h configHandler) getConfig(w http.ResponseWriter, r *http.Request) { conf := configJson{ + ConfigDir: h.cfg.Config.ConfigPath, Host: h.cfg.Config.Host, Port: h.cfg.Config.Port, LogLevel: h.cfg.Config.LogLevel, @@ -57,12 +63,29 @@ func (h configHandler) getConfig(w http.ResponseWriter, r *http.Request) { LogMaxSize: h.cfg.Config.LogMaxSize, LogMaxBackups: h.cfg.Config.LogMaxBackups, BaseURL: h.cfg.Config.BaseURL, + Database: h.cfg.Config.DatabaseType, CheckForUpdates: h.cfg.Config.CheckForUpdates, Version: h.server.version, Commit: h.server.commit, Date: h.server.date, } + ex, err := os.Executable() + if err != nil { + h.encoder.Error(w, err) + return + } + + conf.Application = ex + + absPath, err := filepath.Abs(h.cfg.Config.ConfigPath) + if err != nil { + h.encoder.Error(w, err) + return + } + + conf.ConfigDir = absPath + render.JSON(w, r, conf) } diff --git a/web/src/screens/settings/Application.tsx b/web/src/screens/settings/Application.tsx index dcd7583..04cadaf 100644 --- a/web/src/screens/settings/Application.tsx +++ b/web/src/screens/settings/Application.tsx @@ -23,9 +23,9 @@ interface RowItemProps { const RowItem = ({ label, value, title, emptyText }: RowItemProps) => { return (