diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-11-26 12:12:43 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-11-26 12:12:43 -0500 |
| commit | 25ca0eaea3f8c83d2a209a4790b27b712bcba09c (patch) | |
| tree | 729b80155e5c953518709add004bde7660ebfadf /server/dashboard.go | |
| parent | ea85258e026265656bdad9fb45d263d9f5e3e05d (diff) | |
| download | soen422-25ca0eaea3f8c83d2a209a4790b27b712bcba09c.zip | |
server: display target humidity
Diffstat (limited to 'server/dashboard.go')
| -rw-r--r-- | server/dashboard.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/server/dashboard.go b/server/dashboard.go index 9a9c0b5..48a9423 100644 --- a/server/dashboard.go +++ b/server/dashboard.go @@ -15,12 +15,14 @@ var dashboardHtml string var dashboard = template.Must(template.New("dashboard").Parse(dashboardHtml)) type Dashboard struct { + Target Humidity Average Humidity DutyCycle DutyCycle Rooms map[RoomID]Humidity } type DashboardHandler struct { + target share.Val[Humidity] building Building dutyCycle share.Val[DutyCycle] } @@ -42,6 +44,13 @@ func (h DashboardHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (h DashboardHandler) buildDashboard() Dashboard { + var target Humidity + if targetp, ok := h.target.TryGet(); ok { + target = *targetp + } else { + target = 0 + } + average, ok := h.building.average() if !ok { average = -1 @@ -65,5 +74,5 @@ func (h DashboardHandler) buildDashboard() Dashboard { rooms[id] = humidity } - return Dashboard{average, duty, rooms} + return Dashboard{target, average, duty, rooms} } |