dyn redraw

This commit is contained in:
fbsanchez 2019-06-13 13:07:11 +02:00
parent d12773cfd0
commit 9740275388
3 changed files with 29 additions and 17 deletions

View File

@ -196,9 +196,6 @@ function events_get_column_names($fields)
*/
function events_update_status($id_evento, $status, $filter=null, $history=false)
{
error_log($id_evento);
error_log($status);
if (!$status) {
return false;
}
@ -263,7 +260,6 @@ function events_update_status($id_evento, $status, $filter=null, $history=false)
break;
}
error_log($update_sql);
return db_process_sql($update_sql);
}

View File

@ -669,12 +669,14 @@ function show_event_response_command_dialog(id, response, total_checked) {
});
}
function update_event(table, id_evento, type, redraw) {
function update_event(table, id_evento, type, row) {
var inputs = $("#events_form :input");
var values = {};
var redraw = false;
inputs.each(function() {
values[this.name] = $(this).val();
});
var t1 = new Date();
// Update events matching current filters and id_evento selected.
$.ajax({
@ -688,22 +690,36 @@ function update_event(table, id_evento, type, redraw) {
filter: values
},
success: function() {
var t2 = new Date();
var diff_g = t1.getTime() - t2.getTime();
var diff_s = diff_g / 1000;
// If operation takes less than 2 seconds, redraw.
if (diff_s < 2) {
redraw = true;
}
if (redraw) {
table.draw().page(0);
} else {
$(row)
.closest("tr")
.remove();
}
}
});
}
function validate_event(table, id_evento) {
return update_event(table, id_evento, { validate_event: 1 }, false);
function validate_event(table, id_evento, row) {
row.firstChild.src = "http://localhost/pandora_console/images/spinner.gif";
return update_event(table, id_evento, { validate_event: 1 }, row, false);
}
function in_process_event(table, id_evento) {
return update_event(table, id_evento, { in_process_event: 1 }, false);
function in_process_event(table, id_evento, row) {
row.firstChild.src = "http://localhost/pandora_console/images/spinner.gif";
return update_event(table, id_evento, { in_process_event: 1 }, row, false);
}
function delete_event(table, id_evento) {
function delete_event(table, id_evento, row) {
$(row)
.closest("tr")
.remove();

View File

@ -1428,26 +1428,26 @@ function process_datatables_item(item) {
item.options += ')" ><?php echo html_print_image('images/eye.png', true, ['title' => __('Show more')]); ?></a>';
// Validate.
item.options += '<a href="javascript:" onclick="$(this).hide(); validate_event(dt_<?php echo $table_id; ?>,';
item.options += '<a href="javascript:" onclick="validate_event(dt_<?php echo $table_id; ?>,';
if (item.max_id_evento) {
item.options += item.max_id_evento+')" >';
item.options += item.max_id_evento+', this)" >';
item.options += '<?php echo html_print_image('images/tick.png', true, ['title' => __('Validate events')]); ?></a>';
} else {
item.options += item.id_evento+')" >';
item.options += item.id_evento+', this)" >';
item.options += '<?php echo html_print_image('images/tick.png', true, ['title' => __('Validate event')]); ?></a>';
}
// In process.
item.options += '<a href="javascript:" onclick="$(this).hide(); in_process_event(dt_<?php echo $table_id; ?>,';
item.options += '<a href="javascript:" onclick="in_process_event(dt_<?php echo $table_id; ?>,';
if (item.max_id_evento) {
item.options += item.max_id_evento+')" >';
item.options += item.max_id_evento+', this)" >';
} else {
item.options += item.id_evento+')" >';
item.options += item.id_evento+', this)" >';
}
item.options += '<?php echo html_print_image('images/hourglass.png', true, ['title' => __('Change to in progress status')]); ?></a>';
// Delete.
item.options += '<a href="javascript:" onclick="$(this).hide(); delete_event(dt_<?php echo $table_id; ?>,';
item.options += '<a href="javascript:" onclick="delete_event(dt_<?php echo $table_id; ?>,';
if (item.max_id_evento) {
item.options += item.max_id_evento+', this)" >';
item.options += '<?php echo html_print_image('images/cross.png', true, ['title' => __('Delete events')]); ?></a>';