Skip to content
Merged
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
18 changes: 15 additions & 3 deletions application/controllers/IcingadbimgController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Icinga\Exception\ConfigurationError;
use Icinga\Module\Grafana\Helpers\Util;
use Icinga\Module\Icingadb\Model\CustomvarFlat;
use Icinga\Util\TimezoneDetect;

use ipl\Stdlib\Filter;
use ipl\Web\Url;
Expand Down Expand Up @@ -49,6 +50,8 @@ class IcingadbimgController extends IcingadbGrafanaController
protected $dashboarduid;
protected $panelId;
protected $orgId;
protected $detect;
protected $timezone;

/**
* Mainly loading defaults and the configuration.
Expand Down Expand Up @@ -99,8 +102,16 @@ public function init()
$this->defaultDashboardPanelId
);

$auth = Auth::getInstance();
if (! $auth->isAuthenticated()
|| ($timezone = $auth->getUser()->getPreferences()->getValue('icingaweb', 'timezone')) === null
) {
$this->detect = new TimezoneDetect();
$this->timezone = $this->detect->getTimezoneName();
}

$this->defaultOrgId = $this->myConfig->get('defaultorgid', $this->defaultOrgId);
$this->grafanaTheme = Util::getUserThemeMode(Auth::getInstance()->getUser(), $this->myConfig->get('theme', 'dark'));
$this->grafanaTheme = Util::getUserThemeMode($auth->getUser(), $this->myConfig->get('theme', 'dark'));
$this->height = $this->myConfig->get('height', $this->height);
$this->width = $this->myConfig->get('width', $this->width);
$this->proxyTimeout = $this->myConfig->get('proxytimeout', $this->proxyTimeout);
Expand Down Expand Up @@ -278,7 +289,7 @@ private function getMyimageHtml($serviceName, $hostName, &$imageHtml)

$pngUrl = sprintf(
'%s://%s/render/d-solo/%s/%s?var-hostname=%s&var-service=%s&var-command=%s%s&panelId=%s&orgId=%s&hideLogo=true'
. '&width=%s&height=%s&theme=%s&from=%s&to=%s',
. '&width=%s&height=%s&theme=%s&from=%s&to=%s&timezone=%s',
$this->protocol,
$this->grafanaHost,
$this->dashboarduid,
Expand All @@ -293,7 +304,8 @@ private function getMyimageHtml($serviceName, $hostName, &$imageHtml)
$this->height,
$this->grafanaTheme,
urlencode($this->timerange),
urlencode($this->timerangeto)
urlencode($this->timerangeto),
urlencode($this->timezone)
);

// fetch image with curl
Expand Down