mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 08:03:30 +02:00
Updated eventlog page to use page function
This commit is contained in:
+65
-20
@@ -8,20 +8,22 @@ if ($vars['action'] == "expunge" && $_SESSION['userlevel'] >= '10')
|
|||||||
print_message("Event log truncated");
|
print_message("Event log truncated");
|
||||||
}
|
}
|
||||||
|
|
||||||
$numresults = 250;
|
if(isset($_POST['results_amount']) && $_POST['results_amount'] > 0) {
|
||||||
|
$numresults = $_POST['results'];
|
||||||
|
} else {
|
||||||
|
$numresults = 250;
|
||||||
|
}
|
||||||
|
if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) {
|
||||||
|
$page_number = 1;
|
||||||
|
} else {
|
||||||
|
$page_number = $_POST['page_number'];
|
||||||
|
}
|
||||||
|
$start = ($page_number - 1) * $numresults;
|
||||||
|
|
||||||
$pagetitle[] = "Eventlog";
|
$pagetitle[] = "Eventlog";
|
||||||
|
|
||||||
print_optionbar_start();
|
print_optionbar_start();
|
||||||
|
|
||||||
if (is_numeric($vars['page']))
|
|
||||||
{
|
|
||||||
$start = $vars['page'] * $numresults;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
$start = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$where = "1";
|
$where = "1";
|
||||||
|
|
||||||
if (is_numeric($_POST['device']))
|
if (is_numeric($_POST['device']))
|
||||||
@@ -38,7 +40,7 @@ if ($_POST['string'])
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<form method="post" action="" class="form-inline" role="form">
|
<form method="post" action="" class="form-inline" role="form" id="result_form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" name="string" id="string" value="<?php echo($_POST['string']); ?>" placeholder="Search" class="form-control input-sm" />
|
<input type="text" name="string" id="string" value="<?php echo($_POST['string']); ?>" placeholder="Search" class="form-control input-sm" />
|
||||||
</div>
|
</div>
|
||||||
@@ -61,7 +63,6 @@ if ($_POST['string'])
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default input-sm">Search</button>
|
<button type="submit" class="btn btn-default input-sm">Search</button>
|
||||||
</form>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
@@ -69,24 +70,68 @@ print_optionbar_end();
|
|||||||
|
|
||||||
if ($_SESSION['userlevel'] >= '5')
|
if ($_SESSION['userlevel'] >= '5')
|
||||||
{
|
{
|
||||||
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` AS E WHERE $where ORDER BY `datetime` DESC LIMIT $start,$numresults";
|
$query = " FROM `eventlog` AS E WHERE $where ORDER BY `datetime` DESC";
|
||||||
} else {
|
} else {
|
||||||
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ? ORDER BY `datetime` DESC LIMIT $start,$numresults";
|
$query = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ? ORDER BY `datetime` DESC";
|
||||||
$param[] = $_SESSION['user_id'];
|
$param[] = $_SESSION['user_id'];
|
||||||
}
|
}
|
||||||
|
$count_query = "SELECT COUNT(datetime)";
|
||||||
|
$full_query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate";
|
||||||
|
$count_query = $count_query . $query;
|
||||||
|
$full_query = $full_query . $query . " LIMIT $start,$numresults";
|
||||||
|
|
||||||
echo('<div class="panel panel-default panel-condensed">
|
echo('<div class="panel panel-default panel-condensed">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<strong>Eventlog entries</strong>
|
<div class="row">
|
||||||
</div>
|
<div class="col-md-11">
|
||||||
|
<strong>Eventlog entries</strong>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-1">
|
||||||
|
<select name="results" id="results" class="form-control input-sm" onChange="updateResults(this);">');
|
||||||
|
$result_options = array('10','50','100','250','500','1000','5000');
|
||||||
|
foreach($result_options as $option) {
|
||||||
|
echo "<option value='$option'";
|
||||||
|
if($numresults == $option) {
|
||||||
|
echo " selected";
|
||||||
|
}
|
||||||
|
echo ">$option</option>";
|
||||||
|
}
|
||||||
|
echo('
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<table class="table table-hover table-condensed table-striped">');
|
<table class="table table-hover table-condensed table-striped">');
|
||||||
|
|
||||||
foreach (dbFetchRows($query, $param) as $entry)
|
$count = dbFetchCell($count_query,$param);
|
||||||
|
foreach (dbFetchRows($full_query, $param) as $entry)
|
||||||
{
|
{
|
||||||
include("includes/print-event.inc.php");
|
include("includes/print-event.inc.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo("</table>
|
if($count % $numresults > 0) {
|
||||||
</div>");
|
echo(' <tr>
|
||||||
|
<td colspan="6" align="center">'. generate_pagination($count,$numresults,$page_number) .'</td>
|
||||||
|
</tr>');
|
||||||
|
}
|
||||||
|
|
||||||
|
echo('</table>
|
||||||
|
<input type="hidden" name="page_number" id="page_number" value="'.$page_number.'">
|
||||||
|
<input type="hidden" name="results_amount" id="results_amount" value="'.$numresults.'">
|
||||||
|
</form>');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function updateResults(results) {
|
||||||
|
$('#results_amount').val(results.value);
|
||||||
|
$('#page_number').val(1);
|
||||||
|
$('#result_form').submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function changePage(page,e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$('#page_number').val(page);
|
||||||
|
$('#result_form').submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user