mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-23 05:44:37 +02:00
HostgroupVars: Add form, table, object and actions
This commit is contained in:
parent
a4a97db6c3
commit
c61656c46c
@ -37,6 +37,17 @@ class Director_ListController extends ActionController
|
||||
$this->render('table');
|
||||
}
|
||||
|
||||
public function hostvarsAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
$this->translate('Add Host Variable'),
|
||||
'director/object/hostvar'
|
||||
);
|
||||
$this->view->title = $this->translate('Icinga Host Variables');
|
||||
$this->view->table = $this->loadTable('icingaHostVar')->setConnection($this->db());
|
||||
$this->render('table');
|
||||
}
|
||||
|
||||
public function servicegroupsAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
|
@ -36,6 +36,26 @@ class Director_ObjectController extends ActionController
|
||||
$this->render('form');
|
||||
}
|
||||
|
||||
public function hostvarAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaHostVar')
|
||||
->setDb($this->db())
|
||||
->setSuccessUrl('director/list/hostvars');
|
||||
|
||||
if (($host_id = $this->params->get('host_id'))
|
||||
&& ($varname = $this->params->get('varname'))) {
|
||||
$this->view->form->loadObject(array(
|
||||
'host_id' => $host_id,
|
||||
'varname' => $varname,
|
||||
));
|
||||
$this->view->title = $this->translate('Modify Icinga Host Variable');
|
||||
} else {
|
||||
$this->view->title = $this->translate('Add new Icinga Host Variable');
|
||||
}
|
||||
$this->view->form->handleRequest();
|
||||
$this->render('form');
|
||||
}
|
||||
|
||||
public function hostgroupmemberAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaHostgroupMember')
|
||||
|
35
application/forms/IcingaHostVarForm.php
Normal file
35
application/forms/IcingaHostVarForm.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaHostVarForm extends DirectorObjectForm
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
|
||||
$this->addElement('select', 'host_id', array(
|
||||
'label' => $this->translate('Host'),
|
||||
'description' => $this->translate('The name of the host'),
|
||||
'required' => true
|
||||
));
|
||||
|
||||
$this->addElement('text', 'varname', array(
|
||||
'label' => $this->translate('Name'),
|
||||
'description' => $this->translate('host var name')
|
||||
));
|
||||
|
||||
$this->addElement('textarea', 'varvalue', array(
|
||||
'label' => $this->translate('Value'),
|
||||
'description' => $this->translate('host var value')
|
||||
));
|
||||
|
||||
$this->addElement('text', 'format', array(
|
||||
'label' => $this->translate('Format'),
|
||||
'description' => $this->translate('value format')
|
||||
));
|
||||
|
||||
$this->addElement('submit', $this->translate('Store'));
|
||||
}
|
||||
}
|
52
application/tables/IcingaHostVarTable.php
Normal file
52
application/tables/IcingaHostVarTable.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
|
||||
class IcingaHostVarTable extends QuickTable
|
||||
{
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'host_id' => 'hv.host_id',
|
||||
'host' => 'h.object_name',
|
||||
'varname' => 'hv.varname',
|
||||
'varvalue' => 'hv.varvalue',
|
||||
'format' => 'hv.format',
|
||||
);
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
return $this->url('director/object/hostvar', array(
|
||||
'host_id' => $row->host_id,
|
||||
'varname' => $row->varname,
|
||||
));
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'host' => $view->translate('Host'),
|
||||
'varname' => $view->translate('Name'),
|
||||
'varvalue' => $view->translate('Value'),
|
||||
);
|
||||
}
|
||||
|
||||
public function fetchData()
|
||||
{
|
||||
$db = $this->connection()->getConnection();
|
||||
$query = $db->select()->from(
|
||||
array('hv' => 'icinga_host_var'),
|
||||
$this->getColumns()
|
||||
)->join(
|
||||
array('h' => 'icinga_host'),
|
||||
'hv.host_id = h.id',
|
||||
array()
|
||||
);
|
||||
|
||||
return $db->fetchAll($query);
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@ $section->add($this->translate('Hostgroups'))
|
||||
->setUrl('director/list/hostgroups');
|
||||
$section->add($this->translate('Hostgroup Members'))
|
||||
->setUrl('director/list/hostgroupmembers');
|
||||
$section->add($this->translate('Host Vars'))
|
||||
->setUrl('director/list/hostvars');
|
||||
$section->add($this->translate('Servicegroups'))
|
||||
->setUrl('director/list/servicegroups');
|
||||
$section->add($this->translate('Users'))
|
||||
|
29
library/Director/Objects/IcingaHostVar.php
Normal file
29
library/Director/Objects/IcingaHostVar.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Objects;
|
||||
|
||||
class IcingaHostVar extends IcingaObject
|
||||
{
|
||||
protected $keyName = array('host_id', 'varname');
|
||||
|
||||
protected $table = 'icinga_host_var';
|
||||
|
||||
protected $defaultProperties = array(
|
||||
'host_id' => null,
|
||||
'varname' => null,
|
||||
'varvalue' => null,
|
||||
'format' => null,
|
||||
);
|
||||
|
||||
public function onInsert()
|
||||
{
|
||||
}
|
||||
|
||||
public function onUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public function onDelete()
|
||||
{
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user