Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed BGP Remote peer link and graph in Routing Overview, or just static text when not a device in LibreNMS #15535

Conversation

tim427
Copy link
Contributor

@tim427 tim427 commented Oct 31, 2023

Replaced "overlibLink" with "deviceLink" and using the RemotePeer-device, instead of LocalPeer-device.

When the device isn't monitored by LibreNMS, then just a static text with the address is shown.

Screenshot 2023-10-31 at 21 14 15

DO NOT DELETE THE UNDERLYING TEXT

Please note

Please read this information carefully. You can run ./lnms dev:check to check your code before submitting.

  • Have you followed our code guidelines?
  • If my Pull Request does some changes/fixes/enhancements in the WebUI, I have inserted a screenshot of it.
  • If my Pull Request makes discovery/polling/yaml changes, I have added/updated test data.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

@PipoCanaja
Copy link
Contributor

Hi @tim427
As you jumped right into this page, would you try to move it to Laravel blades ?

@PipoCanaja
Copy link
Contributor

(that being said, I tested this PR and it looks better indeed) :)

$peeraddresslink = '<span class=list-large>' . \LibreNMS\Util\Url::overlibLink($overlib_link, $peer_addr, \LibreNMS\Util\Url::graphTag($graph_array_zoom)) . '</span>';
$peer_device = \App\Models\Device::whereHas('bgppeers', fn ($q) => $q->where('bgpLocalAddr', $peer['bgpPeerIdentifier']))->first();
if (! empty($peer_device)) {
$peeraddresslink = '<span class=list-large>' . \LibreNMS\Util\Url::deviceLink($peer_device, $peer_addr, vars: ['tab' => 'routing', 'proto' => 'bgp']) . '</span>';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, looking at deviceLink, I think it should return the second argument if the first is not a device.
Also, you don't need the name (vars:) for the third argument here. I only put it in last time so I could omit the second argument.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, hopefully I didn't break it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix/addition :)!

@murrant
Copy link
Member

murrant commented Nov 1, 2023

If we are interested in redoing this whole page. The SQL could be optimized a lot like this (basic query, and the peer relationship doesn't exist yet):

$bgpPeers = \App\Models\BgpPeers::with(['device', 'peer'])->get();

Another option would be to turn it into an ajax table so it works well if there are a large amount of peers.

…efault to ''

Import some of the things to improve readability.
murrant
murrant previously approved these changes Nov 2, 2023
@murrant murrant merged commit d5c6d0a into librenms:master Nov 2, 2023
8 checks passed
@tim427 tim427 deleted the remote-bgp-overview-peer-link-fix-or-static-text branch November 2, 2023 08:05
@murrant murrant added the WebUI label Nov 17, 2023
@librenms-bot
Copy link

This pull request has been mentioned on LibreNMS Community. There might be relevant details there:

https://community.librenms.org/t/23-11-0-changelog/22833/1

gdepeyrot pushed a commit to gdepeyrot/librenms that referenced this pull request Nov 29, 2023
…tic text when not a device in LibreNMS (librenms#15535)

* Fixed BGP Remote peer link and graph in Routing Overview, or just static text when not a device in LibreNMS

* Added extra space

* Reverted back to overlibLink (due to BGP update graphs on hover)

* Added extra space

* Remove graph for remote peer, as it is falsely (showed earlier the Updates Graph for local peer)

* Removed unnecessary/unused code

* Remove graph for remote peer, as it is falsely (showed earlier the Updates Graph for local peer), replaced with just a DeviceLinks

* Change Url::deviceLink to return $text if the device doesn't exist.  Default to ''
Import some of the things to improve readability.

* update phpdoc

---------

Co-authored-by: Tony Murray <murraytony@gmail.com>
gdepeyrot pushed a commit to gdepeyrot/librenms that referenced this pull request Nov 29, 2023
…tic text when not a device in LibreNMS (librenms#15535)

* Fixed BGP Remote peer link and graph in Routing Overview, or just static text when not a device in LibreNMS

* Added extra space

* Reverted back to overlibLink (due to BGP update graphs on hover)

* Added extra space

* Remove graph for remote peer, as it is falsely (showed earlier the Updates Graph for local peer)

* Removed unnecessary/unused code

* Remove graph for remote peer, as it is falsely (showed earlier the Updates Graph for local peer), replaced with just a DeviceLinks

* Change Url::deviceLink to return $text if the device doesn't exist.  Default to ''
Import some of the things to improve readability.

* update phpdoc

---------

Co-authored-by: Tony Murray <murraytony@gmail.com>
gunkaaa pushed a commit to gunkaaa/librenms that referenced this pull request Jan 8, 2024
…tic text when not a device in LibreNMS (librenms#15535)

* Fixed BGP Remote peer link and graph in Routing Overview, or just static text when not a device in LibreNMS

* Added extra space

* Reverted back to overlibLink (due to BGP update graphs on hover)

* Added extra space

* Remove graph for remote peer, as it is falsely (showed earlier the Updates Graph for local peer)

* Removed unnecessary/unused code

* Remove graph for remote peer, as it is falsely (showed earlier the Updates Graph for local peer), replaced with just a DeviceLinks

* Change Url::deviceLink to return $text if the device doesn't exist.  Default to ''
Import some of the things to improve readability.

* update phpdoc

---------

Co-authored-by: Tony Murray <murraytony@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants