From 35ca0bc247fee53f0b7b4e8789322d4dc41c792e Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 3 Dec 2019 13:05:33 +0100 Subject: [PATCH 1/4] Possible solution to avoid issues with JS and apostrophe of other languages strings --- pandora_console/include/functions_io.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index baddb18531..f0e2037cf2 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -455,7 +455,7 @@ function __($string /*, variable arguments */) return $string; } - return $l10n->translate($string); + return str_replace('\'', '`', $l10n->translate($string)); } $args = func_get_args(); @@ -465,7 +465,7 @@ function __($string /*, variable arguments */) return vsprintf($string, $args); } - return vsprintf($l10n->translate($string), $args); + return vsprintf(str_replace('\'', '`', $l10n->translate($string)), $args); } From a364af3b2da4663ffa8c56a0647f90d204573f94 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Wed, 11 Dec 2019 18:32:49 +0100 Subject: [PATCH 2/4] Grouped report items on styles conf. Fixed font bug --- .../godmode/setup/setup_visuals.php | 124 ++++++++++-------- 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index eee48b96f6..ad9a8337d0 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -632,8 +632,24 @@ $row++; $table_font->size[0] = '50%'; $table_font->data = []; - $table_font->data[$row][0] = __('Font path'); - $fonts = load_fonts(); + $table_font->data[$row][0] = __('Graphs font family'); + + // Load font families. + $fonts = []; + $dirFonts = scandir(_MPDF_TTFONTPATH); + foreach ($dirFonts as $entryDir) { + if (strstr($entryDir, '.ttf') !== false) { + $explode = explode('-', $entryDir); + if (count($explode) === 1) { + $fonts[$entryDir] = substr($entryDir, 0, (strlen($entryDir) - 4)); + } + + if ($explode[1] === 'Regular.ttf') { + $fonts[$explode[0].'.ttf'] = $explode[0]; + } + } + } + $table_font->data[$row][1] = html_print_select( $fonts, 'fontpath', @@ -646,7 +662,7 @@ $row++; $row++; - $table_font->data[$row][0] = __('Font size'); + $table_font->data[$row][0] = __('Graphs font size'); $font_size_array = [ 1 => 1, @@ -882,14 +898,6 @@ $row++; $table_chars->data[$row][1] = html_print_select($options_zoom_graphs, 'zoom_graph', $config['zoom_graph'], '', '', 0, true, false, false); $row++; - $table_chars->data[$row][0] = __('Graph image height for HTML reports'); - $table_chars->data[$row][0] .= ui_print_help_tip( - __('This is the height in pixels of the module graph or custom graph in the reports (only: HTML)'), - true - ); - $table_chars->data[$row][1] = html_print_input_text('graph_image_height', $config['graph_image_height'], '', 20, 20, true); - $row++; - /* $table_font->data[$row][0] = __('Font path'); $fonts = load_fonts(); @@ -996,21 +1004,20 @@ $row++; echo ''; // ---------------------------------------------------------------------- - // OTHER CONFIGURATION + // Reports // ---------------------------------------------------------------------- - $table_other = new stdClass(); - $table_other->width = '100%'; - $table_other->class = 'databox filters'; - $table_other->style[0] = 'font-weight: bold;'; - $table_other->size[0] = '50%'; - $table_other->data = []; + $table_report = new stdClass(); + $table_report->width = '100%'; + $table_report->class = 'databox filters'; + $table_report->style[0] = 'font-weight: bold;'; + $table_report->size[0] = '50%'; + $table_report->data = []; - // Enrique (27/01/2017) New feature: Show report info on top of reports - $table_other->data[$row][0] = __('Show report info with description').ui_print_help_tip( + $table_report->data[$row][0] = __('Show report info with description').ui_print_help_tip( __('Custom report description info. It will be applied to all reports and templates by default.'), true ); - $table_other->data[$row][1] = html_print_checkbox_switch( + $table_report->data[$row][1] = html_print_checkbox_switch( 'custom_report_info', 1, $config['custom_report_info'], @@ -1018,13 +1025,11 @@ $row++; ); $row++; - // ---------------------------------------------------------------------- - // Juanma (07/05/2014) New feature: Table for custom front page for reports - $table_other->data[$row][0] = __('Custom report front page').ui_print_help_tip( + $table_report->data[$row][0] = __('Custom report front page').ui_print_help_tip( __('Custom report front page. It will be applied to all reports and templates by default.'), true ); - $table_other->data[$row][1] = html_print_checkbox_switch( + $table_report->data[$row][1] = html_print_checkbox_switch( 'custom_report_front', 1, $config['custom_report_front'], @@ -1033,11 +1038,19 @@ $row++; $row++; - $table_other->data[$row][0] = __('Font size for items reports'); - $table_other->data[$row][1] = ""; + $table_report->data[$row][0] = __('PDF font size'); + $table_report->data[$row][1] = ""; $row++; + $table_report->data[$row][0] = __('Graph image height for HTML reports'); + $table_report->data[$row][0] .= ui_print_help_tip( + __('This is the height in pixels of the module graph or custom graph in the reports (only: HTML)'), + true + ); + $table_report->data[$row][1] = html_print_input_text('graph_image_height', $config['graph_image_height'], '', 20, 20, true); + $row++; + // ---------------------------------------------------------------------- $dirItems = scandir($config['homedir'].'/images/custom_logo'); foreach ($dirItems as $entryDir) { @@ -1046,25 +1059,10 @@ $row++; } } - $_fonts = []; - $dirFonts = scandir(_MPDF_TTFONTPATH); - foreach ($dirFonts as $entryDir) { - if (strstr($entryDir, '.ttf') !== false) { - $explode = explode('-', $entryDir); - if (count($explode) === 1) { - $fonts[$entryDir] = substr($entryDir, 0, (strlen($entryDir) - 4)); - } - - if ($explode[1] === 'Regular.ttf') { - $fonts[$explode[0].'.ttf'] = $explode[0]; - } - } - } - // Font - $table_other->data['custom_report_front-font'][0] = __('Custom report front').' - '.__('Font family'); - $table_other->data['custom_report_front-font'][1] = html_print_select( - $_fonts, + $table_report->data['custom_report_front-font'][0] = __('Custom report front').' - '.__('Font family'); + $table_report->data['custom_report_front-font'][1] = html_print_select( + $fonts, 'custom_report_front_font', $config['custom_report_front_font'], false, @@ -1074,11 +1072,11 @@ $row++; ); // Logo - $table_other->data['custom_report_front-logo'][0] = __('Custom report front').' - '.__('Custom logo').ui_print_help_tip( + $table_report->data['custom_report_front-logo'][0] = __('Custom report front').' - '.__('Custom logo').ui_print_help_tip( __("The dir of custom logos is in your www Console in 'images/custom_logo'. You can upload more files (ONLY JPEG AND PNG) in upload tool in console."), true ); - $table_other->data['custom_report_front-logo'][1] = html_print_select( + $table_report->data['custom_report_front-logo'][1] = html_print_select( $customLogos, 'custom_report_front_logo', io_safe_output($config['custom_report_front_logo']), @@ -1088,16 +1086,16 @@ $row++; true ); // Preview - $table_other->data['custom_report_front-preview'][0] = __('Custom report front').' - '.'Preview'; + $table_report->data['custom_report_front-preview'][0] = __('Custom report front').' - '.'Preview'; if (empty($config['custom_report_front_logo'])) { $config['custom_report_front_logo'] = 'images/pandora_logo_white.jpg'; } - $table_other->data['custom_report_front-preview'][1] = ''.html_print_image($config['custom_report_front_logo'], true).''; + $table_report->data['custom_report_front-preview'][1] = ''.html_print_image($config['custom_report_front_logo'], true).''; // Header - $table_other->data['custom_report_front-header'][0] = __('Custom report front').' - '.__('Header'); - $table_other->data['custom_report_front-header'][1] = html_print_textarea( + $table_report->data['custom_report_front-header'][0] = __('Custom report front').' - '.__('Header'); + $table_report->data['custom_report_front-header'][1] = html_print_textarea( 'custom_report_front_header', 5, 15, @@ -1107,13 +1105,13 @@ $row++; ); // First page - $table_other->data['custom_report_front-first_page'][0] = __('Custom report front').' - '.__('First page'); + $table_report->data['custom_report_front-first_page'][0] = __('Custom report front').' - '.__('First page'); $custom_report_front_firstpage = str_replace( '(_URLIMAGE_)', ui_get_full_url(false, true, false, false), $config['custom_report_front_firstpage'] ); - $table_other->data['custom_report_front-first_page'][1] = html_print_textarea( + $table_report->data['custom_report_front-first_page'][1] = html_print_textarea( 'custom_report_front_firstpage', 15, 15, @@ -1123,8 +1121,8 @@ $row++; ); // Footer - $table_other->data['custom_report_front-footer'][0] = __('Custom report front').' - '.__('Footer'); - $table_other->data['custom_report_front-footer'][1] = html_print_textarea( + $table_report->data['custom_report_front-footer'][0] = __('Custom report front').' - '.__('Footer'); + $table_report->data['custom_report_front-footer'][1] = html_print_textarea( 'custom_report_front_footer', 5, 15, @@ -1133,6 +1131,22 @@ $row++; true ); + echo '
'; + echo ''.__('Reports configuration').''; + html_print_table($table_report); + echo '
'; + + + // ---------------------------------------------------------------------- + // OTHER CONFIGURATION + // ---------------------------------------------------------------------- + $table_other = new stdClass(); + $table_other->width = '100%'; + $table_other->class = 'databox filters'; + $table_other->style[0] = 'font-weight: bold;'; + $table_other->size[0] = '50%'; + $table_other->data = []; + From 81dcf4713f21a1e1adc741aa5553eec2c7c349b9 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 12 Dec 2019 14:19:09 +0100 Subject: [PATCH 3/4] Modified arab phrase for solve the issue --- pandora_console/include/languages/ar.po | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/languages/ar.po b/pandora_console/include/languages/ar.po index fded9e6962..1a86c89d99 100644 --- a/pandora_console/include/languages/ar.po +++ b/pandora_console/include/languages/ar.po @@ -20268,7 +20268,7 @@ msgid "" "The alert would fire when the value matches " msgstr "" "سيتم إطلاق التنبيه عندما تتطابق القيمة مع ما يلي " #: ../../include/functions_ui.php:1003 ../../godmode/alerts/alert_view.php:147 msgid "" @@ -20284,9 +20284,7 @@ msgid "" "The alert would fire when the value is between and " "" msgstr "" -"سيتم إطلاق التنبيه عندما تكون القيمة بين and " -"\"\r\n" -"\"" +"سيتم إطلاق التنبيه عندما تكون القيمة بين and " #: ../../include/functions_ui.php:1012 #: ../../godmode/alerts/configure_alert_template.php:808 @@ -20295,9 +20293,7 @@ msgid "" "The alert would fire when the value is not between " "and " msgstr "" -"\" سيتم إطلاق التنبيه عندما لا تكون القيمة بين " -"\" \r\n" -"\"and " +"سيتم إطلاق التنبيه عندما لا تكون القيمة بين and " #: ../../include/functions_ui.php:1016 msgid "The alert would fire when the value is over " From 603b4e71eb89b4a3370bd7d70f976d99f1cdd688 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Fri, 13 Dec 2019 09:06:54 +0100 Subject: [PATCH 4/4] Fix gauge pdf reports --- pandora_console/include/graphs/pandora.d3.js | 6 +++--- pandora_console/include/javascript/pandora.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index a334a85357..9607397ea2 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -1169,7 +1169,7 @@ function createGauges(data, width, height, font_size, no_data_image, font) { maxinum, valor; - for (key in data) { + for (var key in data) { nombre = data[key].gauge; label = data[key].label; @@ -1189,8 +1189,8 @@ function createGauges(data, width, height, font_size, no_data_image, font) { mininum = round_with_decimals(parseFloat(data[key].min)); maxinum = round_with_decimals(parseFloat(data[key].max)); - critical_inverse = parseInt(data[key].critical_inverse); - warning_inverse = parseInt(data[key].warning_inverse); + var critical_inverse = parseInt(data[key].critical_inverse); + var warning_inverse = parseInt(data[key].warning_inverse); valor = round_with_decimals(data[key].value); diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 6a29b6b552..391ed961ef 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -1763,7 +1763,7 @@ function round_with_decimals(value, multiplier) { if (typeof multiplier === "undefined") multiplier = 1; // Return non numeric types without modification - if (typeof value !== "number" || Number.isNaN(value)) { + if (typeof value !== "number" || isNaN(value)) { return value; }