From d0bf68888ef681cd221f3c0d9688801e32722d68 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 1 Mar 2018 12:02:08 +0100 Subject: [PATCH 1/9] [SQL charts] Fixed SQL vertical chart --- pandora_console/include/functions_graph.php | 25 +++++++++++++++--- pandora_console/include/graphs/fgraph.php | 28 +++++++++++++++++---- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index f93d60217d..7db2e8b99c 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3949,9 +3949,28 @@ function graph_custom_sql_graph ($id, $width, $height, switch ($type) { case 'sql_graph_vbar': // vertical bar - return vbar_graph($flash_charts, $data, $width, $height, array(), - array(), "", "", $homeurl, $water_mark, - $config['fontpath'], $config['font_size'], false, $ttl, "", "white", false, false, "black"); + return vbar_graph( + $flash_charts, + $data, + $width, + $height, + array(), + array(), + "", + "", + "", + "", + $water_mark, + $config['fontpath'], + $config['font_size'], + "", + $ttl, + $config['homeurl'], + "white", + false, + false, + "black" + ); break; case 'sql_graph_hbar': // horizontal bar return hbar_graph($flash_charts, $data, $width, $height, array(), diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 591397d7e9..64f9ef724c 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -152,11 +152,29 @@ function slicesbar_graph($chart_data, $period, $width, $height, $colors, return ""; } -function vbar_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', - $from_ux = false, $from_wux = false, $tick_color = 'white') { +function vbar_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', + $from_ux = false, + $from_wux = false, + $tick_color = 'white' +) { + setup_watermark($water_mark, $water_mark_file, $water_mark_url); if (empty($chart_data)) { From 98b57ef6429443c64981d3841ecd79a6895ad9d5 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 1 Mar 2018 12:41:17 +0100 Subject: [PATCH 2/9] [SQL charts] Added breadcrumbs to sql charts --- pandora_console/include/functions_graph.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 7db2e8b99c..a1565361c7 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3862,6 +3862,7 @@ function graph_custom_sql_graph ($id, $width, $height, $ttl = 1) { global $config; + $SQL_GRAPH_MAX_LABEL_SIZE = 20; $report_content = db_get_row ('treport_content', 'id_rc', $id); if($id != null){ @@ -3922,7 +3923,13 @@ function graph_custom_sql_graph ($id, $width, $height, } $label = __('Data'); if (!empty($data_item["label"])) { - $label = $data_item["label"]; + $label = io_safe_output($data_item["label"]); + if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) { + $first_label = $label; + $label = substr($first_label, 0, floor($SQL_GRAPH_MAX_LABEL_SIZE/2)); + $label .= '...'; + $label .= substr($first_label, floor(-$SQL_GRAPH_MAX_LABEL_SIZE/2)); + } } switch ($type) { case 'sql_graph_vbar': // vertical bar From 3359870c2fc6852f7533c323b3b0e6bd212fede4 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 1 Mar 2018 13:11:11 +0100 Subject: [PATCH 3/9] [SQL Charts] Added limit elements and some improves --- pandora_console/include/functions_graph.php | 75 ++++++++++++++------- 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index a1565361c7..8d4bdd68ce 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3859,7 +3859,7 @@ function grafico_eventos_usuario ($width, $height) { */ function graph_custom_sql_graph ($id, $width, $height, $type = 'sql_graph_vbar', $only_image = false, $homeurl = '', - $ttl = 1) { + $ttl = 1, $max_num_elements = 8) { global $config; $SQL_GRAPH_MAX_LABEL_SIZE = 20; @@ -3921,24 +3921,38 @@ function graph_custom_sql_graph ($id, $width, $height, if (!empty($data_item["value"])) { $value = $data_item["value"]; } - $label = __('Data'); - if (!empty($data_item["label"])) { - $label = io_safe_output($data_item["label"]); - if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) { - $first_label = $label; - $label = substr($first_label, 0, floor($SQL_GRAPH_MAX_LABEL_SIZE/2)); - $label .= '...'; - $label .= substr($first_label, floor(-$SQL_GRAPH_MAX_LABEL_SIZE/2)); + if ($count <= $max_num_elements) { + $label = __('Data'); + if (!empty($data_item["label"])) { + $label = io_safe_output($data_item["label"]); + if ((strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) && ($type !== 'sql_graph_vbar')) { + $first_label = $label; + $label = substr($first_label, 0, floor($SQL_GRAPH_MAX_LABEL_SIZE/2)); + $label .= '...'; + $label .= substr($first_label, floor(-$SQL_GRAPH_MAX_LABEL_SIZE/2)); + } + } + switch ($type) { + case 'sql_graph_vbar': // vertical bar + case 'sql_graph_hbar': // horizontal bar + $data[$label."_".$count]['g'] = $value; + break; + case 'sql_graph_pie': // Pie + $data[$label."_".$count] = $value; + break; + } + } else { + switch ($type) { + case 'sql_graph_vbar': // vertical bar + case 'sql_graph_hbar': // horizontal bar + if (!isset($data[__('Other')]['g'])) $data[__('Other')]['g'] = 0; + $data[__('Other')]['g'] += $value; + break; + case 'sql_graph_pie': // Pie + if (!isset($data[__('Other')])) $data[__('Other')] = 0; + $data[__('Other')] += $value; + break; } - } - switch ($type) { - case 'sql_graph_vbar': // vertical bar - case 'sql_graph_hbar': // horizontal bar - $data[$label."_".$count]['g'] = $value; - break; - case 'sql_graph_pie': // Pie - $data[$label."_".$count] = $value; - break; } } @@ -3980,11 +3994,26 @@ function graph_custom_sql_graph ($id, $width, $height, ); break; case 'sql_graph_hbar': // horizontal bar - return hbar_graph($flash_charts, $data, $width, $height, array(), - array(), "", "", true, $homeurl, $water_mark, - $config['fontpath'], $config['font_size'], false, $ttl,$config['homeurl'], - 'white', - 'black'); + return hbar_graph( + $flash_charts, + $data, + $width, + $height, + array(), + array(), + "", + "", + "", + "", + $water_mark, + $config['fontpath'], + $config['font_size'], + false, + $ttl, + $config['homeurl'], + 'white', + 'black' + ); break; case 'sql_graph_pie': // Pie return pie3d_graph($flash_charts, $data, $width, $height, __("other"), $homeurl, From 287d28de4eacf28a729c01c92e1069ab72d2cba0 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 1 Mar 2018 13:16:36 +0100 Subject: [PATCH 4/9] [Vertical Bar Charts] Preserve order after truncate label --- pandora_console/include/graphs/fgraph.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 64f9ef724c..423eaccaea 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -188,9 +188,9 @@ function vbar_graph( $tick_color); } else { + $new_chart_data = array(); foreach ($chart_data as $key => $value) { if(strlen($key) > 20){ - if(strpos($key, ' - ') != -1){ $key_temp = explode(" - ",$key); $key_temp[0] = $key_temp[0]." \n"; @@ -198,14 +198,14 @@ function vbar_graph( $key2 = $key_temp[0].$key_temp[1]; io_safe_output($key2); } - $chart_data[$key2]['g'] = $chart_data[$key]['g']; - unset($chart_data[$key]); + $new_chart_data[$key2]['g'] = $chart_data[$key]['g']; + } else { + $new_chart_data[$key] = $value; } - } - + $graph = array(); - $graph['data'] = $chart_data; + $graph['data'] = $new_chart_data; $graph['width'] = $width; $graph['height'] = $height; $graph['color'] = $color; From 4719742ba2233272cdf967386a742e247d2642bb Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 1 Mar 2018 13:19:58 +0100 Subject: [PATCH 5/9] [Pie Charts] Maximized the number of elements --- pandora_console/include/graphs/fgraph.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 423eaccaea..16fc4a0f0a 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -721,7 +721,7 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, setup_watermark($water_mark, $water_mark_file, $water_mark_url); // This library allows only 8 colors - $max_values = 5; + $max_values = 9; //Remove the html_entities $temp = array(); From 6e62f4c0238d62e5f3422ebcfa6b95b85892e363 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 1 Mar 2018 15:55:58 +0100 Subject: [PATCH 6/9] [SQL Graphs] Added Max items form to top_n_value db column --- .../reporting_builder.item_editor.php | 34 +++++++++---------- .../godmode/reporting/reporting_builder.php | 2 ++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 65565857c0..5265ef9b26 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -361,33 +361,16 @@ switch ($action) { $text = $item['text']; break; case 'sql': - $description = $item['description']; - $sql_query_report = $item['external_source']; - $idCustom = $item['treport_custom_sql_id']; $header = $item['header_definition']; - $historical_db = $item['historical_db']; - $period = 0; - break; case 'sql_graph_pie': - $description = $item['description']; - $sql_query_report = $item['external_source']; - $idCustom = $item['treport_custom_sql_id']; - $historical_db = $item['historical_db']; - $period = 0; - break; case 'sql_graph_vbar': - $description = $item['description']; - $sql_query_report = $item['external_source']; - $idCustom = $item['treport_custom_sql_id']; - $historical_db = $item['historical_db']; - $period = 0; - break; case 'sql_graph_hbar': $description = $item['description']; $sql_query_report = $item['external_source']; $idCustom = $item['treport_custom_sql_id']; $historical_db = $item['historical_db']; $period = 0; + $top_n_value = $item['top_n_value']; break; case 'url': $description = $item['description']; @@ -1283,6 +1266,16 @@ You can of course remove the warnings, that's why we include the source and do n + + + + + + + + Date: Thu, 1 Mar 2018 16:49:50 +0100 Subject: [PATCH 7/9] [SQL charts reports] Added top n report to set the maximum number of elements --- pandora_console/include/functions_graph.php | 2 +- pandora_console/include/functions_reporting.php | 3 ++- pandora_console/include/graphs/fgraph.php | 14 ++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 8d4bdd68ce..3462366c0d 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3925,7 +3925,7 @@ function graph_custom_sql_graph ($id, $width, $height, $label = __('Data'); if (!empty($data_item["label"])) { $label = io_safe_output($data_item["label"]); - if ((strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) && ($type !== 'sql_graph_vbar')) { + if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) { $first_label = $label; $label = substr($first_label, 0, floor($SQL_GRAPH_MAX_LABEL_SIZE/2)); $label .= '...'; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 7737e32f69..1aa1b85dd9 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3294,7 +3294,8 @@ function reporting_sql_graph($report, $content, $type, $content["type"], true, ui_get_full_url(false, false, false, false), - $ttl); + $ttl, + $content['top_n_value']); break; case 'data': break; diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 16fc4a0f0a..d1df2f6397 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -190,14 +190,12 @@ function vbar_graph( else { $new_chart_data = array(); foreach ($chart_data as $key => $value) { - if(strlen($key) > 20){ - if(strpos($key, ' - ') != -1){ - $key_temp = explode(" - ",$key); - $key_temp[0] = $key_temp[0]." \n"; - $key_temp[1]= '...'.substr($key_temp[1],-15); - $key2 = $key_temp[0].$key_temp[1]; - io_safe_output($key2); - } + if(strlen($key) > 20 && strpos($key, ' - ') != -1){ + $key_temp = explode(" - ",$key); + $key_temp[0] = $key_temp[0]." \n"; + $key_temp[1]= '...'.substr($key_temp[1],-15); + $key2 = $key_temp[0].$key_temp[1]; + io_safe_output($key2); $new_chart_data[$key2]['g'] = $chart_data[$key]['g']; } else { $new_chart_data[$key] = $value; From 52e65030182b9ea1a2b915cedc83aad70f6482a0 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 1 Mar 2018 17:07:55 +0100 Subject: [PATCH 8/9] [Vertical Bar Charts] Fixed strpos check --- pandora_console/include/graphs/fgraph.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index d1df2f6397..50939b4271 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -190,7 +190,7 @@ function vbar_graph( else { $new_chart_data = array(); foreach ($chart_data as $key => $value) { - if(strlen($key) > 20 && strpos($key, ' - ') != -1){ + if(strlen($key) > 20 && strpos($key, ' - ') !== false){ $key_temp = explode(" - ",$key); $key_temp[0] = $key_temp[0]." \n"; $key_temp[1]= '...'.substr($key_temp[1],-15); From d7cbcd012f07de35fcf3f6c7aa59ed55afc6b49f Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 2 Mar 2018 09:27:29 +0100 Subject: [PATCH 9/9] [SQL Graph reports] Added dynamic height configuration option --- .../reporting_builder.item_editor.php | 30 +++++++------------ .../godmode/reporting/reporting_builder.php | 2 ++ .../include/functions_reporting.php | 4 ++- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 5265ef9b26..3730319347 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -132,6 +132,7 @@ switch ($action) { $hide_notinit_agents = 0; $server_name = ''; $server_id = 0; + $dyn_height = 230; break; case 'save': default: @@ -173,6 +174,7 @@ switch ($action) { $server_name = ''; $server_id = 0; $get_data_editor = false; + $dyn_height = 230; break; } @@ -196,6 +198,7 @@ switch ($action) { $show_in_two_columns = $style['show_in_two_columns']; $show_in_landscape = $style['show_in_landscape']; $hide_notinit_agents = $style['hide_notinit_agents']; + $dyn_height = $style['dyn_height']; $type = $item['type']; $name = $item['name']; @@ -1541,6 +1544,11 @@ You can of course remove the warnings, that's why we include the source and do n + + + + +