mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
@@ -41,7 +41,7 @@ use LibreNMS\Interfaces\UI\DeviceTab;
|
||||
class PortsController implements DeviceTab
|
||||
{
|
||||
private bool $detail = false;
|
||||
private int $perPage = 15;
|
||||
private int|string $perPage = 15;
|
||||
private string $sortOrder = 'asc';
|
||||
private string $sortColumn = 'default';
|
||||
|
||||
@@ -68,7 +68,8 @@ class PortsController implements DeviceTab
|
||||
public function data(Device $device, Request $request): array
|
||||
{
|
||||
Validator::validate($request->all(), [
|
||||
'perPage' => 'int',
|
||||
'page' => 'int',
|
||||
'perPage' => ['regex:/^(\d+|all)$/'],
|
||||
'sort' => 'in:media,mac,port,traffic,speed',
|
||||
'order' => 'in:asc,desc',
|
||||
'disabled' => 'in:0,1',
|
||||
@@ -113,8 +114,10 @@ class PortsController implements DeviceTab
|
||||
$relationships[] = 'ipv6Networks.ipv6';
|
||||
}
|
||||
|
||||
/** @var Collection|LengthAwarePaginator<Port> $ports */
|
||||
$ports = $this->getFilteredPortsQuery($device, $request, $relationships)->paginate($this->perPage);
|
||||
/** @var Collection<Port>|LengthAwarePaginator<Port> $ports */
|
||||
$ports = $this->getFilteredPortsQuery($device, $request, $relationships)
|
||||
->paginate(fn ($total) => $this->perPage == 'all' ? $total : (int) $this->perPage)
|
||||
->appends('perPage', $this->perPage);
|
||||
|
||||
$data = [
|
||||
'ports' => $ports,
|
||||
|
@@ -19,14 +19,15 @@
|
||||
<div class="tw-flex tw-flex-row-reverse tw-m-3">
|
||||
{{ $data['ports']->links('pagination::tailwind', ['perPage' => $data['perPage']]) }}
|
||||
@isset($data['perPage'])
|
||||
<x-select :options="['10', '25', '100', 'all']"
|
||||
<x-select :options="['15', '25', '100', 'all']"
|
||||
{{-- location.herf = --}}
|
||||
x-on:change="
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
params.set('perPage', $event.target.value);
|
||||
params.delete('page');
|
||||
window.location.search = params.toString();
|
||||
" x-data="{}"
|
||||
:selected="$data['perPage']"
|
||||
selected="{{ $data['perPage'] }}"
|
||||
name="perPage"
|
||||
label="{{ __('Per Page') }}"
|
||||
class="tw-mx-4"></x-select>
|
||||
|
Reference in New Issue
Block a user