Commit b219179c authored by ale's avatar ale

Fix another issue with the status page

Use pb.Status as the node information.
parent f0ce712f
Pipeline #2709 passed with stages
in 4 minutes and 32 seconds
......@@ -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
}
......
......@@ -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 {
......
......@@ -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 {
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment