webui: Added Oxidized reload node list button (#8375)

This commit is contained in:
Søren Rosiak
2018-03-14 21:17:08 +01:00
committed by Neil Lathwood
parent 4da272f451
commit ba4c86f4c0
2 changed files with 46 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2018 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.
*/
if (is_admin() === false) {
$status = 'error';
$message = 'ERROR: You need to be admin to reload Oxidized node list';
} else {
oxidized_reload_nodes();
$status = 'ok';
$message = 'Oxdized node list was reloaded';
}
$output = array(
'status' => $status,
'message' => $message,
);
header('Content-type: application/json');
echo _json_encode($output);

View File

@@ -2,7 +2,7 @@
/*
* LibreNMS
*
* Copyright (c) 2017 Søren Friis Rosiak <sorenrosiak@gmail.com>
* Copyright (c) 2018 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
@@ -25,6 +25,7 @@ $pagetitle[] = 'Oxidized';
<div class="tab-content">
<div class="tab-pane fade in active" id="list">
<div class="table-responsive">
<button type='submit' class='btn btn-success btn-sm' name='btn-reload-nodes' id='btn-reload-nodes'><i class='fa fa-refresh'></i> Reload node list</button>
<table id="oxidized-nodes" class="table table-hover table-condensed table-striped">
<thead>
<tr>
@@ -87,4 +88,22 @@ $pagetitle[] = 'Oxidized';
}
});
});
$("[name='btn-reload-nodes']").on('click', function (event) {
$.ajax({
type: 'POST',
url: 'ajax_form.php',
data: { type: "reload-oxidized-nodes-list" },
dataType: "json",
success: function (data) {
if(data['status'] == 'ok') {
toastr.success(data['message']);
} else {
toastr.error(data['message']);
}
},
error:function(){
toastr.error('An error occured while reloading the Oxidized nodes list');
}
});
});
</script>