addTitleTab(t('Tactical Overview')); $db = $this->getDb(); $hoststateSummary = HoststateSummary::on($db); $servicestateSummary = ServicestateSummary::on($db); $this->handleSearchRequest($servicestateSummary); $searchBar = $this->createSearchBar($servicestateSummary); if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) { if ($searchBar->hasBeenSubmitted()) { $filter = $this->getFilter(); } else { $this->addControl($searchBar); $this->sendMultipartUpdate(); return; } } else { $filter = $searchBar->getFilter(); } $this->filter($hoststateSummary, $filter); $this->filter($servicestateSummary, $filter); yield $this->export($hoststateSummary, $servicestateSummary); $this->addControl($searchBar); $this->addContent( (new HostSummaryDonut($hoststateSummary->first())) ->setBaseFilter($filter) ); $this->addContent( (new ServiceSummaryDonut($servicestateSummary->first())) ->setBaseFilter($filter) ); if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) { $this->sendMultipartUpdate(); } $this->setAutorefreshInterval(10); } public function completeAction() { $suggestions = new ObjectSuggestions(); $suggestions->setModel(ServicestateSummary::class); $suggestions->forRequest(ServerRequest::fromGlobals()); $this->getDocument()->add($suggestions); } public function searchEditorAction() { $editor = $this->createSearchEditor(ServicestateSummary::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')); } protected function prepareSearchFilter(Query $query, string $search, Filter\Any $filter) { parent::prepareSearchFilter($query, $search, $filter); $filter->add(Filter::like('host.name_ci', "*$search*")); } }