mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Service tree view with local scope parents
This commit is contained in:
parent
b2ea3d1d7a
commit
2ab1aa601c
@ -523,6 +523,8 @@ class TreeService extends Tree
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$tmp['parents'] = $item->service()->getAncestors();
|
||||
$tmp['title'] = join('/', $tmp['parents']);
|
||||
$tmp['id'] = (int) $item->service()->id();
|
||||
$tmp['name'] = $item->service()->name();
|
||||
$tmp['alias'] = $item->service()->name();
|
||||
|
@ -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) {
|
||||
|
||||
|
||||
|
@ -848,6 +848,7 @@ var TreeController = {
|
||||
|
||||
break;
|
||||
case "services":
|
||||
console.log(element);
|
||||
if (
|
||||
typeof element.statusImageHTML != "undefined" &&
|
||||
element.statusImageHTML.length > 0
|
||||
@ -861,7 +862,7 @@ var TreeController = {
|
||||
'<span><img class="invert_filter" src="' +
|
||||
(controller.baseURL.length > 0 ? controller.baseURL : "") +
|
||||
'images/help.png" class="img_help" title="' +
|
||||
element.name +
|
||||
(element.title ? element.title : element.name) +
|
||||
'" alt="' +
|
||||
element.name +
|
||||
'"/></span> ';
|
||||
|
Loading…
x
Reference in New Issue
Block a user