Add description to timeseries
This commit is contained in:
parent
32b9f8eeed
commit
8d02bf2c6b
26
dashboard.py
26
dashboard.py
|
@ -126,13 +126,24 @@ class Widget:
|
||||||
log.debug("definitely fail")
|
log.debug("definitely fail")
|
||||||
return f"hsl(0, 100%, {brightness}%)"
|
return f"hsl(0, 100%, {brightness}%)"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description_formatted(self):
|
||||||
|
s = "<table class='description'>"
|
||||||
|
for d, v in self.lts.description.items():
|
||||||
|
if v:
|
||||||
|
s += render_template_string(
|
||||||
|
"<tr><th>{{d}}:</th><td>{{v}}</td></tr>",
|
||||||
|
d=d, v=v)
|
||||||
|
s += "</table>"
|
||||||
|
return Markup(s)
|
||||||
|
|
||||||
class TimeSeries(Widget):
|
class TimeSeries(Widget):
|
||||||
def __init__(self, d):
|
def __init__(self, d):
|
||||||
super().__init__(d)
|
super().__init__(d)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def as_html(self):
|
@property
|
||||||
|
def graph(self):
|
||||||
def t2x(t):
|
def t2x(t):
|
||||||
x = n - math.log((t_last - t) / (n*dt) + 1) * n / k
|
x = n - math.log((t_last - t) / (n*dt) + 1) * n / k
|
||||||
return x
|
return x
|
||||||
|
@ -270,6 +281,9 @@ class TimeSeries(Widget):
|
||||||
html += "</svg>"
|
html += "</svg>"
|
||||||
return Markup(html)
|
return Markup(html)
|
||||||
|
|
||||||
|
def as_html(self):
|
||||||
|
return Markup(render_template("timeseries.html", widget=self))
|
||||||
|
|
||||||
class Gauge(Widget):
|
class Gauge(Widget):
|
||||||
def __init__(self, d):
|
def __init__(self, d):
|
||||||
super().__init__(d)
|
super().__init__(d)
|
||||||
|
@ -311,13 +325,3 @@ class Gauge(Widget):
|
||||||
self.lastvalue_formatted = Markup(f"<span class='value'>{value:.2f}</span><span class='unit'>{unit}</unit>")
|
self.lastvalue_formatted = Markup(f"<span class='value'>{value:.2f}</span><span class='unit'>{unit}</unit>")
|
||||||
return Markup(render_template("gauge.html", widget=self))
|
return Markup(render_template("gauge.html", widget=self))
|
||||||
|
|
||||||
@property
|
|
||||||
def description_formatted(self):
|
|
||||||
s = "<table class='description'>"
|
|
||||||
for d, v in self.lts.description.items():
|
|
||||||
if v:
|
|
||||||
s += render_template_string(
|
|
||||||
"<tr><th>{{d}}:</th><td>{{v}}</td></tr>",
|
|
||||||
d=d, v=v)
|
|
||||||
s += "</table>"
|
|
||||||
return Markup(s)
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 2rem;
|
gap: 2rem;
|
||||||
|
align-items: end;
|
||||||
}
|
}
|
||||||
.widget {
|
.widget {
|
||||||
border: 1px solid #CCC;
|
border: 1px solid #CCC;
|
||||||
|
@ -45,6 +46,13 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
.timeseries {
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: end;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<div class="timeseries">
|
||||||
|
{{ widget.graph }}
|
||||||
|
{{ widget.description_formatted }}
|
||||||
|
</div>
|
Loading…
Reference in New Issue