From 7b6641dc848b6fd912b32de960760854715a35eb Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 21 Apr 2015 14:49:27 +0200 Subject: [PATCH 01/14] Add basic downtime controller and views refs #8902 --- .../controllers/DowntimeController.php | 79 ++++++++ .../views/scripts/downtime/show.phtml | 179 ++++++++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 modules/monitoring/application/controllers/DowntimeController.php create mode 100644 modules/monitoring/application/views/scripts/downtime/show.phtml diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php new file mode 100644 index 000000000..13e7f9e14 --- /dev/null +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -0,0 +1,79 @@ +params->get('downtime_id'); + + $this->downtime = $this->backend->select()->from('downtime', array( + 'id' => 'downtime_internal_id', + 'objecttype' => 'downtime_objecttype', + 'comment' => 'downtime_comment', + 'author_name' => 'downtime_author_name', + 'start' => 'downtime_start', + 'scheduled_start' => 'downtime_scheduled_start', + 'scheduled_end' => 'downtime_scheduled_end', + 'end' => 'downtime_end', + 'duration' => 'downtime_duration', + 'is_flexible' => 'downtime_is_flexible', + 'is_fixed' => 'downtime_is_fixed', + 'is_in_effect' => 'downtime_is_in_effect', + 'entry_time' => 'downtime_entry_time', + 'host_state' => 'downtime_host_state', + 'service_state' => 'downtime_service_state', + 'host_name', + 'host', + 'service', + 'service_description', + 'host_display_name', + 'service_display_name' + ))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow(); + + $this->getTabs() + ->add( + 'downtime', + array( + 'title' => $this->translate( + 'Display detailed information about a downtime.' + ), + 'icon' => 'plug', + 'label' => $this->translate('Downtime'), + 'url' =>'monitoring/downtimes/show' + ) + )->activate('downtime')->extend(new DashboardAction()); + } + + public function showAction() + { + $this->view->downtime = $this->downtime; + $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); + $this->view->delDowntimeForm->setObjects($this->downtime); + $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); + $this->view->showHostLink = Url::fromPath('monitoring/host/show') + ->setParam('host', $this->downtime->host); + $this->view->showServiceLink = Url::fromPath('monitoring/service/show') + ->setParam('host', $this->downtime->host) + ->setParam('service', $this->downtime->service_description); + } +} diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml new file mode 100644 index 000000000..806897e90 --- /dev/null +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -0,0 +1,179 @@ +service_description)) { + $isService = true; + $stateName = Service::getStateText($downtime->service_state); +} else { + $isService = false; + $stateName = Host::getStateText($downtime->host_state); +} +?> + +
+ compact): ?> + tabs; ?> + +

+ + link()->service( + $downtime->service_description, + $downtime->service_display_name, + $downtime->host_name, + $downtime->host_display_name + ); + $icon = $this->icon('service', $this->translate('Service')); + ?> + + icon('host', $this->translate('Host')); + $link = $this->link()->host($downtime->host_name, $downtime->host_display_name) + ?> + + translate( + 'Downtime for %s', + 'Downtime for host or service.' + ), + $link + ); ?> + +

+
+ +
+ + is_flexible): ?> + is_in_effect): ?> + 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), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + is_in_effect): ?> + 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), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + downtime->is_flexible && $this->downtime->is_in_effect): ?> + + + + + + + + + + + + + + + + + + + + + +
translate('Author') ?>escape($this->downtime->author_name) ?>
translate('Comments') ?>escape($this->downtime->comment) ?>
translate('Scheduled start') ?>downtime->scheduled_start) ?>
translate('Scheduled end') ?>downtime->scheduled_end) ?>
translate('Is Flexible') ?> + escape( + $this->downtime->is_flexible ? + $this->translate('Yes') : $this->translate('No') + ); + ?> +
translate('In Effect') ?> + escape( + $this->downtime->is_in_effect ? + $this->translate('Yes') : $this->translate('No') + ); + ?> +
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; + ?> +
+ +
+ From ff47b892e9c2d4ab78cd34443ccab75d5a2d6167 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 21 Apr 2015 17:24:17 +0200 Subject: [PATCH 02/14] Improve order and content of downtime properties Add rows for missing properties, reorder and group related properties. refs #8902 --- .../controllers/DowntimeController.php | 40 +++++++++++- .../views/scripts/downtime/show.phtml | 64 +++---------------- 2 files changed, 47 insertions(+), 57 deletions(-) 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; - ?> + From bb7afd9b2b4a1579188902720182aa2a955dd179 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 21 Apr 2015 17:25:43 +0200 Subject: [PATCH 03/14] Add tooltips to downtime detail view refs #8902 --- .../views/scripts/downtime/show.phtml | 75 ++++++++++++++----- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index d71b92c55..c6084a29f 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -80,37 +80,72 @@

- + - + - + - - - + + + - - - + + + - - - - - - + + - - + + + + + + + + + downtime->is_flexible): ?> + + + + + + + + + + + + + + + +
translate('Author') ?>escape($this->downtime->author_name) ?>icon('user') ?> escape($this->downtime->author_name) ?>
translate('Comments') ?>escape($this->downtime->comment) ?>
translate('Comment') ?>icon('comment') ?> escape($this->downtime->comment) ?>
translate('Scheduled start') ?>downtime->scheduled_start) ?>
translate('Entry Time') ?> escape($this->downtime->entry_time)) ?>
translate('Scheduled end') ?>downtime->scheduled_end) ?>
translate('Is Flexible') ?>
escape( + $this->downtime->is_flexible ? + $this->translate('Flexible') : $this->translate('Fixed') + ); ?> escape( $this->downtime->is_flexible ? - $this->translate('Yes') : $this->translate('No') - ); - ?> + $this->translate('Flexible downtimes have a hard start and end time,' + . ' but also an additional restriction on the duration in which ' + . ' the host or service may actually be down.') : + $this->translate('Fixed downtimes have a static start and end time.') + ); ?>
translate('In Effect') ?>
translate('Scheduled start') ?>downtime->scheduled_start) ?>
translate('Scheduled end') ?>downtime->scheduled_end) ?>
translate('Duration') ?>format()->duration($this->escape($this->downtime->duration)); ?>
translate('Actual start time') ?>start); ?>
translate('Actual end time') ?>end); ?>
translate('In effect') ?> escape( $this->downtime->is_in_effect ? From ab0720fe95f6361596a21324752a762e7dc634e0 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 21 Apr 2015 17:26:08 +0200 Subject: [PATCH 04/14] Add support for multi-selection to downtime list refs #8902 --- .../views/scripts/list/downtimes.phtml | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 3f882a733..2dd62761e 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -19,8 +19,10 @@ if (count($downtimes) === 0) { return; } ?> - - +
- - icon('service', $this->translate('Service')); ?> - link()->service( - $downtime->service_description, $downtime->service_display_name, $downtime->host_name, $downtime->host_display_name - ) ?> - - icon('host', $this->translate('Host')); ?> - link()->host($downtime->host_name, $downtime->host_display_name) ?> - + icon('service'); + } else { + echo $this->icon('host'); + } + ?> + qlink( + sprintf($this->translate('%s on %s', 'Service running on host'), $downtime->service_display_name, $downtime->host_display_name), + 'monitoring/downtime/show', + array('downtime_id' => $downtime->id), + array('title' => sprintf( + $this->translate('Show detailed information for downtime on %s for %s'), + $downtime->service_display_name, + $downtime->host_display_name + ))) ?>
icon('comment', $this->translate('Comment')); ?> [escape($downtime->author_name) ?>] escape($downtime->comment) ?>
From 9114a34223c227eb0440b64fe97d46ca2642c808 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 11:31:53 +0200 Subject: [PATCH 05/14] Display host and service state in downtime detail area refs #8902 --- .../controllers/DowntimeController.php | 6 + .../views/scripts/downtime/show.phtml | 121 ++++++++++-------- 2 files changed, 76 insertions(+), 51 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index af2888383..32c183ba1 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -2,6 +2,8 @@ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ use Icinga\Module\Monitoring\Controller; +use Icinga\Module\Monitoring\Object\Service; +use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -76,6 +78,10 @@ class Monitoring_DowntimeController extends Controller { $this->view->downtime = $this->downtime; $this->view->isService = $this->isService; + $this->view->stateName = isset($this->downtime->service_description) ? + Service::getStateText($this->downtime->service_state) : + Host::getStateText($this->downtime->host_state); + $this->view->delDowntimeForm = $this->createDelDowntimeForm(); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); $this->view->showHostLink = Url::fromPath('monitoring/host/show') diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index c6084a29f..34751cd7c 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -2,6 +2,75 @@ compact): ?> tabs; ?> + + + + + + +
+ is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> +
+ dateTimeRenderer( + ($downtime->is_in_effect ? $downtime->end : $downtime->start), + true + )->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('in %s', 'timespan') + ); + ?> +
+ + 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), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + 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), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + + +
+

isService): ?>
- - 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), - date('H:i', $downtime->start), - $this->format()->duration($downtime->duration), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - 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), - date('d.m.y H:i', $downtime->scheduled_end), - $this->format()->duration($downtime->duration) - ); ?> - - - 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), - date('H:i', $downtime->start), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - 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), - date('H:i', $downtime->scheduled_start), - date('d.m.y', $downtime->scheduled_end), - date('H:i', $downtime->scheduled_end) - ); ?> - - - -
-
- - +
From 20b25e656be03a4258316f5ae9b48418ea35288c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 12:19:58 +0200 Subject: [PATCH 06/14] Show better error message for unknown downtimes refs #8902 --- .../application/controllers/DowntimeController.php | 4 +++- .../application/views/scripts/downtime/show.phtml | 6 ++++++ .../application/views/scripts/list/downtimes.phtml | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 32c183ba1..37f466807 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -76,12 +76,14 @@ class Monitoring_DowntimeController extends Controller public function showAction() { + if (false === $this->downtime) { + return; + } $this->view->downtime = $this->downtime; $this->view->isService = $this->isService; $this->view->stateName = isset($this->downtime->service_description) ? Service::getStateText($this->downtime->service_state) : Host::getStateText($this->downtime->host_state); - $this->view->delDowntimeForm = $this->createDelDowntimeForm(); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); $this->view->showHostLink = Url::fromPath('monitoring/host/show') diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index 34751cd7c..ddc91eeeb 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -1,4 +1,10 @@
+ + translate('No scheduled downtime matching the filter.') ?> +
+ + + compact): ?> tabs; ?> diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 2dd62761e..b21e3c3fb 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -15,7 +15,8 @@ if (! $this->compact): ?> translate('No downtimes found matching the filter') . ''; + echo $this->translate('No downtimes found matching the filter,' + . ' maybe the downtime already expired.') . ''; return; } ?> From a87e1f91d9b9ae5c169850985d19016c8025bb42 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 14:43:30 +0200 Subject: [PATCH 07/14] Implement detail view for multiple downtimes refs #8902 --- .../controllers/DowntimesController.php | 122 ++++++++++++++++++ .../views/scripts/downtimes/show.phtml | 41 ++++++ 2 files changed, 163 insertions(+) create mode 100644 modules/monitoring/application/controllers/DowntimesController.php create mode 100644 modules/monitoring/application/views/scripts/downtimes/show.phtml diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php new file mode 100644 index 000000000..b0057466f --- /dev/null +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -0,0 +1,122 @@ +filter = Filter::fromQueryString(str_replace( + 'downtime_id', + 'downtime_internal_id', + (string)$this->params + )); + $this->downtimes = $this->backend->select()->from('downtime', array( + 'id' => 'downtime_internal_id', + 'objecttype' => 'downtime_objecttype', + 'comment' => 'downtime_comment', + 'author_name' => 'downtime_author_name', + 'start' => 'downtime_start', + 'scheduled_start' => 'downtime_scheduled_start', + 'scheduled_end' => 'downtime_scheduled_end', + 'end' => 'downtime_end', + 'duration' => 'downtime_duration', + 'is_flexible' => 'downtime_is_flexible', + 'is_fixed' => 'downtime_is_fixed', + 'is_in_effect' => 'downtime_is_in_effect', + 'entry_time' => 'downtime_entry_time', + 'host_state' => 'downtime_host_state', + 'service_state' => 'downtime_service_state', + 'host_name', + 'host', + 'service', + 'service_description', + 'host_display_name', + 'service_display_name' + ))->addFilter($this->filter)->getQuery()->fetchAll(); + $this->getTabs() + ->add( + 'downtimes', + array( + 'title' => $this->translate( + 'Display detailed information about multiple downtimes.' + ), + 'icon' => 'plug', + 'label' => $this->translate('Downtimes'), + 'url' =>'monitoring/downtimes/show' + ) + )->activate('downtimes')->extend(new DashboardAction()); + } + + public function showAction() + { + if (false === $this->downtimes) { + return; + } + $this->view->downtimes = $this->downtimes; + $this->view->isService = $this->isService; + + // $this->view->delDowntimeForm = $this->createDelDowntimeForm(); + $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') + ->setQueryString($this->filter->toQueryString()); + $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/removeAll') + ->setParams($this->params); + } + + public function removeAllAction() + { + + } + + private function createDelDowntimeForm() + { + $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm->setObjects($this->downtimes); + $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/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml new file mode 100644 index 000000000..89ecc7073 --- /dev/null +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -0,0 +1,41 @@ +
+ + translate('No scheduled downtimes matching the filter.') ?> +
+ + + + compact): ?> + tabs; ?> + + +

+ +

+ + +
+

+ translate('You have selected') ?> + qlink( + sprintf($this->translate('%d downtimes'), count($downtimes)), + $listAllLink, + null, + array('title' => $this->translate('List all selected downtimes.')) + ) ?> +

+ qlink( + sprintf( + $this->translate('Remove all %d downtimes.'), + count($downtimes) + ), + $removeAllLink, + null, + array( + 'icon' => 'trash', + 'title' => $this->translate('Remove all selected downtimes.') + ) + ) ?> +
+

+
From 07c5e67304e993b7c6ba45b842a2f5fffb44474c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 16:35:35 +0200 Subject: [PATCH 08/14] Display additional downtime info in multiselection detail view refs #8902 --- .../controllers/DowntimesController.php | 24 +-- .../views/scripts/downtimes/show.phtml | 153 ++++++++++++++---- 2 files changed, 138 insertions(+), 39 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index b0057466f..eec408110 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -23,8 +23,6 @@ class Monitoring_DowntimesController extends Controller { protected $downtimes; - protected $isService; - protected $filter; /** @@ -72,6 +70,20 @@ class Monitoring_DowntimesController extends Controller 'url' =>'monitoring/downtimes/show' ) )->activate('downtimes')->extend(new DashboardAction()); + + foreach ($this->downtimes as $downtime) { + if (isset($downtime->service_description)) { + $downtime->isService = true; + } else { + $downtime->isService = false; + } + + if ($downtime->isService) { + $downtime->stateText = Service::getStateText($downtime->service_state); + } else { + $downtime->stateText = Host::getStateText($downtime->host_state); + } + } } public function showAction() @@ -80,9 +92,6 @@ class Monitoring_DowntimesController extends Controller return; } $this->view->downtimes = $this->downtimes; - $this->view->isService = $this->isService; - - // $this->view->delDowntimeForm = $this->createDelDowntimeForm(); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString($this->filter->toQueryString()); $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/removeAll') @@ -90,11 +99,6 @@ class Monitoring_DowntimesController extends Controller } public function removeAllAction() - { - - } - - private function createDelDowntimeForm() { $delDowntimeForm = new DeleteDowntimeCommandForm(); $delDowntimeForm->setObjects($this->downtimes); diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index 89ecc7073..a683722ac 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -8,34 +8,129 @@ compact): ?> tabs; ?> - -

- -

- -
-

- translate('You have selected') ?> - qlink( - sprintf($this->translate('%d downtimes'), count($downtimes)), - $listAllLink, - null, - array('title' => $this->translate('List all selected downtimes.')) - ) ?> -

- qlink( - sprintf( - $this->translate('Remove all %d downtimes.'), - count($downtimes) - ), - $removeAllLink, - null, - array( - 'icon' => 'trash', - 'title' => $this->translate('Remove all selected downtimes.') - ) - ) ?> -
-

+

+ translate('%d Downtimes'), count($downtimes)) ?> + 5 ? + sprintf($this->translate('(%d not shown)'), count ($downtimes) - 5) + : ''; + ?> +

+

+

translate('Author') ?>
+ + 5) { + continue; + } ?> + + + + + + +
+ is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> +
+ dateTimeRenderer( + ($downtime->is_in_effect ? $downtime->end : $downtime->start), + true + )->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('in %s', 'timespan') + ); + ?> +
+ isService): ?> + icon('service') ?> + service ?> on host_name ?>. + + icon('host') ?> + host_name ?>. + + + 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), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + 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), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + +
+

+ qlink( + sprintf($this->translate('List all %d downtimes …'), count($downtimes)), + $listAllLink, + null, + array( + 'title' => $this->translate('List all'), + 'data-base-target' => "_next" + ) + ) ?> +

+

+
+
+

icon('reschedule') ?> translate('Commands') ?>

+

+ translate('Issue commands to all %s selected downtimes.'), + '' . count($downtimes) . '' + ) + ?> +

+ qlink( + sprintf( + $this->translate('Remove all %d scheduled downtimes'), + count($downtimes) + ), + $removeAllLink, + null, + array( + 'icon' => 'trash', + 'title' => $this->translate('Remove all selected downtimes.') + ) + ) ?> +
+

From 400f351ea580800d22f56c23c0512839686f1b25 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 23 Apr 2015 16:55:59 +0200 Subject: [PATCH 09/14] Improve detail view layout refs #8902 --- .../views/scripts/downtime/show.phtml | 57 +++++++++---------- .../views/scripts/downtimes/show.phtml | 12 +--- 2 files changed, 30 insertions(+), 39 deletions(-) diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index ddc91eeeb..ade9495b0 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -76,45 +76,44 @@

- -

- isService): ?> - link()->service( - $downtime->service_description, - $downtime->service_display_name, - $downtime->host_name, - $downtime->host_display_name - ); - $icon = $this->icon('service', $this->translate('Service')); - ?> - - icon('host', $this->translate('Host')); - $link = $this->link()->host($downtime->host_name, $downtime->host_display_name) - ?> - - translate( - 'Downtime on %s', - 'Downtime for host or service.' - ), - $link - ); ?> - -

+

translate('Downtime detail information') ?>

+ + + + - + - + diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index a683722ac..c7ddb0ae6 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -8,14 +8,6 @@ compact): ?> tabs; ?> - -

- translate('%d Downtimes'), count($downtimes)) ?> - 5 ? - sprintf($this->translate('(%d not shown)'), count ($downtimes) - 5) - : ''; - ?> -

+ isService ? $this->translate('Service') : $this->translate('Host') ?> + + isService): ?> + link()->service( + $downtime->service_description, + $downtime->service_display_name, + $downtime->host_name, + $downtime->host_display_name + ); + $icon = $this->icon('service', $this->translate('Service')); + ?> + + icon('host', $this->translate('Host')); + $link = $this->link()->host($downtime->host_name, $downtime->host_display_name) + ?> + + + +
translate('Author') ?>icon('user') ?> escape($this->downtime->author_name) ?>icon('user', $this->translate('User')) ?> escape($this->downtime->author_name) ?>
translate('Comment') ?>icon('comment') ?> escape($this->downtime->comment) ?>icon('comment', $this->translate('Comment')) ?> escape($this->downtime->comment) ?>
translate('Entry Time') ?>
@@ -40,10 +32,10 @@ From d316b31cbb5358df479a7370b6152196909a4294 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 30 Apr 2015 16:50:55 +0200 Subject: [PATCH 14/14] 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 --- .../controllers/DowntimeController.php | 18 ++-- .../controllers/DowntimesController.php | 4 +- .../controllers/ListController.php | 4 +- .../Object/DeleteDowntimeCommandForm.php | 95 +++++++++++-------- .../Object/DeleteDowntimeQuickCommandForm.php | 36 ------- .../Object/DeleteDowntimesCommandForm.php | 89 +++++++++++++++++ .../Controller/MonitoredObjectController.php | 4 +- 7 files changed, 159 insertions(+), 91 deletions(-) delete mode 100644 modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php create mode 100644 modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 086e39f10..7a769b4d6 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -4,7 +4,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Host; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeQuickCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -100,11 +100,17 @@ class Monitoring_DowntimeController extends Controller { $this->assertPermission('monitoring/command/downtime/delete'); - $delDowntimeForm = new DeleteDowntimeQuickCommandForm(); - $delDowntimeForm->setDowntimes(array($this->downtime)) - ->populate( - array('redirect' => Url::fromPath('monitoring/list/downtimes')) - ); + $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm->setAction( + Url::fromPath('monitoring/downtime/show') + ->setParam('downtime_id', $this->downtime->id) + ); + $delDowntimeForm->populate( + array( + 'redirect' => Url::fromPath('monitoring/list/downtimes'), + 'downtime_id' => $this->downtime->id + ) + ); $delDowntimeForm->handleRequest(); return $delDowntimeForm; } diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index 608e3c9fc..28ba76cb4 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -5,7 +5,7 @@ use Icinga\Data\Filter\Filter; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Host; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimesCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -107,7 +107,7 @@ class Monitoring_DowntimesController extends Controller $this->view->downtimes = $this->downtimes; $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString($this->filter->toQueryString()); - $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm = new DeleteDowntimesCommandForm(); $delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes')); $delDowntimeForm->addDescription(sprintf( $this->translate('Confirm removal of %d downtimes.'), diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index b0b0d9f2e..e6147c31b 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -4,7 +4,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeQuickCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Widget\Tabextension\OutputFormat; @@ -294,7 +294,7 @@ class Monitoring_ListController extends Controller )); if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { - $this->view->delDowntimeForm = new DeleteDowntimeQuickCommandForm(); + $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 72728cd5a..8862c2b53 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -12,8 +12,6 @@ use Icinga\Web\Notification; */ class DeleteDowntimeCommandForm extends CommandForm { - protected $downtimes; - /** * (non-PHPDoc) * @see \Zend_Form::init() For the method documentation. @@ -22,50 +20,76 @@ class DeleteDowntimeCommandForm extends CommandForm { $this->setAttrib('class', 'inline'); } - - /** + + /** * (non-PHPDoc) * @see \Icinga\Web\Form::createElements() For the method documentation. */ public function createElements(array $formData = array()) { - $this->addElements(array( + $this->addElements( array( - 'hidden', - 'redirect', array( - 'decorators' => array('ViewHelper') + 'hidden', + 'downtime_id', + array( + 'decorators' => array('ViewHelper') + ) + ), + 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. + * @see \Icinga\Web\Form::addSubmitButton() For the method documentation. + */ + public function addSubmitButton() + { + $this->addElement( + 'button', + 'btn_submit', + array( + 'ignore' => true, + 'escape' => false, + 'type' => 'submit', + 'class' => 'link-like', + 'label' => $this->getView()->icon('trash'), + 'title' => $this->translate('Delete this downtime'), + 'decorators' => array('ViewHelper') + ) + ); + return $this; + } + + /** + * (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); - } + $id = $this->getElement('downtime_id')->getValue(); + + // Presence of downtime id, only delete this specific downtime + $firstDowntime = $this->downtimes[0]; + + $delDowntime = new DeleteDowntimeCommand(); + $delDowntime->setDowntimeId($id); + $delDowntime->setDowntimeType( + isset($firstDowntime->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); @@ -73,17 +97,4 @@ class DeleteDowntimeCommandForm extends CommandForm 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; - } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php deleted file mode 100644 index adbfcae43..000000000 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php +++ /dev/null @@ -1,36 +0,0 @@ -addElement( - 'button', - 'btn_submit', - array( - 'ignore' => true, - 'escape' => false, - 'type' => 'submit', - 'class' => 'link-like', - 'label' => $this->getView()->icon('trash'), - 'title' => $this->translate('Delete this downtime'), - 'decorators' => array('ViewHelper') - ) - ); - return $this; - } -} diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php new file mode 100644 index 000000000..f460f3601 --- /dev/null +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php @@ -0,0 +1,89 @@ +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; + } +} diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 42060d2f0..94d9f6399 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -89,9 +89,7 @@ abstract class MonitoredObjectController extends Controller } if (! empty($this->object->downtimes) && $auth->hasPermission('monitoring/command/downtime/delete')) { $delDowntimeForm = new DeleteDowntimeCommandForm(); - $delDowntimeForm - ->setDowntimes($this->object->downtimes) - ->handleRequest(); + $delDowntimeForm->handleRequest(); $this->view->delDowntimeForm = $delDowntimeForm; } $this->view->object = $this->object;
isService): ?> - icon('service') ?> + icon('service', $this->translate('Service')) ?> service ?> on host_name ?>. - icon('host') ?> + icon('host', $this->translate('Host')) ?> host_name ?>. From b186ce2cacc6da511a2cb5a1f696f12cb097c51e Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 27 Apr 2015 17:53:17 +0200 Subject: [PATCH 10/14] Handle non-existed downtime ids with exceptions refs #8902 --- .../application/controllers/DowntimeController.php | 7 ++++--- .../controllers/DowntimesController.php | 6 ++++++ .../application/views/scripts/downtime/show.phtml | 14 ++++---------- .../application/views/scripts/downtimes/show.phtml | 5 ----- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 37f466807..26a88ae3b 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -54,6 +54,10 @@ class Monitoring_DowntimeController extends Controller 'service_display_name' ))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow(); + if (false === $this->downtime) { + throw new Zend_Controller_Action_Exception($this->translate('Downtime not found')); + } + if (isset($this->downtime->service_description)) { $this->isService = true; } else { @@ -76,9 +80,6 @@ class Monitoring_DowntimeController extends Controller public function showAction() { - if (false === $this->downtime) { - return; - } $this->view->downtime = $this->downtime; $this->view->isService = $this->isService; $this->view->stateName = isset($this->downtime->service_description) ? diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index eec408110..fe4e9f5bb 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -58,6 +58,12 @@ class Monitoring_DowntimesController extends Controller 'host_display_name', 'service_display_name' ))->addFilter($this->filter)->getQuery()->fetchAll(); + if (false === $this->downtimes) { + throw new Zend_Controller_Action_Exception( + $this->translate('Downtime not found') + ); + } + $this->getTabs() ->add( 'downtimes', diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index ade9495b0..6ecc11a7b 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -1,13 +1,7 @@ -
- - translate('No scheduled downtime matching the filter.') ?> -
- - - - compact): ?> - tabs; ?> - +
+ compact): ?> + tabs; ?> + diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index c7ddb0ae6..caff167f2 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -1,9 +1,4 @@
- - translate('No scheduled downtimes matching the filter.') ?> -
- - compact): ?> tabs; ?> From 6ddb0042309d5c088ece002962839936f7def6a2 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 27 Apr 2015 18:04:10 +0200 Subject: [PATCH 11/14] Move removal command actions into the downtime controllers refs #8902 --- .../controllers/DowntimeController.php | 33 ++++------ .../controllers/DowntimesController.php | 41 +++++------- .../controllers/ListController.php | 4 +- .../Object/DeleteDowntimeCommandForm.php | 63 +++++++++---------- .../Object/DeleteDowntimeQuickCommandForm.php | 36 +++++++++++ .../Command/Object/DeleteDowntimeCommand.php | 42 ++++++++++--- .../IcingaCommandFileCommandRenderer.php | 2 +- .../Controller/MonitoredObjectController.php | 12 +--- 8 files changed, 131 insertions(+), 102 deletions(-) create mode 100644 modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 26a88ae3b..086e39f10 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -4,7 +4,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Host; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeQuickCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -85,38 +85,27 @@ class Monitoring_DowntimeController extends Controller $this->view->stateName = isset($this->downtime->service_description) ? Service::getStateText($this->downtime->service_state) : Host::getStateText($this->downtime->host_state); - $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); $this->view->showServiceLink = Url::fromPath('monitoring/service/show') ->setParam('host', $this->downtime->host) ->setParam('service', $this->downtime->service_description); + if ($this->hasPermission('monitoring/command/downtime/delete')) { + $this->view->delDowntimeForm = $this->createDelDowntimeForm(); + } } 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)) + $this->assertPermission('monitoring/command/downtime/delete'); + + $delDowntimeForm = new DeleteDowntimeQuickCommandForm(); + $delDowntimeForm->setDowntimes(array($this->downtime)) + ->populate( + array('redirect' => Url::fromPath('monitoring/list/downtimes')) ); - } else { - $delDowntimeForm->setAction( - $this->view->url('monitoring/service/delete-downtime', array( - 'host' => $this->downtime->host_name, - 'service' => $this->downtime->service_description - )) - ); - } + $delDowntimeForm->handleRequest(); return $delDowntimeForm; } } diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index fe4e9f5bb..608e3c9fc 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -94,39 +94,28 @@ class Monitoring_DowntimesController extends Controller public function showAction() { - if (false === $this->downtimes) { - return; - } $this->view->downtimes = $this->downtimes; $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString($this->filter->toQueryString()); - $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/removeAll') + $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/remove-all') ->setParams($this->params); } public function removeAllAction() { + $this->assertPermission('monitoring/command/downtime/delete'); + $this->view->downtimes = $this->downtimes; + $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') + ->setQueryString($this->filter->toQueryString()); $delDowntimeForm = new DeleteDowntimeCommandForm(); - $delDowntimeForm->setObjects($this->downtimes); - $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; + $delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes')); + $delDowntimeForm->addDescription(sprintf( + $this->translate('Confirm removal of %d downtimes.'), + count($this->downtimes) + )); + $delDowntimeForm->setDowntimes($this->downtimes) + ->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')) + ->handleRequest(); + $this->view->delDowntimeForm = $delDowntimeForm; } -} +} \ No newline at end of file diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index e6147c31b..b0b0d9f2e 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -4,7 +4,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeQuickCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Widget\Tabextension\OutputFormat; @@ -294,7 +294,7 @@ class Monitoring_ListController extends Controller )); if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { - $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); + $this->view->delDowntimeForm = new DeleteDowntimeQuickCommandForm(); } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index d240251cf..72728cd5a 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -4,13 +4,16 @@ 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 DeleteDowntimeCommandForm extends ObjectsCommandForm +class DeleteDowntimeCommandForm extends CommandForm { + protected $downtimes; + /** * (non-PHPDoc) * @see \Zend_Form::init() For the method documentation. @@ -27,14 +30,6 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm public function createElements(array $formData = array()) { $this->addElements(array( - array( - 'hidden', - 'downtime_id', - array( - 'required' => true, - 'decorators' => array('ViewHelper') - ) - ), array( 'hidden', 'redirect', @@ -45,48 +40,50 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm )); return $this; } - + /** * (non-PHPDoc) - * @see \Icinga\Web\Form::addSubmitButton() For the method documentation. + * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ - public function addSubmitButton() + public function getSubmitLabel() { - $this->addElement( - 'button', - 'btn_submit', - array( - 'ignore' => true, - 'escape' => false, - 'type' => 'submit', - 'class' => 'link-like', - 'label' => $this->getView()->icon('trash'), - 'title' => $this->translate('Delete this downtime'), - 'decorators' => array('ViewHelper') - ) - ); - return $this; + 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->objects as $object) { - /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ + foreach ($this->downtimes as $downtime) { $delDowntime = new DeleteDowntimeCommand(); - $delDowntime - ->setObject($object) - ->setDowntimeId($this->getElement('downtime_id')->getValue()); + $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..')); + 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; + } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php new file mode 100644 index 000000000..adbfcae43 --- /dev/null +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeQuickCommandForm.php @@ -0,0 +1,36 @@ +addElement( + 'button', + 'btn_submit', + array( + 'ignore' => true, + 'escape' => false, + 'type' => 'submit', + 'class' => 'link-like', + 'label' => $this->getView()->icon('trash'), + 'title' => $this->translate('Delete this downtime'), + 'decorators' => array('ViewHelper') + ) + ); + return $this; + } +} diff --git a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php index 52ad99e1b..96dc8f755 100644 --- a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php +++ b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php @@ -3,19 +3,22 @@ namespace Icinga\Module\Monitoring\Command\Object; +use Icinga\Module\Monitoring\Command\IcingaCommand; + /** * Delete a host or service downtime */ -class DeleteDowntimeCommand extends ObjectCommand +class DeleteDowntimeCommand extends IcingaCommand { /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation. + * Downtime for a host */ - protected $allowedObjects = array( - self::TYPE_HOST, - self::TYPE_SERVICE - ); + const DOWNTIME_TYPE_HOST = 'host'; + + /** + * Downtime for a service + */ + const DOWNTIME_TYPE_SERVICE = 'service'; /** * ID of the downtime that is to be deleted @@ -23,6 +26,31 @@ class DeleteDowntimeCommand extends ObjectCommand * @var int */ protected $downtimeId; + + /** + * + * @var type + */ + protected $downtimeType = self::DOWNTIME_TYPE_HOST; + + /** + * Set the downtime type, either host or service + * + * @param string $type the downtime type + */ + public function setDowntimeType($type) + { + $this->downtimeType = $type; + } + + /** + * + * @return type + */ + public function getDowntimeType() + { + return $this->downtimeType; + } /** * Set the ID of the downtime that is to be deleted diff --git a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php index cf88d7d2e..83fbd4364 100644 --- a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php +++ b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php @@ -337,7 +337,7 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface public function renderDeleteDowntime(DeleteDowntimeCommand $command) { - if ($command->getObject()->getType() === $command::TYPE_HOST) { + if ($command->getDowntimeType() === 'host') { $commandString = 'DEL_HOST_DOWNTIME'; } else { $commandString = 'DEL_SVC_DOWNTIME'; diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 04102e9d2..42060d2f0 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -90,7 +90,7 @@ abstract class MonitoredObjectController extends Controller if (! empty($this->object->downtimes) && $auth->hasPermission('monitoring/command/downtime/delete')) { $delDowntimeForm = new DeleteDowntimeCommandForm(); $delDowntimeForm - ->setObjects($this->object) + ->setDowntimes($this->object->downtimes) ->handleRequest(); $this->view->delDowntimeForm = $delDowntimeForm; } @@ -147,16 +147,6 @@ abstract class MonitoredObjectController extends Controller $this->handleCommandForm(new DeleteCommentCommandForm()); } - /** - * Delete a downtime - */ - public function deleteDowntimeAction() - { - $this->assertHttpMethod('POST'); - $this->assertPermission('monitoring/command/downtime/delete'); - $this->handleCommandForm(new DeleteDowntimeCommandForm()); - } - /** * Create tabs */ From be566746a94544ba86b9ad64d4e07cbeca644227 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 30 Apr 2015 13:43:30 +0200 Subject: [PATCH 12/14] Provide downtime header in remove and remove-all commands Add new show script for downtimes and move downtime headers into partials to deduplicate code. refs #8902 --- .../views/scripts/downtime/remove.phtml | 11 +++ .../views/scripts/downtime/show.phtml | 71 +------------- .../views/scripts/downtimes/remove-all.phtml | 12 +++ .../views/scripts/downtimes/show.phtml | 96 +------------------ .../partials/downtime/downtime-header.phtml | 67 +++++++++++++ .../partials/downtime/downtimes-header.phtml | 92 ++++++++++++++++++ 6 files changed, 187 insertions(+), 162 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/downtime/remove.phtml create mode 100644 modules/monitoring/application/views/scripts/downtimes/remove-all.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml diff --git a/modules/monitoring/application/views/scripts/downtime/remove.phtml b/modules/monitoring/application/views/scripts/downtime/remove.phtml new file mode 100644 index 000000000..57fe36655 --- /dev/null +++ b/modules/monitoring/application/views/scripts/downtime/remove.phtml @@ -0,0 +1,11 @@ +
+ + compact): ?> + tabs; ?> + + + render('partials/downtime/downtime-header.phtml'); ?> +
+
+ +
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index 6ecc11a7b..aed35b9ac 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -3,75 +3,8 @@ tabs; ?> -
- - - - -
- is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> -
- dateTimeRenderer( - ($downtime->is_in_effect ? $downtime->end : $downtime->start), - true - )->render( - $this->translate('on %s', 'datetime'), - $this->translate('at %s', 'time'), - $this->translate('in %s', 'timespan') - ); - ?> -
- - 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), - date('H:i', $downtime->start), - $this->format()->duration($downtime->duration), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - 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), - date('d.m.y H:i', $downtime->scheduled_end), - $this->format()->duration($downtime->duration) - ); ?> - - - 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), - date('H:i', $downtime->start), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - 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), - date('H:i', $downtime->scheduled_start), - date('d.m.y', $downtime->scheduled_end), - date('H:i', $downtime->scheduled_end) - ); ?> - - - -
+ render('partials/downtime/downtime-header.phtml'); ?>
-

translate('Downtime detail information') ?>

@@ -177,7 +110,7 @@ diff --git a/modules/monitoring/application/views/scripts/downtimes/remove-all.phtml b/modules/monitoring/application/views/scripts/downtimes/remove-all.phtml new file mode 100644 index 000000000..fed0e12f7 --- /dev/null +++ b/modules/monitoring/application/views/scripts/downtimes/remove-all.phtml @@ -0,0 +1,12 @@ +
+ + compact): ?> + tabs; ?> + + + render('partials/downtime/downtimes-header.phtml'); ?> +
+ +
+ +
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index caff167f2..98999f012 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -3,98 +3,8 @@ compact): ?> tabs; ?> -

-

translate('Commands') ?> - +
- - 5) { - continue; - } ?> - - - - - - -
- is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> -
- dateTimeRenderer( - ($downtime->is_in_effect ? $downtime->end : $downtime->start), - true - )->render( - $this->translate('on %s', 'datetime'), - $this->translate('at %s', 'time'), - $this->translate('in %s', 'timespan') - ); - ?> -
- isService): ?> - icon('service', $this->translate('Service')) ?> - service ?> on host_name ?>. - - icon('host', $this->translate('Host')) ?> - host_name ?>. - - - 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), - date('H:i', $downtime->start), - $this->format()->duration($downtime->duration), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - 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), - date('d.m.y H:i', $downtime->scheduled_end), - $this->format()->duration($downtime->duration) - ); ?> - - - 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), - date('H:i', $downtime->start), - date('d.m.y', $downtime->end), - date('H:i', $downtime->end) - ); ?> - - 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), - date('H:i', $downtime->scheduled_start), - date('d.m.y', $downtime->scheduled_end), - date('H:i', $downtime->scheduled_end) - ); ?> - - -
-

- qlink( - sprintf($this->translate('List all %d downtimes …'), count($downtimes)), - $listAllLink, - null, - array( - 'title' => $this->translate('List all'), - 'data-base-target' => "_next" - ) - ) ?> -

+ + render('partials/downtime/downtimes-header.phtml'); ?>

@@ -119,5 +29,5 @@ ) ) ?>
-

+

diff --git a/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml b/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml new file mode 100644 index 000000000..92759a12a --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml @@ -0,0 +1,67 @@ + + + + + +
+ is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> +
+ dateTimeRenderer( + ($downtime->is_in_effect ? $downtime->end : $downtime->start), + true + )->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('in %s', 'timespan') + ); + ?> +
+ + 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), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + 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), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + + +
diff --git a/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml b/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml new file mode 100644 index 000000000..54cd0210c --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml @@ -0,0 +1,92 @@ + + + 5) { + continue; + } ?> + + + + + + +
+ is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> +
+ dateTimeRenderer( + ($downtime->is_in_effect ? $downtime->end : $downtime->start), + true + )->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('in %s', 'timespan') + ); + ?> +
+ isService): ?> + icon('service', $this->translate('Service')) ?> + service ?> on host_name ?>. + + icon('host', $this->translate('Host')) ?> + host_name ?>. + + + 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), + date('H:i', $downtime->start), + $this->format()->duration($downtime->duration), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('d.m.y H:i', $downtime->scheduled_end), + $this->format()->duration($downtime->duration) + ); ?> + + + 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), + date('H:i', $downtime->start), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + 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), + date('H:i', $downtime->scheduled_start), + date('d.m.y', $downtime->scheduled_end), + date('H:i', $downtime->scheduled_end) + ); ?> + + +
+ +

+ qlink( + sprintf($this->translate('List all %d downtimes …'), count($downtimes)), + $listAllLink, + null, + array( + 'title' => $this->translate('List all'), + 'data-base-target' => "_next" + ) + ) ?> +

\ No newline at end of file From a46dece13650902ee130391bc71002c7beb96098 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 30 Apr 2015 16:30:04 +0200 Subject: [PATCH 13/14] Provie link to detail view in downtime partial refs #8902 --- .../scripts/show/components/downtime.phtml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index b338f8a71..bfb9bbf45 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -47,12 +47,15 @@ foreach ($object->downtimes as $downtime) { ) : $this->escape($downtime->comment); if ((bool) $downtime->is_in_effect) { - $state = 'in downtime since ' . $this->timeSince($downtime->start); + $state = 'in downtime since '; + $time = $this->timeSince($downtime->start); } else { if ((bool) $downtime->is_fixed) { - $state = 'scheduled ' . $this->timeUntil($downtime->start); + $state = 'scheduled '; + $time = $this->timeUntil($downtime->start); } else { - $state = 'scheduled flexible ' . $this->timeUntil($downtime->start); + $state = 'scheduled flexible '; + $time = $this->timeUntil($downtime->start); } } @@ -65,7 +68,14 @@ foreach ($object->downtimes as $downtime) { $delDowntimeForm->populate(array('downtime_id' => $downtime->id)); echo $delDowntimeForm; } ?> - translate('Downtime'); ?> - ', $commentText); ?> + translate('Downtime'); ?> + qlink( + $state, + 'monitoring/downtime/show', + array('downtime_id' => $downtime->id), + array('data-base-target' => '_next') + ) . $time ; ?> - ', $commentText); ?>