Web\Table\Objects*: a couple of new tables

This commit is contained in:
Thomas Gelf 2017-06-16 13:52:53 +02:00
parent 70c0f2f21c
commit 311629bbd1
4 changed files with 145 additions and 0 deletions

View File

@ -0,0 +1,13 @@
<?php
namespace Icinga\Module\Director\Web\Table;
use Zend_Db_Select as ZfSelect;
class ObjectsTableApiUser extends ObjectsTable
{
protected function applyObjectTypeFilter(ZfSelect $query)
{
return $query->where("o.object_type IN ('object', 'external_object')");
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Icinga\Module\Director\Web\Table;
class ObjectsTableCommand extends ObjectsTable
{
// TODO: external commands? Notifications separately?
protected $searchColumns = [
'o.object_name',
'o.object_type',
'o.command',
];
protected $columns = [
'object_name' => 'o.object_name',
'command' => 'o.command',
];
protected $showColumns = [
'object_name' => 'Command',
'command' => 'Command line'
];
}

View File

@ -0,0 +1,82 @@
<?php
namespace Icinga\Module\Director\Web\Table;
use ipl\Html\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'),
);
}
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',
[]
);
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Icinga\Module\Director\Web\Table;
use Zend_Db_Select as ZfSelect;
class ObjectsTableHostTemplateChoice extends ObjectsTable
{
protected $columns = [
'object_name' => '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');
}
}