Make the Graphite Web URL configurable over the WebUI

refs #28
This commit is contained in:
Alexander A. Klimov 2017-08-30 14:55:36 +02:00
parent 2beedfb419
commit f86bf88dcc
4 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,16 @@
<?php
namespace Icinga\Module\Graphite\Controllers;
use Icinga\Module\Graphite\Forms\ConfigForm;
use Icinga\Web\Controller;
class ConfigController extends Controller
{
public function indexAction()
{
$this->view->form = $form = new ConfigForm();
$form->setIniConfig($this->Config())->handleRequest();
$this->view->tabs = $this->Module()->getConfigTabs()->activate('backend');
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace Icinga\Module\Graphite\Forms;
use Icinga\Forms\ConfigForm as BaseConfigForm;
class ConfigForm extends BaseConfigForm
{
public function init()
{
$this->setName('form_config_graphite');
$this->setSubmitLabel($this->translate('Save Changes'));
}
public function createElements(array $formData)
{
$this->addElement(
'text',
'graphite_web_url',
array(
'required' => true,
'label' => $this->translate('Graphite Web URL'),
'description' => $this->translate('URL to your Graphite Web'),
'validators' => ['UrlValidator']
)
);
}
}

View file

@ -0,0 +1,7 @@
<div class="controls">
<?= /** @var \Icinga\Web\Widget\Tabs $tabs */ $tabs ?>
</div>
<div class="content">
<?= /** @var \Icinga\Module\Graphite\Forms\ConfigForm $form */ $form ?>
</div>

View file

@ -4,3 +4,9 @@
$this->menuSection(N_('Graphite'), ['icon' => 'chart-area'])->setUrl('graphite/show/overview');
$this->provideConfigTab('backend', array(
'title' => $this->translate('Configure the Graphite Web backend'),
'label' => $this->translate('Backend'),
'url' => 'config'
));