mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix ports display (#14183)
* Fix ports with deleted device breaking all ports display * Only filter callable based filters when required
This commit is contained in:
@@ -146,9 +146,18 @@ abstract class PaginatedAjaxController extends Controller
|
||||
protected function filter($request, $query, $fields)
|
||||
{
|
||||
foreach ($fields as $target => $field) {
|
||||
if (is_callable($field)) {
|
||||
$field($query, $request->get($target));
|
||||
} elseif (($value = $request->get($field)) !== null) {
|
||||
$callable = is_callable($field);
|
||||
$value = $request->get($callable ? $target : $field);
|
||||
|
||||
// unfiltered field
|
||||
if ($value === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// apply the filter
|
||||
if ($callable) {
|
||||
$field($query, $value);
|
||||
} else {
|
||||
$value = $this->adjustFilterValue($field, $value);
|
||||
if (is_string($target)) {
|
||||
$query->where($target, $value);
|
||||
|
@@ -155,7 +155,7 @@ class PortsController extends TableController
|
||||
'status' => $status,
|
||||
'device' => Url::deviceLink($port->device),
|
||||
'port' => Url::portLink($port),
|
||||
'secondsIfLastChange' => ceil($port->device->uptime - ($port->ifLastChange / 100)),
|
||||
'secondsIfLastChange' => ceil(optional($port->device)->uptime - ($port->ifLastChange / 100)),
|
||||
'ifConnectorPresent' => ($port->ifConnectorPresent == 'true') ? 'yes' : 'no',
|
||||
'ifSpeed' => $port->ifSpeed,
|
||||
'ifMtu' => $port->ifMtu,
|
||||
|
Reference in New Issue
Block a user