diff --git a/audit/internal/app/app.go b/audit/internal/app/app.go index 6a14e7f..95c1580 100644 --- a/audit/internal/app/app.go +++ b/audit/internal/app/app.go @@ -57,6 +57,7 @@ type networkManager interface { type serviceManager interface { ListBeeServices() ([]string, error) + ServiceState(name string) string ServiceStatus(name string) (string, error) ServiceDo(name string, action platform.ServiceAction) (string, error) } @@ -356,6 +357,10 @@ func (a *App) ListBeeServices() ([]string, error) { return a.services.ListBeeServices() } +func (a *App) ServiceState(name string) string { + return a.services.ServiceState(name) +} + func (a *App) ServiceStatus(name string) (string, error) { return a.services.ServiceStatus(name) } diff --git a/audit/internal/app/app_test.go b/audit/internal/app/app_test.go index c15ac45..bd1d79e 100644 --- a/audit/internal/app/app_test.go +++ b/audit/internal/app/app_test.go @@ -52,6 +52,10 @@ func (f fakeServices) ListBeeServices() ([]string, error) { return nil, nil } +func (f fakeServices) ServiceState(name string) string { + return "active" +} + func (f fakeServices) ServiceStatus(name string) (string, error) { return f.serviceStatusFn(name) } diff --git a/audit/internal/webui/api.go b/audit/internal/webui/api.go index de8bc4d..392e335 100644 --- a/audit/internal/webui/api.go +++ b/audit/internal/webui/api.go @@ -236,13 +236,15 @@ func (h *handler) handleAPIServicesList(w http.ResponseWriter, r *http.Request) return } type serviceInfo struct { - Name string `json:"name"` - Status string `json:"status"` + Name string `json:"name"` + State string `json:"state"` + Body string `json:"body"` } result := make([]serviceInfo, 0, len(names)) for _, name := range names { - status, _ := h.opts.App.ServiceStatus(name) - result = append(result, serviceInfo{Name: name, Status: status}) + state := h.opts.App.ServiceState(name) + body, _ := h.opts.App.ServiceStatus(name) + result = append(result, serviceInfo{Name: name, State: state, Body: body}) } writeJSON(w, result) } diff --git a/audit/internal/webui/pages.go b/audit/internal/webui/pages.go index 92f3e24..85c08b6 100644 --- a/audit/internal/webui/pages.go +++ b/audit/internal/webui/pages.go @@ -515,9 +515,16 @@ func renderServices() string { function loadServices() { fetch('/api/services').then(r=>r.json()).then(svcs => { const rows = svcs.map(s => { - const st = s.status||'unknown'; - const badge = st.includes('active') ? 'badge-ok' : st.includes('failed') ? 'badge-err' : 'badge-warn'; - return '
| Service | Status | Actions |
|---|