Fixed missed buttons, improve code and added go back button when create-update
This commit is contained in:
parent
5040b4b265
commit
08c945d91d
|
@ -73,7 +73,7 @@ if (! check_acl($config['id_user'], 0, 'RW')
|
|||
exit;
|
||||
}
|
||||
|
||||
if ($edit_graph) {
|
||||
if ($edit_graph === true) {
|
||||
$graphInTgraph = db_get_row_sql(
|
||||
'SELECT * FROM tgraph WHERE id_graph = '.$id_graph
|
||||
);
|
||||
|
@ -113,18 +113,18 @@ if ($edit_graph) {
|
|||
// -----------------------
|
||||
// CREATE/EDIT GRAPH FORM
|
||||
// -----------------------
|
||||
$url = 'index.php?sec=reporting&sec2=godmode/reporting/graph_builder';
|
||||
if ($edit_graph) {
|
||||
$output = "<form method='post' action='".$url.'&edit_graph=1&update_graph=1&id='.$id_graph."'>";
|
||||
$url = 'index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1';
|
||||
if ($edit_graph === true) {
|
||||
$output = "<form method='post' action='".$url.'&update_graph=1&id='.$id_graph."'>";
|
||||
} else {
|
||||
$output = "<form method='post' action='".$url."&edit_graph=1&add_graph=1'>";
|
||||
$output = "<form method='post' action='".$url."&add_graph=1'>";
|
||||
}
|
||||
|
||||
$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) {
|
||||
if ($edit_graph === true) {
|
||||
$output .= "value='".$graphInTgraph['name']."' ";
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ $output .= '</td></tr>';
|
|||
$output .= '<tr>';
|
||||
$output .= "<td class='datos2'><b>".__('Description').'</b></td>';
|
||||
$output .= "<td class='datos2' colspan=3><textarea name='description' class='height_45px' cols=55 rows=2>";
|
||||
if ($edit_graph) {
|
||||
if ($edit_graph === true) {
|
||||
$output .= $graphInTgraph['description'];
|
||||
}
|
||||
|
||||
|
@ -291,15 +291,30 @@ $output .= '</tr>';
|
|||
|
||||
$output .= '</table>';
|
||||
|
||||
if ($edit_graph) {
|
||||
$output .= "<div class='w100p'>";
|
||||
$output .= "<input type=submit name='store' class='sub upd right' value='".__('Update')."'>";
|
||||
$output .= '</div>';
|
||||
} else {
|
||||
$output .= "<div class='w100p'>";
|
||||
$output .= "<input type=submit name='store' class='sub next right' value='".__('Create')."'>";
|
||||
$output .= '</div>';
|
||||
}
|
||||
$stringButton = ($edit_graph === true) ? __('Update') : __('Create');
|
||||
|
||||
$output .= html_print_div(
|
||||
[
|
||||
'class' => 'w100p',
|
||||
'content' => "<input type=submit name='store' class='sub next right databox' value='".$stringButton."'>",
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$output .= html_print_div(
|
||||
[
|
||||
'class' => 'w100p',
|
||||
'content' => html_print_button(
|
||||
__('Go back'),
|
||||
'go_back',
|
||||
false,
|
||||
'window.location.href = \'index.php?sec=reporting&sec2=godmode/reporting/graphs\'',
|
||||
'class="sub cancel right"',
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$output .= '</form>';
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ if ($id_graph !== 0) {
|
|||
}
|
||||
|
||||
|
||||
if ($add_graph) {
|
||||
if ($add_graph === true) {
|
||||
$name = get_parameter_post('name');
|
||||
$description = get_parameter_post('description');
|
||||
$module_number = get_parameter_post('module_number');
|
||||
|
@ -178,7 +178,7 @@ if ($update_graph) {
|
|||
$stacked = $threshold;
|
||||
}
|
||||
|
||||
if (trim($name) != '') {
|
||||
if (empty(trim($name)) === false) {
|
||||
$success = db_process_sql_update(
|
||||
'tgraph',
|
||||
[
|
||||
|
@ -220,7 +220,7 @@ function add_quotes($item)
|
|||
}
|
||||
|
||||
|
||||
if ($add_module) {
|
||||
if ($add_module === true) {
|
||||
$id_graph = get_parameter('id');
|
||||
$id_modules = get_parameter('module');
|
||||
$id_agents = get_parameter('id_agents');
|
||||
|
@ -251,7 +251,7 @@ if ($add_module) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($delete_module) {
|
||||
if ($delete_module === true) {
|
||||
$id_graph = get_parameter('id');
|
||||
|
||||
$deleteGraph = get_parameter('delete');
|
||||
|
@ -260,7 +260,7 @@ if ($delete_module) {
|
|||
db_process_sql('UPDATE tgraph_source SET field_order=field_order-1 WHERE id_graph='.$id_graph.' AND field_order>'.$order_val);
|
||||
}
|
||||
|
||||
if ($change_weight) {
|
||||
if ($change_weight === true) {
|
||||
$weight = get_parameter('weight');
|
||||
$id_gs = get_parameter('graph');
|
||||
db_process_sql_update(
|
||||
|
@ -280,7 +280,7 @@ if ($change_label) {
|
|||
);
|
||||
}
|
||||
|
||||
if ($edit_graph) {
|
||||
if ($edit_graph === true) {
|
||||
$buttons = [
|
||||
'graph_list' => [
|
||||
'active' => false,
|
||||
|
@ -334,7 +334,7 @@ if ($edit_graph) {
|
|||
$graphInTgraph = db_get_row_sql('SELECT name FROM tgraph WHERE id_graph = '.$id_graph);
|
||||
$name = $graphInTgraph['name'];
|
||||
} else {
|
||||
$buttons = '';
|
||||
$buttons = [];
|
||||
}
|
||||
|
||||
$head = __('Graph builder');
|
||||
|
@ -363,7 +363,7 @@ ui_print_standard_header(
|
|||
false,
|
||||
$headerHelp,
|
||||
false,
|
||||
[$buttons],
|
||||
$buttons,
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
|
@ -410,12 +410,12 @@ if ($delete_module) {
|
|||
|
||||
// Parse CHUNK information into showable information.
|
||||
// Split id to get all parameters.
|
||||
if (!$delete_module) {
|
||||
if (isset($_POST['period'])) {
|
||||
if ($delete_module === false) {
|
||||
if (isset($_POST['period']) === true) {
|
||||
$period = $_POST['period'];
|
||||
}
|
||||
|
||||
if ((isset($chunkdata) ) && ($chunkdata != '')) {
|
||||
if ((isset($chunkdata) === true) && (empty($chunkdata) === false)) {
|
||||
$module_array = [];
|
||||
$weight_array = [];
|
||||
$agent_array = [];
|
||||
|
|
|
@ -1,17 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Graph viewer.
|
||||
*
|
||||
* @category Reporting
|
||||
* @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.
|
||||
// Login check
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
@ -231,14 +246,24 @@ if ($view_graph) {
|
|||
];
|
||||
}
|
||||
|
||||
// Header
|
||||
ui_print_page_header(
|
||||
// Header.
|
||||
ui_print_standard_header(
|
||||
$graph['name'],
|
||||
'images/chart.png',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
$options
|
||||
$options,
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Reporting'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Custom graphs'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$width = null;
|
||||
|
|
Loading…
Reference in New Issue