mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-11 16:06:25 +02:00
Merge pull request #2100 from laf/issue-2018
This commit is contained in:
@@ -38,3 +38,5 @@ You will need to configure default credentials for your devices, LibreNMS doesn'
|
|||||||
headers:
|
headers:
|
||||||
X-Auth-Token: '01582bf94c03104ecb7953dsadsadwed'
|
X-Auth-Token: '01582bf94c03104ecb7953dsadsadwed'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you have devices which you do not wish to appear in Oxidized then you can edit those devices in Device -> Edit -> Misc and enable "Exclude from Oxidized?"
|
||||||
|
|||||||
@@ -888,7 +888,7 @@ function list_oxidized() {
|
|||||||
$app->response->headers->set('Content-Type', 'application/json');
|
$app->response->headers->set('Content-Type', 'application/json');
|
||||||
|
|
||||||
$devices = array();
|
$devices = array();
|
||||||
foreach (dbFetchRows("SELECT hostname,os FROM `devices` WHERE `status`='1'") as $device) {
|
foreach (dbFetchRows("SELECT hostname,os FROM `devices` LEFT JOIN devices_attribs AS `DA` ON devices.device_id = DA.device_id AND `DA`.attrib_type='override_Oxidized_disable' WHERE `status`='1' AND (DA.attrib_value = 'false' OR DA.attrib_value IS NULL)") as $device) {
|
||||||
$devices[] = $device;
|
$devices[] = $device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LibreNMS
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version. Please see LICENSE.txt at the top level of
|
||||||
|
* the source code distribution for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (is_admin() === false) {
|
||||||
|
$response = array(
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Need to be admin',
|
||||||
|
);
|
||||||
|
echo _json_encode($response);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$device['device_id'] = mres($_POST['device_id']);
|
||||||
|
$attrib = mres($_POST['attrib']);
|
||||||
|
$state = mres($_POST['state']);
|
||||||
|
$status = 'error';
|
||||||
|
$message = 'Error with config';
|
||||||
|
|
||||||
|
if (empty($device['device_id'])) {
|
||||||
|
$message = 'No device passed';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($state == true) {
|
||||||
|
set_dev_attrib($device, $attrib, $state);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
del_dev_attrib($device, $attrib);
|
||||||
|
}
|
||||||
|
$status = 'ok';
|
||||||
|
$message = 'Config has been updated';
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = array(
|
||||||
|
'status' => $status,
|
||||||
|
'message' => $message,
|
||||||
|
);
|
||||||
|
echo _json_encode($response);
|
||||||
@@ -1167,3 +1167,15 @@ function alert_details($details) {
|
|||||||
|
|
||||||
}//end alert_details()
|
}//end alert_details()
|
||||||
|
|
||||||
|
function dynamic_override_config($type, $name, $device) {
|
||||||
|
$attrib_val = get_dev_attrib($device,$name);
|
||||||
|
if ($attrib_val == 'true') {
|
||||||
|
$checked = 'checked';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$checked = '';
|
||||||
|
}
|
||||||
|
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.'>';
|
||||||
|
}
|
||||||
|
}//end dynamic_override_config()
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
$(document).ready(function() {
|
||||||
|
$("[name='override_config']").bootstrapSwitch('offColor','danger');
|
||||||
|
$('input[name="override_config"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||||
|
event.preventDefault();
|
||||||
|
var $this = $(this);
|
||||||
|
var attrib = $this.data('attrib');
|
||||||
|
var device_id = $this.data('device_id');
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: 'ajax_form.php',
|
||||||
|
data: { type: 'override-config', device_id: device_id, attrib: attrib, state: state },
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -36,6 +36,7 @@ else {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$panes['storage'] = 'Storage';
|
$panes['storage'] = 'Storage';
|
||||||
|
$panes['misc'] = 'Misc';
|
||||||
|
|
||||||
print_optionbar_start();
|
print_optionbar_start();
|
||||||
|
|
||||||
@@ -64,6 +65,8 @@ else {
|
|||||||
|
|
||||||
print_optionbar_end();
|
print_optionbar_end();
|
||||||
|
|
||||||
|
echo '<script src="js/librenms.js"></script>';
|
||||||
|
|
||||||
if (is_file("pages/device/edit/".mres($vars['section']).".inc.php")) {
|
if (is_file("pages/device/edit/".mres($vars['section']).".inc.php")) {
|
||||||
require "pages/device/edit/".mres($vars['section']).".inc.php";
|
require "pages/device/edit/".mres($vars['section']).".inc.php";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<form class="form-horizontal">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="oxidized" class="col-sm-2 control-label">Exclude from Oxidized?</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
'.dynamic_override_config('checkbox','override_Oxidized_disable', $device).'
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
|
||||||
Reference in New Issue
Block a user