diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 13e7f9e14..af2888383 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -19,13 +19,15 @@ class Monitoring_DowntimeController extends Controller { protected $downtime; + protected $isService; + /** * Add tabs */ public function init() { $downtimeId = $this->params->get('downtime_id'); - + $this->downtime = $this->backend->select()->from('downtime', array( 'id' => 'downtime_internal_id', 'objecttype' => 'downtime_objecttype', @@ -50,6 +52,12 @@ class Monitoring_DowntimeController extends Controller 'service_display_name' ))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow(); + if (isset($this->downtime->service_description)) { + $this->isService = true; + } else { + $this->isService = false; + } + $this->getTabs() ->add( 'downtime', @@ -67,8 +75,8 @@ class Monitoring_DowntimeController extends Controller public function showAction() { $this->view->downtime = $this->downtime; - $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); - $this->view->delDowntimeForm->setObjects($this->downtime); + $this->view->isService = $this->isService; + $this->view->delDowntimeForm = $this->createDelDowntimeForm(); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); $this->view->showHostLink = Url::fromPath('monitoring/host/show') ->setParam('host', $this->downtime->host); @@ -76,4 +84,30 @@ class Monitoring_DowntimeController extends Controller ->setParam('host', $this->downtime->host) ->setParam('service', $this->downtime->service_description); } + + private function createDelDowntimeForm() + { + $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm->setObjects($this->downtime); + $delDowntimeForm->populate( + array( + 'downtime_id' => $this->downtime->id, + 'redirect' => Url::fromPath('monitoring/list/downtimes') + ) + ); + if (! $this->isService) { + $delDowntimeForm->setAction( + $this->view->url('monitoring/host/delete-downtime', + array('host' => $this->downtime->host_name)) + ); + } else { + $delDowntimeForm->setAction( + $this->view->url('monitoring/service/delete-downtime', array( + 'host' => $this->downtime->host_name, + 'service' => $this->downtime->service_description + )) + ); + } + return $delDowntimeForm; + } } diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index 806897e90..d71b92c55 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -1,22 +1,9 @@ -service_description)) { - $isService = true; - $stateName = Service::getStateText($downtime->service_state); -} else { - $isService = false; - $stateName = Host::getStateText($downtime->host_state); -} -?> -
compact): ?> tabs; ?> -

- +

+ isService): ?> link()->service( $downtime->service_description, @@ -34,7 +21,7 @@ if (isset($downtime->service_description)) { translate( - 'Downtime for %s', + 'Downtime on %s', 'Downtime for host or service.' ), $link @@ -43,12 +30,12 @@ if (isset($downtime->service_description)) {

-
+
is_flexible): ?> is_in_effect): ?> isService ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), date('d.m.y', $downtime->start), @@ -59,7 +46,7 @@ if (isset($downtime->service_description)) { ); ?> isService ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), date('d.m.y H:i', $downtime->scheduled_start), @@ -70,7 +57,7 @@ if (isset($downtime->service_description)) { is_in_effect): ?> isService ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), date('d.m.y', $downtime->start), @@ -80,7 +67,7 @@ if (isset($downtime->service_description)) { ); ?> isService ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), date('d.m.y', $downtime->scheduled_start), @@ -132,43 +119,12 @@ if (isset($downtime->service_description)) { ?> - - downtime->is_flexible && $this->downtime->is_in_effect): ?> - - translate('Start') ?> - start); ?> - - - translate('End') ?> - end); ?> - - - - translate('Duration') ?> - format()->duration($this->escape($this->downtime->duration)); ?> - - + translate('Commands') ?> - populate(array('downtime_id' => $downtime->id, 'redirect' => $this->listAllLink)); - if (! $isService) { - $delDowntimeForm->setAction( - $this->url('monitoring/host/delete-downtime', - array('host' => $downtime->host_name)) - ); - } else { - $delDowntimeForm->setAction( - $this->url('monitoring/service/delete-downtime', array( - 'host' => $downtime->host_name, - 'service' => $downtime->service_description - )) - ); - } - echo $delDowntimeForm; - ?> +