Skip to content

Commit 2a0bb3f

Browse files
committed
Fixed Form save null as zero
Fixes & Updates
1 parent fb2d2fd commit 2a0bb3f

9 files changed

Lines changed: 67 additions & 73 deletions

File tree

nbproject/private/private.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
<file>file:/home/vitex/Projects/VitexSoftware/iciedit/src/includes/Configure.php</file>
1212
</group>
1313
<group>
14-
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/UI/NavBarSearchBox.php</file>
15-
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/UI/PageTop.php</file>
16-
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/UI/TWBSwitch.php</file>
14+
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/engine/Configurator.php</file>
1715
</group>
1816
</open-files>
1917
</project-private>

src/classes/UI/CfgEditor.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,16 @@ public function insertWidget($fieldBlock, $fieldName, $value)
9999
});", null, true);
100100
}
101101

102+
$templateCheckBoxName = "useFromTemplate[$fieldName]";
103+
102104
if ($templateName && !is_null($templateValue)) {
103-
$fieldBlock->addItem(new \Ease\Html\CheckboxTag(null, true, 1,
104-
['id' => 'useTpl'.$fieldName]));
105+
$fieldBlock->addItem(new \Ease\Html\CheckboxTag($templateCheckBoxName,
106+
true, 1, ['id' => 'useTpl'.$fieldName]));
105107
$hint = current($effective);
106108
$disabled = true;
107109
} else {
108-
$fieldBlock->addItem(new \Ease\Html\CheckboxTag(null, false, 1,
109-
['id' => 'useTpl'.$fieldName]));
110+
$fieldBlock->addItem(new \Ease\Html\CheckboxTag($templateCheckBoxName,
111+
false, 1, ['id' => 'useTpl'.$fieldName]));
110112
$hint = $value;
111113
}
112114
$fieldBlock->addItem(' '._('Hodnota z předlohy').':');

src/classes/UI/ServiceConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function init()
6868
*/
6969
public function form()
7070
{
71-
71+
7272
}
7373

7474
/**

src/classes/UI/ServiceSwapForm.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Icinga\Editor\UI;
34

45
/**
@@ -11,7 +12,6 @@
1112
*/
1213
class ServiceSwapForm extends \Ease\TWB\Form
1314
{
14-
1515
/**
1616
* Služba
1717
* @var IEService
@@ -33,15 +33,18 @@ function finalize()
3333
{
3434
$addNewItem = new ServiceSelect('new_service_id');
3535

36-
$this->addItem(new \Ease\TWB\FormGroup(_('Náhradní služba'), $addNewItem, _('Jméno služby'), sprintf(_('Tato služba se zamění za právě zvolenou službu <strong>%s</strong> u všech hostů kteří ji používají'), $this->service->getName())
36+
$this->addItem(new \Ease\TWB\FormGroup(_('Náhradní služba'),
37+
$addNewItem, _('Jméno služby'),
38+
sprintf(_('Tato služba se zamění za právě zvolenou službu <strong>%s</strong> u všech hostů kteří ji používají'),
39+
$this->service->getName())
3740
));
3841

3942
$this->addItem(new \Ease\TWB\FormGroup(_('Vyměnit'),
4043
new \Ease\TWB\SubmitButton(_('Vyměnit službu').' '.\Ease\TWB\Part::GlyphIcon('flash'),
4144
'info')));
4245

43-
$this->addItem(new \Ease\Html\InputHiddenTag('service_id', $this->service->getID()));
46+
$this->addItem(new \Ease\Html\InputHiddenTag('service_id',
47+
$this->service->getID()));
4448
$this->addItem(new \Ease\Html\InputHiddenTag('action', 'swap'));
4549
}
46-
47-
}
50+
}

src/classes/engine/Configurator.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,12 @@ public function takeData($data, $dataPrefix = null)
430430
unset($data['Save']);
431431
unset($data['class']);
432432
unset($data['CheckBoxGroups']);
433+
if (isset($data['useFromTemplate']) && count($data['useFromTemplate'])) {
434+
foreach ($data['useFromTemplate'] as $key => $one) {
435+
$data[$key] = null;
436+
}
437+
unset($data['useFromTemplate']);
438+
}
433439
foreach ($data as $key => $value) {
434440
if ($value === 'NULL') {
435441
$data[$key] = null;
@@ -2012,41 +2018,41 @@ static function getBaseURL()
20122018

20132019
function csvizeRow()
20142020
{
2015-
2021+
20162022
}
20172023

20182024
function getListingQuerySelect()
20192025
{
2020-
2026+
20212027
}
20222028

20232029
function getListingQueryWhere()
20242030
{
2025-
2031+
20262032
}
20272033

20282034
function operationsMenu()
20292035
{
2030-
2036+
20312037
}
20322038

20332039
function handleUpload()
20342040
{
2035-
2041+
20362042
}
20372043

20382044
function unsetUnknownColumns()
20392045
{
2040-
2046+
20412047
}
20422048

20432049
function sqlColumnsToSelect()
20442050
{
2045-
2051+
20462052
}
20472053

20482054
function getWhere()
20492055
{
2050-
2056+
20512057
}
20522058
}

src/classes/engine/Service.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,12 @@ public function fork($host, $ownerId = null)
569569
*/
570570
public function swapTo($swapToID)
571571
{
572-
$newService = new Engine\IEService($swapToID);
572+
$newService = new Service($swapToID);
573573
$thisName = $this->getName();
574574
$hostsOK = [];
575575
$hostsErr = [];
576576
$hostsAssigned = [];
577-
$host = new Engine\IEHost();
577+
$host = new Host();
578578

579579
if (\Ease\Shared::user()->getSettingValue('admin')) {
580580
$allHosts = $host->getAllFromSQL(NULL,

src/modules/CheckMem.inc.php

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Formulář pro test Disku windows
45
*
@@ -7,21 +8,20 @@
78
* @author Vitex <vitex@hippy.cz>
89
* @copyright 2014 Vitex@hippy.cz (G)
910
*/
11+
1012
namespace Icinga\Editor\modules;
1113

1214
/**
1315
* Description of ping
1416
*
1517
* @author vitex
1618
*/
17-
class CheckMem extends \Icinga\Editor\UI\ServiceConfigurator
18-
{
19+
class CheckMem extends \Icinga\Editor\UI\ServiceConfigurator {
1920

2021
/**
2122
*
2223
*/
23-
public function form()
24-
{
24+
public function form() {
2525
$config = [
2626
'ShowAll' => null,
2727
'MaxWarn' => NULL,
@@ -48,34 +48,18 @@ public function form()
4848

4949
$types = ['physical' => _('Physical memory (RAM)'), 'committed' => _('total memory (RAM+PAGE)')];
5050

51-
$this->form->addInput(new \Ease\Html\Select('type', $types,
52-
str_replace(':', '', $config['type'])), _('Typ'), '',
53-
_('Typ sledované paměti'));
54-
55-
$this->form->addItem(new \Ease\TWB\FormGroup(_('MaxWarn'),
56-
new \Ease\Html\InputTextTag('MaxWarn', $config['MaxWarn']), '80%',
57-
_('Maximum value before a warning is returned.')));
58-
$this->form->addItem(new \Ease\TWB\FormGroup(_('MaxCrit'),
59-
new \Ease\Html\InputTextTag('MaxCrit', $config['MaxCrit']), '95%',
60-
_('Maximum value before a critical is returned.')));
61-
$this->form->addItem(new \Ease\TWB\FormGroup(_('MinWarn'),
62-
new \Ease\Html\InputTextTag('MinWarn', $config['MinWarn']), '10%',
63-
_('Minimum value before a warning is returned.')));
64-
$this->form->addItem(new \Ease\TWB\FormGroup(_('MinCrit'),
65-
new \Ease\Html\InputTextTag('MinCrit', $config['MinCrit']), '5%',
66-
_('Minimum value before a critical is returned.')));
67-
68-
$this->form->addItem(new \Ease\TWB\FormGroup(_('warn'),
69-
new \Ease\Html\InputTextTag('warn', $config['warn']), '5%',
70-
_('Maximum value before a warning is returned.')));
71-
$this->form->addItem(new \Ease\TWB\FormGroup(_('crit'),
72-
new \Ease\Html\InputTextTag('crit', $config['crit']), '5%',
73-
_('Maximum value before a critcal is returned.')));
74-
75-
76-
$this->form->addInput(new UI\TWBSwitch('ShowAll', $config['ShowAll']),
77-
_('Zobrazit vše'), null,
78-
_('Configures display format (if set shows all items not only failures, if set to long shows all cores).'));
51+
$this->form->addInput(new \Ease\Html\Select('type', $types, str_replace(':', '', $config['type'])), _('Typ'), '', _('Typ sledované paměti'));
52+
53+
$this->form->addItem(new \Ease\TWB\FormGroup(_('MaxWarn'), new \Ease\Html\InputTextTag('MaxWarn', $config['MaxWarn']), '80%', _('Maximum value before a warning is returned.')));
54+
$this->form->addItem(new \Ease\TWB\FormGroup(_('MaxCrit'), new \Ease\Html\InputTextTag('MaxCrit', $config['MaxCrit']), '95%', _('Maximum value before a critical is returned.')));
55+
$this->form->addItem(new \Ease\TWB\FormGroup(_('MinWarn'), new \Ease\Html\InputTextTag('MinWarn', $config['MinWarn']), '10%', _('Minimum value before a warning is returned.')));
56+
$this->form->addItem(new \Ease\TWB\FormGroup(_('MinCrit'), new \Ease\Html\InputTextTag('MinCrit', $config['MinCrit']), '5%', _('Minimum value before a critical is returned.')));
57+
58+
$this->form->addItem(new \Ease\TWB\FormGroup(_('warn'), new \Ease\Html\InputTextTag('warn', $config['warn']), '5%', _('Maximum value before a warning is returned.')));
59+
$this->form->addItem(new \Ease\TWB\FormGroup(_('crit'), new \Ease\Html\InputTextTag('crit', $config['crit']), '5%', _('Maximum value before a critcal is returned.')));
60+
61+
62+
$this->form->addInput(new UI\TWBSwitch('ShowAll', $config['ShowAll']), _('Zobrazit vše'), null, _('Configures display format (if set shows all items not only failures, if set to long shows all cores).'));
7963

8064
// $this->form->addInput(new \Ease\Html\InputTextTag('orig', $this->commandParams[0], array('disabled')));
8165
}
@@ -85,10 +69,9 @@ public function form()
8569
*
8670
* @return boolean
8771
*/
88-
public function reconfigureService()
89-
{
72+
public function reconfigureService() {
9073
$config = [];
91-
$page = \Ease\Shared::webPage();
74+
$page = \Ease\Shared::webPage();
9275

9376
foreach ($page->getRequestValues() as $key => $value) {
9477
switch ($key) {
@@ -105,7 +88,7 @@ public function reconfigureService()
10588
case 'crit':
10689
case 'type':
10790
if ($value) {
108-
$config[] = $key.'='.$value;
91+
$config[] = $key . '=' . $value;
10992
}
11093
break;
11194

@@ -118,12 +101,12 @@ public function reconfigureService()
118101

119102
if (count($config)) {
120103

121-
$this->tweaker->service->setDataValue('check_command-params',
122-
implode(' ', $config));
104+
$this->tweaker->service->setDataValue('check_command-params', implode(' ', $config));
123105

124106
return parent::reconfigureService();
125107
}
126108

127109
return FALSE;
128110
}
129-
}
111+
112+
}

src/modules/DriveLetter.inc.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function form() {
4343

4444

4545

46-
if (strstr($config['Drive'], '\\\\')) {
46+
if (!strlen($config['Drive'])) {
4747
$this->form->addInput(new \Ease\Html\Select('Drive', $drives, '\\\\'), _('Disk'), 'X:', _('Volba písmene sledované diskové jednotky'));
4848
} else {
4949
$this->form->addInput(new \Ease\Html\Select('Drive', $drives, str_replace(':', '', $config['Drive'])), _('Disk'), 'X:', _('Volba písmene sledované diskové jednotky'));
@@ -63,10 +63,13 @@ public function reconfigureService() {
6363
switch ($key) {
6464
case 'Drive':
6565

66-
if (strlen(trim($value)) && ($value != '\\\\')) {
67-
$config['Drive'] = $value . ':';
68-
$this->tweaker->service->setDataValue($this->tweaker->service->nameColumn, _('Disk') . ' ' . strtoupper($value) . ':');
69-
$this->tweaker->service->setDataValue('display_name', sprintf(_('Volné místo disku %s: '), strtoupper($value)));
66+
if (strlen(trim($value)) && ($value != '')) {
67+
$config['Drive'] = $value . ':';
68+
$nameColumn = $this->tweaker->service->nameColumn;
69+
$newName = $this->tweaker->service->getDataValue($nameColumn) . ' ' . _('Disk') . ' ' . strtoupper($value) . ':';
70+
71+
$this->tweaker->service->setDataValue($nameColumn, $newName);
72+
$this->tweaker->service->setDataValue('display_name', sprintf(_('Disk %s: '), strtoupper($value)));
7073
}
7174

7275
break;

src/modules/ping.inc.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Formulář testu IMCP odezvy
45
*
@@ -7,21 +8,20 @@
78
* @author Vitex <vitex@hippy.cz>
89
* @copyright 2014 Vitex@hippy.cz (G)
910
*/
11+
1012
namespace Icinga\Editor\modules;
1113

1214
/**
1315
* Description of ping
1416
*
1517
* @author vitex
1618
*/
17-
class ping extends \Icinga\Editor\UI\ServiceConfigurator
18-
{
19+
class ping extends \Icinga\Editor\UI\ServiceConfigurator {
1920

2021
/**
2122
*
2223
*/
23-
public function form()
24-
{
24+
public function form() {
2525
$warningValues = explode(',', $this->commandParams[0]);
2626
$criticalValues = explode(',', $this->commandParams[1]);
2727

@@ -37,8 +37,7 @@ public function form()
3737
*
3838
* @return boolean
3939
*/
40-
public function reconfigureService()
41-
{
40+
public function reconfigureService() {
4241
$page = \Ease\Shared::webPage();
4342
$wt = $page->getRequestValue('wt', 'float');
4443
$ct = $page->getRequestValue('ct', 'float');

0 commit comments

Comments
 (0)