Change port pagination default to 32 (#16131)

* Change port pagination default to 32
that way this includes all ports for most switches.
Most port counts are base 2, so change pagination options to match

* ignore upstream missing closure type

* Fix style again

* more
This commit is contained in:
Tony Murray
2024-06-17 09:09:33 -05:00
committed by GitHub
parent 097d4a3f94
commit 592ea1c263
3 changed files with 60 additions and 5 deletions

View File

@@ -41,7 +41,7 @@ use LibreNMS\Interfaces\UI\DeviceTab;
class PortsController implements DeviceTab class PortsController implements DeviceTab
{ {
private bool $detail = false; private bool $detail = false;
private int|string $perPage = 15; private int|string $perPage = 32;
private string $sortOrder = 'asc'; private string $sortOrder = 'asc';
private string $sortColumn = 'default'; private string $sortColumn = 'default';
@@ -116,7 +116,7 @@ class PortsController implements DeviceTab
/** @var Collection<Port>|LengthAwarePaginator<Port> $ports */ /** @var Collection<Port>|LengthAwarePaginator<Port> $ports */
$ports = $this->getFilteredPortsQuery($device, $request, $relationships) $ports = $this->getFilteredPortsQuery($device, $request, $relationships)
->paginate(fn ($total) => $this->perPage == 'all' ? $total : (int) $this->perPage) ->paginate(fn ($total) => $this->perPage == 'all' ? $total : (int) $this->perPage) // @phpstan-ignore-line missing closure type
->appends('perPage', $this->perPage); ->appends('perPage', $this->perPage);
$data = [ $data = [
@@ -332,7 +332,7 @@ class PortsController implements DeviceTab
private function getFilteredPortsQuery(Device $device, Request $request, array $relationships = []): Builder private function getFilteredPortsQuery(Device $device, Request $request, array $relationships = []): Builder
{ {
$this->perPage = $request->input('perPage', 15); $this->perPage = $request->input('perPage', 32);
$this->sortOrder = $request->input('order', 'asc'); $this->sortOrder = $request->input('order', 'asc');
$this->sortColumn = $request->input('sort', 'default'); $this->sortColumn = $request->input('sort', 'default');

View File

@@ -5214,6 +5214,62 @@
"default": true, "default": true,
"type": "boolean" "type": "boolean"
}, },
"ports_ui.default_sort": {
"order": 10,
"group": "webui",
"section": "ports",
"default": "ifIndex",
"type": "select",
"options": [
"ifIndex",
"mac",
"media",
"port",
"speed",
"traffic"
]
},
"ports_ui.show_disabled": {
"order": 50,
"group": "webui",
"section": "ports",
"default": false,
"type": "boolean"
},
"ports_ui.show_ignored": {
"order": 60,
"group": "webui",
"section": "ports",
"default": false,
"type": "boolean"
},
"ports_ui.filter_admin_status": {
"order": 70,
"group": "webui",
"section": "ports",
"default": "up",
"type": "select",
"options": [
"up",
"down",
"any"
]
},
"ports_ui.filter_oper_status": {
"order": 80,
"group": "webui",
"section": "ports",
"default": "up",
"type": "select",
"options": [
"up",
"down",
"notPresent",
"lowerLayerDown",
"unknown",
"any"
]
},
"port_descr_parser": { "port_descr_parser": {
"default": "includes/port-descr-parser.inc.php", "default": "includes/port-descr-parser.inc.php",
"type": "text" "type": "text"

View File

@@ -19,8 +19,7 @@
<div class="tw-flex tw-flex-row-reverse tw-m-3"> <div class="tw-flex tw-flex-row-reverse tw-m-3">
{{ $data['ports']->links('pagination::tailwind', ['perPage' => $data['perPage']]) }} {{ $data['ports']->links('pagination::tailwind', ['perPage' => $data['perPage']]) }}
@isset($data['perPage']) @isset($data['perPage'])
<x-select :options="['15', '25', '100', 'all']" <x-select :options="['16', '32', '128', 'all']"
{{-- location.herf = --}}
x-on:change=" x-on:change="
const params = new URLSearchParams(window.location.search); const params = new URLSearchParams(window.location.search);
params.set('perPage', $event.target.value); params.set('perPage', $event.target.value);