-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.go
60 lines (51 loc) · 992 Bytes
/
template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"html/template"
"time"
)
const (
Blue template.CSS = "color: #0000ff;"
Red template.CSS = "color: #ff0000;"
Green template.CSS = "color: #00ff00;"
Black template.CSS = ""
)
type Peak struct {
Time string
Current Average
Average Average
}
func newPeak(t time.Time, curVol float64, curCol template.CSS, avgVol float64, avgCol template.CSS) Peak {
return Peak{
t.Format("15:04:05"),
Average{curVol, curCol},
Average{avgVol, avgCol},
}
}
type Minute struct {
Time string
Average Average
}
func newMinute(m int, a float64, c template.CSS) Minute {
h := time.Now().Hour()
return Minute{
fmt.Sprintf("%d:%d", h, m),
Average{a, c},
}
}
type TemplateData struct {
Message string
MaxVolume float64
AvgVolume float64
VolumeThreshold float64
Peaks []Peak
Minutes []Minute
}
type Volume struct {
Value int
Color template.CSS
}
type Average struct {
Value float64
Color template.CSS
}