From 8abd447af1ed4bfdf3115b730a1cfcb78ae1dc57 Mon Sep 17 00:00:00 2001 From: alejandro-campos <alejandro.campos@artica.es> Date: Wed, 27 May 2020 16:11:48 +0200 Subject: [PATCH 1/4] minor fix in snmp browser --- .../include/javascript/pandora_snmp_browser.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandora_console/include/javascript/pandora_snmp_browser.js b/pandora_console/include/javascript/pandora_snmp_browser.js index ef746aa5f4..38864e2bf4 100644 --- a/pandora_console/include/javascript/pandora_snmp_browser.js +++ b/pandora_console/include/javascript/pandora_snmp_browser.js @@ -625,6 +625,20 @@ function snmp_browser_create_modules(module_target, return_post = true) { ); $("input[name=create_modules_" + module_target + "]").addClass("sub spinn"); + $("#dialog_error").on("dialogclose", function(event) { + $("input[name=create_modules_" + module_target + "]").removeClass( + "sub spinn" + ); + $("input[name=create_modules_" + module_target + "]").addClass("sub add"); + }); + + $("#dialog_success").on("dialogclose", function(event) { + $("input[name=create_modules_" + module_target + "]").removeClass( + "sub spinn" + ); + $("input[name=create_modules_" + module_target + "]").addClass("sub add"); + }); + $.ajax({ method: "post", url: "ajax.php", From 6ba1a272745ad4e5e9a9b3d2d99f69ab3d2e0a0d Mon Sep 17 00:00:00 2001 From: alejandro-campos <alejandro.campos@artica.es> Date: Wed, 27 May 2020 18:51:25 +0200 Subject: [PATCH 2/4] added error to dialog submission when no agents or policies have been selected --- .../include/ajax/snmp_browser.ajax.php | 16 +++++++ .../operation/snmpconsole/snmp_browser.php | 45 +++++++++++++------ 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/ajax/snmp_browser.ajax.php b/pandora_console/include/ajax/snmp_browser.ajax.php index 5eaa01d659..3ef830fe09 100644 --- a/pandora_console/include/ajax/snmp_browser.ajax.php +++ b/pandora_console/include/ajax/snmp_browser.ajax.php @@ -112,6 +112,17 @@ if (is_ajax()) { $output .= '</div>'; $output .= '</div>'; + // Dialog no agent selected. + $output .= '<div id="dialog_no_agents_selected" style="display:none" title="'.__('SNMP modules').'">'; + $output .= '<div>'; + $output .= "<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='images/icono_error_mr.png'></div>"; + $output .= "<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>"; + $output .= "<p style='font-family:Verdana; font-size:12pt;margin-bottom: 0px'>".__('Module must be applied to an agent or a policy').'</p>'; + $output .= "<p id='error_text' style='font-family:Verdana; font-size:12pt;'></p>"; + $output .= '</div>'; + $output .= '</div>'; + $output .= '</div>'; + echo $output; } @@ -158,6 +169,11 @@ if (is_ajax()) { $id_target = explode(',', $id_items[0]); } + if (empty($id_items[0])) { + echo json_encode([0 => -1]); + exit; + } + $snmp_extradata = get_parameter('snmp_extradata', ''); if (!is_array($snmp_extradata)) { diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index 8db508da27..5b7dc97a63 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -241,20 +241,37 @@ function snmp_show_result_message(data) { if (dato.length !== 0) { $("#error_text").text(""); - dato.forEach(function (valor, indice, array) { - $("#error_text").append("<br/>" + valor); - }); - $("#dialog_error").dialog({ - resizable: true, - draggable: true, - modal: true, - height: 300, - width: 500, - overlay: { - opacity: 0.5, - background: "black" - } - }); + if (dato[0] ===- 1) { + $("#dialog_no_agents_selected").dialog({ + resizable: true, + draggable: true, + modal: true, + height: 300, + width: 500, + overlay: { + opacity: 0.5, + background: "black" + } + }); + } else { + $("#error_text").text(""); + + dato.forEach(function (valor, indice, array) { + $("#error_text").append("<br/>" + valor); + }); + $("#dialog_error").dialog({ + resizable: true, + draggable: true, + modal: true, + height: 300, + width: 500, + overlay: { + opacity: 0.5, + background: "black" + } + }); + } + } else { $("#dialog_success").dialog({ resizable: true, From 6157030cff2c336aeaf29979c00940315f70df9a Mon Sep 17 00:00:00 2001 From: alejandro-campos <alejandro.campos@artica.es> Date: Wed, 27 May 2020 18:52:50 +0200 Subject: [PATCH 3/4] added error to dialog submission when no agents or policies have been selected --- pandora_console/operation/snmpconsole/snmp_browser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index 5b7dc97a63..0a5e2266e7 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -241,7 +241,7 @@ function snmp_show_result_message(data) { if (dato.length !== 0) { $("#error_text").text(""); - if (dato[0] ===- 1) { + if (dato[0] === -1) { $("#dialog_no_agents_selected").dialog({ resizable: true, draggable: true, From 584b19cc850f639d2c2069b1b11baf9dca041bdc Mon Sep 17 00:00:00 2001 From: alejandro-campos <alejandro.campos@artica.es> Date: Tue, 23 Jun 2020 14:23:14 +0200 Subject: [PATCH 4/4] fix load spinner on close --- pandora_console/operation/snmpconsole/snmp_browser.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index 0a5e2266e7..fd0067f24f 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -248,6 +248,10 @@ function snmp_show_result_message(data) { modal: true, height: 300, width: 500, + close: function(e, ui) { + $("input[name=create_modules_network_component]").removeClass("sub spinn"); + $("input[name=create_modules_network_component]").addClass("sub add"); + }, overlay: { opacity: 0.5, background: "black"