#11490 deleted name in treemap if it's empty and fixed bug in metaconsole

This commit is contained in:
Daniel Cebrian 2023-08-30 12:37:34 +02:00
parent 93b52faf2f
commit 13dbed4327
2 changed files with 25 additions and 11 deletions

View File

@ -486,6 +486,9 @@ function treeMap(recipient, data, width, height, childLinks = false) {
}) })
.attr("height", headerHeight); .attr("height", headerHeight);
parentEnterTransition parentEnterTransition
.filter(function(d) {
if (d.name) return d;
})
.append("rect") .append("rect")
.attr("width", function(d) { .attr("width", function(d) {
return Math.max(0.01, d.dx); return Math.max(0.01, d.dx);
@ -493,6 +496,9 @@ function treeMap(recipient, data, width, height, childLinks = false) {
.attr("height", headerHeight) .attr("height", headerHeight)
.style("fill", headerColor); .style("fill", headerColor);
parentEnterTransition parentEnterTransition
.filter(function(d) {
if (d.name) return d;
})
.append("text") .append("text")
.attr("class", "label") .attr("class", "label")
.attr("fill", "white") .attr("fill", "white")

View File

@ -299,7 +299,22 @@ class GroupsStatusMapWidget extends Widget
GROUP BY a.id_grupo, estado'; GROUP BY a.id_grupo, estado';
$result = db_process_sql($sql); $result = db_process_sql($sql);
if ($result !== false) { if ($result !== false) {
$rows = array_merge_recursive($result, $rows); foreach ($result as $key => $group) {
$not_exist = true;
foreach ($rows as $key2 => $row) {
if ($group['id_grupo'] === $row['id_grupo']
&& $group['estado'] === $row['estado']
) {
$rows[$key2]['total_modules'] += $group['total_modules'];
$not_exist = false;
break;
}
}
if ($not_exist === true) {
$rows[] = $group;
}
}
} }
} }
@ -376,25 +391,18 @@ class GroupsStatusMapWidget extends Widget
continue; continue;
} }
if (empty($level1['children'][$row['id_grupo']][$row['estado']]['value']) === false) { $level1['children'][$row['id_grupo']][] = [
$total = ($row['total_modules'] + $level1['children'][$row['id_grupo']][$row['estado']]['value']);
} else {
$total = $row['total_modules'];
}
$level1['children'][$row['id_grupo']][$row['estado']] = [
'id' => uniqid(), 'id' => uniqid(),
'name' => $row['estado'], 'name' => $row['estado'],
'value' => $total, 'value' => $row['total_modules'],
'color' => $color, 'color' => $color,
'tooltip_content' => $total.__(' Modules(%s)', $name_status), 'tooltip_content' => $row['total_modules'].__(' Modules(%s)', $name_status),
'link' => 'index.php?sec=view&sec2=operation/agentes/status_monitor&refr=0&ag_group='.$row['id_grupo'].'&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status='.$row['estado'].'&sort_field=&sort=none&pure=', 'link' => 'index.php?sec=view&sec2=operation/agentes/status_monitor&refr=0&ag_group='.$row['id_grupo'].'&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status='.$row['estado'].'&sort_field=&sort=none&pure=',
]; ];
$names[$row['id_grupo']] = $row['nombre']; $names[$row['id_grupo']] = $row['nombre'];
} }
$level2 = [ $level2 = [
'name' => __('Group status map'),
'children' => [], 'children' => [],
]; ];
foreach ($level1['children'] as $id_grupo => $group) { foreach ($level1['children'] as $id_grupo => $group) {