Fix proc metrics hide - proper Twig syntax

This commit is contained in:
mirivlad 2026-02-15 03:47:40 +00:00
parent 70393075cb
commit 0e6d8ebcd6
1 changed files with 9 additions and 17 deletions

View File

@ -107,8 +107,7 @@
</div> </div>
<div class="row"> <div class="row">
{% for metricName, metricData in metrics %} {% for metricName, metricData in metrics %}{% if metricName != 'top_cpu_proc' and metricName != 'top_ram_proc' %}
{% if metricName != 'top_cpu_proc' and metricName != 'top_ram_proc' %}
<div class="col-12 mb-4"> <div class="col-12 mb-4">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
@ -135,7 +134,7 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% endfor %}
{% if metrics|length == 0 %} {% if metrics|length == 0 %}
<div class="col-12"> <div class="col-12">
@ -220,8 +219,7 @@
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endfor %}
{% for service in stoppedServices %} {% for service in stoppedServices %}
<div class="col-md-4 col-lg-3 mb-2"> <div class="col-md-4 col-lg-3 mb-2">
@ -252,8 +250,7 @@
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endfor %}
{% for service in unknownServices %} {% for service in unknownServices %}
<div class="col-md-4 col-lg-3 mb-2"> <div class="col-md-4 col-lg-3 mb-2">
@ -284,8 +281,7 @@
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endfor %}
{% else %} {% else %}
<div class="col-12"> <div class="col-12">
<div class="alert alert-warning text-center"> <div class="alert alert-warning text-center">
@ -369,8 +365,7 @@
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endfor %}
<div class="d-grid gap-2 d-md-flex justify-content-md-end"> <div class="d-grid gap-2 d-md-flex justify-content-md-end">
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
@ -470,8 +465,6 @@ document.addEventListener('DOMContentLoaded', function() {
// Графики метрик // Графики метрик
{% for metricName, metricData in metrics %} {% for metricName, metricData in metrics %}
{% if metricName != 'top_cpu_proc' and metricName != 'top_ram_proc' %}
{% if metricName != 'top_cpu_proc' and metricName != 'top_ram_proc' %}
const ctx{{ metricName|replace({'-': '_', '.': '_'}) }} = document.getElementById('chart-{{ metricName }}').getContext('2d'); const ctx{{ metricName|replace({'-': '_', '.': '_'}) }} = document.getElementById('chart-{{ metricName }}').getContext('2d');
// Подготовка данных для графика // Подготовка данных для графика
@ -481,8 +474,7 @@ var data{{ metricName }} = [];
{% for metric in metricData|slice(0, 20)|reverse %} {% for metric in metricData|slice(0, 20)|reverse %}
labels{{ metricName }}.push('{{ metric.created_at|date('H:i') }}'); labels{{ metricName }}.push('{{ metric.created_at|date('H:i') }}');
data{{ metricName }}.push({{ metric.value|raw }}); data{{ metricName }}.push({{ metric.value|raw }});
{% endif %} {% endfor %}
new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, { new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
type: 'line', type: 'line',
@ -563,6 +555,7 @@ new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
lines.push(' ' + proc.name + ': ' + proc.value + '%'); lines.push(' ' + proc.name + ': ' + proc.value + '%');
}); });
} }
{% endif %}
// Show tooltip // Show tooltip
var position = context.chart.canvas.getBoundingClientRect(); var position = context.chart.canvas.getBoundingClientRect();
@ -581,7 +574,6 @@ new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
} }
} }
}); });
{% endif %} {% endfor %}
</script> </script>
{% endblock %} {% endblock %}