From a86efe1634642f2a41fb70a15063c81fb62f1d02 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Nov 2020 14:29:46 +0100 Subject: [PATCH] downtimes/: Show search bar control --- .../controllers/DowntimesController.php | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/application/controllers/DowntimesController.php b/application/controllers/DowntimesController.php index 0800455c..467df39f 100644 --- a/application/controllers/DowntimesController.php +++ b/application/controllers/DowntimesController.php @@ -4,8 +4,10 @@ namespace Icinga\Module\Icingadb\Controllers; +use GuzzleHttp\Psr7\ServerRequest; use Icinga\Module\Icingadb\Common\Links; use Icinga\Module\Icingadb\Model\Downtime; +use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\ContinueWith; use Icinga\Module\Icingadb\Widget\DowntimeList; @@ -35,6 +37,8 @@ class DowntimesController extends Controller 'service.state' ]); + $this->handleSearchRequest($downtimes); + $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($downtimes); $sortControl = $this->createSortControl( @@ -53,9 +57,13 @@ class DowntimesController extends Controller ] ); $viewModeSwitcher = $this->createViewModeSwitcher(); - $filterControl = $this->createFilterControl($downtimes); + $searchBar = $this->createSearchBar($downtimes, [ + $limitControl->getLimitParam(), + $sortControl->getSortParam(), + $viewModeSwitcher->getViewModeParam() + ]); - $this->filter($downtimes); + $this->filter($downtimes, $searchBar->getFilter()); $downtimes->peekAhead($compact); @@ -65,7 +73,7 @@ class DowntimesController extends Controller $this->addControl($sortControl); $this->addControl($limitControl); $this->addControl($viewModeSwitcher); - $this->addControl($filterControl); + $this->addControl($searchBar); $this->addControl(new ContinueWith($this->getFilter(), Links::downtimesDetails())); $results = $downtimes->execute(); @@ -83,6 +91,11 @@ class DowntimesController extends Controller ); } + if ($searchBar->hasBeenSent()) { + $viewModeSwitcher->setUrl($searchBar->getRedirectUrl()); + $this->sendMultipartUpdate($viewModeSwitcher); + } + $this->setAutorefreshInterval(10); } @@ -181,4 +194,12 @@ class DowntimesController extends Controller ] )); } + + public function completeAction() + { + $suggestions = new ObjectSuggestions(); + $suggestions->setModel(Downtime::class); + $suggestions->forRequest(ServerRequest::fromGlobals()); + $this->getDocument()->add($suggestions); + } }