Add new token chart fit to content

This commit is contained in:
daniel 2020-10-05 17:03:30 +02:00 committed by Daniel Rodriguez
parent e403c781ea
commit 1b5ccfb20a
7 changed files with 442 additions and 239 deletions

View File

@ -1,29 +1,44 @@
<?php
/**
* Combined graph
*
* @category Combined graph
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 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-2010 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.
global $config;
require_once 'include/functions_custom_graphs.php';
if (is_ajax()) {
$search_agents = (bool) get_parameter('search_agents');
if (is_ajax() === true) {
$search_agents = (bool) get_parameter('search_agents', false);
if ($search_agents) {
if ($search_agents === true) {
include_once 'include/functions_agents.php';
$id_agent = (int) get_parameter('id_agent');
$string = (string) get_parameter('q');
// q is what autocomplete plugin gives
// Q is what autocomplete plugin gives.
$id_group = (int) get_parameter('id_group');
$filter = [];
@ -47,7 +62,9 @@ if (is_ajax()) {
check_login();
if (! check_acl($config['id_user'], 0, 'RW') && ! check_acl($config['id_user'], 0, 'RM')) {
if (! check_acl($config['id_user'], 0, 'RW')
&& ! check_acl($config['id_user'], 0, 'RM')
) {
db_pandora_audit(
'ACL Violation',
'Trying to access graph builder'
@ -57,7 +74,9 @@ if (! check_acl($config['id_user'], 0, 'RW') && ! check_acl($config['id_user'],
}
if ($edit_graph) {
$graphInTgraph = db_get_row_sql('SELECT * FROM tgraph WHERE id_graph = '.$id_graph);
$graphInTgraph = db_get_row_sql(
'SELECT * FROM tgraph WHERE id_graph = '.$id_graph
);
$stacked = $graphInTgraph['stacked'];
$period = $graphInTgraph['period'];
$id_group = $graphInTgraph['id_group'];
@ -94,56 +113,84 @@ if ($edit_graph) {
// -----------------------
// CREATE/EDIT GRAPH FORM
// -----------------------
echo "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>";
$url = 'index.php?sec=reporting&sec2=godmode/reporting/graph_builder';
if ($edit_graph) {
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&update_graph=1&id=".$id_graph."'>";
$output = "<form method='post' action='".$url.'&edit_graph=1&update_graph=1&id='.$id_graph."'>";
} else {
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&add_graph=1'>";
$output = "<form method='post' action='".$url."&edit_graph=1&add_graph=1'>";
}
echo '<tr>';
echo "<td class='datos'><b>".__('Name').'</b></td>';
echo "<td class='datos'><input type='text' name='name' size='25' ";
$output .= "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>";
$output .= '<tr>';
$output .= "<td class='datos'><b>".__('Name').'</b></td>';
$output .= "<td class='datos'><input type='text' name='name' size='25' ";
if ($edit_graph) {
echo "value='".$graphInTgraph['name']."' ";
$output .= "value='".$graphInTgraph['name']."' ";
}
echo '>';
$output .= '>';
$own_info = get_user_info($config['id_user']);
echo '<td><b>'.__('Group').'</b></td><td>';
$output .= '<td><b>'.__('Group').'</b></td><td>';
if (check_acl($config['id_user'], 0, 'RW')) {
echo html_print_select_groups($config['id_user'], 'RW', true, 'graph_id_group', $id_group, '', '', '', true);
$output .= html_print_select_groups(
$config['id_user'],
'RW',
true,
'graph_id_group',
$id_group,
'',
'',
'',
true
);
} else if (check_acl($config['id_user'], 0, 'RM')) {
echo html_print_select_groups($config['id_user'], 'RM', true, 'graph_id_group', $id_group, '', '', '', true);
$output .= html_print_select_groups(
$config['id_user'],
'RM',
true,
'graph_id_group',
$id_group,
'',
'',
'',
true
);
}
echo '</td></tr>';
echo '<tr>';
echo "<td class='datos2'><b>".__('Description').'</b></td>';
echo "<td class='datos2' colspan=3><textarea name='description' style='height:45px;' cols=55 rows=2>";
$output .= '</td></tr>';
$output .= '<tr>';
$output .= "<td class='datos2'><b>".__('Description').'</b></td>';
$output .= "<td class='datos2' colspan=3><textarea name='description' style='height:45px;' cols=55 rows=2>";
if ($edit_graph) {
echo $graphInTgraph['description'];
$output .= $graphInTgraph['description'];
}
echo '</textarea>';
echo '</td></tr>';
$output .= '</textarea>';
$output .= '</td></tr>';
if ($stacked == CUSTOM_GRAPH_GAUGE) {
$hidden = ' style="display:none;" ';
} else {
$hidden = '';
}
echo '<tr>';
echo "<td class='datos'>";
echo '<b>'.__('Period').'</b></td>';
echo "<td class='datos'>";
html_print_extended_select_for_time('period', $period, '', '', '0', 10);
echo "</td><td class='datos2'>";
echo '<b>'.__('Type of graph').'</b></td>';
echo "<td class='datos2'> <div style='float:left;display:inline-block'>";
$output .= '<tr>';
$output .= "<td class='datos'>";
$output .= '<b>'.__('Period').'</b></td>';
$output .= "<td class='datos'>";
$output .= html_print_extended_select_for_time(
'period',
$period,
'',
'',
'0',
10,
true
);
$output .= "</td><td class='datos2'>";
$output .= '<b>'.__('Type of graph').'</b></td>';
$output .= "<td class='datos2'> <div style='float:left;display:inline-block'>";
require_once $config['homedir'].'/include/functions_graph.php';
@ -158,85 +205,149 @@ $stackeds = [
CUSTOM_GRAPH_VBARS => __('Vertical bars'),
CUSTOM_GRAPH_PIE => __('Pie'),
];
html_print_select($stackeds, 'stacked', $stacked);
$output .= html_print_select($stackeds, 'stacked', $stacked, '', '', 0, true);
echo '</div></td></tr>';
$output .= '</div></td></tr>';
echo "<tr><td class='datos2'><b>".__('Percentil').'</b></td>';
echo "<td class='datos2'>".html_print_checkbox('percentil', 1, $percentil, true).'</td>';
echo "<td class='datos2 thresholdDiv'><b>".__('Equalize maximum thresholds').'</b></td>';
echo "<td class='datos2 thresholdDiv'>".html_print_checkbox('threshold', CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, $check, true, false, '', false);
echo '</td></tr>';
echo "<tr><td class='datos2'><b>".__('Add summatory series').'</b></td>';
echo "<td class='datos2'>".html_print_checkbox('summatory_series', 1, $summatory_series, true)."</td>
<td class='datos2'><b>".__('Add average series').'</b></td>';
echo "<td class='datos2'>".html_print_checkbox('average_series', 1, $average_series, true).'</td></tr>';
echo "<tr><td class='datos2'><b>".__('Modules and series').'</b></td>';
$output .= '<tr>';
$output .= "<td class='datos2 thresholdDiv'><b>";
$output .= __('Equalize maximum thresholds');
$output .= '</b></td>';
$output .= "<td class='datos2 thresholdDiv'>";
$output .= html_print_checkbox(
'threshold',
CUSTOM_GRAPH_BULLET_CHART_THRESHOLD,
$check,
true,
false,
'',
false
);
$output .= '</td></tr>';
echo "<td class='datos2'>".html_print_checkbox('modules_series', 1, $modules_series, true).'</td>';
echo "<td class='datos2'><b>".__('Show full scale graph (TIP)').'</td>';
echo "<td class='datos2'>".html_print_checkbox('fullscale', 1, $fullscale, true).'</td>';
echo '</tr>';
echo '</table>';
$output .= "<tr><td class='datos2 sparse_graph '><b>";
$output .= __('Percentil');
$output .= '</b></td>';
$output .= "<td class='datos2 sparse_graph'>";
$output .= html_print_checkbox(
'percentil',
1,
$percentil,
true
);
$output .= '</td>';
$output .= '</tr>';
$output .= "<tr><td class='datos2 sparse_graph'><b>";
$output .= __('Add summatory series');
$output .= '</b></td>';
$output .= "<td class='datos2 sparse_graph'>";
$output .= html_print_checkbox(
'summatory_series',
1,
$summatory_series,
true
);
$output .= "</td><td class='datos2 sparse_graph'><b>";
$output .= __('Add average series');
$output .= '</b></td>';
$output .= "<td class='datos2 sparse_graph'>";
$output .= html_print_checkbox(
'average_series',
1,
$average_series,
true
);
$output .= '</td></tr>';
$output .= "<tr><td class='datos2 sparse_graph'><b>";
$output .= __('Modules and series');
$output .= '</b></td>';
$output .= "<td class='datos2 sparse_graph'>";
$output .= html_print_checkbox('modules_series', 1, $modules_series, true);
$output .= '</td>';
$output .= "<td class='datos2 sparse_graph'><b>";
$output .= __('Show full scale graph (TIP)');
$output .= '</td>';
$output .= "<td class='datos2 sparse_graph'>";
$output .= html_print_checkbox('fullscale', 1, $fullscale, true);
$output .= '</td>';
$output .= '</tr>';
$output .= '</table>';
if ($edit_graph) {
echo "<div style='width:100%'><input style='float:right;' type=submit name='store' class='sub upd' value='".__('Update')."'></div>";
$output .= "<div style='width:100%'>";
$output .= "<input style='float:right;' type=submit name='store' class='sub upd' value='".__('Update')."'>";
$output .= '</div>';
} else {
echo "<div style='width:100%'><input style='float:right;' type=submit name='store' class='sub next' value='".__('Create')."'></div>";
$output .= "<div style='width:100%'>";
$output .= "<input style='float:right;' type=submit name='store' class='sub next' value='".__('Create')."'>";
$output .= '</div>';
}
echo '</form>';
$output .= '</form>';
echo $output;
?>
<script type="text/javascript">
$(document).ready(function() {
if ($("#stacked").val() == '<?php echo CUSTOM_GRAPH_BULLET_CHART; ?>') {
$(".thresholdDiv").show();
$(".sparse_graph").hide();
} else if (
$("#stacked").val() == '<?php echo CUSTOM_GRAPH_AREA; ?>' ||
$("#stacked").val() == '<?php echo CUSTOM_GRAPH_LINE; ?>'
) {
$(".thresholdDiv").hide();
$(".sparse_graph").show();
} else {
$(".thresholdDiv").hide();
$(".sparse_graph").hide();
}
echo '<script type="text/javascript">
$(document).ready(function() {
if ($("#stacked").val() == '.CUSTOM_GRAPH_BULLET_CHART.') {
$(".thresholdDiv").show();
}else{
$(".thresholdDiv").hide();
}
if(!$("#checkbox-summatory_series").is(":checked") && !$("#checkbox-average_series").is(":checked")){
$("#checkbox-modules_series").attr("disabled", true);
$("#checkbox-modules_series").attr("checked", false);
}
});
if( !$("#checkbox-summatory_series").is(":checked") &&
!$("#checkbox-average_series").is(":checked")
){
$("#checkbox-modules_series").attr("disabled", true);
$("#checkbox-modules_series").attr("checked", false);
}
$("#stacked").change(function(){
if ( $(this).val() == '.CUSTOM_GRAPH_GAUGE.') {
$("[name=threshold]").prop("checked", false);
$(".stacked").hide();
$("input[name=\'width\']").hide();
$(".thresholdDiv").hide();
} else if ($(this).val() == '.CUSTOM_GRAPH_BULLET_CHART.') {
$(".thresholdDiv").show();
$(".stacked").show();
$("input[name=\'width\']").show();
} else {
$("[name=threshold]").prop("checked", false);
$(".stacked").show();
$("input[name=\'width\']").show();
$(".thresholdDiv").hide();
}
});
$("#checkbox-summatory_series").change(function() {
if($("#checkbox-summatory_series").is(":checked") && $("#checkbox-modules_series").is(":disabled")) {
$("#checkbox-modules_series").removeAttr("disabled");
} else if(!$("#checkbox-average_series").is(":checked")) {
$("#checkbox-modules_series").attr("disabled", true);
$("#checkbox-modules_series").attr("checked", false);
}
});
$("#checkbox-average_series").change(function() {
if($("#checkbox-average_series").is(":checked") && $("#checkbox-modules_series").is(":disabled")) {
$("#checkbox-modules_series").removeAttr("disabled");
} else if(!$("#checkbox-summatory_series").is(":checked")) {
$("#checkbox-modules_series").attr("disabled", true);
$("#checkbox-modules_series").attr("checked", false);
}
});
$("#stacked").change(function(){
if ( $(this).val() == '<?php echo CUSTOM_GRAPH_BULLET_CHART; ?>') {
$(".thresholdDiv").show();
$(".sparse_graph").hide();
} else if (
$(this).val() == '<?php echo CUSTOM_GRAPH_AREA; ?>' ||
$(this).val() == '<?php echo CUSTOM_GRAPH_LINE; ?>'
) {
$(".thresholdDiv").hide();
$(".sparse_graph").show();
} else {
$(".thresholdDiv").hide();
$(".sparse_graph").hide();
}
});
</script>';
$("#checkbox-summatory_series").change(function() {
if( $("#checkbox-summatory_series").is(":checked") &&
$("#checkbox-modules_series").is(":disabled")
) {
$("#checkbox-modules_series").removeAttr("disabled");
} else if(!$("#checkbox-average_series").is(":checked")) {
$("#checkbox-modules_series").attr("disabled", true);
$("#checkbox-modules_series").attr("checked", false);
}
});
$("#checkbox-average_series").change(function() {
if( $("#checkbox-average_series").is(":checked") &&
$("#checkbox-modules_series").is(":disabled")
) {
$("#checkbox-modules_series").removeAttr("disabled");
} else if(!$("#checkbox-summatory_series").is(":checked")) {
$("#checkbox-modules_series").attr("disabled", true);
$("#checkbox-modules_series").attr("checked", false);
}
});
});
</script>

View File

@ -1,16 +1,31 @@
<?php
/**
* Combined graph
*
* @category Combined graph
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 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-2010 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.
global $config;
if (is_ajax()) {
@ -21,7 +36,7 @@ if (is_ajax()) {
$id_agent = (int) get_parameter('id_agent');
$string = (string) get_parameter('q');
// q is what autocomplete plugin gives
// Q is what autocomplete plugin gives.
$id_group = (int) get_parameter('id_group');
$filter = [];
@ -45,7 +60,9 @@ if (is_ajax()) {
check_login();
if (! check_acl($config['id_user'], 0, 'RW') && ! check_acl($config['id_user'], 0, 'RM')) {
if (! check_acl($config['id_user'], 0, 'RW')
&& ! check_acl($config['id_user'], 0, 'RM')
) {
db_pandora_audit(
'ACL Violation',
'Trying to access graph builder'
@ -95,7 +112,7 @@ if ($add_graph) {
$stacked = $threshold;
}
// Create graph
// Create graph.
$values = [
'id_user' => $config['id_user'],
'name' => $name,
@ -114,7 +131,7 @@ if ($add_graph) {
if (trim($name) != '') {
$id_graph = db_process_sql_insert('tgraph', $values);
if ($id_graph !== false) {
db_pandora_audit('Report management', "Create graph #$id_graph");
db_pandora_audit('Report management', 'Create graph #'.$id_graph);
} else {
db_pandora_audit('Report management', 'Fail try to create graph');
}
@ -166,9 +183,15 @@ if ($update_graph) {
['id_graph' => $id_graph]
);
if ($success !== false) {
db_pandora_audit('Report management', "Update graph #$id_graph");
db_pandora_audit(
'Report management',
'Update graph #'.$id_graph
);
} else {
db_pandora_audit('Report management', "Fail try to update graph #$id_graph");
db_pandora_audit(
'Report management',
'Fail try to update graph #'.$id_graph
);
}
} else {
$success = false;
@ -188,12 +211,12 @@ if ($add_module) {
$id_agents = get_parameter('id_agents');
$weight = get_parameter('weight');
// Id modules has double entities conversion
// Safe output remove all entities
// Id modules has double entities conversion.
// Safe output remove all entities.
io_safe_output_array($id_modules, '');
// We need to put the entities again
// to browse in db
// to browse in db.
io_safe_input_array($id_modules);
$id_agent_modules = db_get_all_rows_sql(
@ -304,23 +327,39 @@ switch ($tab) {
}
if ($add_graph) {
ui_print_result_message($id_graph, __('Graph stored successfully'), __('There was a problem storing Graph'));
ui_print_result_message(
$id_graph,
__('Graph stored successfully'),
__('There was a problem storing Graph')
);
}
if ($add_module) {
ui_print_result_message($result, __('Module added successfully'), __('There was a problem adding Module'));
ui_print_result_message(
$result,
__('Module added successfully'),
__('There was a problem adding Module')
);
}
if ($update_graph) {
ui_print_result_message($success, __('Update the graph'), __('Bad update the graph'));
ui_print_result_message(
$success,
__('Update the graph'),
__('Bad update the graph')
);
}
if ($delete_module) {
ui_print_result_message($result, __('Graph deleted successfully'), __('There was a problem deleting Graph'));
ui_print_result_message(
$result,
__('Graph deleted successfully'),
__('There was a problem deleting Graph')
);
}
// Parse CHUNK information into showable information
// Split id to get all parameters
// Parse CHUNK information into showable information.
// Split id to get all parameters.
if (!$delete_module) {
if (isset($_POST['period'])) {
$period = $_POST['period'];

View File

@ -917,6 +917,15 @@ $row++;
);
$row++;
$table_chars->data[$row][0] = __('Chart fit to content');
$table_chars->data[$row][1] = html_print_checkbox_switch(
'maximum_y_axis',
1,
$config['maximum_y_axis'],
true
);
$row++;
$table_chars->data[$row][0] = __('Type of module charts');
$table_chars->data[$row][1] = __('Area').'&nbsp;'.html_print_radio_button(
'type_module_charts',

View File

@ -925,6 +925,10 @@ function config_update_config()
$error_update[] = __('Use round corners');
}
if (!config_update_value('maximum_y_axis', (bool) get_parameter('maximum_y_axis'))) {
$error_update[] = __('Chart fit to content');
}
if (!config_update_value('show_qr_code_header', (bool) get_parameter('show_qr_code_header'))) {
$error_update[] = __('Show QR code header');
}
@ -1772,6 +1776,10 @@ function config_process_config()
config_update_value('round_corner', false);
}
if (isset($config['maximum_y_axis']) === false) {
config_update_value('maximum_y_axis', false);
}
if (!isset($config['show_qr_code_header'])) {
config_update_value('show_qr_code_header', false);
}

View File

@ -56,7 +56,17 @@ function forecast_projection_graph(
'projection' => true,
];
$module_data = grafico_modulo_sparse($params, $server_name);
if (is_metaconsole()) {
$id_meta = metaconsole_get_id_server($server_name);
$server = metaconsole_get_connection_by_id($id_meta);
metaconsole_connect($server);
}
$module_data = grafico_modulo_sparse($params);
if (is_metaconsole()) {
metaconsole_restore_db();
}
if (empty($module_data)) {
return [];

View File

@ -629,172 +629,177 @@ function grafico_modulo_sparse_data(
* 'graph_render' => 0,
* 'zoom' => 1,
* 'server_id' => null,
* 'stacked' => 0.
* 'stacked' => 0
* 'maximum_y_axis' => 0.
*
* @return string html Content graphs.
*/
function grafico_modulo_sparse($params, $server_name='')
function grafico_modulo_sparse($params)
{
global $config;
if (!isset($params) || !is_array($params)) {
if (isset($params) === false || is_array($params) === false) {
return false;
}
if (!isset($params['period'])) {
if (isset($params['period']) === false) {
return false;
}
if (!isset($params['show_events'])) {
if (isset($params['show_events']) === false) {
$params['show_events'] = false;
}
if (!isset($params['width'])) {
if (isset($params['width']) === false) {
$params['width'] = '90%';
}
if (!isset($params['height'])) {
if (isset($params['height']) === false) {
$params['height'] = 450;
}
if (!isset($params['title'])) {
if (isset($params['title']) === false) {
$params['title'] = '';
}
if (!isset($params['unit_name'])) {
if (isset($params['unit_name']) === false) {
$params['unit_name'] = null;
}
if (!isset($params['show_alerts'])) {
if (isset($params['show_alerts']) === false) {
$params['show_alerts'] = false;
}
if (!isset($params['date']) || !$params['date']) {
if (isset($params['date']) === false || !$params['date']) {
$params['date'] = get_system_time();
}
if (!isset($params['unit'])) {
if (isset($params['unit']) === false) {
$params['unit'] = '';
}
if (!isset($params['baseline'])) {
if (isset($params['baseline']) === false) {
$params['baseline'] = 0;
}
if (!isset($params['return_data'])) {
if (isset($params['return_data']) === false) {
$params['return_data'] = 0;
}
if (!isset($params['show_title'])) {
if (isset($params['show_title']) === false) {
$show_title = true;
}
if (!isset($params['only_image'])) {
if (isset($params['only_image']) === false) {
$params['only_image'] = false;
}
if (!isset($params['homeurl'])) {
if (isset($params['homeurl']) === false) {
$params['homeurl'] = $config['homeurl'];
}
if (!isset($params['ttl'])) {
if (isset($params['ttl']) === false) {
$params['ttl'] = 1;
}
if (!isset($params['adapt_key'])) {
if (isset($params['adapt_key']) === false) {
$params['adapt_key'] = '';
}
if (!isset($params['compare'])) {
if (isset($params['compare']) === false) {
$params['compare'] = false;
}
if (!isset($params['show_unknown'])) {
if (isset($params['show_unknown']) === false) {
$params['show_unknown'] = false;
}
if (!isset($params['menu'])) {
if (isset($params['menu']) === false) {
$params['menu'] = true;
}
if (!isset($params['show_legend'])) {
if (isset($params['show_legend']) === false) {
$params['show_legend'] = true;
}
if (!isset($params['show_overview'])) {
if (isset($params['show_overview']) === false) {
$params['show_overview'] = true;
}
if (!isset($params['show_export_csv'])) {
if (isset($params['show_export_csv']) === false) {
$params['show_export_csv'] = true;
}
if (!isset($params['backgroundColor'])) {
if (isset($params['backgroundColor']) === false) {
$params['backgroundColor'] = 'white';
}
if (!isset($params['percentil'])) {
if (isset($params['percentil']) === false) {
$params['percentil'] = null;
}
if (!isset($params['dashboard'])) {
if (isset($params['dashboard']) === false) {
$params['dashboard'] = false;
}
if (!isset($params['vconsole']) || $params['vconsole'] == false) {
if (isset($params['vconsole']) === false || $params['vconsole'] == false) {
$params['vconsole'] = false;
} else {
$params['menu'] = false;
}
if (!isset($params['type_graph'])) {
if (isset($params['type_graph']) === false) {
$params['type_graph'] = $config['type_module_charts'];
}
if (!isset($params['fullscale'])) {
if (isset($params['fullscale']) === false) {
$params['fullscale'] = false;
}
if (!isset($params['id_widget_dashboard'])) {
if (isset($params['id_widget_dashboard']) === false) {
$params['id_widget_dashboard'] = false;
}
if (!isset($params['force_interval'])) {
if (isset($params['force_interval']) === false) {
$params['force_interval'] = '';
}
if (!isset($params['time_interval'])) {
if (isset($params['time_interval']) === false) {
$params['time_interval'] = 300;
}
if (!isset($params['array_data_create'])) {
if (isset($params['array_data_create']) === false) {
$params['array_data_create'] = 0;
}
if (!isset($params['return_img_base_64'])) {
if (isset($params['return_img_base_64']) === false) {
$params['return_img_base_64'] = false;
}
if (!isset($params['image_treshold'])) {
if (isset($params['image_treshold']) === false) {
$params['image_treshold'] = false;
}
if (!isset($params['graph_combined'])) {
if (isset($params['graph_combined']) === false) {
$params['graph_combined'] = false;
}
if (!isset($params['zoom'])) {
if (isset($params['zoom']) === false) {
$params['zoom'] = ($config['zoom_graph']) ? $config['zoom_graph'] : 1;
}
if (!isset($params['type_mode_graph'])) {
if (isset($params['type_mode_graph']) === false) {
$params['type_mode_graph'] = $config['type_mode_graph'];
if (isset($params['graph_render']) === true) {
$params['type_mode_graph'] = $params['graph_render'];
}
}
if (!isset($params['projection'])) {
if (isset($params['maximum_y_axis']) === false) {
$params['maximum_y_axis'] = $config['maximum_y_axis'];
}
if (isset($params['projection']) === false) {
$params['projection'] = false;
}
@ -802,7 +807,7 @@ function grafico_modulo_sparse($params, $server_name='')
$params['pdf'] = false;
}
if (!isset($params['agent_module_id'])) {
if (isset($params['agent_module_id']) === false) {
return graph_nodata_image(
$params['width'],
$params['height'],
@ -815,14 +820,12 @@ function grafico_modulo_sparse($params, $server_name='')
$agent_module_id = $params['agent_module_id'];
}
if (!isset($params['stacked'])) {
if (isset($params['stacked']) === false) {
$params['stacked'] = 0;
}
// TODO: Configurable.
$params['grid_color'] = '#C1C1C1';
$params['legend_color'] = '#636363';
$params['font'] = $config['fontpath'];
$params['font_size'] = $config['font_size'];
$params['short_data'] = $config['short_module_graph_data'];
@ -880,14 +883,14 @@ function grafico_modulo_sparse($params, $server_name='')
}
// Format of the graph.
if (empty($params['unit'])) {
if (empty($params['unit']) === true) {
$params['unit'] = $module_data['unit'];
if (modules_is_unit_macro($params['unit'])) {
$params['unit'] = '';
}
}
if (empty($params['divisor'])) {
if (empty($params['divisor']) === true) {
$params['divisor'] = get_data_multiplier($params['unit']);
}
@ -986,7 +989,7 @@ function grafico_modulo_sparse($params, $server_name='')
// Check available data.
if ($params['compare'] === 'separated') {
if (!empty($array_data)) {
if (empty($array_data) === false) {
$return = area_graph(
$agent_module_id,
$array_data,
@ -1011,7 +1014,7 @@ function grafico_modulo_sparse($params, $server_name='')
}
$return .= '<br>';
if (!empty($array_data_prev)) {
if (empty($array_data_prev) === false) {
$series_type_array = series_type_graph_array(
$array_data_prev,
$params
@ -1116,11 +1119,11 @@ function graphic_combined_module(
) {
global $config;
if (!isset($params_combined['from_interface'])) {
if (isset($params_combined['from_interface']) === false) {
$params_combined['from_interface'] = false;
}
if (!isset($params_combined['stacked'])) {
if (isset($params_combined['stacked']) === false) {
if ($params_combined['from_interface']) {
if ($config['type_interface_charts'] == 'line') {
$params_combined['stacked'] = CUSTOM_GRAPH_LINE;
@ -1131,155 +1134,165 @@ function graphic_combined_module(
if ($params_combined['id_graph'] == 0) {
$params_combined['stacked'] = CUSTOM_GRAPH_AREA;
} else {
$params_combined['stacked'] = db_get_row('tgraph', 'id_graph', $params_combined['id_graph']);
$params_combined['stacked'] = db_get_row(
'tgraph',
'id_graph',
$params_combined['id_graph']
);
}
}
}
$params['stacked'] = $params_combined['stacked'];
if (!isset($params_combined['projection']) || $params_combined['projection'] == false) {
if (isset($params_combined['projection']) === false
|| $params_combined['projection'] == false
) {
$params_combined['projection'] = false;
} else {
$params['stacked'] = 'area';
$params['projection'] = true;
}
if (!isset($params_combined['labels'])) {
if (isset($params_combined['labels']) === false) {
$params_combined['labels'] = [];
}
if (!isset($params_combined['summatory'])) {
if (isset($params_combined['summatory']) === false) {
$params_combined['summatory'] = 0;
}
if (!isset($params_combined['average'])) {
if (isset($params_combined['average']) === false) {
$params_combined['average'] = 0;
}
if (!isset($params_combined['modules_series'])) {
if (isset($params_combined['modules_series']) === false) {
$params_combined['modules_series'] = 0;
}
if (!isset($params_combined['return'])) {
if (isset($params_combined['return']) === false) {
$params_combined['return'] = 1;
}
if (!isset($params_combined['id_graph'])) {
if (isset($params_combined['id_graph']) === false) {
$params_combined['id_graph'] = 0;
}
if (!isset($params_combined['type_report'])) {
if (isset($params_combined['type_report']) === false) {
$params_combined['type_report'] = '';
}
if (!isset($params['percentil'])) {
if (isset($params['percentil']) === false) {
$params_combined['percentil'] = null;
} else {
$params_combined['percentil'] = $params['percentil'];
}
if (!isset($params['period'])) {
if (isset($params['period']) === false) {
return false;
}
if (!isset($params['width'])) {
if (isset($params['width']) === false) {
$params['width'] = '90%';
}
if (!isset($params['height'])) {
if (isset($params['height']) === false) {
$params['height'] = 450;
}
if (!isset($params['title'])) {
if (isset($params['title']) === false) {
$params['title'] = '';
}
if (!isset($params['unit_name'])) {
if (isset($params['unit_name']) === false) {
$params['unit_name'] = null;
}
if (!isset($params['show_alerts'])) {
if (isset($params['show_alerts']) === false) {
$params['show_alerts'] = false;
}
if (!isset($params['date']) || !$params['date']) {
if (isset($params['date']) === false || !$params['date']) {
$params['date'] = get_system_time();
}
if (!isset($params['only_image'])) {
if (isset($params['only_image']) === false) {
$params['only_image'] = false;
}
if (!isset($params['ttl'])) {
if (isset($params['ttl']) === false) {
$params['ttl'] = 1;
}
if (!isset($params['backgroundColor'])) {
if (isset($params['backgroundColor']) === false) {
$params['backgroundColor'] = 'white';
}
if (!isset($params['dashboard'])) {
if (isset($params['dashboard']) === false) {
$params['dashboard'] = false;
}
if (!isset($params['menu']) || $params['only_image']) {
if (isset($params['menu']) === false
|| $params['only_image']
) {
$params['menu'] = true;
} else {
$params['menu'] = false;
}
if (!isset($params['vconsole']) || $params['vconsole'] == false) {
if (isset($params['vconsole']) === false
|| $params['vconsole'] == false
) {
$params['vconsole'] = false;
} else {
$params['menu'] = false;
}
if (!isset($params['type_graph'])) {
if (isset($params['type_graph']) === false) {
$params['type_graph'] = $config['type_module_charts'];
}
if (!isset($params['percentil'])) {
if (isset($params['percentil']) === false) {
$params['percentil'] = null;
}
if (!isset($params['fullscale'])) {
if (isset($params['fullscale']) === false) {
$params['fullscale'] = false;
}
if (!isset($params['id_widget_dashboard'])) {
if (isset($params['id_widget_dashboard']) === false) {
$params['id_widget_dashboard'] = false;
}
if (!isset($params['homeurl'])) {
if (isset($params['homeurl']) === false) {
$params['homeurl'] = ui_get_full_url(false, false, false, false);
}
if (!isset($params['show_legend'])) {
if (isset($params['show_legend']) === false) {
$params['show_legend'] = true;
}
if (!isset($params['show_overview'])) {
if (isset($params['show_overview']) === false) {
$params['show_overview'] = true;
}
if (!isset($params['show_export_csv'])) {
if (isset($params['show_export_csv']) === false) {
$params['show_export_csv'] = true;
}
if (!isset($params['return_img_base_64'])) {
if (isset($params['return_img_base_64']) === false) {
$params['return_img_base_64'] = false;
}
if (!isset($params['image_treshold'])) {
if (isset($params['image_treshold']) === false) {
$params['image_treshold'] = false;
}
if (!isset($params['show_unknown'])) {
if (isset($params['show_unknown']) === false) {
$params['show_unknown'] = false;
}
if (!isset($params['type_mode_graph'])) {
if (isset($params['type_mode_graph']) === false) {
$params['type_mode_graph'] = 0;
if (isset($params['graph_render']) === true) {
$params['type_mode_graph'] = $params['graph_render'];
@ -1293,6 +1306,10 @@ function graphic_combined_module(
$params_combined['fullscale'] = $params['fullscale'];
}
if (isset($params['maximum_y_axis']) === false) {
$params['maximum_y_axis'] = $config['maximum_y_axis'];
}
$params['graph_combined'] = true;
$params_combined['graph_combined'] = true;
@ -1305,11 +1322,10 @@ function graphic_combined_module(
);
}
if (!isset($params['zoom'])) {
if (isset($params['zoom']) === false) {
$params['zoom'] = 1;
}
// TODO: Configurable.
$params['grid_color'] = '#C1C1C1';
$params['legend_color'] = '#636363';
@ -1454,23 +1470,23 @@ function graphic_combined_module(
$params_combined['modules_id'] = $modules;
}
if (isset($summatory)) {
if (isset($summatory) === true) {
$params_combined['summatory'] = $summatory;
}
if (isset($average)) {
if (isset($average) === true) {
$params_combined['average'] = $average;
}
if (isset($modules_series)) {
if (isset($modules_series) === true) {
$params_combined['modules_series'] = $modules_series;
}
if (isset($labels)) {
if (isset($labels) === true) {
$params_combined['labels'] = $labels;
}
if (isset($weights)) {
if (isset($weights) === true) {
$params_combined['weight_list'] = $weights;
}
@ -1660,7 +1676,7 @@ function graphic_combined_module(
}
}
if (empty($array_data)) {
if (empty($array_data) === true) {
if ($params_combined['return']) {
return graph_nodata_image($width, $height);
}
@ -4392,7 +4408,7 @@ function fullscale_data(
// Avg count total.
$count_data_total++;
if ($type_mode_graph && !$params['baseline']) {
if (!$params['baseline']) {
// MIN.
// max min.
if ($min_value >= $min_value_max
@ -4460,7 +4476,7 @@ function fullscale_data(
}
}
if ($type_mode_graph && !$params['baseline']) {
if (!$params['baseline']) {
if ((int) $type_mode_graph === 1 || (int) $type_mode_graph === 3) {
$data['min'.$series_suffix]['min'] = $min_value_min;
$data['min'.$series_suffix]['max'] = $min_value_max;

View File

@ -537,8 +537,6 @@ $.fn.VUseTooltip = function() {
var color = item.series.color;
//console.log(item.series.xaxis.ticks[x].label);
/*
"<strong>" +
item.series.label +
@ -1003,6 +1001,7 @@ function pandoraFlotArea(
var update_legend = {};
var force_integer = 0;
var divisor = params.divisor;
var maximum_y_axis = params.maximum_y_axis;
if (typeof divisor === "undefined") {
divisor = 1000;
@ -1896,6 +1895,13 @@ function pandoraFlotArea(
fill_color = "green";
}
if (typeof maximum_y_axis !== "undefined" && maximum_y_axis != 0) {
maximum_y_axis =
parseInt(value.max) > parseInt(maximum_y_axis)
? parseInt(value.max)
: parseInt(maximum_y_axis);
}
switch (series_type[index]) {
case "area":
line_show = true;
@ -2044,6 +2050,10 @@ function pandoraFlotArea(
}
};
if (typeof maximum_y_axis !== "undefined" && maximum_y_axis != 0) {
options.yaxis.max = maximum_y_axis;
}
if (vconsole) {
options.grid["hoverable"] = false;
options.grid["clickable"] = false;