mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Merge branch 'ent-10362-15039-fallo-en-groups-items-de-consolas-visuales' into 'develop'
Ent 10362 15039 fallo en groups items de consolas visuales See merge request artica/pandorafms!5868
This commit is contained in:
commit
8c1bc5fc70
@ -1,7 +1,10 @@
|
|||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
UPDATE pandora.tnetwork_component
|
UPDATE `tnetwork_component`
|
||||||
SET module_enabled=1
|
SET module_enabled=1
|
||||||
WHERE name='Cisco _nameOID_ power state';
|
WHERE name='Cisco _nameOID_ power state';
|
||||||
|
|
||||||
|
ALTER TABLE `tlayout_data`
|
||||||
|
ADD COLUMN `recursive_group` TINYINT NOT NULL DEFAULT '0' AFTER `fill_color`;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
@ -34,6 +34,25 @@ final class Group extends Item
|
|||||||
protected static $indexCacheByUser = true;
|
protected static $indexCacheByUser = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the "recursive Group" switch value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return mixed If the recursive should be true or not.
|
||||||
|
*/
|
||||||
|
private static function getRecursiveGroup(array $data)
|
||||||
|
{
|
||||||
|
return static::issetInArray(
|
||||||
|
$data,
|
||||||
|
[
|
||||||
|
'recursiveGroup',
|
||||||
|
'recursive_group',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the "show statistics" switch value.
|
* Get the "show statistics" switch value.
|
||||||
*
|
*
|
||||||
@ -87,6 +106,11 @@ final class Group extends Item
|
|||||||
$return['id_group'] = $id_group;
|
$return['id_group'] = $id_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$recursive_group = static::getRecursiveGroup($data);
|
||||||
|
if ($recursive_group !== null) {
|
||||||
|
$return['recursive_group'] = static::parseBool($recursive_group);
|
||||||
|
}
|
||||||
|
|
||||||
$show_statistics = static::getShowStatistics($data);
|
$show_statistics = static::getShowStatistics($data);
|
||||||
if ($show_statistics !== null) {
|
if ($show_statistics !== null) {
|
||||||
$return['show_statistics'] = static::parseBool($show_statistics);
|
$return['show_statistics'] = static::parseBool($show_statistics);
|
||||||
@ -112,6 +136,7 @@ final class Group extends Item
|
|||||||
$return['groupId'] = static::extractGroupId($data);
|
$return['groupId'] = static::extractGroupId($data);
|
||||||
$return['imageSrc'] = static::extractImageSrc($data);
|
$return['imageSrc'] = static::extractImageSrc($data);
|
||||||
$return['statusImageSrc'] = static::extractStatusImageSrc($data);
|
$return['statusImageSrc'] = static::extractStatusImageSrc($data);
|
||||||
|
$return['recursiveGroup'] = static::extractRecursiveGroup($data);
|
||||||
$return['showStatistics'] = static::extractShowStatistics($data);
|
$return['showStatistics'] = static::extractShowStatistics($data);
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
@ -177,6 +202,21 @@ final class Group extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the "show statistics" switch value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return boolean If the statistics should be shown or not.
|
||||||
|
*/
|
||||||
|
private static function extractRecursiveGroup(array $data): bool
|
||||||
|
{
|
||||||
|
return static::parseBool(
|
||||||
|
static::issetInArray($data, ['recursiveGroup', 'recursive_group'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract the "show statistics" switch value.
|
* Extract the "show statistics" switch value.
|
||||||
*
|
*
|
||||||
@ -227,63 +267,147 @@ final class Group extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
$groupId = static::extractGroupId($data);
|
$groupId = static::extractGroupId($data);
|
||||||
|
$recursiveGroup = static::extractrecursiveGroup($data);
|
||||||
$showStatistics = static::extractShowStatistics($data);
|
$showStatistics = static::extractShowStatistics($data);
|
||||||
|
|
||||||
if ($showStatistics === true) {
|
if ($showStatistics === true) {
|
||||||
$isMetaconsole = \is_metaconsole();
|
$isMetaconsole = \is_metaconsole();
|
||||||
|
if ($recursiveGroup) {
|
||||||
|
$childers_id = groups_get_children_ids($groupId);
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve the agent stats.
|
// Retrieve the agent stats.
|
||||||
$agentsCritical = \agents_get_agents(
|
if ($recursiveGroup) {
|
||||||
[
|
$numCritical = 0;
|
||||||
'id_grupo' => $groupId,
|
foreach ($childers_id as $id_group) {
|
||||||
'status' => AGENT_STATUS_CRITICAL,
|
$agentsCritical = \agents_get_agents(
|
||||||
],
|
[
|
||||||
['COUNT(*) AS total'],
|
'id_grupo' => $id_group,
|
||||||
'AR',
|
'status' => AGENT_STATUS_CRITICAL,
|
||||||
false,
|
],
|
||||||
false,
|
['COUNT(*) AS total'],
|
||||||
true,
|
'AR',
|
||||||
$isMetaconsole
|
false,
|
||||||
);
|
false,
|
||||||
$numCritical = $agentsCritical[0]['total'];
|
true,
|
||||||
$agentsWarning = \agents_get_agents(
|
$isMetaconsole
|
||||||
[
|
);
|
||||||
'id_grupo' => $groupId,
|
$numCritical += $agentsCritical[0]['total'];
|
||||||
'status' => AGENT_STATUS_WARNING,
|
}
|
||||||
],
|
} else {
|
||||||
['COUNT(*) AS total'],
|
$agentsCritical = \agents_get_agents(
|
||||||
'AR',
|
[
|
||||||
false,
|
'id_grupo' => $groupId,
|
||||||
false,
|
'status' => AGENT_STATUS_CRITICAL,
|
||||||
true,
|
],
|
||||||
$isMetaconsole
|
['COUNT(*) AS total'],
|
||||||
);
|
'AR',
|
||||||
$numWarning = $agentsWarning[0]['total'];
|
false,
|
||||||
$agentsUnknown = \agents_get_agents(
|
false,
|
||||||
[
|
true,
|
||||||
'id_grupo' => $groupId,
|
$isMetaconsole
|
||||||
'status' => AGENT_STATUS_UNKNOWN,
|
);
|
||||||
],
|
$numCritical = $agentsCritical[0]['total'];
|
||||||
['COUNT(*) AS total'],
|
}
|
||||||
'AR',
|
|
||||||
false,
|
if ($recursiveGroup) {
|
||||||
false,
|
$numWarning = 0;
|
||||||
true,
|
foreach ($childers_id as $id_group) {
|
||||||
$isMetaconsole
|
$agentsWarning = \agents_get_agents(
|
||||||
);
|
[
|
||||||
$numUnknown = $agentsUnknown[0]['total'];
|
'id_grupo' => $id_group,
|
||||||
$agentsOk = \agents_get_agents(
|
'status' => AGENT_STATUS_WARNING,
|
||||||
[
|
],
|
||||||
'id_grupo' => $groupId,
|
['COUNT(*) AS total'],
|
||||||
'status' => AGENT_STATUS_NORMAL,
|
'AR',
|
||||||
],
|
false,
|
||||||
['COUNT(*) AS total'],
|
false,
|
||||||
'AR',
|
true,
|
||||||
false,
|
$isMetaconsole
|
||||||
false,
|
);
|
||||||
true,
|
$numWarning += $agentsWarning[0]['total'];
|
||||||
$isMetaconsole
|
}
|
||||||
);
|
} else {
|
||||||
$numNormal = $agentsOk[0]['total'];
|
$agentsWarning = \agents_get_agents(
|
||||||
|
[
|
||||||
|
'id_grupo' => $groupId,
|
||||||
|
'status' => AGENT_STATUS_WARNING,
|
||||||
|
],
|
||||||
|
['COUNT(*) AS total'],
|
||||||
|
'AR',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
$isMetaconsole
|
||||||
|
);
|
||||||
|
$numWarning = $agentsWarning[0]['total'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($recursiveGroup) {
|
||||||
|
$numUnknown = 0;
|
||||||
|
foreach ($childers_id as $id_group) {
|
||||||
|
$agentsUnknown = \agents_get_agents(
|
||||||
|
[
|
||||||
|
'id_grupo' => $id_group,
|
||||||
|
'status' => AGENT_STATUS_UNKNOWN,
|
||||||
|
],
|
||||||
|
['COUNT(*) AS total'],
|
||||||
|
'AR',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
$isMetaconsole
|
||||||
|
);
|
||||||
|
$numUnknown += $agentsUnknown[0]['total'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$agentsUnknown = \agents_get_agents(
|
||||||
|
[
|
||||||
|
'id_grupo' => $groupId,
|
||||||
|
'status' => AGENT_STATUS_UNKNOWN,
|
||||||
|
],
|
||||||
|
['COUNT(*) AS total'],
|
||||||
|
'AR',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
$isMetaconsole
|
||||||
|
);
|
||||||
|
$numUnknown = $agentsUnknown[0]['total'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($recursiveGroup) {
|
||||||
|
$numNormal = 0;
|
||||||
|
foreach ($childers_id as $id_group) {
|
||||||
|
$agentsOk = \agents_get_agents(
|
||||||
|
[
|
||||||
|
'id_grupo' => $id_group,
|
||||||
|
'status' => AGENT_STATUS_NORMAL,
|
||||||
|
],
|
||||||
|
['COUNT(*) AS total'],
|
||||||
|
'AR',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
$isMetaconsole
|
||||||
|
);
|
||||||
|
$numNormal += $agentsOk[0]['total'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$agentsOk = \agents_get_agents(
|
||||||
|
[
|
||||||
|
'id_grupo' => $groupId,
|
||||||
|
'status' => AGENT_STATUS_NORMAL,
|
||||||
|
],
|
||||||
|
['COUNT(*) AS total'],
|
||||||
|
'AR',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
$isMetaconsole
|
||||||
|
);
|
||||||
|
$numNormal = $agentsOk[0]['total'];
|
||||||
|
}
|
||||||
|
|
||||||
$numTotal = ($numCritical + $numWarning + $numUnknown + $numNormal);
|
$numTotal = ($numCritical + $numWarning + $numUnknown + $numNormal);
|
||||||
|
|
||||||
@ -327,6 +451,11 @@ final class Group extends Item
|
|||||||
',',
|
',',
|
||||||
array_keys(\users_get_groups())
|
array_keys(\users_get_groups())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($recursiveGroup === true) {
|
||||||
|
$childers_id = groups_get_children_ids($groupId);
|
||||||
|
$groupFilter .= ','.implode(',', $childers_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
@ -356,8 +485,25 @@ final class Group extends Item
|
|||||||
$status = AGENT_STATUS_NORMAL;
|
$status = AGENT_STATUS_NORMAL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Get the status img src.
|
if ($recursiveGroup === true) {
|
||||||
$status = \groups_get_status($groupId, true);
|
$childers_id = groups_get_children_ids($groupId);
|
||||||
|
$flag_stop_foreach = false;
|
||||||
|
foreach ($childers_id as $id_children) {
|
||||||
|
if ($flag_stop_foreach === true) {
|
||||||
|
// Stop if some child is not normal.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the status img src from all modules childs.
|
||||||
|
$status = \groups_get_status($id_children, true);
|
||||||
|
if ($status !== AGENT_STATUS_NORMAL) {
|
||||||
|
$flag_stop_foreach = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Get the status img src.
|
||||||
|
$status = \groups_get_status($groupId, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$imagePath = \visual_map_get_image_status_element($data, $status);
|
$imagePath = \visual_map_get_image_status_element($data, $status);
|
||||||
@ -559,6 +705,23 @@ final class Group extends Item
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ((int) $values['type'] === GROUP_ITEM) {
|
||||||
|
if (isset($values['recursiveGroup']) === false) {
|
||||||
|
$values['recursiveGroup'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursive group.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Recursive'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'recursiveGroup',
|
||||||
|
'id' => 'recursiveGroup',
|
||||||
|
'type' => 'switch',
|
||||||
|
'value' => $values['recursiveGroup'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// Show statistics.
|
// Show statistics.
|
||||||
$inputs[] = [
|
$inputs[] = [
|
||||||
'label' => __('Show statistics'),
|
'label' => __('Show statistics'),
|
||||||
|
@ -379,6 +379,10 @@ class View extends \HTML
|
|||||||
|
|
||||||
case GROUP_ITEM:
|
case GROUP_ITEM:
|
||||||
$data['imageSrc'] = \get_parameter('imageSrc');
|
$data['imageSrc'] = \get_parameter('imageSrc');
|
||||||
|
$data['recursiveGroup'] = \get_parameter_switch(
|
||||||
|
'recursiveGroup',
|
||||||
|
0
|
||||||
|
);
|
||||||
$data['showStatistics'] = \get_parameter_switch(
|
$data['showStatistics'] = \get_parameter_switch(
|
||||||
'showStatistics',
|
'showStatistics',
|
||||||
0
|
0
|
||||||
|
@ -1726,6 +1726,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` (
|
|||||||
`label_position` VARCHAR(50) NOT NULL DEFAULT 'down',
|
`label_position` VARCHAR(50) NOT NULL DEFAULT 'down',
|
||||||
`border_color` VARCHAR(200) DEFAULT '',
|
`border_color` VARCHAR(200) DEFAULT '',
|
||||||
`fill_color` VARCHAR(200) DEFAULT '',
|
`fill_color` VARCHAR(200) DEFAULT '',
|
||||||
|
`recursive_group` TINYINT NOT NULL DEFAULT 0,
|
||||||
`show_statistics` TINYINT NOT NULL DEFAULT 0,
|
`show_statistics` TINYINT NOT NULL DEFAULT 0,
|
||||||
`linked_layout_node_id` INT NOT NULL DEFAULT 0,
|
`linked_layout_node_id` INT NOT NULL DEFAULT 0,
|
||||||
`linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default',
|
`linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user