mirror of
https://github.com/Icinga/icingaweb2-module-graphite.git
synced 2026-05-28 04:34:57 -04:00
commit
3a98d2c473
6 changed files with 55 additions and 3 deletions
|
|
@ -112,7 +112,10 @@ class ListController extends MonitoringAwareController
|
|||
$dataView,
|
||||
null,
|
||||
null,
|
||||
array_merge(['format', 'stateType', 'addColumns', 'problems'], TimeRangePicker::getAllRangeParameters())
|
||||
array_merge(
|
||||
['format', 'stateType', 'addColumns', 'problems', 'graphs_limit'],
|
||||
TimeRangePicker::getAllRangeParameters()
|
||||
)
|
||||
);
|
||||
$this->handleFormatRequest($dataView);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
/** @var \Icinga\Application\Modules\MenuItemContainer $section */
|
||||
$section = $this->menuSection(N_('Graphite'), ['icon' => 'chart-area']);
|
||||
$section->add(N_('Hosts'), ['url' => 'graphite/list/hosts']);
|
||||
$section->add(N_('Services'), ['url' => 'graphite/list/services']);
|
||||
$section->add(N_('Hosts'), ['url' => 'graphite/list/hosts?graphs_limit=2']);
|
||||
$section->add(N_('Services'), ['url' => 'graphite/list/services?graphs_limit=2']);
|
||||
|
||||
$this->provideConfigTab('backend', array(
|
||||
'title' => $this->translate('Configure the Graphite Web backend'),
|
||||
|
|
|
|||
|
|
@ -297,6 +297,33 @@ abstract class Graphs extends AbstractWidget
|
|||
}
|
||||
unset($graph);
|
||||
|
||||
$currentUrl = Icinga::app()->getRequest()->getUrl();
|
||||
$limit = (int) $currentUrl->getParam('graphs_limit', 50);
|
||||
$total = count($result);
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = -1;
|
||||
}
|
||||
|
||||
if ($limit !== -1 && $total > $limit) {
|
||||
$result = array_slice($result, 0, $limit);
|
||||
|
||||
if (! $this->compact) {
|
||||
/** @var View $view */
|
||||
$view = $this->view();
|
||||
|
||||
$url = $this->getGraphsListBaseUrl();
|
||||
TimeRangePickerTrait::copyAllRangeParameters($url->getParams(), $currentUrl->getParams());
|
||||
|
||||
$result[] = "<p class='load-more'>{$view->qlink(
|
||||
sprintf($view->translate('Load all %d graphs'), $total),
|
||||
$url->setParam('graphs_limit', '-1'),
|
||||
null,
|
||||
['class' => 'action-link']
|
||||
)}</p>";
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->maxVisibleGraphs && count($result) > $this->maxVisibleGraphs) {
|
||||
/** @var View $view */
|
||||
$view = $this->view();
|
||||
|
|
@ -412,6 +439,13 @@ abstract class Graphs extends AbstractWidget
|
|||
*/
|
||||
abstract protected function getDummyImageBaseUrl();
|
||||
|
||||
/**
|
||||
* Get the base URL to the monitored object's graphs list
|
||||
*
|
||||
* @return Url
|
||||
*/
|
||||
abstract protected function getGraphsListBaseUrl();
|
||||
|
||||
/**
|
||||
* Extend the {@link getImageBaseUrl()}'s result's parameters with the concrete monitored object
|
||||
*
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ class Host extends Graphs
|
|||
return Url::fromPath('graphite/graph-dummy/host');
|
||||
}
|
||||
|
||||
protected function getGraphsListBaseUrl()
|
||||
{
|
||||
return Url::fromPath('graphite/list/hosts', ['host' => $this->host]);
|
||||
}
|
||||
|
||||
protected function filterImageUrl(Url $url)
|
||||
{
|
||||
return $url->setParam('host.name', $this->host);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,11 @@ class Service extends Graphs
|
|||
return Url::fromPath('graphite/graph-dummy/service');
|
||||
}
|
||||
|
||||
protected function getGraphsListBaseUrl()
|
||||
{
|
||||
return Url::fromPath('graphite/list/services', ['host' => $this->host, 'service' => $this->service]);
|
||||
}
|
||||
|
||||
protected function filterImageUrl(Url $url)
|
||||
{
|
||||
return $url->setParam('host.name', $this->host)->setParam('service.name', $this->service);
|
||||
|
|
|
|||
|
|
@ -114,3 +114,8 @@ form[name=form_timerangepickercustom_graphite] {
|
|||
padding: .5em;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
p.load-more {
|
||||
margin-right: 1em;
|
||||
text-align: right;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue