Netflow view

This commit is contained in:
Jose Gonzalez 2023-03-09 00:45:41 +01:00
parent 434aa1dbc3
commit c855061d43
3 changed files with 212 additions and 108 deletions

View File

@ -5231,9 +5231,13 @@ function html_print_switch($attributes=[])
* *
* @return string With HTML code. * @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 = '<form method=post>'; if (empty($formStyle) === false) {
$formStyle = ' style="'.$formStyle.'"';
}
$html = '<form method="POST"'.$formStyle.'>';
switch ($type) { switch ($type) {
case 'image': case 'image':
$html .= html_print_input_image($text, $text, $text, $style, true); $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': case 'text':
default: default:
if (!empty($style)) { if (empty($style) === false) {
$style = ' style="'.$style.'"'; $style = ' style="'.$style.'"';
} }
@ -5249,7 +5253,10 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='')
$text, $text,
$text, $text,
false, false,
'class="button-as-link"'.$style, [
'mode' => 'link',
'style' => $style,
],
true true
); );
break; break;

View File

@ -34,7 +34,24 @@ if (! check_acl($config['id_user'], 0, 'AR')) {
$action = get_parameter('action', 'listeners'); $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()) { if (netflow_print_check_version_error()) {
include $config['homedir'].'/operation/network/network_report.php'; include $config['homedir'].'/operation/network/network_report.php';

View File

@ -62,95 +62,170 @@ $style_period = ($is_period) ? '' : 'display: none;';
// Build the table. // Build the table.
$table = new stdClass(); $table = new stdClass();
$table->class = 'databox filters'; $table->class = 'filter-table-adv';
$table->styleTable = 'width: 100%'; $table->width = '100%';
$table->data['0']['0'] = __('Data to show').'&nbsp;&nbsp;'; $table->data = [];
$table->data['0']['0'] .= html_print_select(
network_get_report_actions(false), $table->data[0][] = html_print_label_input_block(
'action', __('Data to show'),
$action, html_print_select(
'', network_get_report_actions(false),
'', 'action',
0, $action,
true '',
'',
0,
true
)
); );
$table->data['0']['1'] = __('Number of result to show').'&nbsp;&nbsp;'; $table->data[0][] = html_print_label_input_block(
$table->data['0']['1'] .= html_print_select( __('Number of result to show'),
[ html_print_select(
'5' => 5, [
'10' => 10, '5' => 5,
'15' => 15, '10' => 10,
'20' => 20, '15' => 15,
'25' => 25, '20' => 20,
'50' => 50, '25' => 25,
'100' => 100, '50' => 50,
'250' => 250, '100' => 100,
], '250' => 250,
'top', ],
$top, 'top',
'', $top,
'', '',
0, '',
true 0,
true
)
); );
$table->data['0']['2'] = ''; $table->data[1][] = html_print_label_input_block(
__('Start date'),
$table->data['1']['0'] = '<div class="flex">'; html_print_div(
$table->data['1']['0'] .= '<div id="end_date_container" style="'.$style_end.'">'; [
$table->data['1']['0'] .= __('Start date').'&nbsp;&nbsp;'; 'id' => 'end_date_container',
$table->data['1']['0'] .= html_print_input_text('date_lower', $date_lower, '', 10, 7, true); 'content' => html_print_input_text(
$table->data['1']['0'] .= '&nbsp;&nbsp;'; 'date_lower',
$table->data['1']['0'] .= html_print_input_text('time_lower', $time_lower, '', 7, 8, true); $date_lower,
$table->data['1']['0'] .= '</div>'; '',
10,
$table->data['1']['0'] .= '<div id="period_container" style="'.$style_period.'">'; 7,
$table->data['1']['0'] .= __('Time Period').'&nbsp;&nbsp;'; true
$table->data['1']['0'] .= html_print_extended_select_for_time('period', $period, '', '', 0, false, true); ).html_print_input_text(
$table->data['1']['0'] .= '</div>'; 'time_lower',
$table->data['1']['0'] .= html_print_checkbox( $time_lower,
'is_period', '',
1, 7,
($is_period === true) ? 1 : 0, 8,
true, true
false, ),
'network_report_click_period(event)' ],
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)'
).'<label style="position:relative; top:13px">'.__('Defined period').'</label>',
)
); );
$table->data['1']['0'] .= ui_print_help_tip(
__('Select this checkbox to write interval instead a date.'),
true
);
$table->data['1']['0'] .= '</div>';
$table->data['1']['1'] = __('End date').'&nbsp;&nbsp;'; $table->data[1][] = html_print_label_input_block(
$table->data['1']['1'] .= html_print_input_text('date_greater', $date_greater, '', 10, 7, true); __('End date'),
$table->data['1']['1'] .= '&nbsp;&nbsp;'; html_print_div(
$table->data['1']['1'] .= html_print_input_text('time_greater', $time_greater, '', 7, 8, true); [
'id' => '',
$table->data['1']['2'] = html_print_submit_button( 'class' => '',
__('Update'), 'content' => html_print_input_text(
'update', 'date_greater',
false, $date_greater,
'class="sub upd"', '',
true 10,
); 7,
$table->data['1']['2'] .= '&nbsp;&nbsp;'; true
$table->data['1']['2'] .= html_print_submit_button( ).html_print_input_text(
__('Export to CSV'), 'time_greater',
'export_csv', $time_greater,
false, '',
'class="sub next" onclick="blockResumit($(this))"', 7,
true 8,
true
),
],
true
)
); );
echo '<form method="post">'; echo '<form method="post">';
html_print_input_hidden('order_by', $order_by); 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_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,
'<span class="subsection_header_title">'.__('Filters').'</span>',
__('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 '</form>'; echo '</form>';
// Print the data. // Print the data.
@ -178,7 +253,8 @@ $hidden_main_link = [
unset($table); unset($table);
$table = new stdClass(); $table = new stdClass();
$table->styleTable = 'width: 60%'; $table->id = '';
$table->width = '100%';
// Print the header. // Print the header.
$table->head = []; $table->head = [];
$table->head['main'] = __('IP'); $table->head['main'] = __('IP');
@ -252,20 +328,6 @@ if (get_parameter('export_csv')) {
exit; 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. // Print the data and build the chart.
$table->data = []; $table->data = [];
$chart_data = []; $chart_data = [];
@ -277,7 +339,7 @@ foreach ($data as $item) {
$row['main'] .= $item['host']; $row['main'] .= $item['host'];
if (!$hide_filter) { if (!$hide_filter) {
$row['main'] .= html_print_link_with_params( $row['main'] .= html_print_link_with_params(
'images/filter.png', 'images/filters@svg.svg',
array_merge($hidden_main_link, ['main_value' => $item['host']]), array_merge($hidden_main_link, ['main_value' => $item['host']]),
'image' 'image'
); );
@ -316,9 +378,7 @@ foreach ($data as $item) {
if (empty($data)) { if (empty($data)) {
ui_print_info_message(__('No data found')); ui_print_info_message(__('No data found'));
} else { } else {
echo '<div class="flex mrgn_top_10px">'; // Pie graph options.
html_print_table($table);
$options = [ $options = [
'height' => 230, 'height' => 230,
'legend' => [ 'legend' => [
@ -328,15 +388,35 @@ if (empty($data)) {
], ],
'labels' => $labels, 'labels' => $labels,
]; ];
// Pie graph.
// Print the graph. html_print_div(
echo '<div class="mrgn_top_50px w40p">'; [
echo pie_graph( 'class' => 'databox netflow-pie-graph-container padding-2 white_box',
$chart_data, 'content' => pie_graph(
$options $chart_data,
$options
),
]
); );
echo '</div>'; // Print the filter remove link.
echo '</div>'; 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);
} }
?> ?>