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

View File

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