Fix Twig syntax in JS code generation

This commit is contained in:
mirivlad 2026-04-26 18:26:32 +08:00
parent 45c40aa86c
commit b54b3a55d5
1 changed files with 4 additions and 3 deletions

View File

@ -550,10 +550,11 @@ var diskTotalGB = {
{% for metricName, metricData in metrics %}
{% if metricName in visibleMetrics and metricName != 'uptime' and metricData %}
{% if metricData[0] is defined %}
const ctx{{ metricName|replace({'-': '_', '.': '_'}) }} = document.getElementById('chart-{{ metricName }}');
if (!ctx{{ metricName|replace({'-': '_', '.': '_'}) }}) { return; }
{% set ctxVarName = 'ctx' ~ metricName|replace({'-': '_', '.': '_'}) %}
const {{ ctxVarName }} = document.getElementById('chart-{{ metricName }}');
if (!{{ ctxVarName }}) { return; }
const ctxInstance{{ metricName|replace({'-': '_', '.': '_'}) }} = ctx{{ metricName|replace({'-': '_', '.': '_'}) }}.getContext('2d');
const ctxInstance{{ metricName|replace({'-': '_', '.': '_'}) }} = {{ ctxVarName }}.getContext('2d');
// Подготовка данных для графика
var labels{{ metricName }} = [];