IcingaHostAppliedServicesTable: Fix assign rendering

This commit is contained in:
Markus Frosch 2019-05-06 14:28:57 +02:00
parent 4037e22709
commit 83245f2dd4

View File

@ -5,6 +5,8 @@ namespace Icinga\Module\Director\Web\Table;
use dipl\Html\Html; use dipl\Html\Html;
use Icinga\Data\DataArray\ArrayDatasource; use Icinga\Data\DataArray\ArrayDatasource;
use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\Filter;
use Icinga\Exception\IcingaException;
use Icinga\Module\Director\IcingaConfig\AssignRenderer;
use Icinga\Module\Director\Objects\HostApplyMatches; use Icinga\Module\Director\Objects\HostApplyMatches;
use Icinga\Module\Director\Objects\IcingaHost; use Icinga\Module\Director\Objects\IcingaHost;
use dipl\Html\Link; use dipl\Html\Link;
@ -97,9 +99,9 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable
} }
} else { } else {
$link = Link::create(sprintf( $link = Link::create(sprintf(
$this->translate('%s (where %s)'), $this->translate('%s (%s)'),
$row->name, $row->name,
$row->filter $this->renderApplyFilter($row->filter)
), 'director/host/appliedservice', [ ), 'director/host/appliedservice', [
'name' => $this->host->getObjectName(), 'name' => $this->host->getObjectName(),
'service_id' => $row->id, 'service_id' => $row->id,
@ -109,6 +111,22 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable
return $this::row([$link], $attributes); return $this::row([$link], $attributes);
} }
/**
* @param Filter $assignFilter
*
* @return string
*/
protected function renderApplyFilter(Filter $assignFilter)
{
try {
$string = AssignRenderer::forFilter($assignFilter)->renderAssign();
} catch (IcingaException $e) {
$string = 'Error in Filter rendering: ' . $e->getMessage();
}
return $string;
}
/** /**
* @return \Icinga\Data\SimpleQuery * @return \Icinga\Data\SimpleQuery
*/ */