diff --git a/pandora_console/extras/mr/66.sql b/pandora_console/extras/mr/66.sql index 14bb14ecfe..808d914c44 100644 --- a/pandora_console/extras/mr/66.sql +++ b/pandora_console/extras/mr/66.sql @@ -365,4 +365,7 @@ ALTER TABLE tagente_modulo ADD COLUMN `last_compact` TIMESTAMP NOT NULL DEFAULT UPDATE `tevent_alert` ea INNER JOIN `tevent_rule` er ON ea.id = er.id_event_alert SET disabled=1 WHERE er.log_agent IS NOT NULL OR er.log_content IS NOT NULL OR er.log_source IS NOT NULL; +ALTER TABLE `tnetwork_explorer_filter` +MODIFY COLUMN `id` INT NOT NULL AUTO_INCREMENT; + COMMIT; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 5481152ac6..888531e915 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -5409,7 +5409,7 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='', $formStyle = ' style="'.$formStyle.'"'; } - $html = '
'; + $html = ''; switch ($type) { case 'image': $html .= html_print_input_image($text, $text, $text, $style, true); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 26df195090..63179618b1 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -1292,6 +1292,11 @@ p.center { margin: 0 5px; } +.loading-text { + font-size: 19px; + text-align: center; +} + /* Legacy spinner */ #loading { position: fixed; diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 6c3318685a..19cf892cb2 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -87,7 +87,7 @@ if (is_ajax() === true) { $filter_id = (int) get_parameter('filter_id', 0); $filter['id_name'] = get_parameter('new_filter_name', ''); $filter['id_group'] = (int) get_parameter('assign_group', 0); -$filter['aggregate'] = get_parameter('aggregate', ''); +$filter['aggregate'] = get_parameter('aggregate', 'dstip'); $filter['ip_dst'] = get_parameter('ip_dst', ''); $filter['ip_src'] = get_parameter('ip_src', ''); $filter['dst_port'] = get_parameter('dst_port', ''); @@ -169,7 +169,8 @@ if ($custom_date === '1') { $date_from = strtotime($date_init); $date_to = strtotime($date_end); // Read buttons. -$draw = get_parameter('draw_button', ''); +// Change default value for not autoload default filter when load view. +$draw = get_parameter('draw_button', 1); $save = get_parameter('save_button', ''); $update = get_parameter('update_button', ''); @@ -663,6 +664,7 @@ if (empty($draw) === false) { // Draw the netflow chart. html_print_div( [ + 'id' => 'container_netflow', 'class' => $netflowContainerClass, 'content' => netflow_draw_item( $date_from, @@ -677,6 +679,22 @@ if (empty($draw) === false) { ), ] ); + $spinner = html_print_div( + [ + 'content' => '', + 'class' => 'spinner-fixed inherit', + 'style' => 'position: initial;', + ], + true + ); + html_print_div( + [ + 'id' => 'spinner', + 'content' => '

'.__('Loading netflow data, please wait...').'

'.$spinner, + 'class' => 'invisible', + 'style' => 'position: initial;', + ] + ); } } else { ui_print_info_message(__('No data to show')); @@ -934,6 +952,11 @@ ui_include_time_picker(); $('#filter_group_color').css('color', '#000000'); } }); + + $("#button-draw_button").on('click', function(){ + $("#container_netflow").remove(); + $("#spinner").removeClass("invisible"); + }); }); $("#text-time, #text-time_lower").timepicker({ diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index d3f736c13d..66847f4c1b 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -135,11 +135,53 @@ if ($advanced_filter !== '') { $filter['advanced_filter'] = $advanced_filter; } +$filter_name = get_parameter('filter_name'); + $order_by = get_parameter('order_by', 'bytes'); if (!in_array($order_by, ['bytes', 'pkts', 'flows'])) { $order_by = 'bytes'; } + +$save = get_parameter('save_button', ''); +$update = get_parameter('update_button', ''); + +// Save user defined filter. +if ($save != '' && check_acl($config['id_user'], 0, 'AW')) { + // Save filter args. + $data['filter_name'] = $filter_name; + $data['top'] = $top; + $data['action'] = $action; + $data['advanced_filter'] = $advanced_filter; + + + $filter_id = db_process_sql_insert('tnetwork_explorer_filter', $data); + if ($filter_id === false) { + $filter_id = 0; + ui_print_error_message(__('Error creating filter')); + } else { + ui_print_success_message(__('Filter created successfully')); + } +} else if ($update != '' && check_acl($config['id_user'], 0, 'AW')) { + // Update current filter. + // Do not update the filter name and group. + $data['top'] = $top; + $data['action'] = $action; + $data['advanced_filter'] = $advanced_filter; + + $result = db_process_sql_update( + 'tnetwork_explorer_filter', + $data, + ['id' => $filter_id] + ); + ui_print_result_message( + $result, + __('Filter updated successfully'), + __('Error updating filter') + ); +} + + // Build the table. $filterTable = new stdClass(); $filterTable->id = ''; @@ -176,6 +218,59 @@ $filterTable->data[0][1] = html_print_label_input_block( html_print_select_date_range('date', true) ); +$filterTable->data[1][0] = html_print_label_input_block( + __('Data to show'), + html_print_select( + network_get_report_actions(), + 'action', + $action, + '', + '', + 0, + true + ) +); + +$advanced_toggle = new stdClass(); +$advanced_toggle->class = 'filter-table-adv'; +$advanced_toggle->size = []; +$advanced_toggle->size[0] = '50%'; +$advanced_toggle->size[1] = '50%'; +$advanced_toggle->width = '100%'; +$user_groups = users_get_groups($config['id_user'], 'AR', $own_info['is_admin'], true); +$user_groups[0] = 0; +// Add all groups. +$sql = 'SELECT * FROM tnetwork_explorer_filter'; +$advanced_toggle->data[0][0] = html_print_label_input_block( + __('Load Filter'), + html_print_select_from_sql($sql, 'filter_id', $filter_id, '', __('Select a filter'), 0, true, false, true, false, 'width:100%;') +); +$advanced_toggle->data[0][1] = html_print_label_input_block( + __('Filter name'), + html_print_input_text('filter_name', $filter_name, false, 40, 45, true, false, false, '', 'w100p') +); +$advanced_toggle->colspan[1][0] = 2; +$advanced_toggle->data[1][0] = html_print_label_input_block( + __('Filter').ui_print_help_icon('pcap_filter', true), + html_print_textarea('advanced_filter', 4, 10, $advanced_filter, 'style="width:100%"', true) +); +$filterTable->colspan[2][0] = 3; +$filterTable->data[2][0] = html_print_label_input_block( + '', + ui_toggle( + html_print_table($advanced_toggle, true), + __('Advanced'), + '', + '', + true, + true, + '', + 'white-box-content', + 'box-flat white_table_graph' + ) +); + + $filterInputTable = ''; $filterInputTable .= html_print_input_hidden('order_by', $order_by); $filterInputTable .= html_print_table($filterTable, true); @@ -262,12 +357,16 @@ $data = netflow_get_top_summary( // Get the params to return the builder. $hidden_main_link = [ - 'time_greater' => $time_greater, - 'date_greater' => $date_greater, - 'time_lower' => $time_lower, - 'date_lower' => $date_lower, - 'top' => $top, - 'action' => $action, + 'custom_date' => get_parameter('custom_date', '0'), + 'date' => get_parameter('date', SECONDS_1DAY), + 'date_init' => get_parameter('date_init'), + 'time_init' => get_parameter('time_init'), + 'date_end' => get_parameter('date_end'), + 'time_end' => get_parameter('time_end'), + 'date_text' => get_parameter('date_text'), + 'date_units' => get_parameter('date_units'), + 'top' => $top, + 'action' => $action, ]; unset($table); @@ -449,6 +548,7 @@ if (empty($data)) { // Print results. html_print_div( [ + 'id' => 'content-netflow', 'style' => 'max-width: -webkit-fill-available; display: flex', 'class' => '', 'content' => $resultsTable.$pieGraph, @@ -456,11 +556,25 @@ if (empty($data)) { ); } +$spinner = html_print_div( + [ + 'content' => '', + 'class' => 'spinner-fixed inherit', + 'style' => 'position: initial;', + ], + true +); +html_print_div( + [ + 'id' => 'spinner', + 'content' => '

'.__('Loading netflow data, please wait...').'

'.$spinner, + 'class' => 'invisible', + 'style' => 'position: initial;', + ] +); ?>