From b219179c622669b1ec0d02c65a7cfee68e25e6b5 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sat, 13 Apr 2019 00:40:14 +0100 Subject: [PATCH] Fix another issue with the status page Use pb.Status as the node information. --- node/bindata.go | 4 ++-- node/http.go | 10 ++++++++-- node/node_test.go | 4 ++++ node/templates/index.html | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/node/bindata.go b/node/bindata.go index ac86f062..53a610a2 100644 --- a/node/bindata.go +++ b/node/bindata.go @@ -303,7 +303,7 @@ var _templatesIndexHtml = []byte(`<!DOCTYPE html> {{range .Nodes}} <li> {{.Name}} <span class="badge">{{.NumListeners}}</span> - {{if not .IcecastUp}}<span class="label label-danger">IC_DOWN</span>{{end}} + {{if not .IcecastOk}}<span class="label label-danger">IC_DOWN</span>{{end}} </li> {{end}} </ul> @@ -339,7 +339,7 @@ func templatesIndexHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "templates/index.html", size: 2567, mode: os.FileMode(420), modTime: time.Unix(1555111991, 0)} + info := bindataFileInfo{name: "templates/index.html", size: 2567, mode: os.FileMode(420), modTime: time.Unix(1555112385, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/node/http.go b/node/http.go index 97a7dc6a..e61ade96 100644 --- a/node/http.go +++ b/node/http.go @@ -183,13 +183,19 @@ func sendRedirect(w http.ResponseWriter, r *http.Request, targetURL string) { } func serveStatusPage(n *Node, w http.ResponseWriter, r *http.Request, tpl *template.Template, domain string) { + // Convert the list of nodes to just the status. nodes := n.lb.getNodes() + statuses := make([]*pb.Status, 0, len(nodes)) + for _, ni := range nodes { + statuses = append(statuses, ni.status) + } + ms := mountsToStatus(n.mounts.GetMounts(), nodes) ctx := struct { Domain string - Nodes []*nodeInfo + Nodes []*pb.Status Mounts []*mountStatus - }{domain, nodes, ms} + }{domain, statuses, ms} var buf bytes.Buffer if err := tpl.ExecuteTemplate(&buf, "index.html", ctx); err != nil { diff --git a/node/node_test.go b/node/node_test.go index a218b751..14ea7aed 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -121,6 +121,10 @@ func TestNode_StatusPage(t *testing.T) { } httpSrv := httptest.NewServer(newHTTPHandler(n, 8080, "example.com")) + defer httpSrv.Close() + + // Give the Node time to gather its status. + time.Sleep(1 * time.Second) resp, err := http.Get(httpSrv.URL) if err != nil { diff --git a/node/templates/index.html b/node/templates/index.html index cfcd9052..d1839167 100644 --- a/node/templates/index.html +++ b/node/templates/index.html @@ -56,7 +56,7 @@ {{range .Nodes}} <li> {{.Name}} <span class="badge">{{.NumListeners}}</span> - {{if not .IcecastUp}}<span class="label label-danger">IC_DOWN</span>{{end}} + {{if not .IcecastOk}}<span class="label label-danger">IC_DOWN</span>{{end}} </li> {{end}} </ul> -- GitLab