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 '
{$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; } }