mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
DeleteDowntimeCommandForm: Show error notification if not successful
resolves #4303
This commit is contained in:
parent
5be964f989
commit
77ca3e0c31
@ -4,6 +4,7 @@
|
|||||||
namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
|
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
|
||||||
|
use Icinga\Module\Monitoring\Exception\CommandTransportException;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\CommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\CommandForm;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
|
|
||||||
@ -98,13 +99,31 @@ class DeleteDowntimeCommandForm extends CommandForm
|
|||||||
->setDowntimeId($this->getElement('downtime_id')->getValue())
|
->setDowntimeId($this->getElement('downtime_id')->getValue())
|
||||||
->setDowntimeName($this->getElement('downtime_name')->getValue())
|
->setDowntimeName($this->getElement('downtime_name')->getValue())
|
||||||
->setIsService($this->getElement('downtime_is_service')->getValue());
|
->setIsService($this->getElement('downtime_is_service')->getValue());
|
||||||
$this->getTransport($this->request)->send($cmd);
|
|
||||||
|
|
||||||
|
$errorMsg = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->getTransport($this->request)->send($cmd);
|
||||||
|
} catch (CommandTransportException $e) {
|
||||||
|
$errorMsg = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $errorMsg) {
|
||||||
$redirect = $this->getElement('redirect')->getValue();
|
$redirect = $this->getElement('redirect')->getValue();
|
||||||
|
Notification::success($this->translate('Deleting downtime.'));
|
||||||
|
} else {
|
||||||
|
if (! $this->getIsApiTarget()) {
|
||||||
|
$redirect = $this->getRequest()->getUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification::error($errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($redirect)) {
|
if (! empty($redirect)) {
|
||||||
$this->setRedirectUrl($redirect);
|
$this->setRedirectUrl($redirect);
|
||||||
}
|
|
||||||
Notification::success($this->translate('Deleting downtime.'));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user