Allow adding custom quick links to device navigation (#10403)

* Add Open-Audit link display device asset details

* Add an external link using the template method

* Add external system link setting.

* Update device.inc.php

* Update Customizing-the-Web-UI.md
This commit is contained in:
Jason Cheng
2019-08-21 03:49:59 +08:00
committed by Neil Lathwood
parent d6862b0e34
commit 49310dc693
2 changed files with 21 additions and 0 deletions

View File

@ -28,3 +28,18 @@ Example contents:
</ul>
</li>
```
## Custom device menu entry
You can add custom external links in the menu on the device page.
This feature allows you to easily link applications to related systems, as shown in the example of Open-audIT.
The Links value is parsed by Laravel Blade's templating engine so you can use Device variables such as `hostname`, `sysName` and more.
`config.php:`
```php
$config['html']['device']['links'][] = ['url' => 'http://atssrv/open-audit/index/devices/{{ $device[\'sysName\'] }}', 'title' => 'Open-AudIT'];
```

View File

@ -454,6 +454,12 @@ if (device_permitted($vars['device']) || $permitted_by_port) {
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="https://'.$device['hostname'].'" onclick="http_fallback(this); return false;" target="_blank" rel="noopener"><i class="fa fa-globe fa-lg icon-theme" aria-hidden="true"></i> Web</a></li>';
foreach (Config::get('html.device.links') as $links) {
$html_link = view(['template' => $links['url']], ['device' => $device])->__toString();
echo '<li><a href="'.$html_link.'" onclick="http_fallback(this); return false;" target="_blank" rel="noopener"><i class="fa fa-globe fa-lg icon-theme" aria-hidden="true"></i> '.$links['title'].'</a></li>';
}
if (Config::has('gateone.server')) {
if (Config::get('gateone.use_librenms_user') == true) {
echo '<li><a href="' . Config::get('gateone.server') . '?ssh=ssh://' . Auth::user()->username . '@' . $device['hostname'] . '&location=' . $device['hostname'] . '" target="_blank" rel="noopener"><i class="fa fa-lock fa-lg icon-theme" aria-hidden="true"></i> SSH</a></li>';