diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php
new file mode 100644
index 000000000..7a769b4d6
--- /dev/null
+++ b/modules/monitoring/application/controllers/DowntimeController.php
@@ -0,0 +1,117 @@
+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();
+
+ 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 {
+ $this->isService = false;
+ }
+
+ $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->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->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()
+ {
+ $this->assertPermission('monitoring/command/downtime/delete');
+
+ $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
new file mode 100644
index 000000000..28ba76cb4
--- /dev/null
+++ b/modules/monitoring/application/controllers/DowntimesController.php
@@ -0,0 +1,121 @@
+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();
+ if (false === $this->downtimes) {
+ throw new Zend_Controller_Action_Exception(
+ $this->translate('Downtime not found')
+ );
+ }
+
+ $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());
+
+ 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()
+ {
+ $this->view->downtimes = $this->downtimes;
+ $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes')
+ ->setQueryString($this->filter->toQueryString());
+ $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 DeleteDowntimesCommandForm();
+ $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/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php
index d240251cf..8862c2b53 100644
--- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php
@@ -4,12 +4,13 @@
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
{
/**
* (non-PHPDoc)
@@ -19,33 +20,34 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
{
$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',
- 'downtime_id',
array(
- 'required' => true,
- 'decorators' => array('ViewHelper')
- )
- ),
- array(
- 'hidden',
- 'redirect',
+ 'hidden',
+ 'downtime_id',
+ array(
+ 'decorators' => array('ViewHelper')
+ )
+ ),
array(
- 'decorators' => array('ViewHelper')
+ 'hidden',
+ 'redirect',
+ array(
+ 'decorators' => array('ViewHelper')
+ )
)
)
- ));
+ );
return $this;
}
-
+
/**
* (non-PHPDoc)
* @see \Icinga\Web\Form::addSubmitButton() For the method documentation.
@@ -67,26 +69,32 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
);
return $this;
}
-
+
/**
* (non-PHPDoc)
- * @see \Icinga\Web\Form::onSuccess() For the method documentation.
+ * @see \Icinga\Web\Form::onSuccess() For the method documentation.
*/
public function onSuccess()
{
- foreach ($this->objects as $object) {
- /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
- $delDowntime = new DeleteDowntimeCommand();
- $delDowntime
- ->setObject($object)
- ->setDowntimeId($this->getElement('downtime_id')->getValue());
- $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);
}
- Notification::success($this->translate('Deleting downtime..'));
+ Notification::success($this->translate('Deleting downtime.'));
return true;
}
}
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/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): ?>
+ = $this->tabs; ?>
+
+
+ = $this->render('partials/downtime/downtime-header.phtml'); ?>
+
+
+ = $delDowntimeForm; ?>
+
\ 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
new file mode 100644
index 000000000..aed35b9ac
--- /dev/null
+++ b/modules/monitoring/application/views/scripts/downtime/show.phtml
@@ -0,0 +1,121 @@
+
+ compact): ?>
+ = $this->tabs; ?>
+
+
+ = $this->render('partials/downtime/downtime-header.phtml'); ?>
+
+
+
= $this->translate('Downtime detail information') ?>
+
+
+
+
+ = $this->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)
+ ?>
+
+ = $icon ?>
+ = $link ?>
+ |
+
+
+ = $this->translate('Author') ?> |
+ = $this->icon('user', $this->translate('User')) ?> = $this->escape($this->downtime->author_name) ?> |
+
+
+ = $this->translate('Comment') ?> |
+ = $this->icon('comment', $this->translate('Comment')) ?> = $this->escape($this->downtime->comment) ?> |
+
+
+ = $this->translate('Entry Time') ?> |
+ = date('d.m.y H:i' ,$this->escape($this->downtime->entry_time)) ?> |
+
+
+ = $this->escape(
+ $this->downtime->is_flexible ?
+ $this->translate('Flexible') : $this->translate('Fixed')
+ ); ?> |
+
+ = $this->escape(
+ $this->downtime->is_flexible ?
+ $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.')
+ ); ?>
+ |
+
+
+ = $this->translate('Scheduled start') ?> |
+ = date('d.m.y H:i', $this->downtime->scheduled_start) ?> |
+
+
+ = $this->translate('Scheduled end') ?> |
+ = date('d.m.y H:i', $this->downtime->scheduled_end) ?> |
+
+ downtime->is_flexible): ?>
+
+ = $this->translate('Duration') ?> |
+ = $this->format()->duration($this->escape($this->downtime->duration)); ?> |
+
+
+ = $this->translate('Actual start time') ?> |
+ = date('d.m.y H:i', $downtime->start); ?> |
+
+
+ = $this->translate('Actual end time') ?> |
+ = date('d.m.y H:i', $downtime->end); ?> |
+
+
+
+
+ = $this->translate('In effect') ?> |
+
+ = $this->escape(
+ $this->downtime->is_in_effect ?
+ $this->translate('Yes') : $this->translate('No')
+ );
+ ?>
+ |
+
+
+
+
+ = $this->translate('Commands') ?> |
+
+ = $delDowntimeForm ?>
+ |
+
+
+
+
+
+
+
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): ?>
+ = $this->tabs; ?>
+
+
+ = $this->render('partials/downtime/downtimes-header.phtml'); ?>
+
+
+
+ = $delDowntimeForm ?>
+
\ 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
new file mode 100644
index 000000000..98999f012
--- /dev/null
+++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml
@@ -0,0 +1,33 @@
+
+
+ compact): ?>
+ = $this->tabs; ?>
+
+
+ = $this->render('partials/downtime/downtimes-header.phtml'); ?>
+
+
+
+
= $this->icon('reschedule') ?> = $this->translate('Commands') ?>
+
+ = sprintf(
+ $this->translate('Issue commands to all %s selected downtimes.'),
+ '' . count($downtimes) . ''
+ )
+ ?>
+
+ = $this->qlink(
+ sprintf(
+ $this->translate('Remove all %d scheduled downtimes'),
+ count($downtimes)
+ ),
+ $removeAllLink,
+ null,
+ array(
+ 'icon' => 'trash',
+ 'title' => $this->translate('Remove all selected downtimes.')
+ )
+ ) ?>
+
+
+
diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml
index 3f882a733..b21e3c3fb 100644
--- a/modules/monitoring/application/views/scripts/list/downtimes.phtml
+++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml
@@ -15,12 +15,15 @@ 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;
}
?>
-
-
+
-
- = $this->icon('service', $this->translate('Service')); ?>
- = $this->link()->service(
- $downtime->service_description, $downtime->service_display_name, $downtime->host_name, $downtime->host_display_name
- ) ?>
-
- = $this->icon('host', $this->translate('Host')); ?>
- = $this->link()->host($downtime->host_name, $downtime->host_display_name) ?>
-
+ icon('service');
+ } else {
+ echo $this->icon('host');
+ }
+ ?>
+ = $this->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
+ ))) ?>
= $this->icon('comment', $this->translate('Comment')); ?> [= $this->escape($downtime->author_name) ?>] = $this->escape($downtime->comment) ?>
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 @@
+
+
+
+ = $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?>
+
+ =
+ $this->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): ?>
+ = sprintf(
+ $this->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)
+ ); ?>
+
+ = sprintf(
+ $this->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): ?>
+ = sprintf(
+ $this->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)
+ ); ?>
+
+ = sprintf(
+ $this->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;
+ } ?>
+
+
+ = $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?>
+
+ =
+ $this->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): ?>
+ = $this->icon('service', $this->translate('Service')) ?>
+ = $downtime->service ?> on = $downtime->host_name ?>.
+
+ = $this->icon('host', $this->translate('Host')) ?>
+ = $downtime->host_name ?>.
+
+
+ is_flexible): ?>
+ is_in_effect): ?>
+ = sprintf(
+ $this->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)
+ ); ?>
+
+ = sprintf(
+ $this->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): ?>
+ = sprintf(
+ $this->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)
+ ); ?>
+
+ = sprintf(
+ $this->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)
+ ); ?>
+
+
+ |
+
+
+
+
+
+
+ = $this->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
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;
} ?>
- = $this->translate('Downtime'); ?>= $state; ?> - = str_replace(array('\r\n', '\n'), ' ', $commentText); ?>
+ = $this->translate('Downtime'); ?>
+ =
+ $this->qlink(
+ $state,
+ 'monitoring/downtime/show',
+ array('downtime_id' => $downtime->id),
+ array('data-base-target' => '_next')
+ ) . $time ; ?> - = str_replace(array('\r\n', '\n'), ' ', $commentText); ?>
|
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..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
- ->setObjects($this->object)
- ->handleRequest();
+ $delDowntimeForm->handleRequest();
$this->view->delDowntimeForm = $delDowntimeForm;
}
$this->view->object = $this->object;
@@ -147,16 +145,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
*/