fixed minor error not init agent in tree view node

This commit is contained in:
daniel 2018-09-05 18:28:31 +02:00
parent 3b0436008a
commit 4781809e14
2 changed files with 35 additions and 30 deletions

View File

@ -950,7 +950,7 @@ class Tree {
SUM(if(%s, 1, 0)) as state_unknown, SUM(if(%s, 1, 0)) as state_unknown,
SUM(if(%s, 1, 0)) as state_notinit, SUM(if(%s, 1, 0)) as state_notinit,
SUM(if(%s, 1, 0)) as state_normal, SUM(if(%s, 1, 0)) as state_normal,
SUM(if(%s, 1, 0)) as state_total SUM(if(%s AND tae.estado IS NOT NULL, 1, 0)) as state_total
", ",
$this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_CRITICAL_ALERT, true), $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_CRITICAL_ALERT, true),
$this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_WARNING_ALERT, true), $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_WARNING_ALERT, true),
@ -977,7 +977,8 @@ class Tree {
FROM tagente ta FROM tagente ta
$inner_or_left JOIN tagente_modulo tam $inner_or_left JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente ON ta.id_agente = tam.id_agente
INNER JOIN tagente_estado tae AND tam.disabled = 0
$inner_or_left JOIN tagente_estado tae
ON tae.id_agente_modulo = tam.id_agente_modulo ON tae.id_agente_modulo = tam.id_agente_modulo
$inner $inner
WHERE ta.id_agente IN WHERE ta.id_agente IN
@ -992,14 +993,13 @@ class Tree {
$group_search_filter $group_search_filter
$condition_inside $condition_inside
) )
AND ta.disabled = 0 AND tam.disabled = 0 AND ta.disabled = 0
$condition $condition
$agent_search_filter $agent_search_filter
$agent_status_filter $agent_status_filter
$module_search_filter $module_search_filter
$module_status_filter $module_status_filter
GROUP BY ta.id_agente GROUP BY ta.id_agente
HAVING state_total > 0
ORDER BY ta.alias ASC, ta.id_agente ASC ORDER BY ta.alias ASC, ta.id_agente ASC
"; ";

View File

@ -28,7 +28,6 @@ class TreeGroup extends Tree {
$this->L1fieldName = "id_group"; $this->L1fieldName = "id_group";
$this->L1extraFields = array( $this->L1extraFields = array(
"tg.nombre AS `name`", "tg.nombre AS `name`",
$this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent',
"tg.icon", "tg.icon",
"tg.id_grupo AS gid" "tg.id_grupo AS gid"
); );
@ -56,42 +55,42 @@ class TreeGroup extends Tree {
protected function getFirstLevel() { protected function getFirstLevel() {
$processed_items = $this->getProcessedGroups(); $processed_items = $this->getProcessedGroups();
if (!empty($processed_items)) { if (!empty($processed_items)) {
// Filter by group name. This should be done after rerieving the items cause we need the possible items descendants // Filter by group name. This should be done after rerieving the items cause we need the possible items descendants
if (!empty($this->filter['searchGroup'])) { if (!empty($this->filter['searchGroup'])) {
// Save the groups which intersect with the user groups // Save the groups which intersect with the user groups
$groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $this->filter['searchGroup'] . '%')); $groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $this->filter['searchGroup'] . '%'));
if ($groups == false) $groups = array(); if ($groups == false) $groups = array();
$userGroupsACL = $this->userGroupsACL; $userGroupsACL = $this->userGroupsACL;
$ids_hash = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) { $ids_hash = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) {
$group_id = $group['id_grupo']; $group_id = $group['id_grupo'];
if (isset($userGroupsACL[$group_id])) { if (isset($userGroupsACL[$group_id])) {
$userGroups[$group_id] = $userGroupsACL[$group_id]; $userGroups[$group_id] = $userGroupsACL[$group_id];
} }
return $userGroups; return $userGroups;
}, array()); }, array());
$result = self::extractGroupsWithIDs($processed_items, $ids_hash); $result = self::extractGroupsWithIDs($processed_items, $ids_hash);
$processed_items = ($result === false) ? array() : $result; $processed_items = ($result === false) ? array() : $result;
}
// groupID filter. To access the view from tactical views f.e.
if (!empty($this->filter['groupID'])) {
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group", $this->strictACL);
$processed_items = ($result === false) ? array() : array($result);
}
} }
// groupID filter. To access the view from tactical views f.e.
if (!empty($this->filter['groupID'])) {
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group", $this->strictACL);
$processed_items = ($result === false) ? array() : array($result);
}
}
$this->tree = $processed_items; $this->tree = $processed_items;
} }
protected function getProcessedGroups () { protected function getProcessedGroups () {
$processed_groups = array(); $processed_groups = array();
// Index and process the groups // Index and process the groups
$groups = $this->getGroupCounters(0); $groups = $this->getGroupCounters();
// If user have not permissions in parent, set parent node to 0 (all) // If user have not permissions in parent, set parent node to 0 (all)
// Avoid to do foreach for admins // Avoid to do foreach for admins
@ -250,6 +249,12 @@ class TreeGroup extends Tree {
return $group_stats; return $group_stats;
} }
protected function getFirstLevelFields() {
$fields = parent::getFirstLevelFields();
$parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent';
return "$fields, $parent";
}
protected function getProcessedModules($modules_tree) { protected function getProcessedModules($modules_tree) {
$groups = array(); $groups = array();