Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix downtime removal command in detail view
Use removal command for single downtimes in detail view. Move removing single and multiple downtimees into seperate forms. refs #8902
- Loading branch information
Showing
7 changed files
with
155 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php
This file was deleted.
Oops, something went wrong.
89 changes: 89 additions & 0 deletions
89
modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ | ||
|
||
namespace Icinga\Module\Monitoring\Forms\Command\Object; | ||
|
||
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand; | ||
use \Icinga\Module\Monitoring\Forms\Command\CommandForm; | ||
use Icinga\Web\Notification; | ||
|
||
/** | ||
* Form for deleting host or service downtimes | ||
*/ | ||
class DeleteDowntimesCommandForm extends CommandForm | ||
{ | ||
protected $downtimes; | ||
|
||
/** | ||
* (non-PHPDoc) | ||
* @see \Zend_Form::init() For the method documentation. | ||
*/ | ||
public function init() | ||
{ | ||
$this->setAttrib('class', 'inline'); | ||
} | ||
|
||
/** | ||
* (non-PHPDoc) | ||
* @see \Icinga\Web\Form::createElements() For the method documentation. | ||
*/ | ||
public function createElements(array $formData = array()) | ||
{ | ||
$this->addElements(array( | ||
array( | ||
'hidden', | ||
'redirect', | ||
array( | ||
'decorators' => array('ViewHelper') | ||
) | ||
) | ||
)); | ||
return $this; | ||
} | ||
|
||
/** | ||
* (non-PHPDoc) | ||
* @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. | ||
*/ | ||
public function getSubmitLabel() | ||
{ | ||
return $this->translatePlural('Remove', 'Remove All', count($this->downtimes)); | ||
} | ||
|
||
/** | ||
* (non-PHPDoc) | ||
* @see \Icinga\Web\Form::onSuccess() For the method documentation. | ||
*/ | ||
public function onSuccess() | ||
{ | ||
foreach ($this->downtimes as $downtime) { | ||
$delDowntime = new DeleteDowntimeCommand(); | ||
$delDowntime->setDowntimeId($downtime->id); | ||
$delDowntime->setDowntimeType( | ||
isset($downtime->service_description) ? | ||
DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : | ||
DeleteDowntimeCommand::DOWNTIME_TYPE_HOST | ||
); | ||
$this->getTransport($this->request)->send($delDowntime); | ||
} | ||
$redirect = $this->getElement('redirect')->getValue(); | ||
if (! empty($redirect)) { | ||
$this->setRedirectUrl($redirect); | ||
} | ||
Notification::success($this->translate('Deleting downtime.')); | ||
return true; | ||
} | ||
|
||
/** | ||
* Set the downtimes to be deleted upon success | ||
* | ||
* @param type $downtimes | ||
* | ||
* @return $this | ||
*/ | ||
public function setDowntimes($downtimes) | ||
{ | ||
$this->downtimes = $downtimes; | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters