display healthy history as status graph

This commit is contained in:
4cuck committed 2023-10-16 23:32:09 +02:00
1 parent 96536eb5fd
commit a06dc24494
1 file changed
+8 -12
+8 -12
View File
@@ -42,10 +42,10 @@
{%- endif -%}</td>
<td {%- if not host.ping_min %} colspan="2" {% endif -%}>
{%- if host.recent_pings|length > 0 -%}
{%- set height = 57 -%}
{%- set height = 34 -%}
{%- set width = 100 -%}
{%- set amount = host.recent_pings|length -%}
{%- set width_bar = width / amount -%}
{%- set width_bar = 5 -%}
{%- set offset = 5 -%}
{%- set error_size = height / 3 %}
{%- if host.ping_max and host.ping_min -%}
@@ -63,20 +63,16 @@
<!-- ping_max {{host.ping_max}} -->
<!-- ping_min {{host.ping_min}} --> #}
{%- if host.ping_min -%}
<svg viewBox="0 0 182 56" width="{{width - 1}}" height="{{height - 1}}">
{%- if host.ping_avg and host.ping_min -%}
{%- set avg_pos = (height-(host.ping_avg - host.ping_min )/step_size) - offset -%}
<line x1="1" x2="181" y1="{{avg_pos}}" y2="{{avg_pos}}" stroke="black" stroke-width="0.72727275" stroke-linecap="butt" stroke-opacity="0.3"><title>Average</title></line>
{%- endif -%}
<svg viewBox="0 0 {{width}} {{height}}" height="{{height - 1}}">
{%- for ping in host.recent_pings -%}
{%- if ping -%}
{%- set height_bar = (ping - host.ping_min )/step_size + offset -%}
{%- set color_bar = "#a09df2" -%}
{%- set title = "Healthy" -%}
{%- set color_bar = "#2fcc66" -%}
{%- else -%}
{%- set height_bar = error_size -%}
{%- set color_bar = "#cc0000" -%}
{%- set title = "Unhealthy" -%}
{%- set color_bar = "#ff6225" -%}
{%- endif -%}
<rect x="{{(loop.index-1) * width_bar}}" y="{{height - height_bar - offset}}" width="{{width_bar}}" height="{{height_bar}}" fill="{{color_bar}}" fill-opacity="0.95"><title>{{ping | default(value="unhealthy") }}</title></rect>
<rect x="{{(loop.index-1) * width_bar}}" y="0" width="{{width_bar - 2}}" height="{{height}}" fill="{{color_bar}}" fill-opacity="0.95"><title>{{title}}</title></rect>
{%- endfor -%}
</svg>
{%- else -%}