From 9384d6cd43d4b1f799a72b830490f45acc792cea Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jun 2017 18:55:35 +0200 Subject: [PATCH] ServiceApplyRulesTable: we are a QueryBasedTable --- .../Web/Table/ServiceApplyRulesTable.php | 39 +++---------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/library/Director/Web/Table/ServiceApplyRulesTable.php b/library/Director/Web/Table/ServiceApplyRulesTable.php index 6b847449..aeae95c5 100644 --- a/library/Director/Web/Table/ServiceApplyRulesTable.php +++ b/library/Director/Web/Table/ServiceApplyRulesTable.php @@ -4,33 +4,19 @@ namespace Icinga\Module\Director\Web\Table; use Icinga\Data\Filter\Filter; use Icinga\Exception\IcingaException; -use Icinga\Module\Director\Db; use Icinga\Module\Director\IcingaConfig\AssignRenderer; -use Icinga\Web\Widget\Tabs; use ipl\Html\Icon; use ipl\Html\Link; use ipl\Html\Table; -use ipl\Translation\TranslationHelper; use ipl\Web\Url; -class ServiceApplyRulesTable extends Table +class ServiceApplyRulesTable extends QueryBasedTable { - use TranslationHelper; - - protected $defaultAttributes = [ - 'class' => ['simple', 'common-table', 'table-row-selectable'], - 'data-base-target' => '_next', + protected $searchColumns = [ + 's.object_name', + 's.assign_filter', ]; - private $db; - - public function __construct(Db $connection) - { - $this->db = $connection->getDbAdapter(); - $this->header(); - $this->fetchRows(); - } - public function getColumnsToBeRendered() { return ['Service Name', 'assign where', 'Actions']; @@ -99,21 +85,6 @@ class ServiceApplyRulesTable extends Table 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() { $columns = [ @@ -121,7 +92,7 @@ class ServiceApplyRulesTable extends Table 'service' => 's.object_name', 'assign_filter' => 's.assign_filter', ]; - $query = $this->db->select()->from( + $query = $this->db()->select()->from( ['s' => 'icinga_service'], $columns )->where(