mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-06 13:34:25 +02:00
parent
7fef9bddde
commit
22c6bf75e7
@ -270,46 +270,49 @@ class TransportConfigForm extends ConfigForm
|
|||||||
parent::addSubmitButton();
|
parent::addSubmitButton();
|
||||||
|
|
||||||
if ($this->getSubForm('transport_form') instanceof ApiTransportForm) {
|
if ($this->getSubForm('transport_form') instanceof ApiTransportForm) {
|
||||||
$this->addElement(
|
|
||||||
'submit',
|
|
||||||
'transport_validation',
|
|
||||||
array(
|
|
||||||
'ignore' => true,
|
|
||||||
'label' => $this->translate('Validate Configuration'),
|
|
||||||
'data-progress-label' => $this->translate('Validation In Progress'),
|
|
||||||
'decorators' => array('ViewHelper')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->setAttrib('data-progress-element', 'transport-progress');
|
|
||||||
$this->addElement(
|
|
||||||
'note',
|
|
||||||
'transport-progress',
|
|
||||||
array(
|
|
||||||
'decorators' => array(
|
|
||||||
'ViewHelper',
|
|
||||||
array('Spinner', array('id' => 'transport-progress'))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$btnSubmit = $this->getElement('btn_submit');
|
$btnSubmit = $this->getElement('btn_submit');
|
||||||
$elements = array('transport_validation', 'transport-progress');
|
|
||||||
if ($btnSubmit !== null) {
|
if ($btnSubmit !== null) {
|
||||||
// In the setup wizard $this is being used as a subform which doesn't have a submit button.
|
// In the setup wizard $this is being used as a subform which doesn't have a submit button.
|
||||||
|
$this->addElement(
|
||||||
|
'submit',
|
||||||
|
'transport_validation',
|
||||||
|
array(
|
||||||
|
'ignore' => true,
|
||||||
|
'label' => $this->translate('Validate Configuration'),
|
||||||
|
'data-progress-label' => $this->translate('Validation In Progress'),
|
||||||
|
'decorators' => array('ViewHelper')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->setAttrib('data-progress-element', 'transport-progress');
|
||||||
|
$this->addElement(
|
||||||
|
'note',
|
||||||
|
'transport-progress',
|
||||||
|
array(
|
||||||
|
'decorators' => array(
|
||||||
|
'ViewHelper',
|
||||||
|
array('Spinner', array('id' => 'transport-progress'))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$elements = array('transport_validation', 'transport-progress');
|
||||||
|
|
||||||
$btnSubmit->setDecorators(array('ViewHelper'));
|
$btnSubmit->setDecorators(array('ViewHelper'));
|
||||||
array_unshift($elements, 'btn_submit');
|
array_unshift($elements, 'btn_submit');
|
||||||
}
|
|
||||||
$this->addDisplayGroup(
|
$this->addDisplayGroup(
|
||||||
$elements,
|
$elements,
|
||||||
'submit_validation',
|
'submit_validation',
|
||||||
array(
|
array(
|
||||||
'decorators' => array(
|
'decorators' => array(
|
||||||
'FormElements',
|
'FormElements',
|
||||||
array('HtmlTag', array('tag' => 'div', 'class' => 'control-group form-controls'))
|
array('HtmlTag', array('tag' => 'div', 'class' => 'control-group form-controls'))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -351,9 +354,12 @@ class TransportConfigForm extends ConfigForm
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! ($this->getElement('transport_validation') === null || (
|
if ($this->getSubForm('transport_form') instanceof ApiTransportForm) {
|
||||||
$this->isSubmitted() && isset($formData['force_creation']) && $formData['force_creation'])
|
if (isset($formData['force_creation']) && $formData['force_creation']) {
|
||||||
)) {
|
// ignore any validation result
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CommandTransport::createTransport(new ConfigObject($this->getValues()))->probe();
|
CommandTransport::createTransport(new ConfigObject($this->getValues()))->probe();
|
||||||
} catch (CommandTransportException $e) {
|
} catch (CommandTransportException $e) {
|
||||||
@ -366,10 +372,10 @@ class TransportConfigForm extends ConfigForm
|
|||||||
'checkbox',
|
'checkbox',
|
||||||
'force_creation',
|
'force_creation',
|
||||||
array(
|
array(
|
||||||
'order' => 0,
|
'order' => 0,
|
||||||
'ignore' => true,
|
'ignore' => true,
|
||||||
'label' => $this->translate('Force Changes'),
|
'label' => $this->translate('Force Changes'),
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'Check this box to enforce changes without connectivity validation'
|
'Check this box to enforce changes without connectivity validation'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -15,6 +15,7 @@ class TransportPage extends Form
|
|||||||
$this->addDescription($this->translate(
|
$this->addDescription($this->translate(
|
||||||
'Please define below how you want to send commands to your monitoring instance.'
|
'Please define below how you want to send commands to your monitoring instance.'
|
||||||
));
|
));
|
||||||
|
$this->setValidatePartial(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createElements(array $formData)
|
public function createElements(array $formData)
|
||||||
@ -30,4 +31,25 @@ class TransportPage extends Form
|
|||||||
{
|
{
|
||||||
return $this->getSubForm('transport_form')->getValues($suppressArrayNotation);
|
return $this->getSubForm('transport_form')->getValues($suppressArrayNotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the configured backend's inspection checks and show the result, if necessary
|
||||||
|
*
|
||||||
|
* This will only run any validation if the user pushed the 'transport_validation' button.
|
||||||
|
*
|
||||||
|
* @param array $formData
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isValidPartial(array $formData)
|
||||||
|
{
|
||||||
|
if (isset($formData['transport_validation']) && parent::isValid($formData)) {
|
||||||
|
$this->info($this->translate('The configuration has been successfully validated.'));
|
||||||
|
} elseif (! isset($formData['transport_validation'])) {
|
||||||
|
// This is usually done by isValid(Partial), but as we're not calling any of these...
|
||||||
|
$this->populate($formData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,9 @@ class MonitoringWizard extends Wizard implements SetupWizard
|
|||||||
* Add buttons to the given page based on its position in the page-chain
|
* Add buttons to the given page based on its position in the page-chain
|
||||||
*
|
*
|
||||||
* @param Form $page The page to add the buttons to
|
* @param Form $page The page to add the buttons to
|
||||||
|
*
|
||||||
|
* @todo This is never called, because its a sub-wizard only
|
||||||
|
* @see WebWizard::addButtons which does some of the needed work
|
||||||
*/
|
*/
|
||||||
protected function addButtons(Form $page)
|
protected function addButtons(Form $page)
|
||||||
{
|
{
|
||||||
|
@ -366,7 +366,7 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
'setup_auth_db_resource',
|
'setup_auth_db_resource',
|
||||||
'setup_config_db_resource',
|
'setup_config_db_resource',
|
||||||
'setup_ldap_resource',
|
'setup_ldap_resource',
|
||||||
'setup_monitoring_ido'
|
'setup_monitoring_ido', // TODO(mf): This should be handled by MonitoringWizard
|
||||||
))) {
|
))) {
|
||||||
$page->addElement(
|
$page->addElement(
|
||||||
'submit',
|
'submit',
|
||||||
@ -380,6 +380,21 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
);
|
);
|
||||||
$page->getDisplayGroup('buttons')->addElement($page->getElement('backend_validation'));
|
$page->getDisplayGroup('buttons')->addElement($page->getElement('backend_validation'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(mf): This should be handled by MonitoringWizard
|
||||||
|
if ($page->getName() === 'setup_command_transport') {
|
||||||
|
$page->addElement(
|
||||||
|
'submit',
|
||||||
|
'transport_validation',
|
||||||
|
array(
|
||||||
|
'ignore' => true,
|
||||||
|
'label' => t('Validate Configuration'),
|
||||||
|
'data-progress-label' => t('Validation In Progress'),
|
||||||
|
'decorators' => array('ViewHelper')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$page->getDisplayGroup('buttons')->addElement($page->getElement('transport_validation'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user