Added new check to equalize maximum thresholds. Ticket #3732.

This commit is contained in:
Daniel Maya 2016-08-23 08:50:23 +02:00
parent 791a4c307f
commit bb26f4b82d
5 changed files with 117 additions and 15 deletions

View File

@ -64,6 +64,12 @@ if ($edit_graph) {
$id_group = $graphInTgraph['id_group']; $id_group = $graphInTgraph['id_group'];
$width = $graphInTgraph['width']; $width = $graphInTgraph['width'];
$height = $graphInTgraph['height']; $height = $graphInTgraph['height'];
$check = false;
if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = CUSTOM_GRAPH_BULLET_CHART;
$check = true;
}
} }
else { else {
$id_agent = 0; $id_agent = 0;
@ -74,7 +80,8 @@ else {
$height = 210; $height = 210;
$period = SECONDS_1DAY; $period = SECONDS_1DAY;
$factor = 1; $factor = 1;
$stacked = 0; $stacked = 4;
$check = false;
} }
@ -137,7 +144,7 @@ echo "<td class='datos'>";
html_print_extended_select_for_time ('period', $period, '', '', '0', 10); html_print_extended_select_for_time ('period', $period, '', '', '0', 10);
echo "</td><td class='datos2'>"; echo "</td><td class='datos2'>";
echo "<b>".__('Type of graph')."</b></td>"; echo "<b>".__('Type of graph')."</b></td>";
echo "<td class='datos2'>"; echo "<td class='datos2'> <div style='float:left;display:inline-block'>";
include_once($config["homedir"] . "/include/functions_graph.php"); include_once($config["homedir"] . "/include/functions_graph.php");
@ -153,7 +160,16 @@ $stackeds = array(
CUSTOM_GRAPH_PIE => __('Pie') CUSTOM_GRAPH_PIE => __('Pie')
); );
html_print_select ($stackeds, 'stacked', $stacked); html_print_select ($stackeds, 'stacked', $stacked);
echo "</td>";
echo "<div style='float:right' id='thresholdDiv' name='thresholdDiv'>&nbsp;&nbsp;<b>".__('Equalize maximum thresholds')."</b>" .
ui_print_help_tip (__("If an option is selected, all graphs will have the highest value from all modules included in the graph as a maximum threshold"), true);
html_print_checkbox('threshold', CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, $check, false, false, '', false);
echo "</div>";
echo "</div></td>";
echo "</table>"; echo "</table>";
@ -167,17 +183,31 @@ echo "</form>";
echo '<script type="text/javascript"> echo '<script type="text/javascript">
$(document).ready(function() {
if ($("#stacked").val() == '. CUSTOM_GRAPH_BULLET_CHART .') {
$("#thresholdDiv").show();
}else{
$("#thresholdDiv").hide();
}
});
$("#stacked").change(function(){ $("#stacked").change(function(){
console.log($(this).val());
if ( $(this).val() == '. CUSTOM_GRAPH_GAUGE .') { if ( $(this).val() == '. CUSTOM_GRAPH_GAUGE .') {
$("[name=threshold]").prop("checked", false);
$(".stacked").hide(); $(".stacked").hide();
$("input[name=\'width\']").hide(); $("input[name=\'width\']").hide();
} $("#thresholdDiv").hide();
else { } else if ($(this).val() == '. CUSTOM_GRAPH_BULLET_CHART .') {
$("#thresholdDiv").show();
$(".stacked").show(); $(".stacked").show();
$("input[name=\'width\']").show(); $("input[name=\'width\']").show();
} else {
$("[name=threshold]").prop("checked", false);
$(".stacked").show();
$("input[name=\'width\']").show();
$("#thresholdDiv").hide();
} }
}); });
</script>'; </script>';
?> ?>

View File

@ -74,7 +74,12 @@ if ($add_graph) {
$height = get_parameter_post ("height"); $height = get_parameter_post ("height");
$stacked = get_parameter ("stacked", 0); $stacked = get_parameter ("stacked", 0);
$period = get_parameter_post ("period"); $period = get_parameter_post ("period");
$threshold = get_parameter('threshold');
if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = $threshold;
}
// Create graph // Create graph
$values = array( $values = array(
'id_user' => $config['id_user'], 'id_user' => $config['id_user'],
@ -112,7 +117,12 @@ if ($update_graph) {
$period = get_parameter('period'); $period = get_parameter('period');
$stacked = get_parameter('stacked'); $stacked = get_parameter('stacked');
$alerts = get_parameter('alerts'); $alerts = get_parameter('alerts');
$threshold = get_parameter('threshold');
if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = $threshold;
}
if (trim($name) != "") { if (trim($name) != "") {
$success = db_process_sql_update('tgraph', $success = db_process_sql_update('tgraph',

View File

@ -430,6 +430,7 @@ define("CUSTOM_GRAPH_GAUGE", 5);
define("CUSTOM_GRAPH_HBARS", 6); define("CUSTOM_GRAPH_HBARS", 6);
define("CUSTOM_GRAPH_VBARS", 7); define("CUSTOM_GRAPH_VBARS", 7);
define("CUSTOM_GRAPH_PIE", 8); define("CUSTOM_GRAPH_PIE", 8);
define("CUSTOM_GRAPH_BULLET_CHART_THRESHOLD", 9);
/* COLLECTIONS */ /* COLLECTIONS */
define("COLLECTION_PENDING_APPLY", 0); define("COLLECTION_PENDING_APPLY", 0);

View File

@ -1083,7 +1083,8 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$graph_values = array(); $graph_values = array();
$module_name_list = array(); $module_name_list = array();
$collector = 0;
// Calculate data for each module // Calculate data for each module
for ($i = 0; $i < $module_number; $i++) { for ($i = 0; $i < $module_number; $i++) {
$automatic_custom_graph_meta = false; $automatic_custom_graph_meta = false;
@ -1432,8 +1433,26 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$stacked = CUSTOM_GRAPH_BULLET_CHART; $stacked = CUSTOM_GRAPH_BULLET_CHART;
switch ($stacked) { switch ($stacked) {
case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD:
case CUSTOM_GRAPH_BULLET_CHART: case CUSTOM_GRAPH_BULLET_CHART:
$datelimit = $date - $period; $datelimit = $date - $period;
if($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$acumulador = 0;
foreach ($module_list as $module_item) {
$module = $module_item;
$query_last_value = sprintf('
SELECT datos
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp < %d
ORDER BY utimestamp DESC',
$module, $date);
$temp_data = db_get_value_sql($query_last_value);
if ($acumulador < $temp_data){
$acumulador = $temp_data;
}
}
}
foreach ($module_list as $module_item) { foreach ($module_list as $module_item) {
$automatic_custom_graph_meta = false; $automatic_custom_graph_meta = false;
if ($config['metaconsole']) { if ($config['metaconsole']) {
@ -1486,7 +1505,12 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$temp_max = reporting_get_agentmodule_data_max($module,$period,$date); $temp_max = reporting_get_agentmodule_data_max($module,$period,$date);
if ($temp_max < 0) if ($temp_max < 0)
$temp_max = 0; $temp_max = 0;
$temp[$module]['max'] = ($temp_max === false) ? 0 : $temp_max; if (isset($acumulador)){
$temp[$module]['max'] = $acumulador;
}else{
$temp[$module]['max'] = ($temp_max === false) ? 0 : $temp_max;
}
$temp_min = reporting_get_agentmodule_data_min($module,$period,$date); $temp_min = reporting_get_agentmodule_data_min($module,$period,$date);
if ($temp_min < 0) if ($temp_min < 0)
$temp_min = 0; $temp_min = 0;
@ -1788,6 +1812,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
"", "", $water_mark, $config['fontpath'], $fixed_font_size, "", "", $water_mark, $config['fontpath'], $fixed_font_size,
"", $ttl, $homeurl, $background_color,$dashboard, $vconsole); "", $ttl, $homeurl, $background_color,$dashboard, $vconsole);
break; break;
case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD:
case CUSTOM_GRAPH_BULLET_CHART: case CUSTOM_GRAPH_BULLET_CHART:
return stacked_bullet_chart($flash_charts, $graph_values, return stacked_bullet_chart($flash_charts, $graph_values,
$width, $height, $color, $module_name_list, $long_index, $width, $height, $color, $module_name_list, $long_index,

View File

@ -94,10 +94,16 @@ if ($view_graph) {
$events = $graph["events"]; $events = $graph["events"];
$description = $graph["description"]; $description = $graph["description"];
$stacked = (int) get_parameter ('stacked', -1); $stacked = (int) get_parameter ('stacked', -1);
$check = get_parameter('threshold',false);
if($check == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$check = true;
$stacked = CUSTOM_GRAPH_BULLET_CHART_THRESHOLD;
}
if ($stacked == -1) if ($stacked == -1)
$stacked = $graph["stacked"]; $stacked = $graph["stacked"];
if ($stacked == CUSTOM_GRAPH_BULLET_CHART ) if ($stacked == CUSTOM_GRAPH_BULLET_CHART || $stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD)
$height = 50; $height = 50;
if ($stacked == CUSTOM_GRAPH_GAUGE ){ if ($stacked == CUSTOM_GRAPH_GAUGE ){
@ -174,7 +180,9 @@ if ($view_graph) {
else { else {
ui_print_info_message ( array ( 'no_close' => true, 'message' => __('No data.') ) ); ui_print_info_message ( array ( 'no_close' => true, 'message' => __('No data.') ) );
} }
if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = 4;
}
$period_label = human_time_description_raw ($period); $period_label = human_time_description_raw ($period);
echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=$id_graph'>"; echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=$id_graph'>";
echo "<table class='databox filters' cellpadding='4' cellspacing='4' style='width: 100%'>"; echo "<table class='databox filters' cellpadding='4' cellspacing='4' style='width: 100%'>";
@ -214,7 +222,15 @@ if ($view_graph) {
$stackeds[CUSTOM_GRAPH_PIE] = __('Pie'); $stackeds[CUSTOM_GRAPH_PIE] = __('Pie');
html_print_select ($stackeds, 'stacked', $stacked , '', '', -1, false, false); html_print_select ($stackeds, 'stacked', $stacked , '', '', -1, false, false);
echo "</td>"; echo "</td>";
echo "<td class='datos'>";
echo "<div style='float:left' id='thresholdDiv' name='thresholdDiv'>&nbsp;&nbsp;<b>".__('Equalize maximum thresholds')."</b>" .
ui_print_help_tip (__("If an option is selected, all graphs will have the highest value from all modules included in the graph as a maximum threshold"), true);
html_print_checkbox('threshold', CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, $check, false, false, '', false);
echo "</div>";
echo "</td>";
echo "<td class='datos'>"; echo "<td class='datos'>";
$zooms = array(); $zooms = array();
$zooms[0] = __('Graph defined'); $zooms[0] = __('Graph defined');
@ -260,6 +276,26 @@ if ($view_graph) {
changeMonth: true, changeMonth: true,
changeYear: true, changeYear: true,
showAnim: "slideDown"}); showAnim: "slideDown"});
if ($("#stacked").val() == '4') {
$("#thresholdDiv").show();
}else{
$("#thresholdDiv").hide();
}
});
$("#stacked").change(function(){
if ($(this).val() == '4') {
console.log($(this).val());
$("#thresholdDiv").show();
$(".stacked").show();
} else {
$("[name=threshold]").prop("checked", false);
$(".stacked").show();
$("#thresholdDiv").hide();
}
}); });
</script> </script>