From d97ac51374b09274ae135c21253bea2dd4f3aa49 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 24 Feb 2023 16:27:22 +0100 Subject: dashboard: suggest to show all subsystems only when needed Check if any subsystems have been hidden from the list before suggesting to show the rest. --- dashboard/app/main.go | 10 ++++++---- dashboard/app/subsystems.html | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dashboard/app/main.go b/dashboard/app/main.go index 65c79fc9d..4bf69e94b 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -158,8 +158,8 @@ type uiSubsystemsPage struct { Header *uiHeader List []*uiSubsystem Unclassified *uiSubsystem - NonEmpty bool - EmptyURL string + SomeHidden bool + ShowAllURL string } type uiSubsystem struct { @@ -861,9 +861,11 @@ func handleSubsystemsList(c context.Context, w http.ResponseWriter, r *http.Requ } nonEmpty := r.FormValue("all") != "true" list := []*uiSubsystem{} + someHidden := false for _, item := range service.List() { record := createUISubsystem(hdr.Namespace, item, cached) if nonEmpty && (record.Open.Count+record.Fixed.Count) == 0 { + someHidden = true continue } list = append(list, record) @@ -884,8 +886,8 @@ func handleSubsystemsList(c context.Context, w http.ResponseWriter, r *http.Requ Header: hdr, List: list, Unclassified: unclassified, - NonEmpty: nonEmpty, - EmptyURL: html.AmendURL(getCurrentURL(c), "all", "true"), + SomeHidden: someHidden, + ShowAllURL: html.AmendURL(getCurrentURL(c), "all", "true"), }) } diff --git a/dashboard/app/subsystems.html b/dashboard/app/subsystems.html index efaf45c7f..208c4f243 100644 --- a/dashboard/app/subsystems.html +++ b/dashboard/app/subsystems.html @@ -15,8 +15,8 @@ The list of polled trees. {{template "header" .Header}}

The list of subsystems


(*) Note that the numbers below do not represent the latest data. They are updated once an hour.

- {{if .NonEmpty}} - Empty subsystems have been hidden from the list. {{link .EmptyURL "Show all"}}.
+ {{if .SomeHidden}} + Empty subsystems have been hidden from the list. {{link .ShowAllURL "Show all"}}.
{{end}} -- cgit mrf-deployment
Subsystems list