hint parents in service selection

This commit is contained in:
fbsanchez 2022-04-20 19:20:54 +02:00
parent 78907e691c
commit 00f594293c
1 changed files with 14 additions and 1 deletions

View File

@ -268,7 +268,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;
},
[]