icingaweb2-module-director/application/tables/IcingaEndpointTable.php

79 lines
2.0 KiB
PHP
Raw Normal View History

2015-06-01 17:26:09 +02:00
<?php
namespace Icinga\Module\Director\Tables;
use Icinga\Module\Director\Web\Table\IcingaObjectTable;
2015-06-01 17:26:09 +02:00
class IcingaEndpointTable extends IcingaObjectTable
2015-06-01 17:26:09 +02:00
{
protected $searchColumns = array(
'endpoint',
);
protected $deploymentEndpoint;
2015-06-01 17:26:09 +02:00
public function getColumns()
{
return array(
'id' => 'e.id',
'endpoint' => 'e.object_name',
'object_type' => 'e.object_type',
2016-02-26 11:58:37 +01:00
'host' => "(CASE WHEN e.host IS NULL THEN NULL ELSE"
. " CONCAT(e.host || ':' || COALESCE(e.port, 5665)) END)",
'zone' => 'z.object_name',
2015-06-01 17:26:09 +02:00
);
}
protected function listTableClasses()
{
return array_merge(array('endpoints'), parent::listTableClasses());
}
protected function getRowClasses($row)
{
if ($row->endpoint === $this->deploymentEndpoint) {
return array('deployment-endpoint', parent::getRowClasses($row));
}
return parent::getRowClasses($row);
}
2015-06-01 17:26:09 +02:00
protected function getActionUrl($row)
{
2015-07-02 14:31:35 +02:00
return $this->url('director/endpoint', array('name' => $row->endpoint));
2015-06-01 17:26:09 +02:00
}
public function getTitles()
{
$view = $this->view();
return array(
2015-06-02 17:36:47 +02:00
'endpoint' => $view->translate('Endpoint'),
2015-12-08 08:29:04 +01:00
'host' => $view->translate('Host'),
2015-06-02 17:36:47 +02:00
'zone' => $view->translate('Zone'),
2015-06-01 17:26:09 +02:00
);
}
public function getBaseQuery()
2015-06-01 17:26:09 +02:00
{
$db = $this->connection()->getConnection();
if ($this->deploymentEndpoint === null) {
$c = $this->connection();
if ($c->hasDeploymentEndpoint()) {
$this->deploymentEndpoint = $c->getDeploymentEndpointName();
}
}
2015-06-01 17:26:09 +02:00
$query = $db->select()->from(
array('e' => 'icinga_endpoint'),
array()
2015-06-01 17:26:09 +02:00
)->joinLeft(
array('z' => 'icinga_zone'),
'e.zone_id = z.id',
array()
);
return $query;
2015-06-01 17:26:09 +02:00
}
}