diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:21:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:21:35 +0000 |
commit | 8adc969fb08ffab5f8e9e0b05b081046bdc2ad9a (patch) | |
tree | 555499bc0262c29210c706b44e0fb23c0ddd8b92 /library/Graphite/Web | |
parent | Adding debian version 1.2.2-3. (diff) | |
download | icingaweb2-module-graphite-8adc969fb08ffab5f8e9e0b05b081046bdc2ad9a.tar.xz icingaweb2-module-graphite-8adc969fb08ffab5f8e9e0b05b081046bdc2ad9a.zip |
Merging upstream version 1.2.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Graphite/Web')
5 files changed, 24 insertions, 73 deletions
diff --git a/library/Graphite/Web/Controller/IcingadbGraphiteController.php b/library/Graphite/Web/Controller/IcingadbGraphiteController.php index 36bc026..58c2382 100644 --- a/library/Graphite/Web/Controller/IcingadbGraphiteController.php +++ b/library/Graphite/Web/Controller/IcingadbGraphiteController.php @@ -28,8 +28,8 @@ class IcingadbGraphiteController extends CompatController /** @var bool Whether to use icingadb as the backend */ protected $useIcingadbAsBackend; - /** @var string[] Graph parameters */ - protected $graphParams = ['graphs_limit', 'graph_range', 'graph_start', 'graph_end', 'legacyParams']; + /** @var string[] Preserved graph parameters */ + protected $preservedParams = ['graphs_limit', 'graph_range', 'graph_start', 'graph_end', 'legacyParams', 'format']; /** @var Filter\Rule Filter from query string parameters */ private $filter; @@ -52,59 +52,4 @@ class IcingadbGraphiteController extends CompatController return $this->filter; } - - /** - * Create and return the LimitControl - * - * This automatically shifts the limit URL parameter from {@link $params}. - * - * @return LimitControl - */ - public function createLimitControl(): LimitControl - { - $limitControl = new LimitControl(Url::fromRequest()); - $limitControl->setDefaultLimit($this->getPageSize(null)); - - $this->params->shift($limitControl->getLimitParam()); - - return $limitControl; - } - - /** - * Create and return the PaginationControl - * - * This automatically shifts the pagination URL parameters from {@link $params}. - * - * @return PaginationControl - */ - public function createPaginationControl(Paginatable $paginatable): PaginationControl - { - $paginationControl = new PaginationControl($paginatable, Url::fromRequest()); - $paginationControl->setDefaultPageSize($this->getPageSize(null)); - $paginationControl->setAttribute('id', $this->getRequest()->protectId('pagination-control')); - - $this->params->shift($paginationControl->getPageParam()); - $this->params->shift($paginationControl->getPageSizeParam()); - - return $paginationControl->apply(); - } - - /** - * Create and return the SortControl - * - * This automatically shifts the sort URL parameter from {@link $params}. - * - * @param Query $query - * @param array $columns Possible sort columns as sort string-label pairs - * - * @return SortControl - */ - public function createSortControl(Query $query, array $columns): SortControl - { - $sortControl = SortControl::create($columns); - - $this->params->shift($sortControl->getSortParam()); - - return $sortControl->apply($query); - } } diff --git a/library/Graphite/Web/Controller/MonitoringAwareController.php b/library/Graphite/Web/Controller/MonitoringAwareController.php index dca2ebd..d4f1a07 100644 --- a/library/Graphite/Web/Controller/MonitoringAwareController.php +++ b/library/Graphite/Web/Controller/MonitoringAwareController.php @@ -22,6 +22,9 @@ abstract class MonitoringAwareController extends Controller /** @var bool Whether to use icingadb as the backend */ protected $useIcingadbAsBackend = false; + /** @var MonitoringBackend */ + protected $backend; + /** * Restrict the given monitored object query for the currently authenticated user * 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( |