mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feat: Add sortorder parameter to list_logs (#14600)
This commit is contained in:
committed by
GitHub
parent
b807fd526b
commit
9826fa9089
@@ -33,6 +33,7 @@ Example:
|
||||
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/logs/eventlog/:hostname
|
||||
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/logs/syslog/:hostname?limit=20
|
||||
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/logs/eventlog/:hostname?limit=20&start=5&from=2017-07-22%2023:00:00
|
||||
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/logs/eventlog/:hostname?sortorder=DESC
|
||||
```
|
||||
|
||||
Output:
|
||||
|
@@ -2601,9 +2601,11 @@ function list_logs(Illuminate\Http\Request $request, Router $router)
|
||||
$param[] = $to;
|
||||
}
|
||||
|
||||
$sort_order = $request->get('sortorder') === 'DESC' ? 'DESC' : 'ASC';
|
||||
|
||||
$count_query = $count_query . $query;
|
||||
$count = dbFetchCell($count_query, $param);
|
||||
$full_query = $full_query . $query . " ORDER BY $timestamp ASC LIMIT $start,$limit";
|
||||
$full_query = $full_query . $query . " ORDER BY $timestamp $sort_order LIMIT $start,$limit";
|
||||
$logs = dbFetchRows($full_query, $param);
|
||||
|
||||
if ($type === 'list_alertlog') {
|
||||
|
Reference in New Issue
Block a user