mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-06-08 16:22:05 -04:00
Add ServiceItemTable::setColumnChooserUrl()
Use the setter to set the url for the ColumnChooser
This commit is contained in:
parent
e555d3c2d8
commit
1cd03462d8
5 changed files with 16 additions and 16 deletions
|
|
@ -114,7 +114,8 @@ class HostsController extends Controller
|
|||
$continueWith = $this->createContinueWith(Links::hostsDetails(), $searchBar, $results->hasResult());
|
||||
if ($viewModeSwitcher->getViewMode() === 'tabular') {
|
||||
$hostList = (new HostItemTable($results, HostItemTable::applyColumnMetaData($hosts, $columns)))
|
||||
->setSort($sortControl->getSort());
|
||||
->setSort($sortControl->getSort())
|
||||
->setColumnChooserUrl(Url::fromPath('icingadb/hosts/columnControl'));
|
||||
} else {
|
||||
$hostList = (new ObjectList($results))
|
||||
->setViewMode($viewModeSwitcher->getViewMode());
|
||||
|
|
|
|||
|
|
@ -127,7 +127,8 @@ class ServicesController extends Controller
|
|||
|
||||
if ($viewModeSwitcher->getViewMode() === 'tabular') {
|
||||
$serviceList = (new ServiceItemTable($results, ServiceItemTable::applyColumnMetaData($services, $columns)))
|
||||
->setSort($sortControl->getSort());
|
||||
->setSort($sortControl->getSort())
|
||||
->setColumnChooserUrl(Url::fromPath('icingadb/services/columnControl'));
|
||||
} else {
|
||||
$serviceList = (new ObjectList($results))
|
||||
->setViewMode($viewModeSwitcher->getViewMode());
|
||||
|
|
|
|||
|
|
@ -29,9 +29,4 @@ class HostItemTable extends StateItemTable
|
|||
{
|
||||
return 'host.state.severity';
|
||||
}
|
||||
|
||||
protected function getControllerPath(): string
|
||||
{
|
||||
return 'hosts';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,4 @@ class ServiceItemTable extends StateItemTable
|
|||
{
|
||||
return 'service.state.severity';
|
||||
}
|
||||
|
||||
protected function getControllerPath(): string
|
||||
{
|
||||
return 'services';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ abstract class StateItemTable extends BaseHtmlElement
|
|||
/** @var ?ValidHtml Message to show if the list is empty */
|
||||
protected $emptyStateMessage;
|
||||
|
||||
/** @var ?Url The url for the column chooser modal */
|
||||
protected ?Url $columnChooserUrl = null;
|
||||
|
||||
/**
|
||||
* Create a new item table
|
||||
*
|
||||
|
|
@ -127,12 +130,17 @@ abstract class StateItemTable extends BaseHtmlElement
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setColumnChooserUrl(Url $url): static
|
||||
{
|
||||
$this->columnChooserUrl = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
abstract protected function getItemClass(): string;
|
||||
|
||||
abstract protected function getVisualColumn(): string;
|
||||
|
||||
abstract protected function getControllerPath(): string;
|
||||
|
||||
protected function createColumnChooserOpener(): ValidHtml
|
||||
{
|
||||
return new HtmlElement(
|
||||
|
|
@ -140,7 +148,7 @@ abstract class StateItemTable extends BaseHtmlElement
|
|||
new Attributes(['class' => 'column-chooser-opener']),
|
||||
(new ActionLink(
|
||||
new Ball('xs'),
|
||||
Url::fromPath("icingadb/{$this->getControllerPath()}/columnControl")->setParam(
|
||||
$this->columnChooserUrl->setParam(
|
||||
'columns',
|
||||
implode(',', array_keys($this->columns))
|
||||
)
|
||||
|
|
@ -236,7 +244,7 @@ abstract class StateItemTable extends BaseHtmlElement
|
|||
$headerRow->addHtml($headerCell);
|
||||
}
|
||||
|
||||
if ($headerCell !== null) {
|
||||
if (! empty($this->columns) && $this->columnChooserUrl !== null) {
|
||||
$headerCell->addHtml($this->createColumnChooserOpener())
|
||||
->getAttribute('class')
|
||||
->addValue('last-th');
|
||||
|
|
|
|||
Loading…
Reference in a new issue