Fix network/temp charts - use displayMetrics for selection

- Network: iterate over displayMetrics to find interfaces
- Temperature: filter by displayMetrics before rendering
- Show all selected temps on single chart
This commit is contained in:
mirivlad 2026-04-26 16:44:03 +08:00
parent 53ecf8bc9a
commit fb6c7d544f
1 changed files with 11 additions and 3 deletions

View File

@ -806,8 +806,16 @@ document.addEventListener('mousemove', function(e) {
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% for iface in net_interfaces %} {% set net_interfaces_js = [] %}
{% if metrics['net_in_' ~ iface] is defined and metrics['net_out_' ~ iface] is defined %} {% for m in displayMetrics %}
{% if m starts with 'net_in_' %}
{% set iface = m|replace({'net_in_': ''}) %}
{% set net_interfaces_js = net_interfaces_js|merge([iface]) %}
{% endif %}
{% endfor %}
{% for iface in net_interfaces_js %}
{% if ('net_in_' ~ iface) in displayMetrics and ('net_out_' ~ iface) in displayMetrics and metrics['net_in_' ~ iface] is defined and metrics['net_out_' ~ iface] is defined %}
(function() { (function() {
var ctx = document.getElementById('chart-net-{{ iface }}'); var ctx = document.getElementById('chart-net-{{ iface }}');
if (!ctx) return; if (!ctx) return;
@ -899,7 +907,7 @@ document.addEventListener('mousemove', function(e) {
var colorIdx = 0; var colorIdx = 0;
{% for mn, md in metrics %} {% for mn, md in metrics %}
{% if mn starts with 'temp_' %} {% if mn in displayMetrics and mn starts with 'temp_' %}
if (!labelsFilled) { if (!labelsFilled) {
{% for p in md|slice(-1000) %} {% for p in md|slice(-1000) %}
labels.push('{{ p.time_bucket|default(p.created_at)|date("d.m H:i") }}'); labels.push('{{ p.time_bucket|default(p.created_at)|date("d.m H:i") }}');