mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-25 23:04:53 +02:00
Settings: use ipl, clean up, fix array handling
This commit is contained in:
parent
fbfa2c935c
commit
fe249a18be
@ -3,6 +3,7 @@
|
||||
namespace Icinga\Module\Director\Controllers;
|
||||
|
||||
use Icinga\Module\Director\ConfigDiff;
|
||||
use Icinga\Module\Director\Forms\SettingsForm;
|
||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||
use Icinga\Module\Director\Settings;
|
||||
use Icinga\Module\Director\Util;
|
||||
@ -144,14 +145,13 @@ class ConfigController extends ActionController
|
||||
{
|
||||
$this->assertPermission('director/admin');
|
||||
|
||||
$this->overviewTabs()->activate('settings');
|
||||
$this->view->title = $this->translate('Settings');
|
||||
$this->view->form = $this
|
||||
->loadForm('Settings')
|
||||
$this->addSingleTab($this->translate('Settings'))
|
||||
->addTitle($this->translate('Global Director Settings'));
|
||||
$this->content()->add(
|
||||
SettingsForm::load()
|
||||
->setSettings(new Settings($this->db()))
|
||||
->handleRequest();
|
||||
|
||||
$this->setViewScript('object/form');
|
||||
->handleRequest()
|
||||
);
|
||||
}
|
||||
|
||||
// Show all files for a given config
|
||||
@ -346,15 +346,7 @@ class ConfigController extends ActionController
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($this->hasPermission('director/admin')) {
|
||||
$tabs->add(
|
||||
'settings',
|
||||
array(
|
||||
'label' => $this->translate('Settings'),
|
||||
'url' => 'director/config/settings'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->view->tabs;
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,9 @@ namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Module\Director\Settings;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
use Icinga\Module\Director\Web\Form\DirectorForm;
|
||||
|
||||
class SettingsForm extends QuickForm
|
||||
class SettingsForm extends DirectorForm
|
||||
{
|
||||
/** @var Settings */
|
||||
protected $settings;
|
||||
|
30
library/Director/Dashboard/Dashlet/SettingsDashlet.php
Normal file
30
library/Director/Dashboard/Dashlet/SettingsDashlet.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Dashboard\Dashlet;
|
||||
|
||||
class SettingsDashlet extends Dashlet
|
||||
{
|
||||
protected $icon = 'edit';
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->translate('Director Settings');
|
||||
}
|
||||
|
||||
public function getSummary()
|
||||
{
|
||||
return $this->translate(
|
||||
'Tweak some global Director settings'
|
||||
);
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return 'director/config/settings';
|
||||
}
|
||||
|
||||
public function listRequiredPermissions()
|
||||
{
|
||||
return array('director/admin');
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ class InfrastructureDashboard extends Dashboard
|
||||
'ApiUserObject',
|
||||
'EndpointObject',
|
||||
'ZoneObject',
|
||||
'Settings',
|
||||
);
|
||||
|
||||
public function getTitle()
|
||||
|
@ -10,7 +10,7 @@ class Settings
|
||||
|
||||
protected $cache;
|
||||
|
||||
protected $defaults = array(
|
||||
protected $defaults = [
|
||||
'default_global_zone' => 'director-global',
|
||||
'magic_apply_for' => '_director_apply_for',
|
||||
'config_format' => 'v2',
|
||||
@ -22,10 +22,16 @@ class Settings
|
||||
'deployment_path_v1' => null,
|
||||
'activation_script_v1' => null,
|
||||
'self-service/agent_name' => 'fqdn',
|
||||
'self-service/transform_hostname' => '0'
|
||||
'self-service/transform_hostname' => '0',
|
||||
'self-service/global_zones' => ['director_global'],
|
||||
// 'experimental_features' => null, // 'allow'
|
||||
// 'master_zone' => null,
|
||||
);
|
||||
];
|
||||
|
||||
protected $jsonEncode = [
|
||||
'self-service/global_zones',
|
||||
'self-service/installer_hashes',
|
||||
];
|
||||
|
||||
public function __construct(Db $connection)
|
||||
{
|
||||
@ -47,6 +53,9 @@ class Settings
|
||||
if (null === ($value = $this->getSetting($key))) {
|
||||
return $default;
|
||||
} else {
|
||||
if (in_array($key, $this->jsonEncode)) {
|
||||
$value = json_decode($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@ -85,6 +94,10 @@ class Settings
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (in_array($name, $this->jsonEncode)) {
|
||||
$value = json_encode(array_values($value));
|
||||
}
|
||||
|
||||
if ($this->getSetting($name) === $value) {
|
||||
return $this;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user