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

Fix debugTable creation in iframe mode #45

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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