Refactor CPU statistics formatting for improved precision
Some checks failed
CI / ci (push) Has been cancelled
Some checks failed
CI / ci (push) Has been cancelled
- Updated JavaScript to ensure CPU total, free, and usage values are formatted as numbers with one decimal place for consistency. - Modified HTML template to apply float formatting to the displayed free CPU value, enhancing clarity in metrics presentation.
This commit is contained in:
@@ -36,11 +36,11 @@
|
||||
var regionBadge = document.getElementById('regionBadge');
|
||||
if (regionBadge) regionBadge.textContent = data.region && data.region.name ? data.region.name : '—';
|
||||
setStat('pcpu.usage', Number((data.pcpu && data.pcpu.usage) || 0).toFixed(1));
|
||||
setStat('pcpu.total', String((data.pcpu && data.pcpu.total) || 0));
|
||||
setStat('pcpu.total', Number((data.pcpu && data.pcpu.total) || 0).toFixed(1));
|
||||
setStat('pcpu.used_percentage', Number((data.pcpu && data.pcpu.used_percentage) || 0).toFixed(1) + '%');
|
||||
setStat('pcpu.usage_val', Number((data.pcpu && data.pcpu.usage) || 0).toFixed(1) + ' CPU');
|
||||
setProgress('pcpu.progress', (data.pcpu && data.pcpu.used_percentage) || 0);
|
||||
setStat('pcpu.free', String((data.pcpu && data.pcpu.free) || 0));
|
||||
setStat('pcpu.free', Number((data.pcpu && data.pcpu.free) || 0).toFixed(1));
|
||||
var pramUsageGb = formatBytes(data.pram && data.pram.usage, 'GB');
|
||||
var pramTotalGb = formatBytes(data.pram && data.pram.total, 'GB');
|
||||
var pramFreeGb = formatBytes(data.pram && data.pram.free, 'GB');
|
||||
@@ -258,7 +258,7 @@
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
callbacks: { label: function(ctx) { return ctx.dataset.label + ': ' + Number(ctx.parsed.y).toFixed(2) + '% CPU'; } }
|
||||
callbacks: { label: function(ctx) { return ctx.dataset.label + ': ' + Number(ctx.parsed.y).toFixed(1) + '% CPU'; } }
|
||||
},
|
||||
annotation: {
|
||||
annotations: annotationConfig
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<progress class="progress progress-primary w-full" value="{{ pcpu.used_percentage }}" max="100"></progress>
|
||||
<div class="flex justify-between text-xs">
|
||||
<span class="text-base-content/60">Free</span>
|
||||
<span class="font-medium">{{ pcpu.free }} CPU</span>
|
||||
<span class="font-medium">{{ pcpu.free|floatformat:1 }} CPU</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user