From 33d323286e3f10e9ea9320eeb67d7a34d831f9eb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 20 Mar 2016 15:09:58 +0100 Subject: [PATCH] ObjectsController: introduce quick search --- .../Web/Controller/ObjectsController.php | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/library/Director/Web/Controller/ObjectsController.php b/library/Director/Web/Controller/ObjectsController.php index 55d041d0..7e828736 100644 --- a/library/Director/Web/Controller/ObjectsController.php +++ b/library/Director/Web/Controller/ObjectsController.php @@ -99,7 +99,59 @@ abstract class ObjectsController extends ActionController $this->view->title = $this->translate('Icinga ' . ucfirst($ltype) . 's'); $table = $this->loadTable($table)->setConnection($this->db()); - $this->view->filterEditor = $table->getFilterEditor($this->getRequest()); + $filterEditor = $table->getFilterEditor($this->getRequest()); + $filter = $filterEditor->getFilter(); + + if ($filter->isEmpty()) { + + if ($this->params->get('modifyFilter')) { + $this->view->addLink .= ' ' . $this->view->qlink( + $this->translate('Show unfiltered'), + $this->getRequest()->getUrl()->setParams(array()), + null, + array( + 'class' => 'icon-cancel', + 'data-base-target' => '_self', + ) + ); + } else { + $this->view->addLink .= ' ' . $this->view->qlink( + $this->translate('Filter'), + $this->getRequest()->getUrl()->with('modifyFilter', true), + null, + array( + 'class' => 'icon-search', + 'data-base-target' => '_self', + ) + ); + } + + } else { + + $this->view->addLink .= ' ' . $this->view->qlink( + $this->shorten($filter, 32), + $this->getRequest()->getUrl()->with('modifyFilter', true), + null, + array( + 'class' => 'icon-search', + 'data-base-target' => '_self', + ) + ); + + $this->view->addLink .= ' ' . $this->view->qlink( + $this->translate('Show unfiltered'), + $this->getRequest()->getUrl()->setParams(array()), + null, + array( + 'class' => 'icon-cancel', + 'data-base-target' => '_self', + ) + ); + } + + if ($this->params->get('modifyFilter')) { + $this->view->filterEditor = $filterEditor; + } if ($this->getRequest()->isApiRequest()) { $objects = array();