mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added ability to sort alert schedules by status (#9257)
Signed-off-by: Rémy Jacquin <[email protected]>
This commit is contained in:
committed by
Neil Lathwood
parent
38e3250528
commit
4e8acdd894
@@ -31,7 +31,13 @@ if (empty($total)) {
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
if (!isset($sort) || empty($sort)) {
|
||||
if (isset($sort) && !empty($sort)) {
|
||||
list($sort_column, $sort_order) = explode(' ', trim($sort));
|
||||
if ($sort_column == 'status') {
|
||||
$sort_by_status = true;
|
||||
$sort = "`S`.`start` $sort_order";
|
||||
}
|
||||
} else {
|
||||
$sort = '`S`.`start` DESC ';
|
||||
}
|
||||
|
||||
@@ -108,6 +114,18 @@ foreach (dbFetchRows($sql, $param) as $schedule) {
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($sort_by_status) && $sort_by_status) {
|
||||
if ($sort_order == 'asc') {
|
||||
usort($response, function ($a, $b) {
|
||||
return $a['status'] - $b['status'];
|
||||
});
|
||||
} else {
|
||||
usort($response, function ($a, $b) {
|
||||
return $b['status'] - $a['status'];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$output = array(
|
||||
'current' => $current,
|
||||
'rowCount' => $rowCount,
|
||||
|
||||
@@ -43,7 +43,7 @@ if (LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
<th data-column-id="end_recurring_hr">End recurring hr</th>
|
||||
<th data-column-id="recurring_day" data-sortable="false" data-searchable="false">Recurring on days</th>
|
||||
<th data-column-id="actions" data-sortable="false" data-searchable="false" data-formatter="commands">Actions</th>
|
||||
<th data-column-id="status" data-sortable="false" data-searchable="false" data-formatter="schedstatus">Status</th>
|
||||
<th data-column-id="status" data-searchable="false" data-formatter="schedstatus">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user