2008-08-28 Esteban Sanchez <estebans@artica.es>

* include/functions_visual_map.php: Fixed an error when there were no
        elements in the map that cause Javascript failure and nothing works.
        Thanks Jorge for the advice.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1043 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
esanchezm 2008-08-28 08:41:51 +00:00
parent 1023f8e2c1
commit f5012005bd
2 changed files with 95 additions and 91 deletions

View File

@ -1,3 +1,9 @@
2008-08-28 Esteban Sanchez <estebans@artica.es>
* include/functions_visual_map.php: Fixed an error when there were no
elements in the map that cause Javascript failure and nothing works.
Thanks Jorge for the advice.
2008-08-27 Raul Mateos <raulofpandora@gmail.com>
* operation/agentes/status_monitor.php: Moved legend.

View File

@ -24,100 +24,98 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
$layout_datas = get_db_all_rows_field_filter ('tlayout_data', 'id_layout', $id_layout);
$lines = array ();
if ($layout_datas === false) {
echo '</div>';
return;
}
foreach ($layout_datas as $layout_data) {
// Linked to other layout ?? - Only if not module defined
if (($layout_data['id_layout_linked'] != 0) && ($layout_data['id_agente_modulo'] == 0)) {
$status = return_status_layout ($layout_data['id_layout_linked']);
} else {
$id_agent = get_db_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']);
$id_agent_module_parent = get_db_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]);
// Item value
$status = return_status_agent_module ($layout_data['id_agente_modulo']);
if ($layout_data['no_link_color'] == 1)
$status_parent = -1;
else
$status_parent = return_status_agent_module ($id_agent_module_parent);
}
// STATIC IMAGE (type = 0)
if ($layout_data['type'] == 0) {
// Link image
//index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1
if ($status == 0) // Bad monitor
$z_index = 2;
elseif ($status == 2) // Alert
$z_index = 3;
else
$z_index = 1; // Print BAD over good
// Draw image
echo '<div style="z-index: '.$z_index.'; color: '.$layout_data['label_color'].'; position: absolute; margin-left: '.$layout_data['pos_x'].'px; margin-top:'.$layout_data['pos_y'].'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
if ($show_links) {
if ($layout_data['id_layout_linked'] == "" || $layout_data['id_layout_linked'] == 0) {
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agent&tab=data'>";
} else {
echo '<a href="index.php?sec=visualc&sec2=operation/visual_console/render_view&pure='.$config["pure"].'&id='.$layout_data['id_layout_linked'].'">';
}
}
if ($status == 0) {
if ($layout_data['width'] != "" && $layout_data['width'] != 0)
echo '<img src="images/console/icons/'.$layout_data['image'].'_bad.png" width="'.$layout_data['width'].'" height="'.$layout_data['height'].'" title="'.$layout_data['label'].'">';
else
echo '<img src="images/console/icons/'.$layout_data['image'].'_bad.png"
title="'.$layout_data['label'].'">';
} else {
if ($layout_data['width'] != "" && $layout_data['width'] != 0)
echo '<img src="images/console/icons/'.$layout_data['image'].'_ok.png" width="'.$layout_data['width'].'"
height="'.$layout_data['height'].'" title="'.$layout_data['label'].'">';
else
echo '<img src="images/console/icons/'.$layout_data['image'].'_ok.png"
title="'.$layout_data['label'].'">';
}
echo "</a>";
// Draw label
echo "<br>";
echo $layout_data['label'];
echo "</div>";
}
// SINGLE GRAPH (type = 1)
if ($layout_data['type'] == 1) { // single graph
if ($layout_datas !== false) {
// Draw image
echo '<div style="z-index: 1; color: '.$layout_data['label_color'].'; position: absolute; margin-left: '.$layout_data['pos_x'].'px; margin-top:'.$layout_data['pos_y'].'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
if ($show_links) {
if (($layout_data['id_layout_linked'] == "") || ($layout_data['id_layout_linked'] == 0)) {
echo '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'&tab=data">';
} else {
echo '<a href="index.php?sec=visualc&sec2=operation/visual_console/render_view&pure='.$config["pure"].'&id='.$layout_data['id_layout_linked'].'">';
}
foreach ($layout_datas as $layout_data) {
// Linked to other layout ?? - Only if not module defined
if (($layout_data['id_layout_linked'] != 0) && ($layout_data['id_agente_modulo'] == 0)) {
$status = return_status_layout ($layout_data['id_layout_linked']);
} else {
$id_agent = get_db_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']);
$id_agent_module_parent = get_db_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]);
// Item value
$status = return_status_agent_module ($layout_data['id_agente_modulo']);
if ($layout_data['no_link_color'] == 1)
$status_parent = -1;
else
$status_parent = return_status_agent_module ($id_agent_module_parent);
}
// STATIC IMAGE (type = 0)
if ($layout_data['type'] == 0) {
// Link image
//index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1
if ($status == 0) // Bad monitor
$z_index = 2;
elseif ($status == 2) // Alert
$z_index = 3;
else
$z_index = 1; // Print BAD over good
// Draw image
echo '<div style="z-index: '.$z_index.'; color: '.$layout_data['label_color'].'; position: absolute; margin-left: '.$layout_data['pos_x'].'px; margin-top:'.$layout_data['pos_y'].'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
if ($show_links) {
if ($layout_data['id_layout_linked'] == "" || $layout_data['id_layout_linked'] == 0) {
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agent&tab=data'>";
} else {
echo '<a href="index.php?sec=visualc&sec2=operation/visual_console/render_view&pure='.$config["pure"].'&id='.$layout_data['id_layout_linked'].'">';
}
}
if ($status == 0) {
if ($layout_data['width'] != "" && $layout_data['width'] != 0)
echo '<img src="images/console/icons/'.$layout_data['image'].'_bad.png" width="'.$layout_data['width'].'" height="'.$layout_data['height'].'" title="'.$layout_data['label'].'">';
else
echo '<img src="images/console/icons/'.$layout_data['image'].'_bad.png"
title="'.$layout_data['label'].'">';
} else {
if ($layout_data['width'] != "" && $layout_data['width'] != 0)
echo '<img src="images/console/icons/'.$layout_data['image'].'_ok.png" width="'.$layout_data['width'].'"
height="'.$layout_data['height'].'" title="'.$layout_data['label'].'">';
else
echo '<img src="images/console/icons/'.$layout_data['image'].'_ok.png"
title="'.$layout_data['label'].'">';
}
echo "</a>";
// Draw label
echo "<br>";
echo $layout_data['label'];
echo "</div>";
}
// SINGLE GRAPH (type = 1)
if ($layout_data['type'] == 1) { // single graph
// Draw image
echo '<div style="z-index: 1; color: '.$layout_data['label_color'].'; position: absolute; margin-left: '.$layout_data['pos_x'].'px; margin-top:'.$layout_data['pos_y'].'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
if ($show_links) {
if (($layout_data['id_layout_linked'] == "") || ($layout_data['id_layout_linked'] == 0)) {
echo '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'&tab=data">';
} else {
echo '<a href="index.php?sec=visualc&sec2=operation/visual_console/render_view&pure='.$config["pure"].'&id='.$layout_data['id_layout_linked'].'">';
}
}
echo '<img src="reporting/fgraph.php?tipo=sparse&id='.$layout_data['id_agente_modulo'].'&label='.$layout_data['label'].'&height='.$layout_data['height'].'&width='.$layout_data['width'].'&period='.$layout_data['period'].'" title="'.$layout_data['label'].'" border="0">';
echo "</a>";
echo "</div>";
} else if ($layout_data['type'] == 2) {
$line['id'] = $layout_data['id'];
$line['x'] = $layout_data['pos_x'];
$line['y'] = $layout_data['pos_y'];
$line['width'] = $layout_data['width'];
$line['height'] = $layout_data['height'];
$line['color'] = $layout_data['label_color'];
array_push ($lines, $line);
}
echo '<img src="reporting/fgraph.php?tipo=sparse&id='.$layout_data['id_agente_modulo'].'&label='.$layout_data['label'].'&height='.$layout_data['height'].'&width='.$layout_data['width'].'&period='.$layout_data['period'].'" title="'.$layout_data['label'].'" border="0">';
echo "</a>";
echo "</div>";
} else if ($layout_data['type'] == 2) {
$line['id'] = $layout_data['id'];
$line['x'] = $layout_data['pos_x'];
$line['y'] = $layout_data['pos_y'];
$line['width'] = $layout_data['width'];
$line['height'] = $layout_data['height'];
$line['color'] = $layout_data['label_color'];
array_push ($lines, $line);
}
// Get parent relationship - Create line data
if ($layout_data["parent_item"] != "" && $layout_data["parent_item"] != 0) {
$line['id'] = $layout_data['id'];
$line['node_begin'] = 'layout-data-'.$layout_data["parent_item"];
$line['node_end'] = 'layout-data-'.$layout_data["id"];
$line['color'] = $status_parent ? '#00dd00' : '#dd0000';
array_push ($lines, $line);
// Get parent relationship - Create line data
if ($layout_data["parent_item"] != "" && $layout_data["parent_item"] != 0) {
$line['id'] = $layout_data['id'];
$line['node_begin'] = 'layout-data-'.$layout_data["parent_item"];
$line['node_end'] = 'layout-data-'.$layout_data["id"];
$line['color'] = $status_parent ? '#00dd00' : '#dd0000';
array_push ($lines, $line);
}
}
}
if ($draw_lines) {