mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-14 01:14:24 +02:00
ServiceVars: Add form, table, object and actions
This commit is contained in:
parent
5412254d83
commit
db8059c4b7
@ -92,6 +92,17 @@ class Director_ListController extends ActionController
|
||||
$this->render('table');
|
||||
}
|
||||
|
||||
public function servicevarsAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
$this->translate('Add Service Variable'),
|
||||
'director/object/servicevar'
|
||||
);
|
||||
$this->view->title = $this->translate('Icinga Service Variables');
|
||||
$this->view->table = $this->loadTable('icingaServiceVar')->setConnection($this->db());
|
||||
$this->render('table');
|
||||
}
|
||||
|
||||
public function commandsAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
|
@ -134,6 +134,26 @@ class Director_ObjectController extends ActionController
|
||||
$this->render('form');
|
||||
}
|
||||
|
||||
public function servicevarAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaServiceVar')
|
||||
->setDb($this->db())
|
||||
->setSuccessUrl('director/list/servicevars');
|
||||
|
||||
if (($host_id = $this->params->get('service_id'))
|
||||
&& ($varname = $this->params->get('varname'))) {
|
||||
$this->view->form->loadObject(array(
|
||||
'service_id' => $host_id,
|
||||
'varname' => $varname,
|
||||
));
|
||||
$this->view->title = $this->translate('Modify Icinga Service Variable');
|
||||
} else {
|
||||
$this->view->title = $this->translate('Add new Icinga Service Variable');
|
||||
}
|
||||
$this->view->form->handleRequest();
|
||||
$this->render('form');
|
||||
}
|
||||
|
||||
public function commandAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaCommand')
|
||||
|
34
application/forms/IcingaServiceVarForm.php
Normal file
34
application/forms/IcingaServiceVarForm.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaServiceVarForm extends DirectorObjectForm
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$this->addElement('select', 'service_id', array(
|
||||
'label' => $this->translate('Service'),
|
||||
'description' => $this->translate('The name of the service'),
|
||||
'required' => true
|
||||
));
|
||||
|
||||
$this->addElement('text', 'varname', array(
|
||||
'label' => $this->translate('Name'),
|
||||
'description' => $this->translate('service var name')
|
||||
));
|
||||
|
||||
$this->addElement('textarea', 'varvalue', array(
|
||||
'label' => $this->translate('Value'),
|
||||
'description' => $this->translate('service 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/IcingaServiceVarTable.php
Normal file
52
application/tables/IcingaServiceVarTable.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
|
||||
class IcingaServiceVarTable extends QuickTable
|
||||
{
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'service_id' => 'sv.service_id',
|
||||
'service' => 'h.object_name',
|
||||
'varname' => 'sv.varname',
|
||||
'varvalue' => 'sv.varvalue',
|
||||
'format' => 'sv.format',
|
||||
);
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
return $this->url('director/object/servicevar', array(
|
||||
'service_id' => $row->service_id,
|
||||
'varname' => $row->varname,
|
||||
));
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'service' => $view->translate('Service'),
|
||||
'varname' => $view->translate('Name'),
|
||||
'varvalue' => $view->translate('Value'),
|
||||
);
|
||||
}
|
||||
|
||||
public function fetchData()
|
||||
{
|
||||
$db = $this->connection()->getConnection();
|
||||
$query = $db->select()->from(
|
||||
array('sv' => 'icinga_service_var'),
|
||||
$this->getColumns()
|
||||
)->join(
|
||||
array('h' => 'icinga_service'),
|
||||
'sv.service_id = h.id',
|
||||
array()
|
||||
);
|
||||
|
||||
return $db->fetchAll($query);
|
||||
}
|
||||
}
|
@ -31,6 +31,8 @@ $section->add($this->translate('Servicegroups'))
|
||||
->setUrl('director/list/servicegroups');
|
||||
$section->add($this->translate('Serviceroup Members'))
|
||||
->setUrl('director/list/servicegroupmembers');
|
||||
$section->add($this->translate('Service Vars'))
|
||||
->setUrl('director/list/servicevars');
|
||||
|
||||
// USER
|
||||
$section->add($this->translate('Users'))
|
||||
|
29
library/Director/Objects/IcingaServiceVar.php
Normal file
29
library/Director/Objects/IcingaServiceVar.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Objects;
|
||||
|
||||
class IcingaServiceVar extends IcingaObject
|
||||
{
|
||||
protected $keyName = array('service_id', 'varname');
|
||||
|
||||
protected $table = 'icinga_service_var';
|
||||
|
||||
protected $defaultProperties = array(
|
||||
'service_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