diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js
index c9af47ed2b..ddd2f42578 100644
--- a/pandora_console/include/javascript/pandora_events.js
+++ b/pandora_console/include/javascript/pandora_events.js
@@ -712,8 +712,7 @@ function update_event(table, id_evento, type, event_rep, row) {
values[this.name] = $(this).val();
});
var t1 = new Date();
- console.log("al ajax directo");
- // Update events matching current filters and id_evento selected.
+
$.ajax({
async: true,
type: "POST",
@@ -751,6 +750,7 @@ function update_event(table, id_evento, type, event_rep, row) {
}
});
}
+// Update events matching current filters and id_evento selected.
function validate_event(table, id_evento, event_rep, row) {
var button = document.getElementById("val-" + id_evento);
@@ -791,14 +791,16 @@ function delete_event(table, id_evento, event_rep, row) {
processed += 1;
return;
}
+ button.children[0];
+ button.children[0].src = "images/spinner.gif";
+ var message =
+ "
Are you sure?
";
confirmDialog({
title: "ATTENTION",
- message:
- "Are you sure?
",
+ message: message,
cancel: "Cancel",
ok: "Ok",
onAccept: function() {
- // Continue execution.
button.children[0];
button.children[0].src = "images/spinner.gif";
return update_event(
@@ -808,116 +810,149 @@ function delete_event(table, id_evento, event_rep, row) {
event_rep,
row
);
+ },
+ onDeny: function() {
+ button.children[0];
+ button.children[0].src = "images/cross.png";
+ return;
}
});
}
-// Imported from old files.
-function execute_event_response(event_list_btn) {
- processed = 0;
- $("#max_custom_event_resp_msg").hide();
- $("#max_custom_selected").hide();
-
- var response_id = $("select[name=response_id]").val();
-
- var total_checked = $(".chk_val:checked").length;
-
- // Check select an event.
- if (total_checked == 0) {
- $("#max_custom_selected").show();
+function execute_delete_event_reponse(table, id_evento, event_rep, row) {
+ var button = document.getElementById("del-" + id_evento);
+ if (!button) {
+ // Button does not exist. Ignore.
+ processed += 1;
return;
}
+ button.children[0];
+ button.children[0].src = "images/spinner.gif";
+ return update_event(table, id_evento, { delete_event: 1 }, event_rep, row);
+}
- if (!isNaN(response_id)) {
- // It is a custom response
- var response = get_response(response_id);
+// Imported from old files.
+function execute_event_response(event_list_btn) {
+ var message =
+ " Are you sure?
";
+ confirmDialog({
+ title: "ATTENTION",
+ message: message,
+ cancel: "Cancel",
+ ok: "Ok",
+ onAccept: function() {
+ // Continue execution.
+ processed = 0;
+ $("#max_custom_event_resp_msg").hide();
+ $("#max_custom_selected").hide();
- // If cannot get response abort it
- if (response == null) {
+ var response_id = $("select[name=response_id]").val();
+
+ var total_checked = $(".chk_val:checked").length;
+
+ // Check select an event.
+ if (total_checked == 0) {
+ $("#max_custom_selected").show();
+ return;
+ }
+
+ if (!isNaN(response_id)) {
+ // It is a custom response
+ var response = get_response(response_id);
+
+ // If cannot get response abort it
+ if (response == null) {
+ return;
+ }
+
+ // Limit number of events to apply custom responses
+ // due performance reasons.
+ if (total_checked > $("#max_execution_event_response").val()) {
+ $("#max_custom_event_resp_msg").show();
+ return;
+ }
+
+ var response_command = [];
+ $(".response_command_input").each(function() {
+ response_command[$(this).attr("name")] = $(this).val();
+ });
+
+ if (event_list_btn) {
+ $("#button-submit_event_response").hide(function() {
+ $("#response_loading_dialog").show(function() {
+ var check_params = get_response_params(response_id);
+
+ if (check_params[0] !== "") {
+ show_event_response_command_dialog(
+ response_id,
+ response,
+ total_checked
+ );
+ } else {
+ check_massive_response_event(
+ response_id,
+ response,
+ total_checked,
+ response_command
+ );
+ }
+ });
+ });
+ } else {
+ $("#button-btn_str").hide(function() {
+ $("#execute_again_loading").show(function() {
+ check_massive_response_event(
+ response_id,
+ response,
+ total_checked,
+ response_command
+ );
+ });
+ });
+ }
+ } else {
+ // It is not a custom response
+ switch (response_id) {
+ case "in_progress_selected":
+ $(".chk_val:checked").each(function() {
+ // Parent: TD. GrandParent: TR.
+ in_process_event(
+ dt_events,
+ $(this).val(),
+ $(this).attr("event_rep"),
+ this.parentElement.parentElement
+ );
+ });
+ break;
+ case "validate_selected":
+ $(".chk_val:checked").each(function() {
+ validate_event(
+ dt_events,
+ $(this).val(),
+ $(this).attr("event_rep"),
+ this.parentElement.parentElement
+ );
+ });
+ break;
+ case "delete_selected":
+ console.log($(this));
+ $(".chk_val:checked").each(function() {
+ execute_delete_event_reponse(
+ dt_events,
+ $(this).val(),
+ $(this).attr("event_rep"),
+ this.parentElement.parentElement
+ );
+ });
+ break;
+ }
+ }
+ },
+ onDeny: function() {
+ processed += 1;
return;
}
-
- // Limit number of events to apply custom responses
- // due performance reasons.
- if (total_checked > $("#max_execution_event_response").val()) {
- $("#max_custom_event_resp_msg").show();
- return;
- }
-
- var response_command = [];
- $(".response_command_input").each(function() {
- response_command[$(this).attr("name")] = $(this).val();
- });
-
- if (event_list_btn) {
- $("#button-submit_event_response").hide(function() {
- $("#response_loading_dialog").show(function() {
- var check_params = get_response_params(response_id);
-
- if (check_params[0] !== "") {
- show_event_response_command_dialog(
- response_id,
- response,
- total_checked
- );
- } else {
- check_massive_response_event(
- response_id,
- response,
- total_checked,
- response_command
- );
- }
- });
- });
- } else {
- $("#button-btn_str").hide(function() {
- $("#execute_again_loading").show(function() {
- check_massive_response_event(
- response_id,
- response,
- total_checked,
- response_command
- );
- });
- });
- }
- } else {
- // It is not a custom response
- switch (response_id) {
- case "in_progress_selected":
- $(".chk_val:checked").each(function() {
- // Parent: TD. GrandParent: TR.
- in_process_event(
- dt_events,
- $(this).val(),
- $(this).attr("event_rep"),
- this.parentElement.parentElement
- );
- });
- break;
- case "validate_selected":
- $(".chk_val:checked").each(function() {
- validate_event(
- dt_events,
- $(this).val(),
- $(this).attr("event_rep"),
- this.parentElement.parentElement
- );
- });
- break;
- case "delete_selected":
- $(".chk_val:checked").each(function() {
- delete_event(
- dt_events,
- $(this).val(),
- $(this).attr("event_rep"),
- this.parentElement.parentElement
- );
- });
- break;
- }
- }
+ });
}
function check_massive_response_event(