summaryrefslogtreecommitdiffstats
path: root/application/forms/Config/SettingConfigForm.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:41:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:41:54 +0000
commit573e13afd00a36a8a331d69823045938a2215c71 (patch)
tree96906f4dd33b7b5660460372269b180af564d982 /application/forms/Config/SettingConfigForm.php
parentInitial commit. (diff)
downloadicingaweb2-module-boxydash-573e13afd00a36a8a331d69823045938a2215c71.tar.xz
icingaweb2-module-boxydash-573e13afd00a36a8a331d69823045938a2215c71.zip
Adding upstream version 0.0.1+20160321.upstream/0.0.1+20160321upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/forms/Config/SettingConfigForm.php')
-rw-r--r--application/forms/Config/SettingConfigForm.php137
1 files changed, 137 insertions, 0 deletions
diff --git a/application/forms/Config/SettingConfigForm.php b/application/forms/Config/SettingConfigForm.php
new file mode 100644
index 0000000..3e26b04
--- /dev/null
+++ b/application/forms/Config/SettingConfigForm.php
@@ -0,0 +1,137 @@
+<?php
+/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
+
+namespace Icinga\Module\Boxydash\Forms\Config;
+
+use Exception;
+use Icinga\Data\ConfigObject;
+use Icinga\Data\ResourceFactory;
+use Icinga\Web\Form;
+use InvalidArgumentException;
+use Icinga\Application\Config;
+use Icinga\Exception\ConfigurationError;
+use Icinga\Forms\ConfigForm;
+use Icinga\Web\Notification;
+
+/**
+ * Form class for creating/modifying monitoring Settings
+ */
+class SettingConfigForm extends ConfigForm
+{
+ protected $resources;
+
+ public function init()
+ {
+ $this->setName('form_config_boxydash_settings');
+ $this->setSubmitLabel($this->translate('Save Changes'));
+ }
+
+ public function createElements(array $formData)
+ {
+ $this->addElement(
+ 'text',
+ 'setting_refresh',
+ array(
+ 'label' => $this->translate('Dashboard Refresh'),
+ 'description' => $this->translate('How quickly the dashboard should refresh (between 1 second and 20 minutes)'),
+ 'value' => '10',
+ 'validators' => array(
+ array(
+ 'Between',
+ false,
+ array(
+ 'min' => '1',
+ 'max' => '1200',
+ 'inclusive' => true,
+ )
+ )
+ )
+ )
+ );
+ $this->addElement(
+ 'text',
+ 'setting_boxsize',
+ array(
+ 'label' => $this->translate('Box Size'),
+ 'description' => $this->translate('The size of displayed boxes in pixels'),
+ 'value' => '10',
+ 'validators' => array(
+ array(
+ 'Regex',
+ false,
+ array(
+ 'pattern' => '/^[\d]+$/',
+ 'messages' => array(
+ 'regexNotMatch' => $this->translate(
+ 'The application prefix must be a positive integer.'
+ )
+ )
+ )
+ )
+ )
+ )
+ );
+ $this->addElement(
+ 'checkbox',
+ 'include_softstate',
+ array(
+ 'required' => true,
+ 'value' => true,
+ 'label' => $this->translate('Include Soft Status'),
+ 'description' => $this->translate('Enable this to have soft status included')
+ )
+ );
+ $this->addElement(
+ 'checkbox',
+ 'requires_authentication',
+ array(
+ 'required' => true,
+ 'value' => true,
+ 'label' => $this->translate('Require Authentication?'),
+ 'description' => $this->translate('Does Boxydash require Authentication? Warning, this may expose sensitive network information.')
+ )
+ );
+ $this->addElement(
+ 'checkbox',
+ 'show_legend',
+ array(
+ 'required' => true,
+ 'value' => true,
+ 'label' => $this->translate('Show the Legend'),
+ 'description' => $this->translate('Do you want to show the legend?')
+ )
+ );
+ $this->addElement(
+ 'text',
+ 'path_prefix',
+ array(
+ 'label' => $this->translate('URL path prefix'),
+ 'description' => $this->translate('Prefix prepended to all links, eg "/icingaweb2". Required in case Icinga Web 2 is installed in a subfolder (eg "http://your-domain.tld/icingaweb2").'),
+ 'value' => '',
+ )
+ );
+
+ }
+
+ public function onSuccess()
+ {
+ $this->config->setSection('settings', $this->getValues());
+
+ if ($this->save()) {
+ Notification::success($this->translate('New setings have successfully been stored'));
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @see Form::onRequest()
+ */
+ public function onRequest()
+ {
+ $this->populate($this->config->getSection('settings')->toArray());
+ }
+
+
+
+}