diff options
Diffstat (limited to 'library/Graphite/Web/Widget')
-rw-r--r-- | library/Graphite/Web/Widget/GraphImage.php | 2 | ||||
-rw-r--r-- | library/Graphite/Web/Widget/Graphs.php | 20 | ||||
-rw-r--r-- | library/Graphite/Web/Widget/IcingadbGraphs.php | 13 |
3 files changed, 19 insertions, 16 deletions
diff --git a/library/Graphite/Web/Widget/GraphImage.php b/library/Graphite/Web/Widget/GraphImage.php index af64e69..e99bf09 100644 --- a/library/Graphite/Web/Widget/GraphImage.php +++ b/library/Graphite/Web/Widget/GraphImage.php @@ -126,7 +126,7 @@ class GraphImage extends AbstractWidget // Try to render a higher time range, but give up // once our default (1h) has been reached (non successfully). if ($diff < 3600) { - $url->setParam('from', $until - $diff * 2); + $url->setParam('from', sprintf('%F', ($until - $diff * 2))); continue; } } diff --git a/library/Graphite/Web/Widget/Graphs.php b/library/Graphite/Web/Widget/Graphs.php index e18b8da..e49a0eb 100644 --- a/library/Graphite/Web/Widget/Graphs.php +++ b/library/Graphite/Web/Widget/Graphs.php @@ -134,7 +134,7 @@ abstract class Graphs extends AbstractWidget * * @param MonitoredObject $object * - * @return static + * @return ?static */ public static function forMonitoredObject(MonitoredObject $object) { @@ -304,17 +304,17 @@ abstract class Graphs extends AbstractWidget $actheight = $this->height; } $actwidth = $this->width; - $actwidthfix = ""; + $explicitWidth = false; if (array_key_exists("width", $urlParams)) { $actwidth = $urlParams["width"]->resolve(['width']); - $actwidthfix = "width: {$actwidth}px; "; + $explicitWidth = $actwidth; } if ($this->renderInline) { $chart->setFrom($this->start) ->setUntil($this->end) - ->setWidth($actwidth) - ->setHeight($actheight) + ->setWidth((int) $actwidth) + ->setHeight((int) $actheight) ->setBackgroundColor('white') ->setForegroundColor('black') ->setMajorGridLineColor('grey') @@ -331,7 +331,7 @@ abstract class Graphs extends AbstractWidget ->setParam('height', $actheight); if (! $this->compact) { - $imageUrl->setParam('legend', 1); + $imageUrl->setParam('legend', '1'); } if ($this->preloadDummy) { @@ -344,8 +344,12 @@ abstract class Graphs extends AbstractWidget $img = '<img id="graphiteImg-' . md5((string) $imageUrl) . '"' . " src=\"$src\" data-actualimageurl=\"$imageUrl\" class=\"detach graphiteImg\"" - . " alt=\"\" width=\"$actwidth\" height=\"$actheight\"" - . " style=\"min-width: {$actwidth}px; $actwidthfix min-height: {$actheight}px;\">"; + . " alt=\"\" width=\"$actwidth\" height=\"$actheight\""; + if ($explicitWidth !== false) { + $img .= " data-width=\"$explicitWidth\""; + } + + $img .= '>'; } $currentGraphs[] = [$img, $metricVariables, $bestPos]; diff --git a/library/Graphite/Web/Widget/IcingadbGraphs.php b/library/Graphite/Web/Widget/IcingadbGraphs.php index e038e92..82bfe53 100644 --- a/library/Graphite/Web/Widget/IcingadbGraphs.php +++ b/library/Graphite/Web/Widget/IcingadbGraphs.php @@ -4,11 +4,9 @@ namespace Icinga\Module\Graphite\Web\Widget; -use Icinga\Data\Filter\Filter; use Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb\IcingadbHost; use Icinga\Module\Graphite\Web\Widget\Graphs\Icingadb\IcingadbService; use Icinga\Module\Icingadb\Common\Links; -use Icinga\Module\Icingadb\Widget\EmptyState; use Icinga\Module\Icingadb\Model\Host; use ipl\Html\BaseHtmlElement; use ipl\Html\Html; @@ -16,7 +14,7 @@ use ipl\Html\HtmlDocument; use ipl\Html\HtmlString; use ipl\Orm\ResultSet; use ipl\Stdlib\BaseFilter; -use ipl\Web\Filter\QueryString; +use ipl\Web\Widget\EmptyState; use ipl\Web\Widget\Link; /** @@ -69,9 +67,10 @@ class IcingadbGraphs extends BaseHtmlElement } $hostUrl = Links::host($hostObj); + $baseFilter = $this->getBaseFilter(); - if ($this->hasBaseFilter()) { - $hostUrl->addFilter(Filter::fromQueryString(QueryString::render($this->getBaseFilter()))); + if ($baseFilter !== null) { + $hostUrl->setFilter($baseFilter); } $hostLink = new Link( @@ -84,8 +83,8 @@ class IcingadbGraphs extends BaseHtmlElement if ($graph->getObjectType() === 'service') { $serviceUrl = Links::service($object, $hostObj); - if ($this->hasBaseFilter()) { - $serviceUrl->addFilter(Filter::fromQueryString(QueryString::render($this->getBaseFilter()))); + if ($baseFilter !== null) { + $serviceUrl->setFilter($baseFilter); } $serviceLink = new Link( |