From 92d1d55d8ef8038058693da94a9863192a1d04ba Mon Sep 17 00:00:00 2001 From: Nicholas Wiersma Date: Fri, 12 Jul 2024 22:40:41 +0200 Subject: [PATCH] fix: warning settings --- assets/style.css | 6 +++--- main.go | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/assets/style.css b/assets/style.css index 32cbcf3..9e72989 100644 --- a/assets/style.css +++ b/assets/style.css @@ -14,11 +14,11 @@ stroke: rgb(87, 148, 242); } -#heat.geyser.warm { +#heat.geyser.warning { stroke: rgb(255, 152, 48); } -#heat.geyser.hot { +#heat.geyser.low { stroke: rgb(242, 73, 92); } @@ -36,7 +36,7 @@ stroke: rgb(55 199 255); } -#water.tank.medium { +#water.tank.warning { stroke: rgb(255, 152, 48); } diff --git a/main.go b/main.go index 8c59f39..e7481b5 100644 --- a/main.go +++ b/main.go @@ -166,8 +166,20 @@ func (m *Module) updateState(id, state string) { } perStr := strconv.FormatFloat(per, 'f', 0, 64) + var class string + if per <= float64(m.cfg.Geyser.Low) { + class = "low" + } else if per <= float64(m.cfg.Geyser.Warning) { + class = "warning" + } + if elem := m.mod.Element().QuerySelector("#heat"); elem != nil { elem.SetAttribute("style", percentageVar+perStr) + elem.Class().Remove("low") + elem.Class().Remove("warning") + if class != "" { + elem.Class().Add(class) + } } if elem := m.mod.Element().QuerySelector("#geyserText .super"); elem != nil { elem.SetTextContent(strconv.Itoa(int(per))) @@ -179,8 +191,20 @@ func (m *Module) updateState(id, state string) { } perStr := strconv.FormatFloat(per, 'f', 2, 64) + var class string + if per <= float64(m.cfg.Tank.Low) { + class = "low" + } else if per <= float64(m.cfg.Tank.Warning) { + class = "warning" + } + if elem := m.mod.Element().QuerySelector("#water"); elem != nil { elem.SetAttribute("style", percentageVar+perStr) + elem.Class().Remove("low") + elem.Class().Remove("warning") + if class != "" { + elem.Class().Add(class) + } } } }