This commit is contained in:
Daniel Maya 2017-06-20 10:31:14 +02:00
parent e68858e4c2
commit 4398b47d92
3 changed files with 102 additions and 44 deletions

View File

@ -116,7 +116,7 @@ function snmp_browser_print_tree ($tree, $id = 0, $depth = 0, $last = 0, $last_a
echo "</a>";
}
echo '&nbsp;<span>' . $level . '</span>'. html_print_checkbox("create_$sub_id", 0, false, true, false, '');;
echo html_print_checkbox("create_$sub_id", 0, false, true, false, '') .'&nbsp;<span>' . $level . '</span>';
if (isset ($sub_level['__VALUE__'])) {
echo '<span class="value" style="display: none;">&nbsp;=&nbsp;' . $sub_level['__VALUE__'] . '</span>';
}
@ -622,69 +622,104 @@ function snmp_browser_print_container ($return = false, $width = '100%', $height
<script type="text/javascript">
$(document).ready(function () {
$('input[name*=create_network_component]').click(function () {
var prueba = $('#ul_0').find('input').map(function(){
var id_check = $('#ul_0').find('input').map(function(){
if(this.id.indexOf('checkbox-create_')!=-1){
if($(this).is(':checked')){
return this.id;
}
} }).get();
$('input[name*=create_network_component]').removeClass("sub add");
$('input[name*=create_network_component]').addClass("sub spinn");
var target_ip = $('#text-target_ip').val();
var community = $('#text-community').val();
var snmp_version = $('#snmp_browser_version').val();
var snmp3_auth_user = $('#text-snmp3_browser_auth_user').val();
var snmp3_security_level = $('#snmp3_browser_security_level').val();
var snmp3_auth_method = $('#snmp3_browser_auth_method').val();
var snmp3_auth_pass = $('#password-snmp3_browser_auth_pass').val();
var snmp3_privacy_method = $('#snmp3_browser_privacy_method').val();
var snmp3_privacy_pass = $('#password-snmp3_browser_privacy_pass').val();
var custom_action = $('#hidden-custom_action').val();
if (custom_action == undefined) {
custom_action = '';
}
prueba.forEach(function(product, index) {
var oids = [];
id_check.forEach(function(product, index) {
var oid = $("#"+product).siblings('a').attr('href');
if(oid.indexOf('javascript: snmpGet("')!=-1){
if(oid.indexOf('javascript: snmpGet("')!=-1) {
oid = oid.replace('javascript: snmpGet("',"");
oid = oid.replace('");',"");
var target_ip = $('#text-target_ip').val();
var community = $('#text-community').val();
var snmp_version = $('#snmp_browser_version').val();
var snmp3_auth_user = $('#text-snmp3_browser_auth_user').val();
var snmp3_security_level = $('#snmp3_browser_security_level').val();
var snmp3_auth_method = $('#snmp3_browser_auth_method').val();
var snmp3_auth_pass = $('#password-snmp3_browser_auth_pass').val();
var snmp3_privacy_method = $('#snmp3_browser_privacy_method').val();
var snmp3_privacy_pass = $('#password-snmp3_browser_privacy_pass').val();
var ajax_url = $('#hidden-ajax_url').val();
oids.push(oid);
}
var custom_action = $('#hidden-custom_action').val();
if (custom_action == undefined) {
custom_action = '';
});
// Prepare the AJAX call
var params = [
"target_ip=" + target_ip,
"community=" + community,
"oids=" + oids,
"snmp_browser_version=" + snmp_version,
"snmp3_browser_auth_user=" + snmp3_auth_user,
"snmp3_browser_security_level=" + snmp3_security_level,
"snmp3_browser_auth_method=" + snmp3_auth_method,
"snmp3_browser_auth_pass=" + snmp3_auth_pass,
"snmp3_browser_privacy_method=" + snmp3_privacy_method,
"snmp3_browser_privacy_pass=" + snmp3_privacy_pass,
"action=" + "create_modules_snmp",
"custom_action=" + custom_action,
"page=include/ajax/snmp_browser.ajax"
];
$.ajax({
type: "GET",
url: "ajax.php",
data: params.join ("&"),
dataType: "json",
success: function(data) {
$('input[name*=create_network_component]').removeClass("sub spinn");
$('input[name*=create_network_component]').addClass("sub add");
if(data.length !== 0){
$('#prueba').text(data);
$("#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,
draggable: true,
modal: true,
height: 300,
width: 500,
overlay: {
opacity: 0.5,
background: "black"
}
});
}
// Prepare the AJAX call
var params = [
"target_ip=" + target_ip,
"community=" + community,
"oid=" + oid,
"snmp_browser_version=" + snmp_version,
"snmp3_browser_auth_user=" + snmp3_auth_user,
"snmp3_browser_security_level=" + snmp3_security_level,
"snmp3_browser_auth_method=" + snmp3_auth_method,
"snmp3_browser_auth_pass=" + snmp3_auth_pass,
"snmp3_browser_privacy_method=" + snmp3_privacy_method,
"snmp3_browser_privacy_pass=" + snmp3_privacy_pass,
"action=" + "snmpget",
"custom_action=" + custom_action,
"page=include/ajax/snmp_browser.ajax"
];
$.ajax({
type: "GET",
url: "ajax.php",
data: params.join ("&"),
dataType: "html",
success: function(data) {
console.log(data);
}
});
}
});
});
$('input[id^=checkbox-create]').change(function () {
if ($(this).is(':checked') ) {
$('input[name*=create_network_component]').show();
var id_input = $(this).attr("id");
id_input = id_input.split("checkbox-create_");
var checks = $('#ul_'+id_input[1]).find('input').map(function(){

View File

@ -656,7 +656,7 @@ input.sub[disabled] {
input.next, input.upd, input.ok, input.wand, input.delete, input.cog,
input.target, input.search, input.copy, input.add, input.graph,
input.percentile, input.binary, input.camera, input.config,
input.cancel, input.default, input.filter, input.pdf {
input.cancel, input.default, input.filter, input.pdf,input.spinn {
padding-right: 30px;
height: 23px;
@ -741,6 +741,9 @@ input.pdf:disabled {
input.camera {
background-image: url(../../images/input_camera.png) !important;
}
input.spinn {
background-image: url(../../images/input_update.png) !important;
}
#toolbox #auto_save {
padding-top: 5px;

View File

@ -47,7 +47,27 @@ if (is_ajax()) {
}
else {
snmp_browser_print_tree ($snmp_tree);
echo html_print_submit_button(__('Create network component'),'create_network_component', false, '', true);
echo html_print_submit_button(__('Create network components'),'create_network_component',
false, array('style' => 'display: none', 'class' => 'sub add'), true);
echo '<div id="dialog_error" style="display: none" title="Network components">';
echo "<div>";
echo "<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='images/icono_error_mr.png'></div>";
echo "<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>ERROR</strong></h3>";
echo "<p style='font-family:Verdana; font-size:12pt;'>".__('Error creating the following modules:')."</p>";
echo "<p id='prueba' style='font-family:Verdana; font-size:12pt;'></p>";
echo "</div>";
echo '</div>';
echo '<div id="dialog_success" style="display: none" title="Network components">';
echo "<div>";
echo "<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='images/icono_exito_mr.png'></div>";
echo "<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>SUCCESS</strong></h3>";
echo "<p style='font-family:Verdana; font-size:12pt;'>".__('Modules successfully created')."</p>";
echo "<p id='prueba' style='font-family:Verdana; font-size:12pt;'></p>";
echo "</div>";
echo '</div>';
}
return;
}