added error to dialog submission when no agents or policies have been selected

This commit is contained in:
alejandro-campos 2020-05-27 18:51:25 +02:00
parent 8abd447af1
commit 6ba1a27274
2 changed files with 47 additions and 14 deletions

View File

@ -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)) {

View File

@ -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,