Skip to content

Commit

Permalink
Merge pull request #45 from NETWAYS/fix/debugtable
Browse files Browse the repository at this point in the history
Fix debugTable creation in iframe mode
  • Loading branch information
martialblog authored Jan 20, 2025
2 parents 677fada + 8ca93fa commit a923832
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ It now uses the check interval to determine how long a graph's image is cached.
- PHP 8.2 and PHP 8.3 Support
- Support strict CSP
- Dark/Light Theme depending on user's settings (removed the `theme` configuration option)
- Debug information can be requested via the `debugGrafana` URL parameter (removed the `debug` configuration option)
- Debug information can be requested via the `grafanaDebug` URL parameter (removed the `debug` configuration option)

**Fixes**
- Use of special characters in custom variables now works
Expand Down
2 changes: 2 additions & 0 deletions doc/03-module-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ ssl_verifypeer = "0"
ssl_verifyhost = "0"
```

Hint: to display debug information for graphs you can use the URL parameter `&grafanaDebug`. This requires the `grafana/debug` permission.

## Available Options

|Setting | Short description|
Expand Down
11 changes: 4 additions & 7 deletions library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public function getPreviewHtml(Model $object, $report = false)
// Add a data table with runtime information and configuration for debugging purposes
if (Url::fromRequest()->hasParam('grafanaDebug') && $this->permission->hasPermission('grafana/debug') && $report === false) {
$returnHtml->addHtml(HtmlElement::create('h2', null, 'Performance Graph Debug'));
$returnHtml->add($this->createDebugTable());
$returnHtml->add($this->createDebugTable($previewHtml));
}

$htmlForObject = HtmlElement::create("div", ["class" => "icinga-module module-grafana"]);
Expand All @@ -486,15 +486,12 @@ public function getPreviewHtml(Model $object, $report = false)
/**
* createDebugTable creates a data table with runtime information and configuration for debugging purposes
*/
private function createDebugTable()
private function createDebugTable($previewHtml)
{
if ($this->accessMode === 'indirectproxy') {
$usedUrl = $this->pngUrl;
} else {
$usedUrl = preg_replace('/.*?src\s*=\s*[\'\"](.*?)[\'\"].*/', "$1", $previewHtml);
}
$usedUrl = $this->pngUrl;

if ($this->accessMode === 'iframe') {
$usedUrl = preg_replace('/.*?src\s*=\s*[\'\"](.*?)[\'\"].*/', "$1", $previewHtml);
$this->height = '100%';
}

Expand Down

0 comments on commit a923832

Please sign in to comment.