Hide proc metrics from charts loop

This commit is contained in:
mirivlad 2026-02-14 18:50:26 +00:00
parent 75499e07e7
commit 9117f19c4d
1 changed files with 14 additions and 0 deletions

View File

@ -408,6 +408,7 @@ function fetchProcesses(serverId, time) {
data.top_cpu.forEach(function(proc) { data.top_cpu.forEach(function(proc) {
lines.push(' ' + proc.name + ': ' + proc.value + '%'); lines.push(' ' + proc.name + ': ' + proc.value + '%');
}); });
{% endif %}
} }
// Добавляем топ-процессы RAM // Добавляем топ-процессы RAM
@ -417,6 +418,7 @@ function fetchProcesses(serverId, time) {
data.top_ram.forEach(function(proc) { data.top_ram.forEach(function(proc) {
lines.push(' ' + proc.name + ': ' + proc.value + '%'); lines.push(' ' + proc.name + ': ' + proc.value + '%');
}); });
{% endif %}
} }
resolve(lines); resolve(lines);
@ -424,7 +426,9 @@ function fetchProcesses(serverId, time) {
.catch(function() { .catch(function() {
resolve([]); resolve([]);
}); });
{% endif %}
}); });
{% endif %}
} }
@ -440,6 +444,7 @@ function requestServices() {
.catch(error => { .catch(error => {
alert('Ошибка получения списка сервисов: ' + error); alert('Ошибка получения списка сервисов: ' + error);
}); });
{% endif %}
} }
// Обработчик кнопки "Выбрать все" // Обработчик кнопки "Выбрать все"
@ -448,7 +453,9 @@ document.getElementById('selectAllServices').addEventListener('change', function
checkboxes.forEach(checkbox => { checkboxes.forEach(checkbox => {
checkbox.checked = this.checked; checkbox.checked = this.checked;
}); });
{% endif %}
}); });
{% endif %}
// Активация нужной вкладки при загрузке // Активация нужной вкладки при загрузке
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
@ -461,9 +468,11 @@ document.addEventListener('DOMContentLoaded', function() {
tabButton.click(); tabButton.click();
} }
}); });
{% endif %}
// Графики метрик // Графики метрик
{% for metricName, metricData in metrics %} {% for metricName, metricData in metrics %}
{% 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');
// Подготовка данных для графика // Подготовка данных для графика
@ -473,6 +482,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 %} {% endfor %}
new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, { new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
@ -544,6 +554,7 @@ new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
data.top_cpu.forEach(function(proc) { data.top_cpu.forEach(function(proc) {
lines.push(' ' + proc.name + ': ' + proc.value + '%'); lines.push(' ' + proc.name + ': ' + proc.value + '%');
}); });
{% endif %}
} }
{% elseif metricName == 'ram_used' %} {% elseif metricName == 'ram_used' %}
// Показываем только top_ram // Показываем только top_ram
@ -553,6 +564,7 @@ new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
data.top_ram.forEach(function(proc) { data.top_ram.forEach(function(proc) {
lines.push(' ' + proc.name + ': ' + proc.value + '%'); lines.push(' ' + proc.name + ': ' + proc.value + '%');
}); });
{% endif %}
} }
{% endif %} {% endif %}
@ -568,11 +580,13 @@ new Chart(ctx{{ metricName|replace({'-': '_', '.': '_'}) }}, {
// tooltipEl.style.opacity = 0; // tooltipEl.style.opacity = 0;
// }, 3000); // }, 3000);
}); });
{% endif %}
} }
} }
} }
} }
}); });
{% endif %}
{% endfor %} {% endfor %}
</script> </script>
{% endblock %} {% endblock %}