diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
commit | f66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/Web/Table/ObjectsTableEndpoint.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.tar.xz icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.zip |
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Director/Web/Table/ObjectsTableEndpoint.php')
-rw-r--r-- | library/Director/Web/Table/ObjectsTableEndpoint.php | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/library/Director/Web/Table/ObjectsTableEndpoint.php b/library/Director/Web/Table/ObjectsTableEndpoint.php new file mode 100644 index 0000000..f73b38b --- /dev/null +++ b/library/Director/Web/Table/ObjectsTableEndpoint.php @@ -0,0 +1,86 @@ +<?php + +namespace Icinga\Module\Director\Web\Table; + +use gipfl\IcingaWeb2\Icon; +use Zend_Db_Select as ZfSelect; + +class ObjectsTableEndpoint extends ObjectsTable +{ + protected $searchColumns = [ + 'o.object_name', + ]; + + protected $deploymentEndpoint; + + public function getColumnsToBeRendered() + { + return array( + 'object_name' => $this->translate('Endpoint'), + 'host' => $this->translate('Host'), + 'zone' => $this->translate('Zone'), + 'object_type' => $this->translate('Type'), + ); + } + + public function getColumns() + { + return [ + 'uuid' => 'o.uuid', + 'object_name' => 'o.object_name', + 'object_type' => 'o.object_type', + 'disabled' => 'o.disabled', + '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_merge(array('deployment-endpoint'), parent::getRowClasses($row)); + } else { + return null; + } + } + + protected function applyObjectTypeFilter(ZfSelect $query, ZfSelect $right = null) + { + return $query->where("o.object_type IN ('object', 'external_object')"); + } + + public function prepareQuery() + { + if ($this->deploymentEndpoint === null) { + /** @var \Icinga\Module\Director\Db $c */ + $c = $this->connection(); + if ($c->hasDeploymentEndpoint()) { + $this->deploymentEndpoint = $c->getDeploymentEndpointName(); + } + } + + return parent::prepareQuery()->joinLeft( + ['z' => 'icinga_zone'], + 'o.zone_id = z.id', + [] + ); + } +} |