#11098 The operation of the create module button from the SNPM Walk modal is adjusted

This commit is contained in:
Jorge Rincon 2023-05-05 14:10:41 +02:00
parent 9ab9087377
commit 82db353dd1
4 changed files with 145 additions and 80 deletions

View File

@ -311,7 +311,7 @@ $data[2] .= html_print_button(
__('SNMP Walk'),
'snmp_walk',
false,
'snmpBrowserWindow()',
'snmpBrowserWindow('.$id_agente.')',
[ 'mode' => 'link' ],
true
);

View File

@ -1126,6 +1126,14 @@ function snmp_browser_print_container(
$output .= '<div style="text-align: left; width: '.$width.'; height: '.$height.';">';
$output .= '<div class="w100p">';
$output .= '<form onsubmit="snmpBrowse(); return false;">';
$output .= html_print_input_hidden(
'id_agent_module',
0,
true,
false,
false,
'id_agent_module'
);
$output .= html_print_table($table, true);
$output .= html_print_div(
[

View File

@ -533,7 +533,7 @@ function checkSNMPVersion() {
}
// Show the SNMP browser window
function snmpBrowserWindow() {
function snmpBrowserWindow(id_agente = 0) {
// Keep elements in the form and the SNMP browser synced
$("#text-target_ip").val($("#text-ip_target").val());
$("#target_port").val($("#text-tcp_port").val());
@ -549,6 +549,8 @@ function snmpBrowserWindow() {
$("#password-snmp3_browser_privacy_pass").val(
$("#password-snmp3_privacy_pass").val()
);
// Realation agente module.
$("#id_agent_module").val(id_agente);
checkSNMPVersion();

View File

@ -609,87 +609,142 @@ function show_add_module() {
var id_agent = 0;
var id_module = 0;
var id_agent_module = $("#id_agent_module").val();
if (id_agent_module) {
// Get SNMP target.
confirmDialog({
title: '<?php echo __('Are you sure?'); ?>',
message: '<?php echo __('Are you sure you want add module?'); ?> ',
ok: '<?php echo __('OK'); ?>',
cancel: '<?php echo __('Cancel'); ?>',
onAccept: function() {
// Get SNMP target.
var snmp_target = {
target_ip : $('#text-target_ip').val(),
community : $('#text-community').val(),
snmp_version : $('#snmp_browser_version').val(),
snmp3_auth_user : $('#text-snmp3_browser_auth_user').val(),
snmp3_security_level : $('#snmp3_browser_security_level').val(),
snmp3_auth_method : $('#snmp3_browser_auth_method').val(),
snmp3_auth_pass : $('#password-snmp3_browser_auth_pass').val(),
snmp3_privacy_method : $('#snmp3_browser_privacy_method').val(),
snmp3_privacy_pass : $('#password-snmp3_browser_privacy_pass').val(),
tcp_port : $('#target_port').val(),
};
// Append values to form.
var input = "";
$.each( snmp_target, function( key, val ) {
input = $("<input>")
.attr("type", "hidden")
.attr("name", key).val(val);
$("#snmp_create_module").append(input);
});
//Submit form to agent module url.
$("#snmp_create_module").attr(
"action",
"index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente="
+id_agent_module+
"&tab=module&edit_module=1"
);
$('#snmp_create_module').submit();
$("#dialog_create_module").dialog({
resizable: true,
draggable: true,
modal: true,
width: '300',
height:'auto',
overlay: {
opacity: 0.5,
background: "black"
},
buttons:
[
{
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-cancel",
text: '<?php echo __('Cancel'); ?>',
click: function() {
$(this).dialog("close");
}
},
{
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
text: '<?php echo __('Create module'); ?>',
click: function(e) {
confirmDialog({
title: '<?php echo __('Are you sure?'); ?>',
message: '<?php echo __('Are you sure you want add module?'); ?> ',
ok: '<?php echo __('OK'); ?>',
cancel: '<?php echo __('Cancel'); ?>',
onAccept: function() {
// Get id agent and add it to form.
id_agent = $('#hidden-id_agent').val();
// Get SNMP target.
var snmp_target = {
target_ip : $('#text-target_ip').val(),
community : $('#text-community').val(),
snmp_version : $('#snmp_browser_version').val(),
snmp3_auth_user : $('#text-snmp3_browser_auth_user').val(),
snmp3_security_level : $('#snmp3_browser_security_level').val(),
snmp3_auth_method : $('#snmp3_browser_auth_method').val(),
snmp3_auth_pass : $('#password-snmp3_browser_auth_pass').val(),
snmp3_privacy_method : $('#snmp3_browser_privacy_method').val(),
snmp3_privacy_pass : $('#password-snmp3_browser_privacy_pass').val(),
tcp_port : $('#target_port').val(),
};
// Append values to form.
var input = "";
$.each( snmp_target, function( key, val ) {
input = $("<input>")
.attr("type", "hidden")
.attr("name", key).val(val);
$("#snmp_create_module").append(input);
});
console.log(input);
//Submit form to agent module url.
$("#snmp_create_module").attr(
"action",
"index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente="
+id_agent+
"&tab=module&edit_module=1"
);
$('#snmp_create_module').submit();
},
onDeny: function () {
$("#dialog_create_module").dialog("close");
return false;
}
});
}
onDeny: function () {
$("#dialog_create_module").dialog("close");
return false;
}
],
});
});
} else {
$("#dialog_create_module").dialog({
resizable: true,
draggable: true,
modal: true,
width: '300',
height:'auto',
overlay: {
opacity: 0.5,
background: "black"
},
buttons:
[
{
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-cancel",
text: '<?php echo __('Cancel'); ?>',
click: function() {
$(this).dialog("close");
}
},
{
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
text: '<?php echo __('Create module'); ?>',
click: function(e) {
confirmDialog({
title: '<?php echo __('Are you sure?'); ?>',
message: '<?php echo __('Are you sure you want add module?'); ?> ',
ok: '<?php echo __('OK'); ?>',
cancel: '<?php echo __('Cancel'); ?>',
onAccept: function() {
// Get id agent and add it to form.
id_agent = $('#hidden-id_agent').val();
// Get SNMP target.
var snmp_target = {
target_ip : $('#text-target_ip').val(),
community : $('#text-community').val(),
snmp_version : $('#snmp_browser_version').val(),
snmp3_auth_user : $('#text-snmp3_browser_auth_user').val(),
snmp3_security_level : $('#snmp3_browser_security_level').val(),
snmp3_auth_method : $('#snmp3_browser_auth_method').val(),
snmp3_auth_pass : $('#password-snmp3_browser_auth_pass').val(),
snmp3_privacy_method : $('#snmp3_browser_privacy_method').val(),
snmp3_privacy_pass : $('#password-snmp3_browser_privacy_pass').val(),
tcp_port : $('#target_port').val(),
};
// Append values to form.
var input = "";
$.each( snmp_target, function( key, val ) {
input = $("<input>")
.attr("type", "hidden")
.attr("name", key).val(val);
$("#snmp_create_module").append(input);
});
//Submit form to agent module url.
$("#snmp_create_module").attr(
"action",
"index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente="
+id_agent+
"&tab=module&edit_module=1"
);
$('#snmp_create_module').submit();
},
onDeny: function () {
$("#dialog_create_module").dialog("close");
return false;
}
});
}
}
],
});
}
}
</script>