From fbf26fab91e3a4908e8782a83cf1581ae558e8e9 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 4 Mar 2021 10:29:52 +0000 Subject: [PATCH] Fix styles file export_data --- pandora_console/include/ajax/module.php | 6 ++ .../include/graphs/export_data.php | 79 +++++++++++-------- .../include/graphs/flot/pandora.flot.js | 2 +- .../include/javascript/jquery.pandora.js | 32 ++++---- .../agentes/interface_traffic_graph_win.php | 34 ++++++-- .../operation/agentes/stat_win.php | 8 +- visual_console_client/src/Item.ts | 3 +- 7 files changed, 106 insertions(+), 58 deletions(-) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 7805d4c467..8751e7e97f 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -394,6 +394,12 @@ if (check_login()) { $index = 0; foreach ($columns as $col => $attr) { $table->head[$index] = $col; + if ($col === 'Data') { + $table->head[$index] .= ui_print_help_tip( + __('In Pandora FMS, data is stored compressed. The data visualization in database, charts or CSV exported data won\'t match, because is interpreted at runtime. Please check \'Pandora FMS Engineering\' chapter from documentation.'), + true + ); + } if (isset($attr['align'])) { $table->align[$index] = $attr['align']; diff --git a/pandora_console/include/graphs/export_data.php b/pandora_console/include/graphs/export_data.php index 5843ca232d..f4de87ff3c 100644 --- a/pandora_console/include/graphs/export_data.php +++ b/pandora_console/include/graphs/export_data.php @@ -1,18 +1,32 @@ load_tables(); } -// Get data +// Get data. $type = (string) get_parameter('type', 'csv'); $data = (string) get_parameter('data'); @@ -36,10 +52,8 @@ $default_filename = 'data_exported - '.date($config['date_format']); $filename = (string) get_parameter('filename', $default_filename); $filename = io_safe_output($filename); -// Using first-class functions to avoid namespace conflicts -// Type: 'csv' /* - $data = array( + * $data = array( * 'head' => array(,,...,), * 'data' => array( * array(,,...,), @@ -49,6 +63,7 @@ $filename = io_safe_output($filename); * ) * ); */ + $output_csv = function ($data, $filename) { global $config; @@ -56,20 +71,22 @@ $output_csv = function ($data, $filename) { $excel_encoding = (bool) get_parameter('excel_encoding', false); - // CSV Output + // CSV Output. header('Content-Type: text/csv; charset=UTF-8'); header('Content-Disposition: attachment; filename="'.$filename.'.csv"'); - // BOM - if (!$excel_encoding) { - print pack('C*', 0xEF, 0xBB, 0xBF); + // BOM. + if ($excel_encoding === false) { + echo pack('C*', 0xEF, 0xBB, 0xBF); } // Header - // Item / data + // Item / data. foreach ($data as $items) { - if (!isset($items['head']) || !isset($items['data'])) { - throw new Exception(__('An error occured exporting the data')); + if (isset($items['head']) === false + || isset($items['data']) === false + ) { + throw new Exception(__('An error occured exporting the data')); } // Get key for item value. @@ -84,7 +101,7 @@ $output_csv = function ($data, $filename) { $item = str_replace('--> '.__('Selected'), '', $item); $line = implode($separator, $item); - if ($excel_encoding) { + if ($excel_encoding === true) { echo mb_convert_encoding($line, 'UTF-16LE', 'UTF-8')."\n"; } else { echo $line."\n"; @@ -93,9 +110,8 @@ $output_csv = function ($data, $filename) { } }; -// Type: 'json' /* - $data = array( + * $data = array( * array( * 'key' => , * 'key' => , @@ -117,8 +133,9 @@ $output_csv = function ($data, $filename) { * ) * ); */ + $output_json = function ($data, $filename) { - // JSON Output + // JSON Output. header('Content-Type: application/json; charset=UTF-8'); header('Content-Disposition: attachment; filename="'.$filename.'.json"'); @@ -134,7 +151,7 @@ $output_json = function ($data, $filename) { }; try { - if (!$data) { + if (empty($data) === true) { throw new Exception(__('An error occured exporting the data')); } diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index e8a0f5e0b0..308ec1ddfa 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2390,7 +2390,7 @@ function pandoraFlotArea( if (series.data[j]) { var y = series.data[j][1]; - var x = Math.round(series.data[j][0]) - 1; + var x = Math.round(series.data[j][0]); } } diff --git a/pandora_console/include/javascript/jquery.pandora.js b/pandora_console/include/javascript/jquery.pandora.js index 812806f83b..16907db4fc 100644 --- a/pandora_console/include/javascript/jquery.pandora.js +++ b/pandora_console/include/javascript/jquery.pandora.js @@ -45,7 +45,7 @@ $(document).ready(function() { jQuery.post( "ajax.php", { - page: "operation/messages/message_list", + page: "operation/messages/message_list" }, function(data, status) { $("#dialog_messages") @@ -58,10 +58,10 @@ $(document).ready(function() { modal: true, overlay: { opacity: 0.5, - background: "black", + background: "black" }, width: 700, - height: 300, + height: 300 }) .show(); }, @@ -80,7 +80,7 @@ $(document).ready(function() { jQuery.post( "ajax.php", { - page: "operation/system_alert", + page: "operation/system_alert" }, function(data, status) { $("#alert_messages").show(); @@ -104,7 +104,7 @@ $(document).ready(function() { "ajax.php", { page: "general/alert_enterprise", - message: elem, + message: elem }, function(data, status) { $("#alert_messages").show(); @@ -130,7 +130,7 @@ $(document).ready(function() { "ajax.php", { page: "general/alert_enterprise", - message: elem, + message: elem }, function(data, status) { $("#alert_messages").show(); @@ -155,7 +155,7 @@ $(document).ready(function() { "ajax.php", { page: "general/alert_enterprise", - message: elem, + message: elem }, function(data, status) { $("#alert_messages").show(); @@ -190,7 +190,7 @@ $(document).ready(function() { width: 850, overlay: { opacity: 0.5, - background: "black", + background: "black" }, open: function() { if (hide_counter != 1) { @@ -212,7 +212,7 @@ $(document).ready(function() { } else { $("#ok_buttom").show(); } - }, + } }); $("#submit-hide-license-error-msg").click(function() { @@ -230,8 +230,8 @@ $(document).ready(function() { width: 620, overlay: { opacity: 0.5, - background: "black", - }, + background: "black" + } }); } @@ -244,8 +244,8 @@ $(document).ready(function() { width: 520, overlay: { opacity: 0.5, - background: "black", - }, + background: "black" + } }); } @@ -258,8 +258,8 @@ $(document).ready(function() { width: 520, overlay: { opacity: 0.5, - background: "black", - }, + background: "black" + } }); } @@ -327,7 +327,7 @@ $(document).ready(function() { left: +parseInt(screen.width / 2) - parseInt($("#alert_messages").css("width")) / 2 + - "px", + "px" }); }); diff --git a/pandora_console/operation/agentes/interface_traffic_graph_win.php b/pandora_console/operation/agentes/interface_traffic_graph_win.php index e89937a0c1..3f759999ec 100644 --- a/pandora_console/operation/agentes/interface_traffic_graph_win.php +++ b/pandora_console/operation/agentes/interface_traffic_graph_win.php @@ -284,14 +284,34 @@ if (empty($server_id) === false) { $menu_form .= html_print_input_hidden('server', $server_id, true); } +$menu_form .= '
'; +$menu_form .= '
'; +$menu_form .= html_print_image( + 'images/arrow_down_green.png', + true, + [ + 'class' => 'module_graph_menu_arrow', + 'float' => 'left', + ], + false, + false, + true +); +$menu_form .= ''; +$menu_form .= ''.__('Graph configuration menu').''; +$menu_form .= ui_print_help_tip( + __('In Pandora FMS, data is stored compressed. The data visualization in database, charts or CSV exported data won\'t match, because is interpreted at runtime. Please check \'Pandora FMS Engineering\' chapter from documentation.'), + true +); +$menu_form .= ''; +$menu_form .= '
'; +$menu_form .= ''; +$menu_form .= '
'; +$menu_form .= ''; + echo $menu_form; -echo '
-
- '.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).' - '.__('Graph configuration menu').'
- -
'; -echo ''; // Hidden div to forced title. html_print_div( diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 9211027113..383c108379 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -423,8 +423,12 @@ ui_print_message_dialog( false, true ); - $menu_form .= ''; - $menu_form .= __('Graph configuration menu'); + $menu_form .= ''; + $menu_form .= ''.__('Graph configuration menu').''; + $menu_form .= ui_print_help_tip( + __('In Pandora FMS, data is stored compressed. The data visualization in database, charts or CSV exported data won\'t match, because is interpreted at runtime. Please check \'Pandora FMS Engineering\' chapter from documentation.'), + true + ); $menu_form .= ''; $menu_form .= ''; $menu_form .= '