ServiceApplyRulesTable: we are a QueryBasedTable
This commit is contained in:
parent
02c015d163
commit
9384d6cd43
|
@ -4,33 +4,19 @@ namespace Icinga\Module\Director\Web\Table;
|
||||||
|
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Module\Director\Db;
|
|
||||||
use Icinga\Module\Director\IcingaConfig\AssignRenderer;
|
use Icinga\Module\Director\IcingaConfig\AssignRenderer;
|
||||||
use Icinga\Web\Widget\Tabs;
|
|
||||||
use ipl\Html\Icon;
|
use ipl\Html\Icon;
|
||||||
use ipl\Html\Link;
|
use ipl\Html\Link;
|
||||||
use ipl\Html\Table;
|
use ipl\Html\Table;
|
||||||
use ipl\Translation\TranslationHelper;
|
|
||||||
use ipl\Web\Url;
|
use ipl\Web\Url;
|
||||||
|
|
||||||
class ServiceApplyRulesTable extends Table
|
class ServiceApplyRulesTable extends QueryBasedTable
|
||||||
{
|
{
|
||||||
use TranslationHelper;
|
protected $searchColumns = [
|
||||||
|
's.object_name',
|
||||||
protected $defaultAttributes = [
|
's.assign_filter',
|
||||||
'class' => ['simple', 'common-table', 'table-row-selectable'],
|
|
||||||
'data-base-target' => '_next',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
private $db;
|
|
||||||
|
|
||||||
public function __construct(Db $connection)
|
|
||||||
{
|
|
||||||
$this->db = $connection->getDbAdapter();
|
|
||||||
$this->header();
|
|
||||||
$this->fetchRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getColumnsToBeRendered()
|
public function getColumnsToBeRendered()
|
||||||
{
|
{
|
||||||
return ['Service Name', 'assign where', 'Actions'];
|
return ['Service Name', 'assign where', 'Actions'];
|
||||||
|
@ -99,21 +85,6 @@ class ServiceApplyRulesTable extends Table
|
||||||
return $links;
|
return $links;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fetchRows()
|
|
||||||
{
|
|
||||||
$body = $this->body();
|
|
||||||
foreach ($this->fetch() as $row) {
|
|
||||||
$body->add($this->renderRow($row));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function fetch()
|
|
||||||
{
|
|
||||||
return $this->db->fetchAll(
|
|
||||||
$this->prepareQuery()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function prepareQuery()
|
public function prepareQuery()
|
||||||
{
|
{
|
||||||
$columns = [
|
$columns = [
|
||||||
|
@ -121,7 +92,7 @@ class ServiceApplyRulesTable extends Table
|
||||||
'service' => 's.object_name',
|
'service' => 's.object_name',
|
||||||
'assign_filter' => 's.assign_filter',
|
'assign_filter' => 's.assign_filter',
|
||||||
];
|
];
|
||||||
$query = $this->db->select()->from(
|
$query = $this->db()->select()->from(
|
||||||
['s' => 'icinga_service'],
|
['s' => 'icinga_service'],
|
||||||
$columns
|
$columns
|
||||||
)->where(
|
)->where(
|
||||||
|
|
Loading…
Reference in New Issue