From 9db8078e72418a85f26db989fbef72e32271ed25 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 11 Mar 2019 15:18:09 +0100 Subject: [PATCH] Fixed first painted map Former-commit-id: 8f1098e312b4524568501a25642a533615e899f9 --- .../include/functions_pandora_networkmap.php | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/pandora_console/include/functions_pandora_networkmap.php b/pandora_console/include/functions_pandora_networkmap.php index 550a63f40e..7c7c96191c 100644 --- a/pandora_console/include/functions_pandora_networkmap.php +++ b/pandora_console/include/functions_pandora_networkmap.php @@ -769,14 +769,13 @@ function networkmap_links_to_js_links($relations, $nodes_graph) $agent = 0; $agent2 = 0; + $control1 = false; + $control2 = false; if (($relation['parent_type'] == 1) && ($relation['child_type'] == 1)) { - $mod1_status = db_get_value_filter('estado', 'tagente_estado', ['id_agente_modulo' => $relation['id_parent_source_data']]); - $mod2_status = db_get_value_filter('estado', 'tagente_estado', ['id_agente_modulo' => $relation['id_child_source_data']]); - - if (($mod1_status == AGENT_MODULE_STATUS_CRITICAL_BAD) || ($mod2_status == AGENT_MODULE_STATUS_CRITICAL_BAD)) { + if (($item['status_start'] == AGENT_MODULE_STATUS_CRITICAL_BAD) || ($item['status_end'] == AGENT_MODULE_STATUS_CRITICAL_BAD)) { $item['link_color'] = '#FC4444'; - } else if (($mod1_status == AGENT_MODULE_STATUS_WARNING) || ($mod2_status == AGENT_MODULE_STATUS_WARNING)) { + } else if (($item['status_start'] == AGENT_MODULE_STATUS_WARNING) || ($item['status_end'] == AGENT_MODULE_STATUS_WARNING)) { $item['link_color'] = '#FAD403'; } @@ -786,17 +785,23 @@ function networkmap_links_to_js_links($relations, $nodes_graph) if (isset($node['id_agent'])) { if ($node['id_agent'] == $agent) { $agent = $node['id_db']; - } else if ($node['id_agent'] == $agent2) { + $control1 = true; + } + + if ($node['id_agent'] == $agent2) { $agent2 = $node['id_db']; + $control2 = true; + } + + if ($control1 && $control2) { + break; } } } } else if ($relation['child_type'] == 1) { - $mod1_status = db_get_value_filter('estado', 'tagente_estado', ['id_agente_modulo' => $relation['id_child_source_data']]); - - if ($mod1_status == AGENT_MODULE_STATUS_CRITICAL_BAD) { + if ($item['status_start'] == AGENT_MODULE_STATUS_CRITICAL_BAD) { $item['link_color'] = '#FC4444'; - } else if ($mod1_status == AGENT_MODULE_STATUS_WARNING) { + } else if ($item['status_start'] == AGENT_MODULE_STATUS_WARNING) { $item['link_color'] = '#FAD403'; } @@ -805,28 +810,41 @@ function networkmap_links_to_js_links($relations, $nodes_graph) if (isset($node['id_agent'])) { if ($node['id_agent'] == $relation['id_parent_source_data']) { $agent = $node['id_db']; - } else if ($node['id_agent'] == $agent2) { + $control1 = true; + } + + if ($node['id_agent'] == $agent2) { $agent2 = $node['id_db']; + $control2 = true; + } + + if ($control1 && $control2) { + break; } } } } else if ($relation['parent_type'] == 1) { - $mod1_status = db_get_value_filter('estado', 'tagente_estado', ['id_agente_modulo' => $relation['id_parent_source_data']]); - - if ($mod1_status == AGENT_MODULE_STATUS_CRITICAL_BAD) { + if ($item['status_end'] == AGENT_MODULE_STATUS_CRITICAL_BAD) { $item['link_color'] = '#FC4444'; - } else if ($mod1_status == AGENT_MODULE_STATUS_WARNING) { + } else if ($item['status_end'] == AGENT_MODULE_STATUS_WARNING) { $item['link_color'] = '#FAD403'; } $agent = agents_get_agent_id_by_module_id($relation['id_parent_source_data']); - foreach ($nodes_graph as $key2 => $node) { if (isset($node['id_agent'])) { if ($node['id_agent'] == $agent) { $agent = $node['id_db']; - } else if ($node['id_agent'] == $relation['id_child_source_data']) { + $control1 = true; + } + + if ($node['id_agent'] == $relation['id_child_source_data']) { $agent2 = $node['id_db']; + $control2 = true; + } + + if ($control1 && $control2) { + break; } } }