Skip to content

Commit

Permalink
Merge branch 'bugfix/widget-error'
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Mar 21, 2018
2 parents 6caea7a + bfc6994 commit 9b4df63
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<h2>' . mt('graphite', 'Graphs') . '</h2>'
. $this->renderTimeRangePicker($this->getView()) . $graphs;
Expand Down
4 changes: 3 additions & 1 deletion library/Graphite/Web/Controller/TimeRangePickerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ protected function renderTimeRangePicker(View $view)
{
$url = Url::fromRequest()->getAbsoluteUrl();

return $this->getTimeRangePickerCommonForm()
return '<div>'
. $this->getTimeRangePickerCommonForm()
. '<div class="flyover flyover-arrow-top" id="'
. $view->protectId('graphite-customrange')
. '">'
Expand All @@ -55,6 +56,7 @@ protected function renderTimeRangePicker(View $view)
'icon' => 'calendar'
])
. $this->getTimeRangePickerCustomForm()->setAttrib('class', 'flyover-content')
. '</div>'
. '</div>';
}

Expand Down
33 changes: 29 additions & 4 deletions library/Graphite/Web/Widget/Graphs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
*
Expand Down Expand Up @@ -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 "<p>{$view->escape($view->translate('No graphs found'))}</p>";
}
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 9b4df63

Please sign in to comment.