2014-08-05 Alejandro Gallardo <alejandro.gallardo@artica.es>

* general/main_menu.php: Fixed the menu position when
	it's fixed and the header's not.

	* include/functions_graph.php,
	  include/graphs/pandora.d3.js: Added colors to the elements
	depending on their status on the functions 'sunburst' and
	'graph_monitor_wheel'.

	* include/styles/pandora.css: Fixed the z-index of the
	shortcut bar.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10382 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
alexhigh 2014-08-05 13:09:46 +00:00
parent 6ab46fe635
commit 825852d324
5 changed files with 185 additions and 14 deletions

View File

@ -1,3 +1,16 @@
2014-08-05 Alejandro Gallardo <alejandro.gallardo@artica.es>
* general/main_menu.php: Fixed the menu position when
it's fixed and the header's not.
* include/functions_graph.php,
include/graphs/pandora.d3.js: Added colors to the elements
depending on their status on the functions 'sunburst' and
'graph_monitor_wheel'.
* include/styles/pandora.css: Fixed the z-index of the
shortcut bar.
2014-08-04 Alejandro Gallardo <alejandro.gallardo@artica.es>
* general/header.php: Now the header can be configured

View File

@ -63,6 +63,7 @@ ui_require_jquery_file ('cookie');
var autohidden_menu = <?php echo $autohidden_menu; ?>;
var fixed_menu = <?php echo json_encode((bool)$config['fixed_menu']); ?>;
var fixed_header = <?php echo json_encode((bool)$config['fixed_header']); ?>;
var menuState = $.cookie(btoa('pandora_menu_state'));
if (!menuState) {
@ -133,6 +134,16 @@ $(document).ready( function() {
})
.children('div')
.css('margin-bottom', $('div#head').innerHeight() + 'px');
if (!fixed_header) {
$(window).scroll(function () {
if ($(this).scrollTop() <= $('div#head').innerHeight()) {
$('div#menu').css('top', $('div#head').innerHeight() - $(this).scrollTop() + 'px' );
} else {
$('div#menu').css('top', '0');
}
});
}
}
if (autohidden_menu) {

View File

@ -4097,6 +4097,7 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
include_once ($config['homedir'] . "/include/functions_users.php");
include_once ($config['homedir'] . "/include/functions_groups.php");
include_once ($config['homedir'] . "/include/functions_agents.php");
include_once ($config['homedir'] . "/include/functions_modules.php");
$graph_data = array();
@ -4126,21 +4127,22 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
$module_groups = modules_get_modulegroups();
$module_groups[0] = __('Not assigned');
$modules = agents_get_modules(array_keys($agents), $fields);
$modules = agents_get_modules(array_keys($agents), '*');
$data_agents = array();
if (!empty($modules)) {
foreach ($modules as $key => $module) {
$module_id = $module['id_agente_modulo'];
$agent_id = $module['id_agente'];
$module_group_id = $module['id_module_group'];
$module_id = (int) $module['id_agente_modulo'];
$agent_id = (int) $module['id_agente'];
$module_group_id = (int) $module['id_module_group'];
$module_name = $module['nombre'];
$module_status = modules_get_agentmodule_status($module_id);
if (!isset($data_agents[$agent_id])) {
$data_agents[$agent_id] = array();
$data_agents[$agent_id]['id'] = $agent_id;
$data_agents[$agent_id]['name'] = $agents[$agent_id]['nombre'];
$data_agents[$agent_id]['group'] = $agents[$agent_id]['id_grupo'];
$data_agents[$agent_id]['group'] = (int) $agents[$agent_id]['id_grupo'];
$data_agents[$agent_id]['type'] = 'agent';
$data_agents[$agent_id]['size'] = 30;
$data_agents[$agent_id]['children'] = array();
@ -4148,6 +4150,15 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
$tooltip_content = __('Agent') . ": <b>" . $data_agents[$agent_id]['name'] . "</b>";
$data_agents[$agent_id]['tooltip_content'] = $tooltip_content;
$data_agents[$agent_id]['modules_critical'] = 0;
$data_agents[$agent_id]['modules_warning'] = 0;
$data_agents[$agent_id]['modules_normal'] = 0;
$data_agents[$agent_id]['modules_not_init'] = 0;
$data_agents[$agent_id]['modules_not_normal'] = 0;
$data_agents[$agent_id]['modules_unknown'] = 0;
$data_agents[$agent_id]['color'] = COL_UNKNOWN;
unset($agents[$agent_id]);
}
if (!isset($data_agents[$agent_id]['children'][$module_group_id])) {
@ -4160,6 +4171,89 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
$tooltip_content = __('Module group') . ": <b>" . $module_groups[$module_group_id] . "</b>";
$data_agents[$agent_id]['children'][$module_group_id]['tooltip_content'] = $tooltip_content;
$data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_warning'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_normal'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_not_init'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_unknown'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_UNKNOWN;
}
switch ($module_status) {
case AGENT_MODULE_STATUS_CRITICAL_BAD:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
$data_agents[$agent_id]['modules_critical']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_critical']++;
break;
case AGENT_MODULE_STATUS_WARNING:
case AGENT_MODULE_STATUS_WARNING_ALERT:
$data_agents[$agent_id]['modules_warning']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_warning']++;
break;
case AGENT_MODULE_STATUS_NORMAL:
case AGENT_MODULE_STATUS_NORMAL_ALERT:
$data_agents[$agent_id]['modules_normal']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_normal']++;
break;
case AGENT_MODULE_STATUS_NOT_INIT:
$data_agents[$agent_id]['modules_not_init']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_not_init']++;
break;
case AGENT_MODULE_STATUS_NOT_NORMAL:
$data_agents[$agent_id]['modules_not_normal']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal']++;
break;
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_UNKNOWN:
$data_agents[$agent_id]['modules_unknown']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_unknown']++;
break;
}
if ($data_agents[$agent_id]['modules_critical'] > 0) {
$data_agents[$agent_id]['color'] = COL_CRITICAL;
}
else if ($data_agents[$agent_id]['modules_warning'] > 0) {
$data_agents[$agent_id]['color'] = COL_WARNING;
}
else if ($data_agents[$agent_id]['modules_not_normal'] > 0) {
$data_agents[$agent_id]['color'] = COL_WARNING;
}
else if ($data_agents[$agent_id]['modules_unknown'] > 0) {
$data_agents[$agent_id]['color'] = COL_UNKNOWN;
}
else if ($data_agents[$agent_id]['modules_normal'] > 0) {
$data_agents[$agent_id]['color'] = COL_NORMAL;
}
else {
$data_agents[$agent_id]['color'] = COL_NOTINIT;
}
if ($data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_CRITICAL;
}
else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_warning'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_WARNING;
}
else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_WARNING;
}
else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_unknown'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_UNKNOWN;
}
else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_normal'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_NORMAL;
}
else {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_NOTINIT;
}
$data_module = array();
@ -4171,6 +4265,37 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
$tooltip_content = __('Module') . ": <b>" . $module_name . "</b>";
$data_module['tooltip_content'] = $tooltip_content;
switch ($module_status) {
case AGENT_MODULE_STATUS_CRITICAL_BAD:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
$data_module['color'] = COL_CRITICAL;
break;
case AGENT_MODULE_STATUS_WARNING:
case AGENT_MODULE_STATUS_WARNING_ALERT:
$data_module['color'] = COL_WARNING;
break;
case AGENT_MODULE_STATUS_NORMAL:
case AGENT_MODULE_STATUS_NORMAL_ALERT:
$data_module['color'] = COL_NORMAL;
break;
case AGENT_MODULE_STATUS_NOT_INIT:
$data_module['color'] = COL_NOTINIT;
break;
case AGENT_MODULE_STATUS_NOT_NORMAL:
$data_module['color'] = COL_WARNING;
break;
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_UNKNOWN:
default:
$data_module['color'] = COL_UNKNOWN;
break;
}
$data_agents[$agent_id]['children'][$module_group_id]['children'][] = $data_module;
unset($modules[$module_id]);
@ -4179,9 +4304,10 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
foreach ($agents as $id => $agent) {
if (!isset($data_agents[$id])) {
$data_agents[$id] = array();
$data_agents[$id]['id'] = $id;
$data_agents[$id]['name'] = $agent['name'];
$data_agents[$id]['id'] = (int) $id;
$data_agents[$id]['name'] = $agent['nombre'];
$data_agents[$id]['type'] = 'agent';
$data_agents[$id]['color'] = COL_NOTINIT;
}
}
$agents = null;
@ -4195,13 +4321,34 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
foreach ($groups as $id => $group) {
$group_aux = array();
$group_aux['id'] = $id;
$group_aux['id'] = (int) $id;
$group_aux['name'] = $group['nombre'];
$group_aux['parent'] = $group['parent'];
$group_aux['parent'] = (int) $group['parent'];
$group_aux['type'] = 'group';
$group_aux['size'] = 100;
$group_aux['status'] = groups_get_status($id);
$tooltip_content = __('Group') . ": <b>" . $group_aux['name'] . "</b>";
switch ($group_aux['status']) {
case AGENT_STATUS_CRITICAL:
$group_aux['color'] = COL_CRITICAL;
break;
case AGENT_STATUS_WARNING:
case AGENT_STATUS_ALERT_FIRED:
$group_aux['color'] = COL_WARNING;
break;
case AGENT_STATUS_NORMAL:
$group_aux['color'] = COL_NORMAL;
break;
case AGENT_STATUS_UNKNOWN:
default:
$group_aux['color'] = COL_UNKNOWN;
break;
}
$tooltip_content = html_print_image("images/groups_small/" . $group['icon'] . ".png", true) . "&nbsp;" . __('Group') . ": <b>" . $group_aux['name'] . "</b>";
$group_aux['tooltip_content'] = $tooltip_content;
if (!isset($group['children']))
@ -4209,7 +4356,7 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
if (!empty($group['children']))
$group_aux['children'] = iterate_group_array($group['children']);
$agents = extract_agents_with_group_id($data_agents, $id);
$agents = extract_agents_with_group_id($data_agents, (int) $id);
if (!empty($agents))
$group_aux['children'] = array_merge($group_aux['children'], $agents);
@ -4235,7 +4382,7 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
}
$graph_data = array('name' => __('Main node'), 'children' => iterate_group_array($data_groups, $data_agents));
if (empty($graph_data['children']))
return fs_error_image();

View File

@ -715,7 +715,7 @@ function sunburst (recipient, data, width, height) {
.data(partition.nodes(data))
.enter().append("path")
.attr("d", arc)
.style("fill", function(d) { return color((d.children ? d : d.parent).name); })
.style("fill", function(d) { return d.color ? d3.rgb(d.color) : color((d.children ? d : d.parent).name); })
.on("click", click)
.on("mouseover", over_user)
.on("mouseout", out_user)

View File

@ -2667,7 +2667,7 @@ td.empty_field {
margin: 0px !important;
bottom: 0px;
left: 0px;
z-index: 1020;
z-index: 9001;
}
#shortcut_bar {