mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
Usergroup: Add form, table, object and actions
This commit is contained in:
parent
f5af3a7123
commit
a991e6815d
@ -70,6 +70,17 @@ class Director_ListController extends ActionController
|
||||
$this->render('table');
|
||||
}
|
||||
|
||||
public function usergroupsAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
$this->translate('Add Usergroup'),
|
||||
'director/object/usergroup'
|
||||
);
|
||||
$this->view->title = $this->translate('Icinga Usergroups');
|
||||
$this->view->table = $this->loadTable('icingaUsergroup')->setConnection($this->db());
|
||||
$this->render('table');
|
||||
}
|
||||
|
||||
public function endpointsAction()
|
||||
{
|
||||
$this->view->addLink = $this->view->qlink(
|
||||
|
@ -100,6 +100,22 @@ class Director_ObjectController extends ActionController
|
||||
$this->render('form');
|
||||
}
|
||||
|
||||
public function usergroupAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaUsergroup')
|
||||
->setDb($this->db())
|
||||
->setSuccessUrl('director/list/usergroups');
|
||||
|
||||
if ($id = $this->params->get('id')) {
|
||||
$this->view->form->loadObject($id);
|
||||
$this->view->title = $this->translate('Modify Icinga Usergroup');
|
||||
} else {
|
||||
$this->view->title = $this->translate('Add new Icinga Usergroup');
|
||||
}
|
||||
$this->view->form->handleRequest();
|
||||
$this->render('form');
|
||||
}
|
||||
|
||||
public function endpointAction()
|
||||
{
|
||||
$this->view->form = $this->loadForm('icingaEndpoint')
|
||||
|
48
application/forms/IcingaUsergroupForm.php
Normal file
48
application/forms/IcingaUsergroupForm.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaUsergroupForm 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' => 'Usergroup object',
|
||||
'template' => 'Usergroup template',
|
||||
)
|
||||
));
|
||||
|
||||
if ($isTemplate) {
|
||||
$this->addElement('text', 'object_name', array(
|
||||
'label' => $this->translate('Usergroup template name'),
|
||||
'required' => true,
|
||||
'description' => $this->translate('Usergroup for the Icinga usergroup template you are going to create')
|
||||
));
|
||||
} else {
|
||||
$this->addElement('text', 'object_name', array(
|
||||
'label' => $this->translate('Usergroup'),
|
||||
'required' => true,
|
||||
'description' => $this->translate('Usergroup for the Icinga usergroup you are going to create')
|
||||
));
|
||||
}
|
||||
|
||||
$this->addElement('text', 'display_name', array(
|
||||
'label' => $this->translate('Display Name'),
|
||||
'description' => $this->translate('The name which should displayed.')
|
||||
));
|
||||
|
||||
$this->addElement('select', 'zone_id', array(
|
||||
'label' => $this->translate('Cluster Zone'),
|
||||
'description' => $this->translate('Check this usergroup in this specific Icinga cluster zone')
|
||||
));
|
||||
|
||||
$this->addElement('submit', $this->translate('Store'));
|
||||
}
|
||||
}
|
48
application/tables/IcingaUsergroupTable.php
Normal file
48
application/tables/IcingaUsergroupTable.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
|
||||
class IcingaUsergroupTable extends QuickTable
|
||||
{
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'id' => 'ug.id',
|
||||
'usergroup' => 'ug.object_name',
|
||||
'display_name' => 'ug.display_name',
|
||||
'zone' => 'z.object_name',
|
||||
);
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
return $this->url('director/object/usergroup', array('id' => $row->id));
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'usergroup' => $view->translate('Usergroup'),
|
||||
'display_name' => $view->translate('Display Name'),
|
||||
'zone' => $view->translate('Zone'),
|
||||
);
|
||||
}
|
||||
|
||||
public function fetchData()
|
||||
{
|
||||
$db = $this->connection()->getConnection();
|
||||
$query = $db->select()->from(
|
||||
array('ug' => 'icinga_usergroup'),
|
||||
$this->getColumns()
|
||||
)->joinLeft(
|
||||
array('z' => 'icinga_zone'),
|
||||
'ug.zone_id = z.id',
|
||||
array()
|
||||
);
|
||||
|
||||
return $db->fetchAll($query);
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ $section->add($this->translate('Servicegroups'))
|
||||
->setUrl('director/list/servicegroups');
|
||||
$section->add($this->translate('Users'))
|
||||
->setUrl('director/list/users');
|
||||
$section->add($this->translate('Usergroups'))
|
||||
->setUrl('director/list/usergroups');
|
||||
$section->add($this->translate('Endpoints'))
|
||||
->setUrl('director/list/endpoints');
|
||||
$section->add($this->translate('Activity Log'))
|
||||
|
16
library/Director/Objects/IcingaUsergroup.php
Normal file
16
library/Director/Objects/IcingaUsergroup.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Objects;
|
||||
|
||||
class IcingaUsergroup extends IcingaObject
|
||||
{
|
||||
protected $table = 'icinga_usergroup';
|
||||
|
||||
protected $defaultProperties = array(
|
||||
'id' => null,
|
||||
'object_name' => null,
|
||||
'display_name' => null,
|
||||
'object_type' => null,
|
||||
'zone_id' => null,
|
||||
);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user