diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index b1b0a5e48a..7384ac17ff 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -954,7 +954,7 @@ echo sprintf('
', $menuTypeClass); $("a.autorefresh").click (function () { $("a.autorefresh_txt").toggle (); - $("#combo_refr").toggle (); + $("#combo_refr").toggle(); $("select#ref").change (function () { href = $("a.autorefresh").attr ("href"); diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index 0b29b3a895..b9420eba44 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -523,6 +523,14 @@ class TreeService extends Tree continue 2; } + $title = get_parameter('title', ''); + if (empty($title) === true) { + $tmp['title'] = ''; + } else { + $tmp['title'] = $title.'/'; + } + + $tmp['title'] .= $service->name(); $tmp['id'] = (int) $item->service()->id(); $tmp['name'] = $item->service()->name(); $tmp['alias'] = $item->service()->name(); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index ca0c9dad7d..c1b6697022 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -5986,6 +5986,56 @@ function send_test_email( } +/** + * Return array of ancestors of item, given array. + * + * @param integer $item From index. + * @param array $data Array data. + * @param string $key Pivot key (identifies the parent). + * @param string|null $extract Extract certain column or index. + * @param array $visited Cycle detection. + * + * @return array Array of ancestors. + */ +function get_ancestors( + int $item, + array $data, + string $key, + ?string $extract=null, + array &$visited=[] +) :array { + if (isset($visited[$item]) === true) { + return []; + } + + $visited[$item] = 1; + + if (isset($data[$item]) === false) { + return []; + } + + if (isset($data[$item][$key]) === false) { + if ($extract !== null) { + return [$data[$item][$extract]]; + } + + return [$item]; + } + + if ($extract !== null) { + return array_merge( + get_ancestors($data[$item][$key], $data, $key, $extract, $visited), + [$data[$item][$extract]] + ); + } + + return array_merge( + get_ancestors($data[$item][$key], $data, $key, $extract, $visited), + [$item] + ); +} + + if (function_exists('str_contains') === false) { diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 7f22c6e9d0..073a862c4c 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -861,7 +861,7 @@ var TreeController = { '' +
                 element.name +
                 ' '; @@ -1314,6 +1314,7 @@ var TreeController = { serverID: element.serverID, rootType: element.rootType, metaID: element.metaID, + title: element.title, filter: controller.filter, auth_class: controller.auth_class, id_user: controller.id_user, diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_map.php b/pandora_console/include/lib/Dashboard/Widgets/service_map.php index 21a7edc82c..9fafaf6751 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_map.php @@ -272,7 +272,20 @@ class ServiceMapWidget extends Widget $fields = array_reduce( $services_res, function ($carry, $item) { - $carry[$item['id']] = $item['name']; + $parents = ''; + if (class_exists('\PandoraFMS\Enterprise\Service') === true) { + try { + $service = new \PandoraFMS\Enterprise\Service($item['id']); + $ancestors = $service->getAncestors(); + if (empty($ancestors) === false) { + $parents = '('.join('/', $ancestors).')'; + } + } catch (\Exception $e) { + $parents = ''; + } + } + + $carry[$item['id']] = $item['name'].' '.$parents; return $carry; }, []