diff --git a/application/controllers/HistoryController.php b/application/controllers/HistoryController.php index 34b72714..b4fc6df2 100644 --- a/application/controllers/HistoryController.php +++ b/application/controllers/HistoryController.php @@ -13,6 +13,7 @@ use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher; use ipl\Stdlib\Filter; use ipl\Web\Control\LimitControl; use ipl\Web\Control\SortControl; +use ipl\Web\Filter\QueryString; use ipl\Web\Url; class HistoryController extends Controller @@ -22,6 +23,12 @@ class HistoryController extends Controller $this->addTitleTab(t('History')); $compact = $this->view->compact; // TODO: Find a less-legacy way.. + $preserveParams = [ + LimitControl::DEFAULT_LIMIT_PARAM, + SortControl::DEFAULT_SORT_PARAM, + ViewModeSwitcher::DEFAULT_VIEW_MODE_PARAM + ]; + $db = $this->getDb(); $history = History::on($db)->with([ @@ -38,7 +45,6 @@ class HistoryController extends Controller ]); $before = $this->params->shift('before', time()); - $url = Url::fromPath('icingadb/history')->setParams(clone $this->params); $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($history); @@ -49,11 +55,7 @@ class HistoryController extends Controller ] ); $viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl, true); - $searchBar = $this->createSearchBar($history, [ - $limitControl->getLimitParam(), - $sortControl->getSortParam(), - $viewModeSwitcher->getViewModeParam() - ]); + $searchBar = $this->createSearchBar($history, $preserveParams); if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) { if ($searchBar->hasBeenSubmitted()) { @@ -92,6 +94,9 @@ class HistoryController extends Controller $this->addControl($viewModeSwitcher); $this->addControl($searchBar); + $url = Url::fromRequest()->onlyWith($preserveParams); + $url->setQueryString(QueryString::render($filter) . '&' . $url->getParams()->toString()); + $historyList = (new HistoryList($history->execute())) ->setPageSize($limitControl->getLimit()) ->setViewMode($viewModeSwitcher->getViewMode()) diff --git a/application/controllers/NotificationsController.php b/application/controllers/NotificationsController.php index c0e2902c..1c8a5ff0 100644 --- a/application/controllers/NotificationsController.php +++ b/application/controllers/NotificationsController.php @@ -14,6 +14,7 @@ use ipl\Sql\Sql; use ipl\Stdlib\Filter; use ipl\Web\Control\LimitControl; use ipl\Web\Control\SortControl; +use ipl\Web\Filter\QueryString; use ipl\Web\Url; class NotificationsController extends Controller @@ -23,6 +24,12 @@ class NotificationsController extends Controller $this->addTitleTab(t('Notifications')); $compact = $this->view->compact; + $preserveParams = [ + LimitControl::DEFAULT_LIMIT_PARAM, + SortControl::DEFAULT_SORT_PARAM, + ViewModeSwitcher::DEFAULT_VIEW_MODE_PARAM + ]; + $db = $this->getDb(); $notifications = NotificationHistory::on($db)->with([ @@ -35,7 +42,6 @@ class NotificationsController extends Controller $this->handleSearchRequest($notifications); $before = $this->params->shift('before', time()); - $url = Url::fromPath('icingadb/notifications')->setParams(clone $this->params); $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($notifications); @@ -46,11 +52,7 @@ class NotificationsController extends Controller ] ); $viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl, true); - $searchBar = $this->createSearchBar($notifications, [ - $limitControl->getLimitParam(), - $sortControl->getSortParam(), - $viewModeSwitcher->getViewModeParam() - ]); + $searchBar = $this->createSearchBar($notifications, $preserveParams); if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) { if ($searchBar->hasBeenSubmitted()) { @@ -87,6 +89,9 @@ class NotificationsController extends Controller $this->addControl($viewModeSwitcher); $this->addControl($searchBar); + $url = Url::fromRequest()->onlyWith($preserveParams); + $url->setQueryString(QueryString::render($filter) . '&' . $url->getParams()->toString()); + $notificationList = (new NotificationList($notifications->execute())) ->setPageSize($limitControl->getLimit()) ->setViewMode($viewModeSwitcher->getViewMode())