From dd1b58b83a888af256c005e11786226901135785 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 2 Mar 2023 14:35:01 +0100 Subject: [PATCH] Reporting Custom Graphs change visual --- .../general/first_task/custom_graphs.php | 15 +- .../godmode/reporting/graph_builder.main.php | 240 ++++----- pandora_console/godmode/reporting/graphs.php | 466 +++++++++++------- .../godmode/reporting/reporting_builder.php | 2 +- .../godmode/snmpconsole/snmp_filters.php | 6 +- .../snmpconsole/snmp_trap_generator.php | 2 +- 6 files changed, 426 insertions(+), 305 deletions(-) diff --git a/pandora_console/general/first_task/custom_graphs.php b/pandora_console/general/first_task/custom_graphs.php index 9429218133..96f4c1262b 100644 --- a/pandora_console/general/first_task/custom_graphs.php +++ b/pandora_console/general/first_task/custom_graphs.php @@ -15,9 +15,6 @@ global $config; check_login(); ui_require_css_file('first_task'); ?> - true, 'message' => __('There are no custom graphs defined yet.') ]); -?>
@@ -36,7 +33,17 @@ ui_print_info_message(['no_close' => true, 'message' => __('There are no custom ?>

- + 'wand'], + true + ) + ); + ?>
\ No newline at end of file diff --git a/pandora_console/godmode/reporting/graph_builder.main.php b/pandora_console/godmode/reporting/graph_builder.main.php index 92120e154f..bd2996da3c 100644 --- a/pandora_console/godmode/reporting/graph_builder.main.php +++ b/pandora_console/godmode/reporting/graph_builder.main.php @@ -115,20 +115,18 @@ if ($edit_graph === true) { // ----------------------- $url = 'index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1'; if ($edit_graph === true) { - $output = "
"; + $output = ""; } else { - $output = ""; + $output = ""; } -$output .= ""; -$output .= ''; -$output .= "'; -$output .= "'; $own_info = get_user_info($config['id_user']); @@ -140,9 +138,9 @@ if (users_can_manage_group_all('RW') === false $return_all_group = false; } -$output .= ''; -$output .= ''; -$output .= "'; -$output .= "'; -if ($stacked == CUSTOM_GRAPH_GAUGE) { - $hidden = ' class="invisible" '; -} else { - $hidden = ''; -} - -$output .= ''; -$output .= "'; -$output .= "'; +$output .= ''; -$output .= "'; +$output .= ''; +$output .= "'; - -$output .= ''; -$output .= "'; -$output .= "'; -$output .= "'; -$output .= "'; +$output .= "'; + +$output .= ''; $output .= ''; -$output .= "'; -$output .= "'; -$output .= "'; -$output .= "'; -$output .= "'; -$output .= "'; -$output .= "'; $output .= ''; - +$output .= ''; $output .= '
".__('Name').' 'width:50%']); +$output .= ''.__('Group').''; +$output .= ''; if (check_acl($config['id_user'], 0, 'RW')) { - $output .= html_print_input( + $inputGroup = html_print_input( [ 'type' => 'select_groups', 'id_user' => $config['id_user'], @@ -158,7 +156,7 @@ if (check_acl($config['id_user'], 0, 'RW')) { ] ); } else if (check_acl($config['id_user'], 0, 'RM')) { - $output .= html_print_input( + $inputGroup = html_print_input( [ 'type' => 'select_groups', 'id_user' => $config['id_user'], @@ -175,38 +173,34 @@ if (check_acl($config['id_user'], 0, 'RW')) { ); } +$output .= html_print_label_input_block(__('Group'), $inputGroup); $output .= '
".__('Description').''; -$output .= '
"; -$output .= ''.__('Period').'"; -$output .= html_print_extended_select_for_time( - 'period', - $period, - '', - '', - '0', - 10, - true +$output .= '
'; +$graphInTgraph['description'] = (isset($graphInTgraph['description']) === true) ? $graphInTgraph['description'] : ''; +$output .= html_print_label_input_block( + __('Description'), + html_print_textarea('description', 10, 5, $graphInTgraph['description'], '', true) ); -$output .= ""; -$output .= ''.__('Type of graph').'
"; +$output .= '
"; +$output .= html_print_label_input_block( + __('Period'), + html_print_extended_select_for_time( + 'period', + $period, + '', + '', + '0', + false, + true, + false, + false, + 'w100p' + ) +); +$output .= ""; require_once $config['homedir'].'/include/functions_graph.php'; @@ -221,90 +215,116 @@ $stackeds = [ CUSTOM_GRAPH_VBARS => __('Vertical bars'), CUSTOM_GRAPH_PIE => __('Pie'), ]; -$output .= html_print_select($stackeds, 'stacked', $stacked, '', '', 0, true); - -$output .= '
"; -$output .= __('Equalize maximum thresholds'); -$output .= '"; -$output .= html_print_checkbox( - 'threshold', - CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, - $check, - true, - false, - '', - false +$output .= html_print_label_input_block( + __('Type of graph'), + html_print_select( + $stackeds, + 'stacked', + $stacked, + '', + '', + 0, + true + ) ); $output .= '
"; -$output .= __('Percentil'); -$output .= '"; -$output .= html_print_checkbox( - 'percentil', - 1, - $percentil, - true +$output .= '
"; +$output .= html_print_label_input_block( + __('Equalize maximum thresholds'), + html_print_checkbox( + 'threshold', + CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, + $check, + true, + false, + '', + false + ) +); +$output .= ''; +$output .= html_print_label_input_block( + __('Percentil'), + html_print_checkbox( + 'percentil', + 1, + $percentil, + true + ) ); $output .= '
"; -$output .= __('Add summatory series'); -$output .= '"; -$output .= html_print_checkbox( - 'summatory_series', - 1, - $summatory_series, - true +$output .= '
'; +$output .= html_print_label_input_block( + __('Add summatory series'), + html_print_checkbox( + 'summatory_series', + 1, + $summatory_series, + true + ) ); -$output .= ""; -$output .= __('Add average series'); -$output .= '"; -$output .= html_print_checkbox( - 'average_series', - 1, - $average_series, - true +$output .= ""; +$output .= html_print_label_input_block( + __('Add average series'), + html_print_checkbox( + 'average_series', + 1, + $average_series, + true + ) ); $output .= '
"; -$output .= __('Modules and series'); -$output .= '"; -$output .= html_print_checkbox('modules_series', 1, $modules_series, true); +$output .= '
'; +$output .= html_print_label_input_block( + __('Modules and series'), + html_print_checkbox('modules_series', 1, $modules_series, true) +); $output .= '"; -$output .= __('Show full scale graph (TIP)'); -$output .= '"; -$output .= html_print_checkbox('fullscale', 1, $fullscale, true); +$output .= ""; +$output .= html_print_label_input_block( + __('Show full scale graph (TIP)'), + html_print_checkbox('fullscale', 1, $fullscale, true) +); $output .= '
'; +$labelButton = ($edit_graph === true) ? __('Update') : __('Create'); + +$ActionButtons[] = html_print_submit_button( + $labelButton, + 'store', + false, + [ + 'class' => 'sub ok submitButton', + 'icon' => 'next', + ], + true +); + +$ActionButtons[] = html_print_button( + __('Go back'), + 'back', + false, + "window.location.href = 'index.php?sec=reporting&sec2=godmode/reporting/graphs'", + [ + 'class' => 'sub ok submitButton', + 'icon' => 'back', + 'mode' => 'secondary', + ], + true +); + $output .= html_print_div( [ 'class' => 'action-buttons', - 'content' => html_print_submit_button( - ($edit_graph === true) ? __('Update') : __('Create'), - 'store', - false, - [ 'icon' => 'next' ], - true - ).html_print_go_back_button( - 'index.php?sec=reporting&sec2=godmode/reporting/graphs', - [], - true - ), + 'content' => html_print_action_buttons(implode('', $ActionButtons), ['type' => 'form_action'], true), ], true ); diff --git a/pandora_console/godmode/reporting/graphs.php b/pandora_console/godmode/reporting/graphs.php index b5c3524d93..302bb0c80f 100644 --- a/pandora_console/godmode/reporting/graphs.php +++ b/pandora_console/godmode/reporting/graphs.php @@ -222,218 +222,310 @@ $graphs = custom_graphs_get_user($config['id_user'], false, true, $access); $offset = (int) get_parameter('offset'); $table_aux = new stdClass(); - $table_aux->width = '100%'; - $table_aux->class = 'databox filters'; - $table_aux->cellpadding = 0; - $table_aux->cellspacing = 0; +$table_aux->width = '100%'; +if (is_metaconsole() === true) { + $table_aux->class = 'databox filters'; + $table_aux->cellpadding = 0; + $table_aux->cellspacing = 0; + $table_aux->colspan[0][0] = 4; + $table_aux->data[0][0] = ''.__('Group').''; + $table_aux->data[0][1] = html_print_select_groups(false, $access, true, 'id_group', $id_group, '', '', '', true, false, true, '', false, '', false, false, 'id_grupo', $strict_user).'
'; + $table_aux->data[0][2] = ''.__('Free text for search: ').ui_print_help_tip( + __('Search by report name or description, list matches.'), + true + ).''; + $table_aux->data[0][3] = html_print_input_text('search', $search, '', 30, '', true); + $table_aux->data[0][6] = html_print_submit_button(__('Search'), 'search_submit', false, 'class="sub upd"', true); + $filter = ""; + $filter .= html_print_table($table_aux, true); + $filter .= '
'; + ui_toggle($filter, __('Show Option')); +} else { + $table_aux->class = 'filter-table-adv'; + $table_aux->size[0] = '50%'; - $table_aux->colspan[0][0] = 4; - $table_aux->data[0][0] = ''.__('Group').''; + $table_aux->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + $access, + true, + 'id_group', + $id_group, + '', + '', + '', + true, + false, + true, + '', + false, + '', + false, + false, + 'id_grupo', + $strict_user + ) + ); + $table_aux->data[0][1] = html_print_label_input_block( + __('Free text for search: ').ui_print_help_tip(__('Search by report name or description, list matches.'), true), + html_print_input_text('search', $search, '', 30, '', true) + ); - $table_aux->data[0][1] = html_print_select_groups(false, $access, true, 'id_group', $id_group, '', '', '', true, false, true, '', false, '', false, false, 'id_grupo', $strict_user).'
'; + $searchForm .= '
'; + $searchForm .= html_print_table($table_aux, true); - $table_aux->data[0][2] = ''.__('Free text for search: ').ui_print_help_tip( - __('Search by report name or description, list matches.'), - true - ).''; - $table_aux->data[0][3] = html_print_input_text('search', $search, '', 30, '', true); + $searchForm .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Filter'), + 'search_submit', + false, + [ + 'mode' => 'mini', + 'icon' => 'search', + ], + true + ), + ], + true + ); + $searchForm .= '
'; - $table_aux->data[0][6] = html_print_submit_button(__('Search'), 'search_submit', false, 'class="sub upd"', true); + ui_toggle( + $searchForm, + ''.__('Filters').'', + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' + ); +} - if (is_metaconsole()) { - $filter = "
"; - $filter .= html_print_table($table_aux, true); - $filter .= '
'; - ui_toggle($filter, __('Show Option')); - } else { - echo "
"; - html_print_table($table_aux); +// Show only selected groups. +if ($id_group > 0) { + $group = ["$id_group" => $id_group]; +} else { + $group = false; +} + +$own_info = get_user_info($config['id_user']); +if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM')) { + $return_all_group = true; +} else { + $return_all_group = false; +} + +if ($search != '') { + $filter = [ + 'name' => $search_name, + 'order' => 'name', + ]; +} else { + $filter = ['order' => 'name']; +} + +// Fix : group filter was not working +// Show only selected groups. +if ($id_group > 0) { + $group = ["$id_group" => $id_group]; + $filter['id_group'] = $id_group; +} else { + $group = false; +} + +// Filter normal and metaconsole reports. +if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { + $filter['metaconsole'] = 1; +} else { + $filter['metaconsole'] = 0; +} + +if ($id_group != null || $search != null) { + $graphs = custom_graphs_search($id_group, $search); +} + +if (!empty($graphs)) { + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'info_table'; + $table->cellpadding = 0; + $table->cellspacing = 0; + $table->align = []; + $table->head = []; + + $table->head[0] = __('Graph name'); + $table->head[1] = __('Description'); + $table->head[2] = __('Number of Graphs'); + $table->head[3] = __('Group'); + $table->size[0] = '30%'; + $table->size[2] = '200px'; + $table->size[3] = '200px'; + $table->align[2] = 'left'; + $table->align[3] = 'left'; + $op_column = false; + if ($report_w || $report_m) { + $op_column = true; + $table->align[4] = 'left'; + $table->head[4] = __('Op.'); + $table->size[4] = '90px'; + } + + if ($report_w || $report_m) { + $table->align[5] = 'left'; + $table->head[5] = html_print_checkbox('all_delete', 0, false, true, false); + $table->size[5] = '20px'; + } + + $table->data = []; + + $result_graphs = array_slice($graphs, $offset, $config['block_size']); + + foreach ($result_graphs as $graph) { + $data = []; + + $data[0] = ''.ui_print_truncate_text( + $graph['name'], + 70 + ).''; + + $data[1] = ui_print_truncate_text($graph['description'], 70); + + $data[2] = $graph['graphs_count']; + $data[3] = ui_print_group_icon($graph['id_group'], true); + + $data[4] = ''; + $table->cellclass[][4] = 'table_action_buttons'; + if (($report_w || $report_m)) { + $data[4] = ''.html_print_image( + 'images/edit.svg', + true, + ['class' => 'invert_filter main_menu_icon'] + ).''; + } + + $data[5] = ''; + if (check_acl_restricted_all($config['id_user'], $graph['id_group'], 'RM')) { + $data[4] .= ''.html_print_image( + 'images/delete.svg', + true, + [ + 'alt' => __('Delete'), + 'title' => __('Delete'), + 'class' => 'invert_filter main_menu_icon', + ] + ).''; + + $data[5] .= html_print_checkbox_extended( + 'delete_multiple[]', + $graph['id_graph'], + false, + false, + '', + [ + 'class' => 'check_delete mrgn_lft_2px check_delete', + 'form' => 'form_delete', + 'data-value' => $graph['id_graph'], + ], + true + ); + } + + array_push($table->data, $data); + } + + if (is_metaconsole() === true) { + if (!empty($result_graphs)) { + echo ""; + html_print_input_hidden('multiple_delete', 1); + html_print_table($table); + ui_pagination(count($graphs), false, 0, 0, false, 'offset', true, 'pagination-bottom'); + echo "
"; + html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); echo ''; } - // Show only selected groups. - if ($id_group > 0) { - $group = ["$id_group" => $id_group]; - } else { - $group = false; + + echo "
"; + if ($report_w || $report_m) { + echo '
'; + html_print_submit_button(__('Create graph'), 'create', false, 'class="sub next mrgn_right_5px"'); + echo '
'; + } + } else { + if ($report_w || $report_m) { + $ActionButtons[] = '
'; + $ActionButtons[] = html_print_submit_button( + __('Create graph'), + 'create', + false, + [ + 'class' => 'sub ok', + 'icon' => 'next', + ], + true + ); + $ActionButtons[] = '
'; } - $own_info = get_user_info($config['id_user']); - if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM')) { - $return_all_group = true; - } else { - $return_all_group = false; + if (!empty($result_graphs)) { + $ActionButtons[] = "
"; + $ActionButtons[] = html_print_input_hidden('multiple_delete', 1, true); + $ActionButtons[] = html_print_submit_button( + __('Delete'), + 'delete_btn', + false, + [ + 'class' => 'secondary', + 'icon' => 'delete', + ], + true + ); + $ActionButtons[] = '
'; } - if ($search != '') { - $filter = [ - 'name' => $search_name, - 'order' => 'name', - ]; - } else { - $filter = ['order' => 'name']; - } + // FALTA METER EL PRINT TABLE. + html_print_table($table); + html_print_action_buttons( + implode('', $ActionButtons), + ['type' => 'form_action'] + ); + } - // Fix : group filter was not working - // Show only selected groups. - if ($id_group > 0) { - $group = ["$id_group" => $id_group]; - $filter['id_group'] = $id_group; - } else { - $group = false; - } + echo '
'; - // Filter normal and metaconsole reports. - if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { - $filter['metaconsole'] = 1; - } else { - $filter['metaconsole'] = 0; - } + echo '
'; +} else { + include_once $config['homedir'].'/general/first_task/custom_graphs.php'; +} - if ($id_group != null || $search != null) { - $graphs = custom_graphs_search($id_group, $search); - } - - ui_pagination(count($graphs)); - - if (!empty($graphs)) { - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'info_table'; - $table->cellpadding = 0; - $table->cellspacing = 0; - $table->align = []; - $table->head = []; - - $table->head[0] = __('Graph name'); - $table->head[1] = __('Description'); - $table->head[2] = __('Number of Graphs'); - $table->head[3] = __('Group'); - $table->size[0] = '30%'; - $table->size[2] = '200px'; - $table->size[3] = '200px'; - $table->align[2] = 'left'; - $table->align[3] = 'left'; - $op_column = false; - if ($report_w || $report_m) { - $op_column = true; - $table->align[4] = 'left'; - $table->head[4] = __('Op.'); - $table->size[4] = '90px'; - } - - if ($report_w || $report_m) { - $table->align[5] = 'left'; - $table->head[5] = html_print_checkbox('all_delete', 0, false, true, false); - $table->size[5] = '20px'; - } - - $table->data = []; - - $result_graphs = array_slice($graphs, $offset, $config['block_size']); - - foreach ($result_graphs as $graph) { - $data = []; - - $data[0] = ''.ui_print_truncate_text( - $graph['name'], - 70 - ).''; - - $data[1] = ui_print_truncate_text($graph['description'], 70); - - $data[2] = $graph['graphs_count']; - $data[3] = ui_print_group_icon($graph['id_group'], true); - - $data[4] = ''; - $table->cellclass[][4] = 'table_action_buttons'; - if (($report_w || $report_m)) { - $data[4] = ''.html_print_image( - 'images/config.png', - true, - ['class' => 'invert_filter'] - ).''; - } - - $data[5] = ''; - if (check_acl_restricted_all($config['id_user'], $graph['id_group'], 'RM')) { - $data[4] .= ''.html_print_image( - 'images/cross.png', - true, - [ - 'alt' => __('Delete'), - 'title' => __('Delete'), - 'class' => 'invert_filter', - ] - ).''; - - $data[5] .= html_print_checkbox_extended( - 'delete_multiple[]', - $graph['id_graph'], - false, - false, - '', - 'class="check_delete mrgn_lft_2px"', - true - ); - } - - array_push($table->data, $data); - } - - - if (!empty($result_graphs)) { - echo "
"; - html_print_input_hidden('multiple_delete', 1); - html_print_table($table); - ui_pagination(count($graphs), false, 0, 0, false, 'offset', true, 'pagination-bottom'); - echo "
"; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo ''; - } - - - echo "
"; - if ($report_w || $report_m) { - echo '
'; - html_print_submit_button(__('Create graph'), 'create', false, 'class="sub next mrgn_right_5px"'); - echo '
'; - } - - echo '
'; - - echo '
'; - } else { - include_once $config['homedir'].'/general/first_task/custom_graphs.php'; - } - - ?> +?>