index chart fix

pull/78/head
Hunter Long 2018-10-03 08:20:45 -07:00
parent ac2ce43499
commit fc1fe03f89
2 changed files with 10 additions and 5 deletions

View File

@ -71,15 +71,17 @@ func renderServiceChartsHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "max-age=60")
//var data []string
//end := now.EndOfDay().UTC()
//start := now.BeginningOfDay().UTC()
end := time.Now().UTC()
start := time.Now().Add((-24 * 7) * time.Hour).UTC()
var srvs []*core.Service
for _, s := range services {
srvs = append(srvs, s.(*core.Service))
}
out := struct {
Services []*core.Service
}{srvs}
Start int64
End int64
}{srvs, start.Unix(), end.Unix()}
executeJSResponse(w, r, "charts.js", out)
}

View File

@ -1,4 +1,7 @@
{{define "charts"}}{{ range Services }}
{{define "charts"}}
{{$start := .Start}}
{{$end := .End}}
{{ range .Services }}
var ctx_{{js .Id}} = document.getElementById("service_{{js .Id}}").getContext('2d');
var chartdata_{{js .Id}} = new Chart(ctx_{{js .Id}}, {
type: 'line',
@ -133,5 +136,5 @@ var chartdata_{{js .Id}} = new Chart(ctx_{{js .Id}}, {
}
});
AjaxChart(chartdata_{{js .Id}},{{js .Id}},0,99999999999,"hour");
AjaxChart(chartdata_{{js .Id}},{{js .Id}},{{$start}},{{$end}},"hour");
{{end}}{{end}}