#12288 added spinner in netflow and fixed bug filter

This commit is contained in:
Daniel Cebrian 2023-10-19 17:18:13 +02:00
parent d5193615f9
commit 7bba90cd4f
4 changed files with 86 additions and 14 deletions

View File

@ -1292,6 +1292,11 @@ p.center {
margin: 0 5px;
}
.loading-text {
font-size: 19px;
text-align: center;
}
/* Legacy spinner */
#loading {
position: fixed;

View File

@ -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', '');
@ -145,7 +145,8 @@ if ($custom_date === '1') {
}
// 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', '');
@ -639,6 +640,7 @@ if (empty($draw) === false) {
// Draw the netflow chart.
html_print_div(
[
'id' => 'container_netflow',
'class' => $netflowContainerClass,
'content' => netflow_draw_item(
$date_from,
@ -653,6 +655,22 @@ if (empty($draw) === false) {
),
]
);
$spinner = html_print_div(
[
'content' => '<span></span>',
'class' => 'spinner-fixed inherit',
'style' => 'position: initial;',
],
true
);
html_print_div(
[
'id' => 'spinner',
'content' => '<p class="loading-text">'.__('Loading netflow data, plase wait...').'</p>'.$spinner,
'class' => 'invisible',
'style' => 'position: initial;',
]
);
}
} else {
ui_print_info_message(__('No data to show'));
@ -891,8 +909,6 @@ ui_include_time_picker();
$(document).ready( function() {
displayMonitoringFilter();
// Update visibility of controls.
nf_view_click_period();
// Hide update filter button
if ($("#filter_id").val() == 0) {
$("#submit-update_button").hide();
@ -912,6 +928,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({

View File

@ -239,12 +239,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);
@ -426,18 +430,34 @@ if (empty($data)) {
// Print results.
html_print_div(
[
'id' => 'content-netflow',
'style' => 'max-width: -webkit-fill-available; display: flex',
'class' => '',
'content' => $resultsTable.$pieGraph,
]
);
$spinner = html_print_div(
[
'content' => '<span></span>',
'class' => 'spinner-fixed inherit',
'style' => 'position: initial;',
],
true
);
html_print_div(
[
'id' => 'spinner',
'content' => '<p class="loading-text">Loading netflow data, plase wait...</p>'.$spinner,
'class' => 'invisible',
'style' => 'position: initial;',
]
);
}
?>
<script>
$(document).ready(function(){
nf_view_click_period();
$('#filter_id').change(function(){
jQuery.post (
"ajax.php",
@ -453,6 +473,11 @@ $(document).ready(function(){
$('select#filter_id').select2('close');
}, 'json');
});
$('#button-update').on('click', function(){
$('#content-netflow').remove();
$('#spinner').removeClass("invisible");
});
});
// Configure jQuery timepickers.

View File

@ -313,7 +313,7 @@ ui_toggle(
$has_data = false;
if ((bool) get_parameter('update_netflow') === true) {
if ((bool) get_parameter('update_netflow', 1) === true) {
$map_data = netflow_build_map_data(
$date_from,
$date_to,
@ -331,6 +331,23 @@ if ($has_data === true) {
ui_print_info_message(__('No data to show'));
}
$spinner = html_print_div(
[
'content' => '<span></span>',
'class' => 'spinner-fixed inherit',
'style' => 'position: initial;',
],
true
);
html_print_div(
[
'id' => 'spinner',
'content' => '<p class="loading-text">Loading netflow data, plase wait...</p>'.$spinner,
'class' => 'invisible',
'style' => 'position: initial;',
]
);
?>
<style>
.networkconsole {
@ -340,7 +357,6 @@ if ($has_data === true) {
<script>
$(document).ready(function(){
nf_view_click_period();
$('#filter_id').change(function(){
jQuery.post (
@ -357,6 +373,11 @@ $(document).ready(function(){
$('select#filter_id').select2('close');
}, 'json');
});
$('#button-update_netflow').on('click', function(){
$('.networkconsole').remove();
$('#spinner').removeClass("invisible");
});
});
// Configure jQuery timepickers.