Allow multi mode for timeseries

Temporary until I think of something better.
This commit is contained in:
Peter J. Holzer 2022-12-30 19:43:56 +01:00 committed by Peter J. Holzer
parent 55a86772e0
commit 32b9f8eeed
1 changed files with 17 additions and 1 deletions

View File

@ -21,7 +21,23 @@ class Dashboard:
self.widgets = [] self.widgets = []
for w in d["widgets"]: for w in d["widgets"]:
if w["type"] == "timeseries": 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": elif w["type"] == "gauge":
if w.get("multi"): if w.get("multi"):
ts_list = LTS.find(w["data"][0]) ts_list = LTS.find(w["data"][0])