Merge branch 'bugfix/respect-filter-in-state-links-in-group-overviews-10778'

fixes #10778
This commit is contained in:
Eric Lippmann 2016-02-27 16:28:32 +01:00
commit 16cc5e333a
5 changed files with 48 additions and 8 deletions

View File

@ -209,6 +209,7 @@ class Controller extends ModuleActionController
); );
$editor = Widget::create('filterEditor'); $editor = Widget::create('filterEditor');
/** @var \Icinga\Web\Widget\FilterEditor $editor */
call_user_func_array( call_user_func_array(
array($editor, 'preserveParams'), array($editor, 'preserveParams'),
array_merge($defaultPreservedParams, $preserveParams ?: array()) array_merge($defaultPreservedParams, $preserveParams ?: array())
@ -221,10 +222,12 @@ class Controller extends ModuleActionController
->setSearchColumns($searchColumns) ->setSearchColumns($searchColumns)
->handleRequest($this->getRequest()); ->handleRequest($this->getRequest());
if (! $this->view->compact) { if ($this->view->compact) {
$this->view->filterEditor = $editor; $editor->setVisible(false);
} }
$this->view->filterEditor = $editor;
return $this; return $this;
} }
} }

View File

@ -212,17 +212,18 @@ class Url
} }
/** /**
* Set the new Filter of the url to be the current filter and the given filter * Add the given filter to the current filter of the URL
* *
* @param Filter $and * @param Filter $and
*
* @return $this
*/ */
public function addFilter($and) public function addFilter($and)
{ {
$this->setQueryString( $this->setQueryString(
Filter::matchAll( Filter::fromQueryString($this->getQueryString())
$and, ->andFilter($and)
Filter::fromQueryString($this->getQueryString()) ->toQueryString()
)->toQueryString()
); );
return $this; return $this;
} }

View File

@ -55,6 +55,13 @@ class FilterEditor extends AbstractWidget
*/ */
private $selectedIdx; private $selectedIdx;
/**
* Whether the filter control is visible
*
* @var bool
*/
protected $visible = true;
/** /**
* Create a new FilterWidget * Create a new FilterWidget
* *
@ -144,6 +151,30 @@ class FilterEditor extends AbstractWidget
return $this; return $this;
} }
/**
* Get whether the filter control is visible
*
* @return bool
*/
public function isVisible()
{
return $this->visible;
}
/**
* Set whether the filter control is visible
*
* @param bool $visible
*
* @return $this
*/
public function setVisible($visible)
{
$this->visible = (bool) $visible;
return $this;
}
protected function redirectNow($url) protected function redirectNow($url)
{ {
$response = Icinga::app()->getFrontController()->getResponse(); $response = Icinga::app()->getFrontController()->getResponse();
@ -731,6 +762,9 @@ class FilterEditor extends AbstractWidget
public function render() public function render()
{ {
if (! $this->visible) {
return '';
}
if (! $this->preservedUrl()->getParam('modifyFilter')) { if (! $this->preservedUrl()->getParam('modifyFilter')) {
return '<div class="filter">' . $this->renderSearch() . $this->view()->escape($this->shorten($this->filter, 50)) . '</div>'; return '<div class="filter">' . $this->renderSearch() . $this->view()->escape($this->shorten($this->filter, 50)) . '</div>';
} }

View File

@ -50,6 +50,7 @@ if (! $this->compact): ?>
$stateBadges = new StateBadges(); $stateBadges = new StateBadges();
$stateBadges $stateBadges
->setUrl('monitoring/list/hosts') ->setUrl('monitoring/list/hosts')
->setBaseFilter($this->filterEditor->getFilter())
->add( ->add(
StateBadges::STATE_UP, StateBadges::STATE_UP,
$hostgroup->hosts_up, $hostgroup->hosts_up,

View File

@ -43,6 +43,7 @@ if (! $this->compact): ?>
$stateBadges = new StateBadges(); $stateBadges = new StateBadges();
$stateBadges $stateBadges
->setUrl('monitoring/list/services') ->setUrl('monitoring/list/services')
->setBaseFilter($this->filterEditor->getFilter())
->add( ->add(
StateBadges::STATE_OK, StateBadges::STATE_OK,
$serviceGroup->services_ok, $serviceGroup->services_ok,