Fixes variables conflict between config and metricConfig

main
Yasen Pramatarov 2025-01-15 18:22:09 +02:00
parent 89076d3aeb
commit 0cf4795fc7
2 changed files with 5 additions and 5 deletions

View File

@ -150,13 +150,13 @@ if ($response['db'] === null) {
// Fetch all metrics for this agent
foreach ($metrics as $section => $section_metrics) {
foreach ($section_metrics as $metric => $config) {
foreach ($section_metrics as $metric => $metricConfig) {
$data = $agentObject->getLatestData($platform_id, $agent, $metric);
if ($data !== null) {
$record['metrics'][$section][$metric] = [
'value' => $data['value'],
'label' => $config['label'],
'link' => isset($config['link']) ? $config['link'] : null
'label' => $metricConfig['label'],
'link' => isset($metricConfig['link']) ? $metricConfig['link'] : null
];
// Use the most recent timestamp
if ($record['timestamp'] === null || strtotime($data['timestamp']) > strtotime($record['timestamp'])) {

View File

@ -26,9 +26,9 @@
<tr class="table-secondary">
<th colspan="<?= count($widget['records']) + 1 ?>"><?= htmlspecialchars($section) ?></th>
</tr>
<?php foreach ($section_metrics as $metric => $config) { ?>
<?php foreach ($section_metrics as $metric => $metricConfig) { ?>
<tr>
<td><?= htmlspecialchars($config['label']) ?></td>
<td><?= htmlspecialchars($metricConfig['label']) ?></td>
<?php foreach ($widget['records'] as $record) { ?>
<td>
<?php if (isset($record['metrics'][$section][$metric])) {