From 32b9f8eeedf00d0d25b3f47840b081777bf73a99 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Fri, 30 Dec 2022 19:43:56 +0100 Subject: [PATCH] Allow multi mode for timeseries Temporary until I think of something better. --- dashboard.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dashboard.py b/dashboard.py index fc32386..a9d136f 100644 --- a/dashboard.py +++ b/dashboard.py @@ -21,7 +21,23 @@ class Dashboard: self.widgets = [] for w in d["widgets"]: if w["type"] == "timeseries": - self.widgets.append(TimeSeries(w)) + # XXX - currently just a copy of the gauge code, + # but I want to add support for timeseries graphs with + # multiple series later so this will change + if w.get("multi"): + ts_list = LTS.find(w["data"][0]) + for ts in ts_list: + tso = LTS(id=ts) + if not tso.data: + log.warning("%s has no data: Skipping", tso.id) + continue + if tso.data[-1][0] < time.time() - 86400: + log.info("%s too old; Skipping", tso.id) + continue + w1 = {**w, "data": [ts]} + self.widgets.append(TimeSeries(w1)) + else: + self.widgets.append(TimeSeries(w)) elif w["type"] == "gauge": if w.get("multi"): ts_list = LTS.find(w["data"][0])