From c855061d430de746e9d6ceb0559d2f295b8cb53a Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 9 Mar 2023 00:45:41 +0100 Subject: [PATCH] Netflow view --- pandora_console/include/functions_html.php | 15 +- .../operation/netflow/netflow_explorer.php | 19 +- .../operation/network/network_report.php | 286 +++++++++++------- 3 files changed, 212 insertions(+), 108 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 5d6f413573..71a2d10152 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -5231,9 +5231,13 @@ function html_print_switch($attributes=[]) * * @return string With HTML code. */ -function html_print_link_with_params($text, $params=[], $type='text', $style='') +function html_print_link_with_params($text, $params=[], $type='text', $style='', $formStyle='') { - $html = '
'; + if (empty($formStyle) === false) { + $formStyle = ' style="'.$formStyle.'"'; + } + + $html = ''; switch ($type) { case 'image': $html .= html_print_input_image($text, $text, $text, $style, true); @@ -5241,7 +5245,7 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='') case 'text': default: - if (!empty($style)) { + if (empty($style) === false) { $style = ' style="'.$style.'"'; } @@ -5249,7 +5253,10 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='') $text, $text, false, - 'class="button-as-link"'.$style, + [ + 'mode' => 'link', + 'style' => $style, + ], true ); break; diff --git a/pandora_console/operation/netflow/netflow_explorer.php b/pandora_console/operation/netflow/netflow_explorer.php index e191118855..cb09927178 100644 --- a/pandora_console/operation/netflow/netflow_explorer.php +++ b/pandora_console/operation/netflow/netflow_explorer.php @@ -34,7 +34,24 @@ if (! check_acl($config['id_user'], 0, 'AR')) { $action = get_parameter('action', 'listeners'); -ui_print_page_header(__('Netflow explorer')); +ui_print_standard_header( + __('Netflow explorer'), + '', + false, + '', + false, + [], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Network'), + ], + ] +); if (netflow_print_check_version_error()) { include $config['homedir'].'/operation/network/network_report.php'; diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index bb0800a262..a25ccff67b 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -62,95 +62,170 @@ $style_period = ($is_period) ? '' : 'display: none;'; // Build the table. $table = new stdClass(); -$table->class = 'databox filters'; -$table->styleTable = 'width: 100%'; -$table->data['0']['0'] = __('Data to show').'  '; -$table->data['0']['0'] .= html_print_select( - network_get_report_actions(false), - 'action', - $action, - '', - '', - 0, - true +$table->class = 'filter-table-adv'; +$table->width = '100%'; +$table->data = []; + +$table->data[0][] = html_print_label_input_block( + __('Data to show'), + html_print_select( + network_get_report_actions(false), + 'action', + $action, + '', + '', + 0, + true + ) ); -$table->data['0']['1'] = __('Number of result to show').'  '; -$table->data['0']['1'] .= html_print_select( - [ - '5' => 5, - '10' => 10, - '15' => 15, - '20' => 20, - '25' => 25, - '50' => 50, - '100' => 100, - '250' => 250, - ], - 'top', - $top, - '', - '', - 0, - true +$table->data[0][] = html_print_label_input_block( + __('Number of result to show'), + html_print_select( + [ + '5' => 5, + '10' => 10, + '15' => 15, + '20' => 20, + '25' => 25, + '50' => 50, + '100' => 100, + '250' => 250, + ], + 'top', + $top, + '', + '', + 0, + true + ) ); -$table->data['0']['2'] = ''; - -$table->data['1']['0'] = '
'; -$table->data['1']['0'] .= '
'; -$table->data['1']['0'] .= __('Start date').'  '; -$table->data['1']['0'] .= html_print_input_text('date_lower', $date_lower, '', 10, 7, true); -$table->data['1']['0'] .= '  '; -$table->data['1']['0'] .= html_print_input_text('time_lower', $time_lower, '', 7, 8, true); -$table->data['1']['0'] .= '
'; - -$table->data['1']['0'] .= '
'; -$table->data['1']['0'] .= __('Time Period').'  '; -$table->data['1']['0'] .= html_print_extended_select_for_time('period', $period, '', '', 0, false, true); -$table->data['1']['0'] .= '
'; -$table->data['1']['0'] .= html_print_checkbox( - 'is_period', - 1, - ($is_period === true) ? 1 : 0, - true, - false, - 'network_report_click_period(event)' +$table->data[1][] = html_print_label_input_block( + __('Start date'), + html_print_div( + [ + 'id' => 'end_date_container', + 'content' => html_print_input_text( + 'date_lower', + $date_lower, + '', + 10, + 7, + true + ).html_print_input_text( + 'time_lower', + $time_lower, + '', + 7, + 8, + true + ), + ], + true + ).html_print_div( + [ + 'id' => 'period_container', + 'style' => 'display: none;', + 'content' => html_print_label_input_block( + '', + html_print_extended_select_for_time( + 'period', + $period, + '', + '', + 0, + false, + true + ), + ), + ], + true + ).html_print_label_input_block( + '', + html_print_checkbox_switch( + 'is_period', + 1, + ($is_period === true) ? 1 : 0, + true, + false, + 'network_report_click_period(event)' + ).'', + ) ); -$table->data['1']['0'] .= ui_print_help_tip( - __('Select this checkbox to write interval instead a date.'), - true -); -$table->data['1']['0'] .= '
'; -$table->data['1']['1'] = __('End date').'  '; -$table->data['1']['1'] .= html_print_input_text('date_greater', $date_greater, '', 10, 7, true); -$table->data['1']['1'] .= '  '; -$table->data['1']['1'] .= html_print_input_text('time_greater', $time_greater, '', 7, 8, true); - -$table->data['1']['2'] = html_print_submit_button( - __('Update'), - 'update', - false, - 'class="sub upd"', - true -); -$table->data['1']['2'] .= '  '; -$table->data['1']['2'] .= html_print_submit_button( - __('Export to CSV'), - 'export_csv', - false, - 'class="sub next" onclick="blockResumit($(this))"', - true +$table->data[1][] = html_print_label_input_block( + __('End date'), + html_print_div( + [ + 'id' => '', + 'class' => '', + 'content' => html_print_input_text( + 'date_greater', + $date_greater, + '', + 10, + 7, + true + ).html_print_input_text( + 'time_greater', + $time_greater, + '', + 7, + 8, + true + ), + ], + true + ) ); echo ''; html_print_input_hidden('order_by', $order_by); -if (!empty($main_value)) { +if (empty($main_value) === false) { html_print_input_hidden('main_value', $main_value); } -html_print_table($table); +$outputTable = html_print_table($table, true); +$outputTable .= html_print_div( + [ + 'class' => 'action-buttons-right-forced', + 'content' => html_print_submit_button( + __('Filter'), + 'update', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], + true + ), + ], + true +); +ui_toggle( + $outputTable, + ''.__('Filters').'', + __('Filters'), + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' +); +html_print_action_buttons( + html_print_submit_button( + __('Export to CSV'), + 'export_csv', + false, + [ + 'icon' => 'load', + 'onclick' => 'blockResumit($(this))', + ], + true + ) +); echo '
'; // Print the data. @@ -178,7 +253,8 @@ $hidden_main_link = [ unset($table); $table = new stdClass(); -$table->styleTable = 'width: 60%'; +$table->id = ''; +$table->width = '100%'; // Print the header. $table->head = []; $table->head['main'] = __('IP'); @@ -252,20 +328,6 @@ if (get_parameter('export_csv')) { exit; } -// Print the filter remove link. -if (!empty($main_value)) { - echo html_print_link_with_params( - in_array($action, ['udp', 'tcp']) ? __('Filtered by port %s. Click here to remove the filter.', $main_value) : __('Filtered by IP %s. Click here to remove the filter.', $main_value), - array_merge( - $hidden_main_link, - [ - 'main_value' => $main_value, - 'remove_filter' => 1, - ] - ) - ); -} - // Print the data and build the chart. $table->data = []; $chart_data = []; @@ -277,7 +339,7 @@ foreach ($data as $item) { $row['main'] .= $item['host']; if (!$hide_filter) { $row['main'] .= html_print_link_with_params( - 'images/filter.png', + 'images/filters@svg.svg', array_merge($hidden_main_link, ['main_value' => $item['host']]), 'image' ); @@ -316,9 +378,7 @@ foreach ($data as $item) { if (empty($data)) { ui_print_info_message(__('No data found')); } else { - echo '
'; - html_print_table($table); - + // Pie graph options. $options = [ 'height' => 230, 'legend' => [ @@ -328,15 +388,35 @@ if (empty($data)) { ], 'labels' => $labels, ]; - - // Print the graph. - echo '
'; - echo pie_graph( - $chart_data, - $options + // Pie graph. + html_print_div( + [ + 'class' => 'databox netflow-pie-graph-container padding-2 white_box', + 'content' => pie_graph( + $chart_data, + $options + ), + ] ); - echo '
'; - echo '
'; + // Print the filter remove link. + if (empty($main_value) === false) { + echo html_print_link_with_params( + in_array($action, ['udp', 'tcp']) ? __('Filtered by port %s. Click here to remove the filter.', $main_value) : __('Filtered by IP %s. Click here to remove the filter.', $main_value), + array_merge( + $hidden_main_link, + [ + 'main_value' => $main_value, + 'remove_filter' => 1, + ] + ), + 'text', + '', + 'width: 100%; display: flex; justify-content: center;' + ); + } + + // Print results. + html_print_table($table); } ?>