diff --git a/internal/apps/mysql/app.go b/internal/apps/mysql/app.go index 48948932..73868a3b 100644 --- a/internal/apps/mysql/app.go +++ b/internal/apps/mysql/app.go @@ -37,7 +37,7 @@ func (s *App) Route(r chi.Router) { r.Get("/load", s.Load) r.Get("/config", s.GetConfig) r.Post("/config", s.UpdateConfig) - r.Post("/clear_error_log", s.ClearErrorLog) + r.Post("/clear_log", s.ClearLog) r.Get("/slow_log", s.SlowLog) r.Post("/clear_slow_log", s.ClearSlowLog) r.Get("/root_password", s.GetRootPassword) @@ -159,8 +159,8 @@ func (s *App) Load(w http.ResponseWriter, r *http.Request) { service.Success(w, load) } -// ClearErrorLog 清空错误日志 -func (s *App) ClearErrorLog(w http.ResponseWriter, r *http.Request) { +// ClearLog 清空日志 +func (s *App) ClearLog(w http.ResponseWriter, r *http.Request) { if err := systemctl.LogClear("mysqld"); err != nil { service.Error(w, http.StatusInternalServerError, "%v", err) return diff --git a/internal/apps/php/app.go b/internal/apps/php/app.go index a4078081..874272d1 100644 --- a/internal/apps/php/app.go +++ b/internal/apps/php/app.go @@ -46,9 +46,9 @@ func (s *App) Route(version uint) func(r chi.Router) { r.Get("/fpm_config", php.GetFPMConfig) r.Post("/fpm_config", php.UpdateFPMConfig) r.Get("/load", php.Load) - r.Get("/error_log", php.ErrorLog) + r.Get("/log", php.Log) r.Get("/slow_log", php.SlowLog) - r.Post("/clear_error_log", php.ClearErrorLog) + r.Post("/clear_log", php.ClearLog) r.Post("/clear_slow_log", php.ClearSlowLog) r.Get("/extensions", php.ExtensionList) r.Post("/extensions", php.InstallExtension) @@ -169,7 +169,7 @@ func (s *App) Load(w http.ResponseWriter, r *http.Request) { service.Success(w, loads) } -func (s *App) ErrorLog(w http.ResponseWriter, r *http.Request) { +func (s *App) Log(w http.ResponseWriter, r *http.Request) { service.Success(w, fmt.Sprintf("%s/server/php/%d/var/log/php-fpm.log", app.Root, s.version)) } @@ -177,7 +177,7 @@ func (s *App) SlowLog(w http.ResponseWriter, r *http.Request) { service.Success(w, fmt.Sprintf("%s/server/php/%d/var/log/slow.log", app.Root, s.version)) } -func (s *App) ClearErrorLog(w http.ResponseWriter, r *http.Request) { +func (s *App) ClearLog(w http.ResponseWriter, r *http.Request) { if _, err := shell.Execf("cat /dev/null > %s/server/php/%d/var/log/php-fpm.log", app.Root, s.version); err != nil { service.Error(w, http.StatusInternalServerError, "%v", err) return diff --git a/internal/http/request/app.go b/internal/http/request/app.go index 84d6794f..15066eb8 100644 --- a/internal/http/request/app.go +++ b/internal/http/request/app.go @@ -9,6 +9,10 @@ type AppSlug struct { Slug string `json:"slug" form:"slug" validate:"required"` } +type AppSlugs struct { + Slugs string `json:"slugs" form:"slugs" validate:"required"` +} + type AppUpdateShow struct { Slug string `json:"slug" form:"slug" validate:"required|exists:apps,slug"` Show bool `json:"show" form:"show"` diff --git a/internal/service/app.go b/internal/service/app.go index bb4bdd9f..1828eaa0 100644 --- a/internal/service/app.go +++ b/internal/service/app.go @@ -2,6 +2,7 @@ package service import ( "net/http" + "strings" "github.com/leonelquinteros/gotext" "github.com/libtnb/chix" @@ -144,28 +145,27 @@ func (s *AppService) UpdateShow(w http.ResponseWriter, r *http.Request) { } func (s *AppService) IsInstalled(w http.ResponseWriter, r *http.Request) { - req, err := Bind[request.AppSlug](r) + req, err := Bind[request.AppSlugs](r) if err != nil { Error(w, http.StatusUnprocessableEntity, "%v", err) return } - app, err := s.appRepo.Get(req.Slug) - if err != nil { - Error(w, http.StatusInternalServerError, "%v", err) - return + flag := false + slugs := strings.Split(req.Slugs, ",") + for _, item := range slugs { + installed, err := s.appRepo.IsInstalled(item) + if err != nil { + Error(w, http.StatusInternalServerError, "%v", err) + return + } + if installed { + flag = true + break + } } - installed, err := s.appRepo.IsInstalled(req.Slug) - if err != nil { - Error(w, http.StatusInternalServerError, "%v", err) - return - } - - Success(w, chix.M{ - "name": app.Name, - "installed": installed, - }) + Success(w, flag) } func (s *AppService) UpdateCache(w http.ResponseWriter, r *http.Request) { diff --git a/internal/service/monitor.go b/internal/service/monitor.go index ab31fcca..d13a9a04 100644 --- a/internal/service/monitor.go +++ b/internal/service/monitor.go @@ -68,6 +68,10 @@ func (s *MonitorService) List(w http.ResponseWriter, r *http.Request) { Error(w, http.StatusInternalServerError, "%v", err) return } + if len(monitors) == 0 { + Success(w, types.MonitorData{}) + return + } var list types.MonitorData var bytesSent uint64 diff --git a/renovate.json b/renovate.json index 4afcdae2..27077a70 100644 --- a/renovate.json +++ b/renovate.json @@ -29,5 +29,7 @@ "automerge": true } ], - "ignoreDeps": [] + "ignoreDeps": [ + "monaco-editor" + ] } diff --git a/web/index.html b/web/index.html index 294b95c5..29a01472 100644 --- a/web/index.html +++ b/web/index.html @@ -23,7 +23,6 @@