assertRouteAccess(); } public function indexAction() { $this->addTitleTab(t('Service Groups')); $compact = $this->view->compact; $db = $this->getDb(); $servicegroups = ServicegroupSummary::on($db); $this->handleSearchRequest($servicegroups); $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($servicegroups); $sortControl = $this->createSortControl( $servicegroups, [ 'display_name' => t('Name'), 'services_severity desc' => t('Severity'), 'services_total desc' => t('Total Services') ] ); $searchBar = $this->createSearchBar($servicegroups, [ $limitControl->getLimitParam(), $sortControl->getSortParam() ]); if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) { if ($searchBar->hasBeenSubmitted()) { $filter = $this->getFilter(); } else { $this->addControl($searchBar); $this->sendMultipartUpdate(); return; } } else { $filter = $searchBar->getFilter(); } $this->filter($servicegroups, $filter); $servicegroups->peekAhead($compact); yield $this->export($servicegroups); $this->addControl($paginationControl); $this->addControl($sortControl); $this->addControl($limitControl); $this->addControl($searchBar); $results = $servicegroups->execute(); $this->addContent( (new ServicegroupList($results))->setBaseFilter($filter) ); if ($compact) { $this->addContent( (new ShowMore($results, Url::fromRequest()->without(['showCompact', 'limit', 'view']))) ->setBaseTarget('_next') ->setAttribute('title', sprintf( t('Show all %d servicegroups'), $servicegroups->count() )) ); } if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) { $this->sendMultipartUpdate(); } $this->setAutorefreshInterval(30); } public function completeAction() { $suggestions = new ObjectSuggestions(); $suggestions->setModel(Servicegroup::class); $suggestions->forRequest(ServerRequest::fromGlobals()); $this->getDocument()->add($suggestions); } public function searchEditorAction() { $editor = $this->createSearchEditor(ServicegroupSummary::on($this->getDb()), [ LimitControl::DEFAULT_LIMIT_PARAM, SortControl::DEFAULT_SORT_PARAM, ViewModeSwitcher::DEFAULT_VIEW_MODE_PARAM ]); $this->getDocument()->add($editor); $this->setTitle(t('Adjust Filter')); } }