mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
VLANs global page, missing changes (#16484)
I had some additional changes that got missed in the main merge. They are included here. fix #16472
This commit is contained in:
@ -10,6 +10,15 @@ use LibreNMS\Util\Url;
|
||||
|
||||
class VlanPortsController extends TableController
|
||||
{
|
||||
protected function searchFields(Request $request): array
|
||||
{
|
||||
return [
|
||||
'ifName',
|
||||
'ifDescr',
|
||||
'ifAlias',
|
||||
];
|
||||
}
|
||||
|
||||
protected function sortFields($request): array
|
||||
{
|
||||
return [
|
||||
@ -31,7 +40,7 @@ class VlanPortsController extends TableController
|
||||
return Port::with('device')
|
||||
->leftJoin('ports_vlans', 'ports.port_id', 'ports_vlans.port_id')
|
||||
->where(function ($query) {
|
||||
$query->where('ifVlan', $this->vlanId)
|
||||
$query->where(fn ($q) => $q->where('ifVlan', $this->vlanId)->whereNull('ports_vlans.vlan'))
|
||||
->orWhere('ports_vlans.vlan', $this->vlanId);
|
||||
})
|
||||
->select([
|
||||
@ -58,7 +67,7 @@ class VlanPortsController extends TableController
|
||||
{
|
||||
return [
|
||||
'device' => Url::deviceLink($model->device),
|
||||
'port' => Url::portLink($model),
|
||||
'port' => Url::portLink($model, $model->getFullLabel()),
|
||||
// left joined columns
|
||||
'untagged' => $model['untagged'],
|
||||
'state' => $model['state'],
|
||||
|
@ -104,6 +104,20 @@ class Port extends DeviceRelatedModel
|
||||
return Rewrite::shortenIfName(Rewrite::normalizeIfName($this->ifName ?: $this->ifDescr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a label containing both the ifName and ifAlias if they differ.
|
||||
*/
|
||||
public function getFullLabel(): string
|
||||
{
|
||||
$label = $this->getLabel();
|
||||
|
||||
if ($label == $this->ifAlias || empty($this->ifAlias)) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
return "$label - $this->ifAlias";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description of this port
|
||||
*/
|
||||
|
Reference in New Issue
Block a user