mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 16:04:35 +02:00
Added support for per device unix-agent port
This commit is contained in:
@@ -1178,6 +1178,9 @@ function dynamic_override_config($type, $name, $device) {
|
||||
if ($type == 'checkbox') {
|
||||
return '<input type="checkbox" id="override_config" name="override_config" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" data-size="small" '.$checked.'>';
|
||||
}
|
||||
elseif ($type == 'text') {
|
||||
return '<input type="text" id="override_config_text" name="override_config_text" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" value="'.$attrib_val.'">';
|
||||
}
|
||||
}//end dynamic_override_config()
|
||||
|
||||
function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') {
|
||||
|
||||
@@ -25,6 +25,32 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
|
||||
// Device override for text inputs
|
||||
$(document).on('blur', 'input[name="override_config_text"]', function(event) {
|
||||
event.preventDefault();
|
||||
var $this = $(this);
|
||||
var attrib = $this.data('attrib');
|
||||
var device_id = $this.data('device_id');
|
||||
var value = $this.val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: { type: 'override-config', device_id: device_id, attrib: attrib, state: value },
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data.status == 'ok') {
|
||||
toastr.success(data.message);
|
||||
}
|
||||
else {
|
||||
toastr.error(data.message);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
toastr.error('Could not set this override');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Checkbox config ajax calls
|
||||
$("[name='global-config-check']").bootstrapSwitch('offColor','danger');
|
||||
$('input[name="global-config-check"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||
|
||||
@@ -14,6 +14,12 @@ echo '
|
||||
'.dynamic_override_config('checkbox','override_Oxidized_disable', $device).'
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="unixagent" class="col-sm-2 control-label">Unix agent port</label>
|
||||
<div class="col-sm-10">
|
||||
'.dynamic_override_config('text','override_Unixagent_port', $device).'
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
';
|
||||
|
||||
|
||||
@@ -19,12 +19,28 @@ $oxidized_conf = array(
|
||||
),
|
||||
);
|
||||
|
||||
$unixagent_conf = array(
|
||||
array('name' => 'unix-agent.port',
|
||||
'descr' => 'Default unix-agent port',
|
||||
'type' => 'text',
|
||||
),
|
||||
array('name' => 'unix-agent.connection-timeout',
|
||||
'descr' => 'Connection timeout',
|
||||
'type' => 'text',
|
||||
),
|
||||
array('name' => 'unix-agent.read-timeout',
|
||||
'descr' => 'Read timeout',
|
||||
'type' => 'text',
|
||||
),
|
||||
);
|
||||
|
||||
echo '
|
||||
<div class="panel-group" id="accordion">
|
||||
<form class="form-horizontal" role="form" action="" method="post">
|
||||
';
|
||||
|
||||
echo generate_dynamic_config_panel('Oxidized integration',true,$config_groups,$oxidized_conf);
|
||||
echo generate_dynamic_config_panel('Unix-agent integration',true,$config_groups,$unixagent_conf);
|
||||
|
||||
echo '
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user