mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Convert to device_attribs
This commit is contained in:
@@ -13,10 +13,11 @@
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
|
||||
$port_id = mres($_POST['port_id']);
|
||||
$notes = mres($_POST['notes']);
|
||||
$device_id = mres($_POST['device_id']);
|
||||
$port_id_notes = mres($_POST['port_id_notes']);
|
||||
$attrib_value = mres($_POST['notes']);
|
||||
|
||||
if (isset($notes) && (dbUpdate(array('notes' => $notes), 'ports', 'port_id = ?', array($port_id)))) {
|
||||
if (isset($attrib_value) && set_dev_attrib(array('device_id' => $device_id), $port_id_notes, $attrib_value)) {
|
||||
$status = 'ok';
|
||||
$message = 'Updated';
|
||||
}
|
||||
@@ -27,6 +28,8 @@ else {
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'notes' => $notes,
|
||||
'port_id' => $port_id
|
||||
'attrib_type' => $port_id_notes,
|
||||
'attrib_value' => $attrib_value,
|
||||
'device_id' => $device_id
|
||||
|
||||
)));
|
||||
|
@@ -10,9 +10,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
$pagetitle[] = 'Notes';
|
||||
$data = dbFetchRow("SELECT `notes` FROM `ports` WHERE port_id = ?", array(
|
||||
$port['port_id']
|
||||
));
|
||||
$port_id_notes = 'port_id_notes:' . $port['port_id'];
|
||||
$device_id = $device['device_id'];
|
||||
$data = get_dev_attrib($device,$port_id_notes);
|
||||
?>
|
||||
|
||||
<form class="form-horizontal" action="" method="post">
|
||||
@@ -21,14 +21,14 @@ $data = dbFetchRow("SELECT `notes` FROM `ports` WHERE port_id = ?", array(
|
||||
<div class="form-group">
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" rows="6" name="notes" id="port-notes"><?php
|
||||
echo htmlentities($data['notes']); ?></textarea>
|
||||
echo htmlentities($data); ?></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-port_id="' . $port['port_id'] . '">Submit</button>
|
||||
<button type="submit" name="btn-update-notes" id="btn-update-notes" class="btn btn-primary">Submit</button>
|
||||
';
|
||||
?>
|
||||
</div>
|
||||
@@ -38,12 +38,13 @@ echo '
|
||||
$("[name='btn-update-notes']").on('click', function(event) {
|
||||
event.preventDefault();
|
||||
var $this = $(this);
|
||||
var port_id = $(this).data("port_id");
|
||||
var device_id = "<?php echo $device_id; ?>";
|
||||
var port_id_notes = "<?php echo $port_id_notes; ?>";
|
||||
var notes = $("#port-notes").val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: { type: "update-port-notes", notes: notes, port_id: port_id},
|
||||
data: { type: "update-port-notes", notes: notes, port_id_notes: port_id_notes, device_id: device_id },
|
||||
dataType: "html",
|
||||
success: function(data){
|
||||
toastr.success('Saved');
|
||||
|
@@ -1 +0,0 @@
|
||||
ALTER TABLE `ports` ADD COLUMN `notes` text;
|
Reference in New Issue
Block a user