diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-02-24 16:27:22 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2023-02-27 09:10:32 +0100 |
| commit | d97ac51374b09274ae135c21253bea2dd4f3aa49 (patch) | |
| tree | d3d21c33dfa53e4e8c6f4674661b236b3de775d8 | |
| parent | 9189cb53da283575621c0138ff58bc091db844e4 (diff) | |
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.
| -rw-r--r-- | dashboard/app/main.go | 10 | ||||
| -rw-r--r-- | 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}} <h2>The list of subsystems</h2><br> <i>(*) Note that the numbers below do not represent the latest data. They are updated once an hour.</i><br><br> - {{if .NonEmpty}} - Empty subsystems have been hidden from the list. {{link .EmptyURL "Show all"}}. <br> + {{if .SomeHidden}} + Empty subsystems have been hidden from the list. {{link .ShowAllURL "Show all"}}. <br> {{end}} <table class="list_table"> <caption>Subsystems list</caption> |
