Skip to content

Commit af5183e

Browse files
mdicssmartialblog
andcommitted
Update IcingaDbGrapher.php
Add Links to grafana to every panel. So you can open the panel in grafana even if more than one panel of a dashboard is shown in icinga. With the link added to the title, you only can open the first shown pane Co-authored-by: Markus Opolka <[email protected]>
1 parent aba0c33 commit af5183e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,17 @@ public function getPreviewHtml(Model $object, $report = false)
464464
$res = $this->getMyPreviewHtml($serviceName, $hostName, $previewHtml);
465465

466466
if ($res) {
467-
$html->addHtml($previewHtml);
467+
// Add Link to Panel if the user has the permission
468+
if ($this->permission->hasPermission('grafana/showlink')) {
469+
$linkUrl = $url;
470+
$linkUrl = preg_replace('/(viewPanel=)[^&]+/', '${1}' . $panelid, $linkUrl);
471+
$textLink = new Link('View in Grafana', $linkUrl, ['target' => '_blank', 'class' => 'external-link']);
472+
$html->add($textLink);
473+
$iconLink = new Link(new Icon('arrow-up-right-from-square', ['title' => 'View in Grafana']), $linkUrl, ['target' => '_blank', 'class' => 'external-link']);
474+
$html->add($iconLink);
475+
}
476+
477+
$html->addHtml($previewHtml);
468478
}
469479

470480
$returnHtml->add($html);

0 commit comments

Comments
 (0)