From 171e15e95aa483fb7aa768e13880978da814f4ea Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 19 Jun 2017 14:54:43 +0200 Subject: [PATCH] ObjectsTableService: new variant for legacy table --- .../Web/Table/ObjectsTableService.php | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 library/Director/Web/Table/ObjectsTableService.php diff --git a/library/Director/Web/Table/ObjectsTableService.php b/library/Director/Web/Table/ObjectsTableService.php new file mode 100644 index 00000000..b3e34866 --- /dev/null +++ b/library/Director/Web/Table/ObjectsTableService.php @@ -0,0 +1,91 @@ + 'o.object_name', + 'disabled' => 'o.disabled', + 'host' => 'h.object_name', + 'host_disabled' => 'h.disabled', + 'id' => 'o.id', + ]; + } + protected function assemble() + { + $this->enableMultiSelect( + 'director/services/edit', + 'director/services', + ['name', 'host'] + ); + } + + public function filterTemplate( + IcingaService $template, + $inheritance = IcingaObjectFilterHelper::INHERIT_DIRECT + ) { + IcingaObjectFilterHelper::filterByTemplate( + $this->getQuery(), + $template, + 'o', + $inheritance + ); + + return $this; + } + + public function getColumnsToBeRendered() + { + return [ + 'host' => 'Host', + 'object_name' => 'Service Name' + ]; + } + + public function renderRow($row) + { + $url = Url::fromPath('director/service/edit', [ + 'name' => $row->object_name, + 'host' => $row->host, + 'id' => $row->id, + ]); + + $tr = static::tr([ + static::td(Link::create($row->host, $url)), + static::td($row->object_name) + ]); + + if ($row->host_disabled === 'y' || $row->disabled === 'y') { + $tr->attributes()->add('class', 'disabled'); + } + return $tr; + } + + public function prepareQuery() + { + return parent::prepareQuery()->join( + ['h' => 'icinga_host'], + "o.host_id = h.id AND h.object_type = 'object'", + [] + )->order('o.object_name')->order('h.object_name'); + } +}