Monitoring/Commands: Add help messages to the problem acknowledgement form

refs #4524
This commit is contained in:
Eric Lippmann 2013-08-15 13:42:38 +02:00 committed by Jannis Moßhammer
parent 26402f1c0a
commit fb71ecc5ca
1 changed files with 109 additions and 58 deletions

View File

@ -28,30 +28,35 @@
namespace Monitoring\Form\Command; namespace Monitoring\Form\Command;
use Icinga\Web\Form\Element\DateTimePicker; use \Icinga\Web\Form\Element\DateTimePicker;
use Icinga\Web\Form\Element\Note; use \Icinga\Web\Form\Element\Note;
use Icinga\Protocol\Commandpipe\Acknowledgement; use \Icinga\Protocol\Commandpipe\Acknowledgement;
use Icinga\Protocol\Commandpipe\Comment; use \Icinga\Protocol\Commandpipe\Comment;
use Icinga\Util\DateTimeFactory; use \Icinga\Util\DateTimeFactory;
/** /**
* Form for problem acknowledgements * Form for problem acknowledgements
*/ */
class AcknowledgeForm extends CommandForm class AcknowledgeForm extends CommandForm
{ {
/**
* Initialize form
*/
public function init()
{
$this->setName('AcknowledgeForm');
}
/** /**
* Create the form's elements * Create the form's elements
*/ */
protected function create() protected function create()
{ {
$this->addElement(
new Note(
array(
'name' => 'commanddescription',
'value' => t(
'This command is used to acknowledge a host/service problem. When a problem is '
. 'acknowledged, future notifications about problems are temporarily disabled until the '
. 'host/service changes from its current state.'
)
)
)
);
$this->addElement($this->createAuthorField()); $this->addElement($this->createAuthorField());
$this->addElement( $this->addElement(
@ -63,6 +68,18 @@ class AcknowledgeForm extends CommandForm
'required' => true 'required' => true
) )
); );
$this->addElement(
new Note(
array(
'name' => 'commentnote',
'value' => t(
' If you work with other administrators, you may find it useful to share information '
. 'about a host or service that is having problems if more than one of you may be working on '
. 'it. Make sure you enter a brief description of what you are doing.'
)
)
)
);
$this->addElement( $this->addElement(
'checkbox', 'checkbox',
@ -72,57 +89,75 @@ class AcknowledgeForm extends CommandForm
'value' => false 'value' => false
) )
); );
$this->addElement(
$expireNote = new Note( new Note(
array(
'name' => 'expirenote',
'value' => t('If the acknowledgement should expire, check the box and enter an expiration timestamp.')
)
);
$expireCheck = $this->createElement(
'checkbox',
'expire',
array(
'label' => t('Use expire time')
)
);
if ($this->getRequest()->getPost('expire', '0') === '1') {
$now = DateTimeFactory::create();
$expireTime = new DateTimePicker(
array( array(
'name' => 'expiretime', 'name' => 'persistentnote',
'label' => t('Expire time'), 'value' => t(
'value' => $now->getTimestamp() + 3600 'If you would like the comment to remain once the acknowledgement is removed, '
. 'check this option.'
)
) )
);
$this->addElements(array($expireNote, $expireCheck, $expireTime));
} else {
$this->addElements(array($expireNote, $expireCheck));
}
$this->enableAutoSubmit(array('expire'));
$this->addDisplayGroup(
array(
'expirenote',
'expire',
'expiretime'
),
'expire_group',
array(
'legend' => t('Expire acknowledgement')
) )
); );
$this->addElement(
'checkbox',
'expire',
array(
'label' => t('Use Expire Time')
)
);
$this->enableAutoSubmit(array('expire'));
$this->addElement(
new Note(
array(
'name' => 'expirenote',
'value' => t('If the acknowledgement should expire, check this option.')
)
)
);
if ($this->getRequest()->getPost('expire', '0') === '1') {
$now = DateTimeFactory::create();
$this->addElement(
new DateTimePicker(
array(
'name' => 'expiretime',
'label' => t('Expire Time'),
'value' => $now->getTimestamp() + 3600
)
)
);
$this->addElement(
new Note(
array(
'name' => 'expiretimenote',
'value' => t(
'Enter here the expire date/time for this acknowledgement. Icinga will '
. ' delete the acknowledgement after this time expired.'
)
)
)
);
}
$this->addElement( $this->addElement(
'checkbox', 'checkbox',
'sticky', 'sticky',
array( array(
'label' => t('Sticky acknowledgement'), 'label' => t('Sticky Acknowledgement'),
'value' => false 'value' => true
)
);
$this->addElement(
new Note(
array(
'name' => 'stickynote',
'value' => t(
'If you want the acknowledgement to disable notifications until the host/service '
. 'recovers, check this option.'
)
)
) )
); );
@ -131,7 +166,18 @@ class AcknowledgeForm extends CommandForm
'notify', 'notify',
array( array(
'label' => t('Send notification'), 'label' => t('Send notification'),
'value' => false 'value' => true
)
);
$this->addElement(
new Note(
array(
'name' => 'sendnotificationnote',
'value' => t(
'If you do not want an acknowledgement notification sent out to the appropriate '
. 'contacts, uncheck this option.'
)
)
) )
); );
@ -143,7 +189,8 @@ class AcknowledgeForm extends CommandForm
/** /**
* Add validator for dependent fields * Add validator for dependent fields
* *
* @param array $data * @param array $data
*
* @see \Icinga\Web\Form::preValidation() * @see \Icinga\Web\Form::preValidation()
*/ */
protected function preValidation(array $data) protected function preValidation(array $data)
@ -154,6 +201,11 @@ class AcknowledgeForm extends CommandForm
} }
} }
/**
* Create acknowledgement from request data
*
* @return \Icinga\Protocol\Commandpipe\Acknowledgement
*/
public function getAcknowledgement() public function getAcknowledgement()
{ {
$expireTime = -1; $expireTime = -1;
@ -170,6 +222,5 @@ class AcknowledgeForm extends CommandForm
$expireTime, $expireTime,
$this->getValue('sticky') $this->getValue('sticky')
); );
} }
} }