HostgroupMember: Add form, table, object and actions
This commit is contained in:
parent
87f1015262
commit
a4a97db6c3
|
@ -26,6 +26,17 @@ class Director_ListController extends ActionController
|
|||
$this->render('table');
|
||||
}
|
||||
|
||||
public function hostgroupmembersAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
$this->translate('Add Hostgroup Member'),
|
||||
'director/object/hostgroupmember'
|
||||
);
|
||||
$this->view->title = $this->translate('Icinga Hostgroup Members');
|
||||
$this->view->table = $this->loadTable('icingaHostgroupMember')->setConnection($this->db());
|
||||
$this->render('table');
|
||||
}
|
||||
|
||||
public function servicegroupsAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
|
|
|
@ -36,6 +36,29 @@ class Director_ObjectController extends ActionController
|
|||
$this->render('form');
|
||||
}
|
||||
|
||||
public function hostgroupmemberAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaHostgroupMember')
|
||||
->setDb($this->db())
|
||||
->setSuccessUrl('director/list/hostgroupmembers');
|
||||
|
||||
if (($host_id = $this->params->get('host_id'))
|
||||
&& ($hostgroup_id = $this->params->get('hostgroup_id'))) {
|
||||
|
||||
$this->view->form->loadObject(
|
||||
array(
|
||||
'host_id' => $host_id,
|
||||
'hostgroup_id' => $hostgroup_id,
|
||||
)
|
||||
);
|
||||
$this->view->title = $this->translate('Modify Icinga Hostgroup Member');
|
||||
} else {
|
||||
$this->view->title = $this->translate('Add new Icinga Hostgroup Member');
|
||||
}
|
||||
$this->view->form->handleRequest();
|
||||
$this->render('form');
|
||||
}
|
||||
|
||||
public function servicegroupAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaServicegroup')
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaHostgroupMemberForm extends DirectorObjectForm
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$this->addElement('select', 'hostgroup_id', array(
|
||||
'label' => $this->translate('Hostgroup'),
|
||||
'description' => $this->translate('The name of the hostgroup')
|
||||
));
|
||||
|
||||
$this->addElement('select', 'host_id', array(
|
||||
'label' => $this->translate('Host'),
|
||||
'description' => $this->translate('The name of the host')
|
||||
));
|
||||
|
||||
$this->addElement('submit', $this->translate('Store'));
|
||||
}
|
||||
}
|
|
@ -26,9 +26,9 @@ class IcingaCommandArgumentTable extends QuickTable
|
|||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
$view->translate('Command'),
|
||||
$view->translate('Argument'),
|
||||
$view->translate('Value'),
|
||||
'command' => $view->translate('Command'),
|
||||
'argument_name' => $view->translate('Argument'),
|
||||
'argument_value' => $view->translate('Value'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ class IcingaCommandTable extends QuickTable
|
|||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
$view->translate('Command'),
|
||||
$view->translate('Command line'),
|
||||
$view->translate('Zone'),
|
||||
'command' => $view->translate('Command'),
|
||||
'command_line' => $view->translate('Command line'),
|
||||
'zone' => $view->translate('Zone'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
|
||||
class IcingaHostgroupMemberTable extends QuickTable
|
||||
{
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'hostgroup_id' => 'hg.id',
|
||||
'host_id' => 'h.id',
|
||||
'hostgroup' => 'hg.object_name',
|
||||
'host' => 'h.object_name'
|
||||
);
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
return $this->url('director/object/hostgroupmember', array(
|
||||
'hostgroup_id' => $row->hostgroup_id,
|
||||
'host_id' => $row->host_id,
|
||||
));
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'hostgroup' => $view->translate('Hostgroup'),
|
||||
'host' => $view->translate('Member'),
|
||||
);
|
||||
}
|
||||
|
||||
public function fetchData()
|
||||
{
|
||||
$db = $this->connection()->getConnection();
|
||||
$query = $db->select()->from(
|
||||
array('hg' => 'icinga_hostgroup'),
|
||||
$this->getColumns()
|
||||
)->join(
|
||||
array('hgh' => 'icinga_hostgroup_host'),
|
||||
'hgh.hostgroup_id = hg.id',
|
||||
array()
|
||||
)->join(
|
||||
array('h' => 'icinga_host'),
|
||||
'hgh.host_id = h.id',
|
||||
array()
|
||||
);
|
||||
|
||||
return $db->fetchAll($query);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,8 @@ $section->add($this->translate('Hosts'))
|
|||
->setUrl('director/list/hosts');
|
||||
$section->add($this->translate('Hostgroups'))
|
||||
->setUrl('director/list/hostgroups');
|
||||
$section->add($this->translate('Hostgroup Members'))
|
||||
->setUrl('director/list/hostgroupmembers');
|
||||
$section->add($this->translate('Servicegroups'))
|
||||
->setUrl('director/list/servicegroups');
|
||||
$section->add($this->translate('Users'))
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Objects;
|
||||
|
||||
class IcingaHostgroupMember extends IcingaObject
|
||||
{
|
||||
protected $keyName = array('host_id', 'hostgroup_id');
|
||||
|
||||
protected $table = 'icinga_hostgroup_host';
|
||||
|
||||
protected $defaultProperties = array(
|
||||
'hostgroup_id' => null,
|
||||
'host_id' => null,
|
||||
);
|
||||
|
||||
public function onInsert()
|
||||
{
|
||||
}
|
||||
|
||||
public function onUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public function onDelete()
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue