Automatic refresh on index page

This commit is contained in:
Chteufleur 2015-10-07 21:55:55 +02:00
parent f28209fa79
commit 9e60500551
2 changed files with 9 additions and 2 deletions

View File

@ -18,6 +18,7 @@ var (
type SensorPrint struct { type SensorPrint struct {
Name string Name string
Mac string
Value string Value string
Unit string Unit string
Horodate string Horodate string
@ -47,8 +48,8 @@ func getLastTemps() ([]SensorPrint) {
if sens.Name == "" { if sens.Name == "" {
sens.Name = s.SensorMAC sens.Name = s.SensorMAC
} }
sens.Mac = s.SensorMAC
// t := temperature.GetLastTempForSensor(s.Id)
t := temperatureTmp.GetTemp(s.Id) t := temperatureTmp.GetTemp(s.Id)
sens.Value = strconv.FormatInt(t.Value, 10) sens.Value = strconv.FormatInt(t.Value, 10)
sens.Unit = "°C" sens.Unit = "°C"

View File

@ -4,7 +4,7 @@
{{define "body"}} {{define "body"}}
<br/> <br/>
{{range $key, $val := .sensors}} {{range $key, $val := .sensors}}
<div class="panel panel-info"> <div class="panel panel-info" id="{{$val.Mac}}">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">{{$val.Name}}</h3> <h3 class="panel-title">{{$val.Name}}</h3>
</div> </div>
@ -15,4 +15,10 @@
</div> </div>
</div> </div>
{{end}} {{end}}
<script type="text/javascript">
setTimeout(function() {
location.reload();
}, 5*60*1000);
</script>
{{end}} {{end}}