Endpoint: add table, form and object
This commit is contained in:
parent
39c53813e7
commit
b74d26808f
|
@ -48,6 +48,17 @@ class Director_ListController extends ActionController
|
|||
$this->render('table');
|
||||
}
|
||||
|
||||
public function endpointsAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
$this->translate('Add Endpoint'),
|
||||
'director/object/endpoint'
|
||||
);
|
||||
$this->view->title = $this->translate('Icinga Endpoints');
|
||||
$this->view->table = $this->loadTable('icingaEndpoint')->setConnection($this->db());
|
||||
$this->render('table');
|
||||
}
|
||||
|
||||
public function zonesAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
|
|
|
@ -68,6 +68,22 @@ class Director_ObjectController extends ActionController
|
|||
$this->render('form');
|
||||
}
|
||||
|
||||
public function endpointAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaEndpoint')
|
||||
->setDb($this->db())
|
||||
->setSuccessUrl('director/list/endpoints');
|
||||
|
||||
if ($id = $this->params->get('id')) {
|
||||
$this->view->form->loadObject($id);
|
||||
$this->view->title = $this->translate('Modify Icinga Endpoint');
|
||||
} else {
|
||||
$this->view->title = $this->translate('Add new Icinga Endpoint');
|
||||
}
|
||||
$this->view->form->handleRequest();
|
||||
$this->render('form');
|
||||
}
|
||||
|
||||
public function zoneAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaZone')
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaEndpointForm extends DirectorObjectForm
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$isTemplate = isset($_POST['object_type']) && $_POST['object_type'] === 'template';
|
||||
$this->addElement('select', 'object_type', array(
|
||||
'label' => $this->translate('Object type'),
|
||||
'description' => $this->translate('Whether this should be a template'),
|
||||
'multiOptions' => array(
|
||||
null => '- please choose -',
|
||||
'object' => 'Endpoint object',
|
||||
'template' => 'Endpoint template',
|
||||
)
|
||||
));
|
||||
|
||||
if ($isTemplate) {
|
||||
$this->addElement('text', 'object_name', array(
|
||||
'label' => $this->translate('Endpoint template name'),
|
||||
'required' => true,
|
||||
'description' => $this->translate('Name for the Icinga endpoint template you are going to create')
|
||||
));
|
||||
} else {
|
||||
$this->addElement('text', 'object_name', array(
|
||||
'label' => $this->translate('Endpoint'),
|
||||
'required' => true,
|
||||
'description' => $this->translate('Name for the Icinga endpoint you are going to create')
|
||||
));
|
||||
}
|
||||
|
||||
$this->addElement('text', 'address', array(
|
||||
'label' => $this->translate('Endpoint address'),
|
||||
'description' => $this->translate('IP address / hostname of remote node')
|
||||
));
|
||||
|
||||
$this->addElement('text', 'port', array(
|
||||
'label' => $this->translate('Port'),
|
||||
'description' => $this->translate('The port of the endpoint.'),
|
||||
));
|
||||
|
||||
$this->addElement('text', 'log_duration', array(
|
||||
'label' => $this->translate('Log Duration'),
|
||||
'description' => $this->translate('The log duration time.')
|
||||
));
|
||||
|
||||
$this->addElement('select', 'zone_id', array(
|
||||
'label' => $this->translate('Cluster Zone'),
|
||||
'description' => $this->translate('Check this host in this specific Icinga cluster zone')
|
||||
));
|
||||
|
||||
$this->addElement('submit', $this->translate('Store'));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
|
||||
class IcingaEndpointTable extends QuickTable
|
||||
{
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'id' => 'e.id',
|
||||
'endpoint' => 'e.object_name',
|
||||
'zone' => 'z.object_name',
|
||||
'address' => 'e.address',
|
||||
);
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
return $this->url('director/object/endpoint', array('id' => $row->id));
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'host' => $view->translate('Endpoint'),
|
||||
'address' => $view->translate('Address'),
|
||||
'zone' => $view->translate('Zone'),
|
||||
);
|
||||
}
|
||||
|
||||
public function fetchData()
|
||||
{
|
||||
$db = $this->connection()->getConnection();
|
||||
$query = $db->select()->from(
|
||||
array('e' => 'icinga_endpoint'),
|
||||
$this->getColumns()
|
||||
)->joinLeft(
|
||||
array('z' => 'icinga_zone'),
|
||||
'e.zone_id = z.id',
|
||||
array()
|
||||
);
|
||||
|
||||
return $db->fetchAll($query);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,8 @@ $section->add($this->translate('Hosts'))
|
|||
->setUrl('director/list/hosts');
|
||||
$section->add($this->translate('Users'))
|
||||
->setUrl('director/list/users');
|
||||
$section->add($this->translate('Endpoints'))
|
||||
->setUrl('director/list/endpoints');
|
||||
$section->add($this->translate('Activity Log'))
|
||||
->setUrl('director/list/activitylog')
|
||||
->setPriority(900);
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Objects;
|
||||
|
||||
class IcingaEndpoint extends IcingaObject
|
||||
{
|
||||
protected $table = 'icinga_endpoint';
|
||||
|
||||
protected $defaultProperties = array(
|
||||
'id' => null,
|
||||
'zone_id' => null,
|
||||
'object_name' => null,
|
||||
'address' => null,
|
||||
'port' => null,
|
||||
'log_duration' => null,
|
||||
'object_type' => null,
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue