mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-06-11 01:29:59 -04:00
Controller::createViewModeSwitcher(): Add param $viewModeSwitcherClass
Use the parameter to customize the type of ViewModeSwitcher used
This commit is contained in:
parent
2786e1d383
commit
4d2cd6c3d4
3 changed files with 16 additions and 27 deletions
|
|
@ -64,7 +64,11 @@ class HostsController extends Controller
|
|||
],
|
||||
['host.state.severity DESC', 'host.state.last_state_change DESC']
|
||||
);
|
||||
$viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl);
|
||||
$viewModeSwitcher = $this->createViewModeSwitcher(
|
||||
$paginationControl,
|
||||
$limitControl,
|
||||
viewModeSwitcherClass: TabularViewModeSwitcher::class
|
||||
);
|
||||
$columns = $this->createColumnControl($hosts, $viewModeSwitcher);
|
||||
|
||||
$searchBar = $this->createSearchBar($hosts, [
|
||||
|
|
@ -292,11 +296,6 @@ class HostsController extends Controller
|
|||
return new FeatureStatus('host', $summary->first());
|
||||
}
|
||||
|
||||
protected function getViewModeSwitcherInstance(): ViewModeSwitcher
|
||||
{
|
||||
return new TabularViewModeSwitcher();
|
||||
}
|
||||
|
||||
protected function getDefaultColumns(): string
|
||||
{
|
||||
return 'host.name, host.state.output';
|
||||
|
|
|
|||
|
|
@ -75,7 +75,11 @@ class ServicesController extends Controller
|
|||
],
|
||||
['service.state.severity DESC', 'service.state.last_state_change DESC']
|
||||
);
|
||||
$viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl);
|
||||
$viewModeSwitcher = $this->createViewModeSwitcher(
|
||||
$paginationControl,
|
||||
$limitControl,
|
||||
viewModeSwitcherClass: TabularViewModeSwitcher::class
|
||||
);
|
||||
$columns = $this->createColumnControl($services, $viewModeSwitcher);
|
||||
|
||||
$searchBar = $this->createSearchBar($services, [
|
||||
|
|
@ -461,11 +465,6 @@ class ServicesController extends Controller
|
|||
return new FeatureStatus('service', $summary->first());
|
||||
}
|
||||
|
||||
protected function getViewModeSwitcherInstance(): ViewModeSwitcher
|
||||
{
|
||||
return new TabularViewModeSwitcher();
|
||||
}
|
||||
|
||||
protected function prepareSearchFilter(Query $query, string $search, Filter\Any $filter, array $additionalColumns)
|
||||
{
|
||||
if ($this->params->shift('_hostFilterOnly', false)) {
|
||||
|
|
|
|||
|
|
@ -122,17 +122,19 @@ class Controller extends CompatController
|
|||
* This automatically shifts the view mode URL parameter from {@link $params}.
|
||||
*
|
||||
* @param PaginationControl $paginationControl
|
||||
* @param LimitControl $limitControl
|
||||
* @param bool $verticalPagination
|
||||
* @param LimitControl $limitControl
|
||||
* @param bool $verticalPagination
|
||||
* @param class-string<ViewModeSwitcher> $viewModeSwitcherClass
|
||||
*
|
||||
* @return ViewModeSwitcher|GridViewModeSwitcher
|
||||
*/
|
||||
public function createViewModeSwitcher(
|
||||
PaginationControl $paginationControl,
|
||||
LimitControl $limitControl,
|
||||
bool $verticalPagination = false
|
||||
bool $verticalPagination = false,
|
||||
string $viewModeSwitcherClass = ViewModeSwitcher::class
|
||||
): ViewModeSwitcher {
|
||||
$viewModeSwitcher = $this->getViewModeSwitcherInstance();
|
||||
$viewModeSwitcher = new $viewModeSwitcherClass();
|
||||
|
||||
$viewModeSwitcher->setIdProtector([$this->getRequest(), 'protectId']);
|
||||
|
||||
|
|
@ -259,17 +261,6 @@ class Controller extends CompatController
|
|||
return $viewModeSwitcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the view mode switcher for the current controller,
|
||||
* controllers that need special view mode switchers should override this method.
|
||||
*
|
||||
* @return ViewModeSwitcher
|
||||
*/
|
||||
protected function getViewModeSwitcherInstance(): ViewModeSwitcher
|
||||
{
|
||||
return new ViewModeSwitcher();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a search request
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue