diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 12cb62810c..05ec6abb51 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -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); } diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index a102b1e376..feeb355788 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -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(); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 8ec1783bb5..be762c127a 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1428,26 +1428,26 @@ function process_datatables_item(item) { item.options += ')" > __('Show more')]); ?>'; // Validate. - item.options += ''; + item.options += item.max_id_evento+', this)" >'; item.options += ' __('Validate events')]); ?>'; } else { - item.options += item.id_evento+')" >'; + item.options += item.id_evento+', this)" >'; item.options += ' __('Validate event')]); ?>'; } // In process. - item.options += ''; + item.options += item.max_id_evento+', this)" >'; } else { - item.options += item.id_evento+')" >'; + item.options += item.id_evento+', this)" >'; } item.options += ' __('Change to in progress status')]); ?>'; // Delete. - item.options += ''; item.options += ' __('Delete events')]); ?>';