mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add Device Notes Field
Add a “Notes” field for devices to accommodate #1897
This commit is contained in:
32
html/includes/forms/update-notes.inc.php
Normal file
32
html/includes/forms/update-notes.inc.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* LibreNMS
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$status = 'error';
|
||||||
|
$message = 'unknown error';
|
||||||
|
|
||||||
|
$device_id = mres($_POST['device_id']);
|
||||||
|
$notes = mres($_POST['notes']);
|
||||||
|
|
||||||
|
if (isset($notes) && (dbUpdate(array('notes' => $notes), 'devices', 'device_id = ?', array($device_id)))) {
|
||||||
|
$status = 'ok';
|
||||||
|
$message = 'Updated';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$status = 'error';
|
||||||
|
$message = 'ERROR: Could not update';
|
||||||
|
}
|
||||||
|
die(json_encode(array(
|
||||||
|
'status' => $status,
|
||||||
|
'message' => $message,
|
||||||
|
'notes' => $notes,
|
||||||
|
'device_id' => $device_id
|
||||||
|
)));
|
||||||
@@ -357,6 +357,12 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) {
|
|||||||
</a>
|
</a>
|
||||||
</li>';
|
</li>';
|
||||||
|
|
||||||
|
echo '<li class="'.$select['notes'].'">
|
||||||
|
<a href="'.generate_device_url($device, array('tab' => 'notes')).'">
|
||||||
|
<img src="images/16/page_white_text.png" align="absmiddle" border="0" /> Notes
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
|
||||||
|
|
||||||
echo '<li style="float: right;"><a href="https://'.$device['hostname'].'"><img src="images/16/http.png" alt="https" title="Launch browser to https://'.$device['hostname'].'" border="0" width="16" height="16" target="_blank"></a></li>
|
echo '<li style="float: right;"><a href="https://'.$device['hostname'].'"><img src="images/16/http.png" alt="https" title="Launch browser to https://'.$device['hostname'].'" border="0" width="16" height="16" target="_blank"></a></li>
|
||||||
<li style="float: right;"><a href="ssh://'.$device['hostname'].'"><img src="images/16/ssh.png" alt="ssh" title="SSH to '.$device['hostname'].'" border="0" width="16" height="16"></a></li>
|
<li style="float: right;"><a href="ssh://'.$device['hostname'].'"><img src="images/16/ssh.png" alt="ssh" title="SSH to '.$device['hostname'].'" border="0" width="16" height="16"></a></li>
|
||||||
|
|||||||
56
html/pages/device/notes.inc.php
Normal file
56
html/pages/device/notes.inc.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* LibreNMS
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$data = dbFetchRow("SELECT `notes` FROM `devices` WHERE device_id = ?", array(
|
||||||
|
$device['device_id']
|
||||||
|
));
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form class="form-horizontal" action="" method="post">
|
||||||
|
<h3>Device Notes</h3>
|
||||||
|
<hr>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<textarea class="form-control" rows="6" name="notes" id="device-notes"><?php
|
||||||
|
echo $data['notes']; ?></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<?php
|
||||||
|
echo '
|
||||||
|
<button type="submit" name="btn-update-notes" id="btn-update-notes" class="btn btn-primary" data-device_id="' . $device['device_id'] . '">Submit</button>
|
||||||
|
';
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
$("[name='btn-update-notes']").on('click', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
var $this = $(this);
|
||||||
|
var device_id = $(this).data("device_id");
|
||||||
|
var notes = $("#device-notes").val();
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: 'ajax_form.php',
|
||||||
|
data: { type: "update-notes", notes: notes, device_id: device_id},
|
||||||
|
dataType: "html",
|
||||||
|
success: function(data){
|
||||||
|
toastr.success('Saved');
|
||||||
|
},
|
||||||
|
error:function(){
|
||||||
|
toastr.error('Error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
1
sql-schema/072.sql
Normal file
1
sql-schema/072.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `devices` ADD COLUMN `notes` text;
|
||||||
Reference in New Issue
Block a user