From 6ba1a272745ad4e5e9a9b3d2d99f69ab3d2e0a0d Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Wed, 27 May 2020 18:51:25 +0200 Subject: [PATCH] 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 .= ''; $output .= ''; + // Dialog no agent selected. + $output .= ''; + 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("
" + 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("
" + 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,