diff --git a/metrics.go b/metrics.go index e153430..1bc4c2d 100644 --- a/metrics.go +++ b/metrics.go @@ -38,7 +38,7 @@ func metricsHandler(response http.ResponseWriter, request *http.Request) { property, ok := request.URL.Query()["property"] if !ok || len(property[0]) < 1 { log.Println("Url Param 'property' is missing") - fmt.Fprintf(response, "{ \"msg\": \"property must be specified in URL\" }") + fmt.Fprintf(response, "{ \"msg\": \"error: property must be specified in URL\" }") return } @@ -46,7 +46,7 @@ func metricsHandler(response http.ResponseWriter, request *http.Request) { if !ok || len(deveui[0]) < 1 { log.Println("Url Param 'deveui' is missing") - fmt.Fprintf(response, "{ \"msg\": \"deveui must be specified in URL\" }") + fmt.Fprintf(response, "{ \"msg\": \"error: deveui must be specified in URL\" }") return } // Query()["deveui"] will return an array of items, @@ -55,7 +55,7 @@ func metricsHandler(response http.ResponseWriter, request *http.Request) { if !(Contains(getMyDevs(name), mydeveui)) { log.Println("specified 'deveui' does not belong to this user") - fmt.Fprintf(response, "{ \"msg\": \"specified deveui does not belong to this user\" }") + fmt.Fprintf(response, "{ \"msg\": \"error: specified deveui does not belong to this user\" }") return } @@ -334,7 +334,7 @@ func getLastMetrics(deveui string) OneMetric { res.Weight = value i, err := strconv.Atoi(value) if err == nil { - res.Weight_kg = fmt.Sprintf("%.2f", float64(i)/1000.0) + res.Weight_kg = fmt.Sprintf("%.3f", float64(i)/1000.0) } else { res.Weight_kg = "ERR" } diff --git a/snippets/graph.html b/snippets/graph.html index 2b5f2e0..d7c4c82 100644 --- a/snippets/graph.html +++ b/snippets/graph.html @@ -184,7 +184,7 @@ function drawGraph(deveui, alias, property, start, stop, create_graph) { maxfunc = function(max) { return max + 2000 } labels = { formatter: function(val, index) { - return (val / 1000.0).toFixed(2); + return (val / 1000.0).toFixed(3); } }; } else if (property==="h") { @@ -212,6 +212,12 @@ function drawGraph(deveui, alias, property, start, stop, create_graph) {
Abo ist abgelaufen
+`); + } else if (mydata.msg.includes("error:")) { + $('#chart').html(`
+
+ Fehler im Aufruf +
`); } else { location.reload(true);