Browse Source

Disabled sensor 77

Dmitry Yu Okunev 3 years ago
parent
commit
2e608b1ff6

+ 1 - 1
server/httpsite/app/controllers/Dashboard.go

@@ -42,7 +42,7 @@ var groups = map[string]groupInfo {
 		"ServerRack5":		groupInfo{DefaultSensorId: 66,	SensorIds: []int{ 64,  65,  66 }},
 		"ServerRack4":		groupInfo{DefaultSensorId: 69,	SensorIds: []int{ 67,  68,  69 }},
 		"ServerRack3":		groupInfo{DefaultSensorId: 74,	SensorIds: []int{ 72,  73,  74 }},
-		"ServerRack2":		groupInfo{DefaultSensorId: 77,	SensorIds: []int{ 75,  76,  77 }},
+		"ServerRack2":		groupInfo{DefaultSensorId: 76,	SensorIds: []int{ 75,  76, -77 }},
 		"ServerRack1":		groupInfo{DefaultSensorId: 85,	SensorIds: []int{ 84,  83,  85 }},
 		"ServerRack0":		groupInfo{DefaultSensorId: 81,	SensorIds: []int{ 80,  82,  81 }},
 		"ServerRack6":		groupInfo{DefaultSensorId: 89,	SensorIds: []int{ 89,  88,  90 }},

+ 24 - 2
server/httpsite/app/init.go

@@ -4,6 +4,7 @@ import (
 	  "fmt"
 	  "time"
 	  "reflect"
+	  "math"
 	  "os"
 	  "github.com/revel/revel"
 	  "strings"
@@ -39,9 +40,9 @@ func initDB() {
 }
 
 func initRecordsConverted() {
-/*	if revel.DevMode {	// Don't corrupt data
+	if revel.DevMode {	// Don't corrupt data
 		return
-	}*/
+	}
 
 	go func() {
 		for ;; {
@@ -120,6 +121,21 @@ func initCasClient() {
 	})
 }
 
+func toFloat64(i interface{}) (float64) {
+	switch v := i.(type) {
+		case int64:
+			return float64(v)
+		case int:
+			return float64(v)
+		case float32:
+			return float64(v)
+		case float64:
+			return v
+	}
+
+	return math.NaN()
+}
+
 func init() {
 	// Filters is the default set of global filters.
 	revel.Filters = []revel.Filter{
@@ -203,6 +219,12 @@ func init() {
 		}
 		return arg == reflect.Zero(reflect.TypeOf(arg)).Interface()
 	}
+	revel.TemplateFuncs["flt"] = func(a, b interface{}) (bool) {
+		aV := toFloat64(a)
+		bV := toFloat64(b)
+
+		return aV < bV
+	}
 }
 
 // TODO turn this into revel.HeaderFilter

+ 5 - 1
server/httpsite/app/views/Dashboard/_sensitiveMapTile.html

@@ -2,6 +2,10 @@
 	{{ if isEmpty . }}
 		NaN
 	{{ else }}
-		{{ .Value }}
+		{{ if flt .Value 0 }}
+			NaN
+		{{ else }}
+			{{ .Value }}
+		{{ end }}
 	{{ end }}
 </li>