mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-05-28 04:35:53 -04:00
parent
321f9d9503
commit
18b201d824
3 changed files with 62 additions and 0 deletions
50
application/controllers/SettingsController.php
Normal file
50
application/controllers/SettingsController.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
use Icinga\Module\Director\ActionController;
|
||||
|
||||
use Icinga\Forms\ConfigForm;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
||||
class Director_SettingsController extends ActionController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->tabs = $this->Module()->getConfigTabs()->activate('config');
|
||||
|
||||
$resource = $this->Config()->get('db', 'resource');
|
||||
|
||||
$form = new ConfigForm();
|
||||
|
||||
$form->setIniConfig($this->Config('config'));
|
||||
$form->addElement('select', 'resource', array(
|
||||
'required' => true,
|
||||
'label' => $this->translate('DB Resource'),
|
||||
'multiOptions' => $this->getResources(),
|
||||
'value' => $resource
|
||||
));
|
||||
$form->setSubmitLabel($this->translate('Save'));
|
||||
|
||||
$form->setOnSuccess(function($form) {
|
||||
/** @var $form ConfigForm */
|
||||
$this->Config('config')->setSection('db', array(
|
||||
'resource' => $form->getValue('resource')
|
||||
));
|
||||
$form->save();
|
||||
});
|
||||
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function getResources()
|
||||
{
|
||||
$resources = array();
|
||||
foreach (ResourceFactory::getResourceConfigs() as $name => $resource) {
|
||||
if ($resource->type === 'db') {
|
||||
$resources['ido'][$name] = $name;
|
||||
}
|
||||
}
|
||||
return $resources;
|
||||
}
|
||||
}
|
||||
7
application/views/scripts/settings/index.phtml
Normal file
7
application/views/scripts/settings/index.phtml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
</div>
|
||||
|
||||
<div class="content" data-base-target="_next">
|
||||
<?= $form; ?>
|
||||
</div>
|
||||
|
|
@ -3,6 +3,11 @@
|
|||
// Sample permission:
|
||||
$this->providePermission('director/templates', 'Allow to modify templates');
|
||||
|
||||
$this->provideConfigTab('config', array(
|
||||
'title' => 'Configuration',
|
||||
'url' => 'settings'
|
||||
));
|
||||
|
||||
$section = $this->menuSection(
|
||||
$this->translate('Icinga Director')
|
||||
)->setIcon('cubes');
|
||||
|
|
|
|||
Loading…
Reference in a new issue