Added check modules and series

This commit is contained in:
danielmaya 2017-11-07 12:27:25 +01:00
parent e01f00ac3d
commit 61b33221bf
6 changed files with 50 additions and 15 deletions

View File

@ -1263,6 +1263,7 @@ UPDATE tagente_modulo SET cron_interval = '' WHERE cron_interval LIKE '% %';
ALTER TABLE tgraph ADD COLUMN `percentil` int(4) unsigned default '0';
ALTER TABLE tgraph ADD COLUMN `summatory_series` tinyint(1) UNSIGNED NOT NULL default '0';
ALTER TABLE tgraph ADD COLUMN `average_series` tinyint(1) UNSIGNED NOT NULL default '0';
ALTER TABLE tgraph ADD COLUMN `modules_series` tinyint(1) UNSIGNED NOT NULL default '0';
-- ---------------------------------------------------------------------
-- Table `tnetflow_filter`

View File

@ -68,6 +68,7 @@ if ($edit_graph) {
$percentil = $graphInTgraph['percentil'];
$summatory_series = $graphInTgraph['summatory_series'];
$average_series = $graphInTgraph['average_series'];
$modules_series = $graphInTgraph['modules_series'];
if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = CUSTOM_GRAPH_BULLET_CHART;
@ -88,6 +89,7 @@ else {
$percentil = 0;
$summatory_series = 0;
$average_series = 0;
$modules_series = 0;
}
@ -178,18 +180,19 @@ echo "</div>";
echo "</div></td>";
echo "<tr><td class='datos2'><b>".__('Add summatory series')."</b>" .
ui_print_help_tip (__("This will add a synthetic series to the graph,
using all series to give a SUM or an average of all present series values
in each interval. This feature could be used instead synthetic modules
if you only want to see a graph"), true)."</td>";
// echo "<tr><td class='datos2'><b>".__('Add summatory series')."</b>" .
// ui_print_help_tip (__("This will add a synthetic series to the graph,
// using all series to give a SUM or an average of all present series values
// in each interval. This feature could be used instead synthetic modules
// if you only want to see a graph"), true)."</td>";
echo "<tr><td class='datos2'><b>".__('Percentil')."</b></td>";
echo "<td class='datos2'>" . html_print_checkbox ("percentil", 1, $percentil, true) . "</td></tr>";
echo "<tr><td class='datos2'><b>".__('Add summatory series')."</b></td>";
echo "<td class='datos2'>" . html_print_checkbox ("summatory_series", 1, $summatory_series, true) . "</td>
<td class='datos2'><b>".__('Add average series')."</b></td>";
echo "<td class='datos2'>" . html_print_checkbox ("average_series", 1, $average_series, true) . "</td></tr>";
echo "<tr><td class='datos2'><b>".__('Percentil')."</b></td>";
echo "<td class='datos2'>" . html_print_checkbox ("percentil", 1, $percentil, true) . "</td></tr>";
echo "<tr><td class='datos2'><b>".__('Modules and series')."</b></td>";
echo "<td class='datos2'>" . html_print_checkbox ("modules_series", 1, $modules_series, true) . "</td></tr>";
echo "</table>";
if ($edit_graph) {
@ -208,6 +211,12 @@ echo '<script type="text/javascript">
}else{
$("#thresholdDiv").hide();
}
if(!$("#checkbox-summatory_series").is(":checked") && !$("#checkbox-average_series").is(":checked")){
$("#checkbox-modules_series").attr("disabled", true);
$("#checkbox-modules_series").attr("checked", false);
}
});
$("#stacked").change(function(){
@ -227,6 +236,24 @@ echo '<script type="text/javascript">
$("#thresholdDiv").hide();
}
});
$("#checkbox-summatory_series").change(function() {
if($("#checkbox-summatory_series").is(":checked") && $("#checkbox-modules_series").is(":disabled")) {
$("#checkbox-modules_series").removeAttr("disabled");
} else if(!$("#checkbox-average_series").is(":checked")) {
$("#checkbox-modules_series").attr("disabled", true);
$("#checkbox-modules_series").attr("checked", false);
}
});
$("#checkbox-average_series").change(function() {
if($("#checkbox-average_series").is(":checked") && $("#checkbox-modules_series").is(":disabled")) {
$("#checkbox-modules_series").removeAttr("disabled");
} else if(!$("#checkbox-summatory_series").is(":checked")) {
$("#checkbox-modules_series").attr("disabled", true);
$("#checkbox-modules_series").attr("checked", false);
}
});
</script>';
?>

View File

@ -89,6 +89,7 @@ if ($add_graph) {
$percentil = get_parameter ("percentil", 0);
$summatory_series = get_parameter ("summatory_series", 0);
$average_series = get_parameter ("average_series", 0);
$modules_series = get_parameter ("modules_series", 0);
if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = $threshold;
@ -107,7 +108,8 @@ if ($add_graph) {
'stacked' => $stacked,
'percentil' => $percentil,
'summatory_series' => $summatory_series,
'average_series' => $average_series
'average_series' => $average_series,
'modules_series' => $modules_series
);
if (trim($name) != "") {
@ -137,6 +139,7 @@ if ($update_graph) {
$percentil = get_parameter('percentil');
$summatory_series = get_parameter ("summatory_series");
$average_series = get_parameter ("average_series");
$modules_series = get_parameter ("modules_series");
$alerts = get_parameter('alerts');
$threshold = get_parameter('threshold');
@ -149,7 +152,8 @@ if ($update_graph) {
$success = db_process_sql_update('tgraph',
array('name' => $name, 'id_group' => $id_group, 'description' => $description,
'width' => $width, 'height' => $height, 'period' => $period, 'stacked' => $stacked,
'percentil' => $percentil, 'summatory_series' => $summatory_series, 'average_series' => $average_series),
'percentil' => $percentil, 'summatory_series' => $summatory_series,
'average_series' => $average_series, 'modules_series' => $modules_series),
array('id_graph' => $id_graph));
if ($success !== false)
db_pandora_audit("Report management", "Update graph #$id_graph");

View File

@ -202,9 +202,10 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$sources = db_get_all_rows_field_filter('tgraph_source', 'id_graph',
$id_graph);
$series = db_get_all_rows_sql('SELECT summatory_series,average_series FROM tgraph WHERE id_graph = '.$id_graph);
$series = db_get_all_rows_sql('SELECT summatory_series,average_series,modules_series FROM tgraph WHERE id_graph = '.$id_graph);
$summatory = $series[0]['summatory_series'];
$average = $series[0]['average_series'];
$modules_series = $series[0]['modules_series'];
$modules = array ();
$weights = array ();
@ -268,7 +269,8 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$id_widget_dashboard,
$fullscale,
$summatory,
$average);
$average,
$modules_series);
if ($return)
return $output;

View File

@ -1114,7 +1114,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$name_list = array(), $unit_list = array(), $show_last = true, $show_max = true,
$show_min = true, $show_avg = true, $labels = array(), $dashboard = false,
$vconsole = false, $percentil = null, $from_interface = false,
$id_widget_dashboard=false, $fullscale = false, $summatory = 0, $average = 0) {
$id_widget_dashboard=false, $fullscale = false, $summatory = 0, $average = 0, $modules_series = 0) {
global $config;
global $graphic_type;
@ -2131,7 +2131,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
}
//summatory and average series
if($stacked == CUSTOM_GRAPH_AREA || $stacked == CUSTOM_GRAPH_LINE) {
if($stacked == CUSTOM_GRAPH_AREA || $stacked == CUSTOM_GRAPH_LINE && $modules_series) {
if($summatory && $average){
foreach ($graph_values as $key => $value) {
$cont = count($value);

View File

@ -1192,6 +1192,7 @@ CREATE TABLE IF NOT EXISTS `tgraph` (
`percentil` tinyint(1) UNSIGNED NOT NULL default 0,
`summatory_series` tinyint(1) UNSIGNED NOT NULL default 0,
`average_series` tinyint(1) UNSIGNED NOT NULL default 0,
`modules_series` tinyint(1) UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id_graph`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;