diff --git a/library/Graphite/ProvidedHook/Monitoring/DetailviewExtension.php b/library/Graphite/ProvidedHook/Monitoring/DetailviewExtension.php index 5c1613f2..fd851ff5 100644 --- a/library/Graphite/ProvidedHook/Monitoring/DetailviewExtension.php +++ b/library/Graphite/ProvidedHook/Monitoring/DetailviewExtension.php @@ -13,15 +13,16 @@ class DetailviewExtension extends DetailviewExtensionHook public function getHtmlForObject(MonitoredObject $object) { - $graphs = Graphs::forMonitoredObject($object) + $graphs = (string) Graphs::forMonitoredObject($object) ->setWidth(440) ->setHeight(220) ->setClasses(['monitored-object-detail-view']) ->setMaxVisibleGraphs(2) ->setPreloadDummy() + ->setShowNoGraphsFound(false) ->handleRequest(); - if ($graphs->hasGraphs()) { + if ($graphs !== '') { $this->handleTimeRangePickerRequest(); return '

' . mt('graphite', 'Graphs') . '

' . $this->renderTimeRangePicker($this->getView()) . $graphs; diff --git a/library/Graphite/Web/Controller/TimeRangePickerTrait.php b/library/Graphite/Web/Controller/TimeRangePickerTrait.php index 51e863cc..237582fc 100644 --- a/library/Graphite/Web/Controller/TimeRangePickerTrait.php +++ b/library/Graphite/Web/Controller/TimeRangePickerTrait.php @@ -45,7 +45,8 @@ protected function renderTimeRangePicker(View $view) { $url = Url::fromRequest()->getAbsoluteUrl(); - return $this->getTimeRangePickerCommonForm() + return '
' + . $this->getTimeRangePickerCommonForm() . '
' @@ -55,6 +56,7 @@ protected function renderTimeRangePicker(View $view) 'icon' => 'calendar' ]) . $this->getTimeRangePickerCustomForm()->setAttrib('class', 'flyover-content') + . '
' . '
'; } diff --git a/library/Graphite/Web/Widget/Graphs.php b/library/Graphite/Web/Widget/Graphs.php index c1db3fda..52f19ca3 100644 --- a/library/Graphite/Web/Widget/Graphs.php +++ b/library/Graphite/Web/Widget/Graphs.php @@ -100,6 +100,13 @@ abstract class Graphs extends AbstractWidget */ protected $preloadDummy = false; + /** + * Whether to explicitly display that no graphs were found + * + * @var bool|null + */ + protected $showNoGraphsFound; + /** * Cache for {@link getGraphsList()} * @@ -311,7 +318,7 @@ public function render() { $result = $this->getGraphsList(); - if ($result === '' && ! Config::module('graphite')->get('ui', 'disable_no_graphs_found')) { + if ($result === '' && $this->getShowNoGraphsFound()) { $view = $this->view(); return "

{$view->escape($view->translate('No graphs found'))}

"; } @@ -531,12 +538,30 @@ public function setPreloadDummy($preloadDummy = true) } /** - * Whether there are any graphs to display + * Get whether to explicitly display that no graphs were found * * @return bool */ - public function hasGraphs() + public function getShowNoGraphsFound() + { + if ($this->showNoGraphsFound === null) { + $this->showNoGraphsFound = ! Config::module('graphite')->get('ui', 'disable_no_graphs_found'); + } + + return $this->showNoGraphsFound; + } + + /** + * Set whether to explicitly display that no graphs were found + * + * @param bool $showNoGraphsFound + * + * @return $this + */ + public function setShowNoGraphsFound($showNoGraphsFound = true) { - return $this->getGraphsList() !== ''; + $this->showNoGraphsFound = $showNoGraphsFound; + + return $this; } }