From 9b5c1f06d07d622d770d4da726c540db05faf998 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 12 Sep 2014 16:52:45 +0200 Subject: [PATCH] monitoring/commands: Let detail snippets use the new command forms refs #6593 --- .../show/components/acknowledgement.phtml | 57 +++++----- .../show/components/checkstatistics.phtml | 50 +++++---- .../scripts/show/components/comments.phtml | 83 ++++++++------ .../scripts/show/components/downtime.phtml | 105 ++++++++++-------- .../views/scripts/show/components/flags.phtml | 80 +------------ 5 files changed, 160 insertions(+), 215 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index 38359bf34..669a37241 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -1,40 +1,39 @@ state, array(0, 99))) { + // Ignore this markup if the object is in a non-problem state or pending return; } -$cf = $this->getHelper('CommandForm'); - -$data = array('host' => $object->host_name); -if ($object->service_description) { - $data['service'] = $object->service_description; +if ($object->getType() === $object::TYPE_HOST) { + $ackLink = $this->href( + 'monitoring/host/acknowledge-problem', + array('host' => $object->getHost()) + ); +} else { + $ackLink = $this->href( + 'monitoring/service/acknowledge-problem', + array('host' => $object->getHost(), 'service' => $object->getService()) + ); } -?> - -host_acknowledged - || $object instanceof Service && $object->service_acknowledged): ?> - Issue acknowledged - labelSubmitForm( - $this->translate('Remove Acknowledgement'), - $this->translate('Remove problem acknowledgement'), - 'link-like', - 'removeacknowledgement', - $data - ) ?> +if ($object->acknowledged): ?> + + translate('Acknowledged') ?> + + - translate('Not acknowledged') ?> - - icon('acknowledgement_petrol.png') ?> translate('Acknowledge') ?> - + + translate('Not acknowledged') ?> + + + + icon('acknowledgement_petrol.png') ?> translate('Acknowledge') ?> + + + - diff --git a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml index f0b39e603..93020f1f2 100644 --- a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml +++ b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml @@ -1,31 +1,36 @@ getHelper('CommandForm'); +/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ -?> - translate('Last check') ?> - img('img/icons/refresh_petrol.png') ?> labelSubmitForm( - $this->translate('Check now'), - $this->translate('Reschedule next check immediately'), - 'link-like', - 'reschedulenextcheck', - array( - 'host' => $this->object->host_name, - 'service' => $this->object->service_description, - 'checktime' => time(), - 'forcecheck' => '1' - ) - ) ?> timeSince($object->last_check) ?> +if ($object->getType() === $object::TYPE_HOST) { + $reschedule = $this->href( + 'monitoring/host/reschedule-check', + array('host' => $object->getHost()) + ); +} else { + $reschedule = $this->href( + 'monitoring/service/reschedule-check', + array('host' => $object->getHost(), 'service' => $object->getService()) + ); +} + +?> + + + translate('Last check') ?> + + + timeSince($object->last_check) ?> + translate('Next check') ?> - img('img/icons/reschedule_petrol.png') ?> translate('Reschedule') ?> timeUntil($object->next_check) ?> + + + icon('reschedule_petrol.png') ?> translate('Reschedule') ?> + + timeUntil($object->next_check) ?> + check_execution_time): ?> @@ -39,4 +44,3 @@ $cf = $this->getHelper('CommandForm'); check_latency ?>s - diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index 4365acdd5..cf65b8e04 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -1,15 +1,32 @@ + + translate('Comments') ?> + + getType() === $object::TYPE_HOST) { + $addCommentLink = $this->href( + 'monitoring/host/add-comment', + array('host' => $object->getHost()) + ); + } else { + $addCommentLink = $this->href( + 'monitoring/service/add-comment', + array('host' => $object->getHost(), 'service' => $object->getService()) + ); + } + + ?> + + icon('comment_petrol.png') ?> translate('Add comment') ?> + + + + getHelper('CommandForm'); - -$data = array('host' => $object->host_name); -if ($object->service_description) { - $data['service'] = $object->service_description; -} - -$list = array(); foreach ($object->comments as $comment) { - // Ticket hook sample $text = $this->tickets ? preg_replace_callback( $this->tickets->getPattern(), @@ -17,34 +34,26 @@ foreach ($object->comments as $comment) { $this->escape($comment->comment) ) : $this->escape($comment->comment); - $deleteData = $data; - $deleteData['commentid'] = $comment->id; - // $iconForm = $cf->iconSubmitForm( - // 'img/icons/remove_petrol.png', - $iconForm = $cf->labelSubmitForm( - 'X', - 'Remove comment', - 'link-like', - 'removecomment', - $deleteData - ); + $form = clone $delCommentForm; + $form->populate(array('comment_id' => $comment->id)); - $list[] = sprintf( - '%s (%s)
%s (%s):%s
', - $this->escape($comment->author), - $this->timeSince($comment->timestamp), - $iconForm, - ucfirst($comment->type), - str_replace(array('\r\n', '\n'), '
', $text) - ); -} + ?> -?> - - translate('Comments') ?> - - icon('comment_petrol.png') ?> translate('Add comment') ?> - - - + + escape($comment->author) ?> (timeSince($comment->timestamp) ?>) + + + + + + +
+ (type) ?>): + + ', $text) ?> +
+ + + + diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index f78666531..9198c2120 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -1,39 +1,31 @@ + + translate('Downtimes') ?> + + getType() === $object::TYPE_HOST) { + $scheduleDowntimeLink = $this->href( + 'monitoring/host/schedule-downtime', + array('host' => $object->getHost()) + ); + } else { + $scheduleDowntimeLink = $this->href( + 'monitoring/service/schedule-downtime', + array('host' => $object->getHost(), 'service' => $object->getService()) + ); + } + ?> + + icon('in_downtime_petrol.png') ?> translate('Schedule downtime') ?> + + + + getHelper('CommandForm'); - -$data = array('host' => $object->host_name); -if ($object->service_description) { - $data['service'] = $object->service_description; -} - - -$list = array(); foreach ($object->downtimes as $downtime) { - $deleteData = $data; - $deleteData['downtimeid'] = $downtime->id; - - // TODO: This needs improvement - if ((int) $downtime->is_in_effect) { - $state = 'in downtime since ' . $this->timeSince($downtime->start); - } else { - if ($downtime->is_fixed) { - $state = 'scheduled ' . $this->timeUntil($downtime->start); - } else { - $state = 'scheduled flexible ' . $this->timeUntil($downtime->start); - } - } - - // $iconForm = $cf->iconSubmitForm( - // 'img/icons/remove_petrol.png', - $iconForm = $cf->labelSubmitForm( - 'X', - 'Remove Downtime', - 'link-like', - 'removedowntime', - $deleteData - ); - // Ticket hook sample $text = $this->tickets ? preg_replace_callback( $this->tickets->getPattern(), @@ -41,20 +33,35 @@ foreach ($object->downtimes as $downtime) { $this->escape($downtime->comment) ) : $this->escape($downtime->comment); - $list[] = sprintf( - '%s
%s %s:%s
', - $this->escape($downtime->author), - $iconForm, - $state, - str_replace(array('\r\n', '\n'), '
', $text) - ); -} + $form = clone $delDowntimeForm; + $form->populate(array('downtime_id' => $downtime->id)); -?> - - translate('Downtimes') ?> - - icon('in_downtime_petrol.png') ?> translate('Schedule downtime') ?> - - - + if ((bool) $downtime->is_in_effect) { + $state = 'in downtime since ' . $this->timeSince($downtime->start); + } else { + if ((bool) $downtime->is_fixed) { + $state = 'scheduled ' . $this->timeUntil($downtime->start); + } else { + $state = 'scheduled flexible ' . $this->timeUntil($downtime->start); + } + } + + ?> + + + escape($downtime->author) ?> + + + + + + +
+ + + ', $text) ?> +
+ + + + diff --git a/modules/monitoring/application/views/scripts/show/components/flags.phtml b/modules/monitoring/application/views/scripts/show/components/flags.phtml index fb02b97a3..1ecc788b7 100644 --- a/modules/monitoring/application/views/scripts/show/components/flags.phtml +++ b/modules/monitoring/application/views/scripts/show/components/flags.phtml @@ -1,77 +1,3 @@ -object; -$cf = $this->getHelper('CommandForm'); - -$data = array( - 'host' => $o->host_name, - 'service' => $o->service_description -); - -?> - - translate('Passive Checks') ?> - toggleSubmitForm( - '', - $o->passive_checks_enabled, - 'startacceptingpassivechecks', - 'stopacceptingpassivechecks', - $o->passive_checks_enabled_changed === '1', - $data - ) ?> - - - translate('Active Checks') ?> - toggleSubmitForm( - '', - $o->active_checks_enabled, - 'enableactivechecks', - 'disableactivechecks', - $o->active_checks_enabled_changed === '1', - $data - ) ?> - - - translate('Notifications') ?> - toggleSubmitForm( - '', - $o->notifications_enabled, - 'enablenotifications', - 'disablenotifications', - $o->notifications_enabled_changed === '1', - $data - ) ?> - - - translate('Event Handler') ?> - toggleSubmitForm( - '', - $o->event_handler_enabled, - 'enableeventhandler', - 'disableeventhandler', - $o->event_handler_enabled_changed === '1', - $data - ) ?> - - - translate('Flap Detection') ?> - toggleSubmitForm( - '', - $o->flap_detection_enabled, - 'enableflapdetection', - 'disableflapdetection', - $o->flap_detection_enabled_changed === '1', - $data - ) ?> - - - translate('Obsessing') ?> - toggleSubmitForm( - '', - $o->obsessing, - 'startobsessing', - 'stopobsessing', - $o->obsessing_changed === '1', - $data - ) ?> - + + +