aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-02-22 16:46:50 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2023-02-22 17:52:26 +0100
commit6b9e84f9440313dcd09e408d09d3440f666db8ff (patch)
treedc2e303dd94c107149188744e1cc6afe563ce908
parent9f1e2cb341151afb58bc3b8551b89b52f921b61c (diff)
dashboard: hide empty subsystems from list
Add a link to show everything.
-rw-r--r--dashboard/app/main.go19
-rw-r--r--dashboard/app/main_test.go5
-rw-r--r--dashboard/app/subsystems.html7
3 files changed, 24 insertions, 7 deletions
diff --git a/dashboard/app/main.go b/dashboard/app/main.go
index 176dc897a..55574c4c0 100644
--- a/dashboard/app/main.go
+++ b/dashboard/app/main.go
@@ -155,8 +155,10 @@ type uiSubsystemPage struct {
}
type uiSubsystemsPage struct {
- Header *uiHeader
- List []*uiSubsystem
+ Header *uiHeader
+ List []*uiSubsystem
+ NonEmpty bool
+ EmptyURL string
}
type uiSubsystem struct {
@@ -851,14 +853,21 @@ func handleSubsystemsList(c context.Context, w http.ResponseWriter, r *http.Requ
if service == nil {
return fmt.Errorf("the namespace does not have subsystems")
}
+ nonEmpty := r.FormValue("all") != "true"
list := []*uiSubsystem{}
for _, item := range service.List() {
- list = append(list, createUISubsystem(hdr.Namespace, item, cached))
+ record := createUISubsystem(hdr.Namespace, item, cached)
+ if nonEmpty && (record.Open.Count+record.Fixed.Count) == 0 {
+ continue
+ }
+ list = append(list, record)
}
sort.Slice(list, func(i, j int) bool { return list[i].Name < list[j].Name })
return serveTemplate(w, "subsystems.html", &uiSubsystemsPage{
- Header: hdr,
- List: list,
+ Header: hdr,
+ List: list,
+ NonEmpty: nonEmpty,
+ EmptyURL: html.AmendURL(getCurrentURL(c), "all", "true"),
})
}
diff --git a/dashboard/app/main_test.go b/dashboard/app/main_test.go
index 8f732ac3d..fe9410da3 100644
--- a/dashboard/app/main_test.go
+++ b/dashboard/app/main_test.go
@@ -208,6 +208,11 @@ func TestSubsystemsList(t *testing.T) {
reply, err := c.AuthGET(AccessAdmin, "/test1/subsystems")
c.expectOK(err)
assert.Contains(t, string(reply), "subsystemA")
+ assert.NotContains(t, string(reply), "subsystemB")
+
+ reply, err = c.AuthGET(AccessAdmin, "/test1/subsystems?all=true")
+ c.expectOK(err)
+ assert.Contains(t, string(reply), "subsystemA")
assert.Contains(t, string(reply), "subsystemB")
}
diff --git a/dashboard/app/subsystems.html b/dashboard/app/subsystems.html
index 9314ac557..b6f9bbd71 100644
--- a/dashboard/app/subsystems.html
+++ b/dashboard/app/subsystems.html
@@ -13,8 +13,11 @@ The list of polled trees.
</head>
<body>
{{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>
+ <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>
+ {{if .NonEmpty}}
+ Empty subsystems have been hidden from the list. {{link .EmptyURL "Show all"}}. <br />
+ {{end}}
<table class="list_table">
<caption>Subsystems list</caption>
<tr>