Merge branch 'ent-6106-Exportacion-CSV-en-icono-grafica-es-diferente-a-la-exportacion-normal' into 'develop'

Fix styles file export_data

See merge request artica/pandorafms!3691
This commit is contained in:
Daniel Rodriguez 2021-03-04 10:29:52 +00:00
commit 94b04a8ef4
6 changed files with 104 additions and 57 deletions

View File

@ -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'];

View File

@ -1,18 +1,32 @@
<?php
/**
* CSV charts.
*
* @category CSV charts
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Don't use authentication methods.
// This file only uses data retrieved in a request.
// Load files.
require_once '../../include/config.php';
require_once '../../include/functions.php';
enterprise_include_once('include/functions_reporting_csv.php');
@ -21,12 +35,14 @@ global $config;
$user_language = get_user_language($config['id_user']);
$l10n = null;
if (file_exists('../languages/'.$user_language.'.mo')) {
$l10n = new gettext_reader(new CachedFileReader('../languages/'.$user_language.'.mo'));
if (file_exists('../languages/'.$user_language.'.mo') === true) {
$l10n = new gettext_reader(
new CachedFileReader('../languages/'.$user_language.'.mo')
);
$l10n->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(<column>,<column>,...,<column>),
* 'data' => array(
* array(<data>,<data>,...,<data>),
@ -49,6 +63,7 @@ $filename = io_safe_output($filename);
* )
* );
*/
$output_csv = function ($data, $filename) {
global $config;
@ -56,19 +71,21 @@ $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'])) {
if (isset($items['head']) === false
|| isset($items['data']) === false
) {
throw new Exception(__('An error occured exporting the data'));
}
@ -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' => <value>,
* 'key' => <value>,
@ -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'));
}

View File

@ -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]);
}
}

View File

@ -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"
});
});

View File

@ -284,14 +284,34 @@ if (empty($server_id) === false) {
$menu_form .= html_print_input_hidden('server', $server_id, true);
}
$menu_form .= '<div class="module_graph_menu_dropdown">';
$menu_form .= '<div id="module_graph_menu_header" class="module_graph_menu_header">';
$menu_form .= html_print_image(
'images/arrow_down_green.png',
true,
[
'class' => 'module_graph_menu_arrow',
'float' => 'left',
],
false,
false,
true
);
$menu_form .= '<span style="flex: 2; justify-content:center;" class="flex-row">';
$menu_form .= '<b>'.__('Graph configuration menu').'</b>';
$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 .= '</span>';
$menu_form .= '</div>';
$menu_form .= '<div class="module_graph_menu_content module_graph_menu_content_closed" style="display:none;">';
$menu_form .= $form_table;
$menu_form .= '</div>';
$menu_form .= '</div>';
$menu_form .= '</form>';
echo $menu_form;
echo '<div class="module_graph_menu_dropdown">
<div id="module_graph_menu_header" class="module_graph_menu_header">
'.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).'
<span style="flex: 2;">'.__('Graph configuration menu').'</span></div>
<div class="module_graph_menu_content module_graph_menu_content_closed" style="display:none;">'.$form_table.'</div>
</div>';
echo '</form>';
// Hidden div to forced title.
html_print_div(

View File

@ -423,8 +423,12 @@ ui_print_message_dialog(
false,
true
);
$menu_form .= '<span style="flex: 2;">';
$menu_form .= __('Graph configuration menu');
$menu_form .= '<span style="flex: 2; justify-content:center;" class="flex-row">';
$menu_form .= '<b>'.__('Graph configuration menu').'</b>';
$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 .= '</span>';
$menu_form .= '</div>';
$menu_form .= '<div class="module_graph_menu_content module_graph_menu_content_closed" style="display:none;">';