From 311629bbd1ccea89802e508065fe80419a8c69a4 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 16 Jun 2017 13:52:53 +0200 Subject: [PATCH] Web\Table\Objects*: a couple of new tables --- .../Web/Table/ObjectsTableApiUser.php | 13 +++ .../Web/Table/ObjectsTableCommand.php | 23 ++++++ .../Web/Table/ObjectsTableEndpoint.php | 82 +++++++++++++++++++ .../Table/ObjectsTableHostTemplateChoice.php | 27 ++++++ 4 files changed, 145 insertions(+) create mode 100644 library/Director/Web/Table/ObjectsTableApiUser.php create mode 100644 library/Director/Web/Table/ObjectsTableCommand.php create mode 100644 library/Director/Web/Table/ObjectsTableEndpoint.php create mode 100644 library/Director/Web/Table/ObjectsTableHostTemplateChoice.php diff --git a/library/Director/Web/Table/ObjectsTableApiUser.php b/library/Director/Web/Table/ObjectsTableApiUser.php new file mode 100644 index 00000000..2ee929e5 --- /dev/null +++ b/library/Director/Web/Table/ObjectsTableApiUser.php @@ -0,0 +1,13 @@ +where("o.object_type IN ('object', 'external_object')"); + } +} diff --git a/library/Director/Web/Table/ObjectsTableCommand.php b/library/Director/Web/Table/ObjectsTableCommand.php new file mode 100644 index 00000000..bafcaecd --- /dev/null +++ b/library/Director/Web/Table/ObjectsTableCommand.php @@ -0,0 +1,23 @@ + 'o.object_name', + 'command' => 'o.command', + ]; + + protected $showColumns = [ + 'object_name' => 'Command', + 'command' => 'Command line' + ]; +} diff --git a/library/Director/Web/Table/ObjectsTableEndpoint.php b/library/Director/Web/Table/ObjectsTableEndpoint.php new file mode 100644 index 00000000..46136059 --- /dev/null +++ b/library/Director/Web/Table/ObjectsTableEndpoint.php @@ -0,0 +1,82 @@ + $this->translate('Endpoint'), + 'host' => $this->translate('Host'), + 'zone' => $this->translate('Zone'), + ); + } + + public function getColumns() + { + return [ + 'object_name' => 'o.object_name', + 'object_type' => 'o.object_type', + 'host' => "(CASE WHEN o.host IS NULL THEN NULL ELSE" + . " CONCAT(o.host || ':' || COALESCE(o.port, 5665)) END)", + 'zone' => 'z.object_name', + ]; + } + + protected function getMainLinkLabel($row) + { + if ($row->object_name === $this->deploymentEndpoint) { + return [ + $row->object_name, + ' ', + Icon::create('upload', [ + 'title' => $this->translate( + 'This is your Config master and will receive our Deployments' + ) + ]) + ]; + } else { + return $row->object_name; + } + } + + public function getRowClasses($row) + { + if ($row->object_name === $this->deploymentEndpoint) { + return array('deployment-endpoint', parent::getRowClasses($row)); + } else { + return null; + } + } + + protected function applyObjectTypeFilter(ZfSelect $query) + { + return $query->where("o.object_type IN ('object', 'external_object')"); + } + + public function prepareQuery() + { + if ($this->deploymentEndpoint === null) { + $c = $this->connection(); + if ($c->hasDeploymentEndpoint()) { + $this->deploymentEndpoint = $c->getDeploymentEndpointName(); + } + } + + return parent::prepareQuery()->joinLeft( + ['z' => 'icinga_zone'], + 'o.zone_id = z.id', + [] + ); + } +} diff --git a/library/Director/Web/Table/ObjectsTableHostTemplateChoice.php b/library/Director/Web/Table/ObjectsTableHostTemplateChoice.php new file mode 100644 index 00000000..fe5f4908 --- /dev/null +++ b/library/Director/Web/Table/ObjectsTableHostTemplateChoice.php @@ -0,0 +1,27 @@ + 'o.object_name', + 'templates' => 'GROUP_CONCAT(t.object_name)' + ]; + + protected function applyObjectTypeFilter(ZfSelect $query) + { + return $query; + } + + protected function prepareQuery() + { + return parent::prepareQuery()->joinLeft( + ['t' => 'icinga_host'], + 't.template_choice_id = o.id', + [] + )->group('o.id'); + } +}