Fixed problems with dashboard performance when include users maps. Tiquet: #3438

(cherry picked from commit e3e549cbe8)
This commit is contained in:
m-lopez-f 2016-03-15 09:25:48 +01:00
parent e1783604a6
commit 368a96222e
9 changed files with 238 additions and 121 deletions

View File

@ -36,13 +36,14 @@ enterprise_include_once('include/functions_visual_map.php');
$id_visual_console = get_parameter('id_visual_console', null);
$render_map = (bool)get_parameter('render_map', false);
$graph_javascript = (bool)get_parameter('graph_javascript', false);
if ($render_map) {
$width = (int)get_parameter('width', '400');
$height = (int)get_parameter('height', '400');
visual_map_print_visual_map($id_visual_console, true, true, $width,
$height);
$height, '', false, $graph_javascript);
return;
}

View File

@ -164,7 +164,7 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$background_color = 'white', $modules_param = array(), $homeurl = '',
$name_list = array(), $unit_list = array(), $show_last = true,
$show_max = true, $show_min = true, $show_avg = true, $ttl = 1,
$dashboard = false) {
$dashboard = false, $vconsole = false) {
global $config;
@ -243,7 +243,8 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$show_min,
$show_avg,
$labels,
$dashboard);
$dashboard,
$vconsole);
if ($return)
return $output;

View File

@ -765,7 +765,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$unit = '', $baseline = 0, $return_data = 0, $show_title = true,
$only_image = false, $homeurl = '', $ttl = 1, $projection = false,
$adapt_key = '', $compare = false, $show_unknown = false,
$menu = true, $backgroundColor = 'white', $percentil = null) {
$menu = true, $backgroundColor = 'white', $percentil = null,
$dashboard = false, $vconsole = false) {
global $config;
global $graphic_type;
@ -892,7 +893,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$config['font_size'], $unit, $ttl, $series_type,
$chart_extra_data, $warning_min, $critical_min,
$adapt_key, false, $series_suffix_str, $menu,
$backgroundColor);
$backgroundColor, $dashboard, $vconsole);
}
}
elseif ($config['type_module_charts'] === 'line') {
@ -969,7 +970,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$only_image = false, $homeurl = '', $ttl = 1, $projection = false,
$prediction_period = false, $background_color = 'white',
$name_list = array(), $unit_list = array(), $show_last = true, $show_max = true,
$show_min = true, $show_avg = true, $labels = false, $dashboard = false) {
$show_min = true, $show_avg = true, $labels = false, $dashboard = false, $vconsole = false) {
global $config;
global $graphic_type;
@ -1712,7 +1713,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $homeurl, $water_mark, $config['fontpath'],
$fixed_font_size, $unit, $ttl, array(), array(), 0, 0, '',
false, '', true, $background_color,$dashboard);
false, '', true, $background_color,$dashboard, $vconsole);
break;
default:
case CUSTOM_GRAPH_STACKED_AREA:
@ -1720,21 +1721,21 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$width, $height, $color, $module_name_list, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], $fixed_font_size,
"", $ttl, $homeurl, $background_color,$dashboard);
"", $ttl, $homeurl, $background_color,$dashboard, $vconsole);
break;
case CUSTOM_GRAPH_LINE:
return line_graph($flash_charts, $graph_values, $width,
$height, $color, $module_name_list, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], $fixed_font_size,
$unit, $ttl, $homeurl, $background_color,$dashboard);
$unit, $ttl, $homeurl, $background_color,$dashboard, $vconsole);
break;
case CUSTOM_GRAPH_STACKED_LINE:
return stacked_line_graph($flash_charts, $graph_values,
$width, $height, $color, $module_name_list, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], $fixed_font_size,
"", $ttl, $homeurl, $background_color,$dashboard);
"", $ttl, $homeurl, $background_color,$dashboard, $vconsole);
break;
case CUSTOM_GRAPH_BULLET_CHART:
return stacked_bullet_chart($flash_charts, $graph_values,

View File

@ -88,7 +88,7 @@ function visual_map_print_user_line_handles($layoutData) {
}
function visual_map_print_item($mode = "read", $layoutData,
$proportion = null, $show_links = true, $isExternalLink = false) {
$proportion = null, $show_links = true, $isExternalLink = false, $graph_javascript = true) {
global $config;
require_once ($config["homedir"] . '/include/functions_graph.php');
@ -771,12 +771,15 @@ function visual_map_print_item($mode = "read", $layoutData,
if ($layoutData['id_custom_graph'] != 0) {
$img = custom_graphs_print(
$layoutData['id_custom_graph'], $height, $width,
$period, null, true, 0, true, $layoutData['image']);
$period, null, true, 0, true, $layoutData['image'],
array(), '', array(), array(), true,
true, true, true, 1, false, $graph_javascript);
}
else {
$img = grafico_modulo_sparse($id_module, $period, 0, $width,
$height, '', null, false, 1, false, 0, '', 0, 0, true, true,
'', 1, false, '', false, false, true, $layoutData['image']);
$height, '', null, false, 1, false, 0, '', 0, 0,
true, true, '', 1, false, '', false, false, true,
$layoutData['image'], null, false, $graph_javascript);
}
//Restore db connection
@ -1918,7 +1921,7 @@ function visual_map_print_user_lines($layout_data, $proportion = null) {
* @param bool $draw_lines
*/
function visual_map_print_visual_map ($id_layout, $show_links = true,
$draw_lines = true, $width = null, $height = null, $home_url = '', $isExternalLink = false) {
$draw_lines = true, $width = null, $height = null, $home_url = '', $isExternalLink = false, $graph_javascript = true) {
enterprise_include_once('include/functions_visual_map.php');
@ -2067,7 +2070,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true,
break;
default:
visual_map_print_item("read", $layout_data,
$proportion, $show_links, $isExternalLink);
$proportion, $show_links, $isExternalLink, $graph_javascript);
break;
}
}

View File

@ -218,7 +218,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
$chart_extra_data = array(), $yellow_threshold = 0,
$red_threshold = 0, $adapt_key = '', $force_integer = false,
$series_suffix_str = '', $menu = true, $backgroundColor = 'white',
$dashboard = false) {
$dashboard = false, $vconsole = false) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
@ -260,35 +260,55 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
$dashboard);
}
else {
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
$graph['unit'] = $unit;
$graph['series_type'] = $series_type;
$id_graph = serialize_in_temp($graph, null, $ttl);
// Warning: This string is used in the function "api_get_module_graph" from 'functions_api.php' with the regec patern "/<img src='(.+)'>/"
return "<img src='" .
ui_get_full_url (false, false, false, false) .
"include/graphs/functions_pchart.php?" .
"static_graph=1&" .
"graph_type=area&" .
"ttl=" . $ttl . "&" .
"id_graph=" . $id_graph . "'>";
if ($vconsole) {
return flot_area_simple_graph(
$chart_data,
$width,
$height,
$color,
$legend,
$long_index,
$homeurl,
$unit,
$water_mark_url,
$series_type,
$chart_extra_data,
$yellow_threshold,
$red_threshold,
$adapt_key,
$force_integer,
$series_suffix_str,
$menu,
$backgroundColor,
$dashboard,
$vconsole);
}
else {
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
$graph['unit'] = $unit;
$graph['series_type'] = $series_type;
$id_graph = serialize_in_temp($graph, null, $ttl);
// Warning: This string is used in the function "api_get_module_graph" from 'functions_api.php' with the regec patern "/<img src='(.+)'>/"
return "<img src='" .
ui_get_full_url (false, false, false, false) .
"include/graphs/functions_pchart.php?" .
"static_graph=1&" .
"graph_type=area&" .
"ttl=" . $ttl . "&" .
"id_graph=" . $id_graph . "'>";
}
}
}
@ -296,7 +316,7 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height,
$color, $legend, $long_index, $no_data_image, $xaxisname = "",
$yaxisname = "", $water_mark = "", $font = '', $font_size = '',
$unit = '', $ttl = 1, $homeurl = '', $backgroundColor = 'white',
$dashboard = false) {
$dashboard = false, $vconsole = false) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
@ -327,25 +347,51 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height,
$dashboard);
}
else {
//Stack the data
stack_data($chart_data, $legend, $color);
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . ui_get_full_url (false, false, false, false) . "include/graphs/functions_pchart.php?static_graph=1&graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
if ($vconsole) {
return flot_area_stacked_graph(
$chart_data,
$width,
$height,
$color,
$legend,
$long_index,
$homeurl,
$unit,
$water_mark_url,
array(),
array(),
0,
0,
'',
false,
'',
true,
$backgroundColor,
$dashboard,
$vconsole);
}
else {
//Stack the data
stack_data($chart_data, $legend, $color);
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . ui_get_full_url (false, false, false, false) .
"include/graphs/functions_pchart.php?static_graph=1&graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}
}
@ -353,7 +399,7 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height,
$color, $legend, $long_index, $no_data_image, $xaxisname = "",
$yaxisname = "", $water_mark = "", $font = '', $font_size = '',
$unit = '', $ttl = 1, $homeurl = '', $backgroundColor = 'white',
$dashboard = false) {
$dashboard = false, $vconsole = false) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
@ -385,25 +431,50 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height,
$dashboard);
}
else {
//Stack the data
stack_data($chart_data, $legend, $color);
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
if ($vconsole) {
return flot_line_stacked_graph(
$chart_data,
$width,
$height,
$color,
$legend,
$long_index,
$homeurl,
$unit,
$water_mark_url,
array(),
array(),
0,
0,
'',
false,
'',
true,
$background_color,
$dashboard,
$vconsole);
}
else {
//Stack the data
stack_data($chart_data, $legend, $color);
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}
}
@ -464,7 +535,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color,
$legend, $long_index, $no_data_image, $xaxisname = "",
$yaxisname = "", $water_mark = "", $font = '', $font_size = '',
$unit = '', $ttl = 1, $homeurl = '', $backgroundColor = 'white',
$dashboard = false) {
$dashboard = false, $vconsole = false) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
@ -495,22 +566,47 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color,
$dashboard);
}
else {
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
if ($vconsole) {
return flot_line_simple_graph(
$chart_data,
$width,
$height,
$color,
$legend,
$long_index,
$homeurl,
$unit,
$water_mark_url,
array(),
array(),
0,
0,
'',
false,
'',
true,
$backgroundColor,
$dashboard,
$vconsole);
}
else {
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}
}

View File

@ -706,7 +706,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
}
}
function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumulate_data, intervaltick, water_mark, maxvalue, separator, separator2) {
function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumulate_data, intervaltick, water_mark, maxvalue, separator, separator2, graph_javascript) {
values = values.split(separator2);
labels = labels.split(separator);
@ -804,7 +804,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
colors, type, serie_types, water_mark, width, max_x, homeurl, unit,
font_size, menu, events, event_ids, legend_events, alerts,
alert_ids, legend_alerts, yellow_threshold, red_threshold,
force_integer, separator, separator2, series_suffix_str) {
force_integer, separator, separator2, series_suffix_str, vconsole) {
var threshold = true;
var thresholded = false;
@ -1024,11 +1024,25 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
labelFormatter: lFormatter
}
};
if (vconsole) {
options.grid['hoverable'] = false;
options.grid['clickable'] = false;
options.crosshair = false;
options.selection = false;
}
var stack = 0, bars = true, lines = false, steps = false;
var plot = $.plot($('#' + graph_id), datas, options);
if (vconsole) {
var myCanvas = plot.getCanvas();
plot.setupGrid(); // redraw plot to new size
plot.draw();
var image = myCanvas.toDataURL("image/png");
return;
}
// Adjust the overview plot to the width and position of the main plot
adjust_left_width_canvas(graph_id, 'overview_'+graph_id);
@ -1267,7 +1281,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
$('#'+graph_id).bind('mouseout',resetInteractivity);
$('#overview_'+graph_id).bind('mouseout',resetInteractivity);
// Reset interactivity styles
function resetInteractivity() {
$('#timestamp_'+graph_id).hide();

View File

@ -152,7 +152,7 @@ function d3_bullet_chart($chart_data, $width, $height, $color, $legend,
$id_bullet = uniqid();
$output .=
'<div id="bullet_graph_' . $id_bullet . '" class="bulle" style="overflow: hidden;"></div>
'<div id="bullet_graph_' . $id_bullet . '" class="bullet" style="overflow: hidden; width: '.$width.'px"></div>
<style>
.bullet_graph {
@ -226,7 +226,7 @@ function d3_bullet_chart($chart_data, $width, $height, $color, $legend,
var title = svg.append("g")
.style("text-anchor", "end")
.attr("transform", "translate(-20," + height + ")");
.attr("transform", "translate(-10, 15)");
title.append("text")
.attr("class", "title")

View File

@ -94,7 +94,7 @@ function flot_area_stacked_graph($chart_data, $width, $height, $color,
$serie_types = array(), $chart_extra_data = array(),
$yellow_threshold = 0, $red_threshold = 0, $adapt_key= '',
$force_integer = false, $series_suffix_str = '', $menu = true,
$background_color = 'white', $dashboard = false) {
$background_color = 'white', $dashboard = false, $vconsole = false) {
global $config;
@ -102,7 +102,7 @@ function flot_area_stacked_graph($chart_data, $width, $height, $color,
$legend, $long_index, $homeurl, $unit, 'area_stacked',
$water_mark, $serie_types, $chart_extra_data, $yellow_threshold,
$red_threshold, $adapt_key, $force_integer, $series_suffix_str,
$menu, $background_color, $dashboard);
$menu, $background_color, $dashboard, $vconsole);
}
function flot_area_simple_graph($chart_data, $width, $height, $color,
@ -110,7 +110,7 @@ function flot_area_simple_graph($chart_data, $width, $height, $color,
$serie_types = array(), $chart_extra_data = array(),
$yellow_threshold = 0, $red_threshold = 0, $adapt_key= '',
$force_integer = false, $series_suffix_str = '', $menu = true,
$background_color = 'white', $dashboard = false) {
$background_color = 'white', $dashboard = false, $vconsole = false) {
global $config;
@ -118,7 +118,7 @@ function flot_area_simple_graph($chart_data, $width, $height, $color,
$legend, $long_index, $homeurl, $unit, 'area_simple',
$water_mark, $serie_types, $chart_extra_data, $yellow_threshold,
$red_threshold, $adapt_key, $force_integer, $series_suffix_str,
$menu, $background_color, $dashboard);
$menu, $background_color, $dashboard, $vconsole);
}
function flot_line_stacked_graph($chart_data, $width, $height, $color,
@ -126,7 +126,7 @@ function flot_line_stacked_graph($chart_data, $width, $height, $color,
$serie_types = array(), $chart_extra_data = array(),
$yellow_threshold = 0, $red_threshold = 0, $adapt_key= '',
$force_integer = false, $series_suffix_str = '', $menu = true,
$background_color = 'white', $dashboard = false) {
$background_color = 'white', $dashboard = false, $vconsole = false) {
global $config;
@ -134,7 +134,7 @@ function flot_line_stacked_graph($chart_data, $width, $height, $color,
$legend, $long_index, $homeurl, $unit, 'line_stacked',
$water_mark, $serie_types, $chart_extra_data, $yellow_threshold,
$red_threshold, $adapt_key, $force_integer, $series_suffix_str,
$menu, $background_color, $dashboard);
$menu, $background_color, $dashboard, $vconsole);
}
function flot_line_simple_graph($chart_data, $width, $height, $color,
@ -142,7 +142,7 @@ function flot_line_simple_graph($chart_data, $width, $height, $color,
$serie_types = array(), $chart_extra_data = array(),
$yellow_threshold = 0, $red_threshold = 0, $adapt_key= '',
$force_integer = false, $series_suffix_str = '', $menu = true,
$background_color = 'white', $dashboard = false) {
$background_color = 'white', $dashboard = false, $vconsole = false) {
global $config;
@ -150,14 +150,14 @@ function flot_line_simple_graph($chart_data, $width, $height, $color,
$legend, $long_index, $homeurl, $unit, 'line_simple',
$water_mark, $serie_types, $chart_extra_data, $yellow_threshold,
$red_threshold, $adapt_key, $force_integer, $series_suffix_str,
$menu, $background_color, $dashboard);
$menu, $background_color, $dashboard, $vconsole);
}
function flot_area_graph($chart_data, $width, $height, $color, $legend,
$long_index, $homeurl, $unit, $type, $water_mark, $serie_types,
$chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key,
$force_integer, $series_suffix_str = '', $menu = true,
$background_color = 'white', $dashboard = false) {
$background_color = 'white', $dashboard = false, $vconsole = false) {
global $config;
@ -425,7 +425,8 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
"$force_integer, \n" .
"'$separator', \n" .
"'$separator2', \n" .
"'$series_suffix_str');";
"'$series_suffix_str',
'$vconsole');";
$return .= "\n//]]>";
$return .= "</script>";

View File

@ -153,7 +153,7 @@ else {
html_print_input_hidden('metaconsole', 1);
}
visual_map_print_visual_map ($id_layout);
visual_map_print_visual_map ($id_layout, true, true, null, null, '', false, true);