From 9d36887a02defe9d969f5cb76f3cf7ea9447c39f Mon Sep 17 00:00:00 2001 From: danielmaya Date: Wed, 28 Feb 2018 14:33:22 +0100 Subject: [PATCH 1/2] Fixed graph precision --- pandora_console/extras/mr/13.sql | 13 +++++++++++ .../godmode/setup/setup_visuals.php | 23 ++++++++----------- pandora_console/include/functions_config.php | 4 ++++ .../include/graphs/flot/pandora.flot.js | 18 ++++++++++----- .../include/graphs/functions_flot.php | 10 +++----- 5 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 pandora_console/extras/mr/13.sql diff --git a/pandora_console/extras/mr/13.sql b/pandora_console/extras/mr/13.sql new file mode 100644 index 0000000000..70ccfb05b7 --- /dev/null +++ b/pandora_console/extras/mr/13.sql @@ -0,0 +1,13 @@ +START TRANSACTION; + + SET @st_oum720 = (SELECT IF( + (SELECT value FROM tconfig WHERE token like 'short_module_graph_data') = 1, + "UPDATE tconfig SET value = 2 WHERE token LIKE 'short_module_graph_data'", + "UPDATE tconfig SET value = '' WHERE token LIKE 'short_module_graph_data'" + )); + + PREPARE pr_oum720 FROM @st_oum720; + EXECUTE pr_oum720; + DEALLOCATE PREPARE pr_oum720; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 479269af08..adb686bf05 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -487,11 +487,18 @@ if (!enterprise_installed()) { $disabled_graph_precision = true; } -$table_chars->data[$row][0] = __('Data precision for reports and visual consoles'); -$table_chars->data[$row][0] .= ui_print_help_tip(__('Number of decimals shown in reports and visual consoles. It must be a number between 0 and 5'), true); +$table_chars->data[$row][0] = __('Data precision in PandoraFMS'); +$table_chars->data[$row][0] .= ui_print_help_tip(__('Number of decimals shown. It must be a number between 0 and 5, except in graphs.'), true); $table_chars->data[$row][1] = html_print_input_text ('graph_precision', $config["graph_precision"], '', 5, 5, true, $disabled_graph_precision, false, "onChange=\"change_precision()\""); $row++; +if (!isset($config["short_module_graph_data"])) + $config["short_module_graph_data"] = true; +$table_chars->data[$row][0] = __('Data precision in graphs'); +$table_chars->data[$row][0] .= ui_print_help_tip(__('Number of decimals shown. If the field is empty, it will show all the decimals'), true); +$table_chars->data[$row][1] = html_print_input_text ('short_module_graph_data', $config["short_module_graph_data"], '', 5, 5, true, $disabled_graph_precision, false, "onChange=\"change_precision()\""); +$row++; + $table_chars->data[$row][0] = __('Default line thickness for the Custom Graph.'); $table_chars->data[$row][1] = html_print_input_text ('custom_graph_width', $config["custom_graph_width"], '', 5, 5, true); @@ -510,18 +517,6 @@ $table_chars->data[$row][1] .= __('No').' ' . html_print_radio_button ('flash_charts', 0, '', $config["global_flash_charts"], true); $row++; -if (!isset($config["short_module_graph_data"])) - $config["short_module_graph_data"] = true; -$table_chars->data[$row][0] = __('Shortened module graph data'); -$table_chars->data[$row][0] .= ui_print_help_tip(__('The data number of the module graphs will be rounded and shortened'), true); -$table_chars->data[$row][1] = __('Yes') . ' ' . - html_print_radio_button ('short_module_graph_data', 1, '', - $config["short_module_graph_data"], true) . - '  '; -$table_chars->data[$row][1] .= __('No') . ' ' . - html_print_radio_button ('short_module_graph_data', 0, '', - $config["short_module_graph_data"], true); -$row++; $table_chars->data[$row][0] = __('Type of module charts'); $table_chars->data[$row][1] = __('Area').' ' . diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index c817482f96..87c8e9cb6a 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1864,6 +1864,10 @@ function config_process_config () { config_update_value ('networkmap_max_width', 900); } + if (!isset($config['short_module_graph_data'])) { + config_update_value ('short_module_graph_data', ''); + } + if (!isset($config['tutorial_mode'])) { config_update_value ('tutorial_mode', 'full'); } diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 44ec22168e..6175ef554b 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -1773,7 +1773,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, $('#timestamp_'+graph_id).show(); // If no legend, the timestamp labels are short and with value if (legend.length == 0) { - $('#timestamp_'+graph_id).text(labels[j] + ' (' + (short_data ? parseFloat(y).toFixed(2) : parseFloat(y)) + ')'); + $('#timestamp_'+graph_id).text(labels[j] + ' (' + (short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) + ')'); } else { $('#timestamp_'+graph_id).text(labels_long[j]); @@ -1809,7 +1809,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, // The graphs of points type and unknown graphs will dont be updated if (serie_types[i] != 'points' && series.label != $('#hidden-unknown_text').val()) { $('#legend_' + graph_id + ' .legendLabel') - .eq(i).html(label_aux + '= ' + (short_data ? parseFloat(y).toFixed(2) : parseFloat(y)) + how_bigger + ' ' + unit); + .eq(i).html(label_aux + '= ' + (short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) + how_bigger + ' ' + unit); } $('#legend_' + graph_id + ' .legendLabel') @@ -1925,7 +1925,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, function yFormatter(v, axis) { axis.datamin = 0; if (short_data) { - var formatted = number_format(v, force_integer, ""); + var formatted = number_format(v, force_integer, "", short_data); } else { var formatted = v; @@ -2177,15 +2177,16 @@ function check_adaptions(graph_id) { }); } -function number_format(number, force_integer, unit) { +function number_format(number, force_integer, unit, short_data) { if (force_integer) { if (Math.round(number) != number) { return ''; } } else { - // Round to 2 decimals - number = Math.round(number * 100) / 100; + short_data ++; + decimals = pad(1, short_data, 0); + number = Math.round(number * decimals) / decimals; } var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"]; @@ -2206,6 +2207,11 @@ function number_format(number, force_integer, unit) { return number + ' ' + shorts[pos] + unit; } + +function pad(input, length, padding) { + var str = input + ""; + return (length <= str.length) ? str : pad(str+padding, length, padding); +} // Recalculate the threshold data depends on warning and critical function axis_thresholded (threshold_data, y_min, y_max, red_threshold, extremes, red_up) { diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 2c77fdd812..527539bcc9 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -490,14 +490,10 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, true); if (!isset($config["short_module_graph_data"])) - $config["short_module_graph_data"] = true; + $config["short_module_graph_data"] = ''; - if ($config["short_module_graph_data"]) { - $short_data = true; - } - else { - $short_data = false; - } + $short_data = $config["short_module_graph_data"]; + // Javascript code From 610c5a5147c43f3543eb8dfa11d6665ca6b721d8 Mon Sep 17 00:00:00 2001 From: danielmaya Date: Wed, 28 Feb 2018 15:45:58 +0100 Subject: [PATCH 2/2] Updated MR and current_package_enterprise --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 4 ++-- pandora_console/pandoradb_data.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 1a86b10541..4e292b4f0d 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1159,10 +1159,10 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 12); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 13); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '719'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '720'); -- --------------------------------------------------------------------- -- Table `tplanned_downtime_agents` diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 23239e8585..105e4833a1 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 12), +('MR', 13), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), -('current_package_enterprise', '719'), +('current_package_enterprise', '720'), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'); UNLOCK TABLES;