diff --git a/pandora_console/include/ajax/snmp_browser.ajax.php b/pandora_console/include/ajax/snmp_browser.ajax.php index 858875c624..eb4d8e8b54 100644 --- a/pandora_console/include/ajax/snmp_browser.ajax.php +++ b/pandora_console/include/ajax/snmp_browser.ajax.php @@ -113,6 +113,17 @@ if (is_ajax()) { $output .= ''; $output .= ''; + // Dialog no agent selected. + $output .= ''; + echo $output; } @@ -159,6 +170,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/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", diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index 8db508da27..fd0067f24f 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -241,20 +241,41 @@ function snmp_show_result_message(data) { if (dato.length !== 0) { $("#error_text").text(""); - dato.forEach(function (valor, indice, array) { - $("#error_text").append("
" + 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, + 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" + } + }); + } else { + $("#error_text").text(""); + + dato.forEach(function (valor, indice, array) { + $("#error_text").append("
" + 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,