mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 17:44:41 +00:00
Firewall: Diagnostics: Aliases - simplify sort and add natural sorting. closes https://github.com/opnsense/core/pull/5716
This commit is contained in:
parent
6814f32755
commit
fcef2d65d2
@ -111,17 +111,6 @@ class AliasUtilController extends ApiControllerBase
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
$this->request->hasPost('sort') &&
|
||||
is_array($this->request->getPost('sort')) &&
|
||||
array_key_exists('ip', $this->request->getPost('sort')) &&
|
||||
$this->request->getPost('sort')['ip'] === 'desc'
|
||||
) {
|
||||
rsort($entry_keys);
|
||||
} else {
|
||||
sort($entry_keys);
|
||||
}
|
||||
|
||||
$formatted_full = array_map(function ($value) use (&$entries) {
|
||||
$item = ['ip' => $value];
|
||||
foreach ($entries[$value] as $ekey => $evalue) {
|
||||
@ -130,15 +119,16 @@ class AliasUtilController extends ApiControllerBase
|
||||
return $item;
|
||||
}, $entry_keys);
|
||||
|
||||
if (
|
||||
$this->request->hasPost('sort') &&
|
||||
is_array($this->request->getPost('sort')) &&
|
||||
!array_key_exists('ip', $this->request->getPost('sort'))
|
||||
) {
|
||||
if ($this->request->hasPost('sort') && is_array($this->request->getPost('sort'))) {
|
||||
$sortcolumn = array_key_first($this->request->getPost('sort'));
|
||||
$sort_order = $this->request->getPost('sort')[$sortcolumn];
|
||||
if (!empty(array_column($formatted_full, $sortcolumn))) {
|
||||
array_multisort(array_column($formatted_full, $sortcolumn), $sort_order == 'asc' ? SORT_ASC : SORT_DESC, $formatted_full);
|
||||
array_multisort(
|
||||
array_column($formatted_full, $sortcolumn),
|
||||
$sort_order == 'asc' ? SORT_ASC : SORT_DESC,
|
||||
SORT_NATURAL,
|
||||
$formatted_full
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user