From ef16ba5f48543447ca81b5a7afc2a445eae9c52b Mon Sep 17 00:00:00 2001
From: Matthias Jentsch
Date: Fri, 6 Mar 2015 09:23:11 +0100
Subject: [PATCH] Add commands for adding comments to services
refs #8348
---
.../controllers/ServicesController.php | 40 +++++++-
.../views/scripts/services/show.phtml | 95 ++++++++++++-------
2 files changed, 96 insertions(+), 39 deletions(-)
diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php
index ceabd643e..a20572d0d 100644
--- a/modules/monitoring/application/controllers/ServicesController.php
+++ b/modules/monitoring/application/controllers/ServicesController.php
@@ -10,7 +10,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm;
-use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm;
+use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
+use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service;
use Icinga\Module\Monitoring\Object\ServiceList;
@@ -58,7 +59,8 @@ class Monitoring_ServicesController extends Controller
'service_is_flapping',
'service_notifications_enabled',
'service_output',
- 'service_last_ack'
+ 'service_last_ack',
+ 'service_last_comment'
));
$form
@@ -200,18 +202,23 @@ class Monitoring_ServicesController extends Controller
->handleRequest();
$this->view->removeAckForm = $removeAckForm;
}
+ /*
if (! empty($objectsInDowntime)) {
$removeDowntimeForm = new DeleteDowntimeCommandForm();
- $removeDowntimeForm->setObjects($objectsInDowntime)
+ $removeDowntimeForm
+ ->setObjects($objectsInDowntime)
->handleRequest();
$this->view->removeDowntimeForm = $removeDowntimeForm;
}
+ */
$this->setAutorefreshInterval(15);
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check');
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath(
'monitoring/services/process-check-result'
);
+ $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment');
+ $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment');
$this->view->hostStates = (object)$hostStates;
$this->view->serviceStates = (object)$serviceStates;
$this->view->objects = $this->serviceList;
@@ -250,6 +257,33 @@ class Monitoring_ServicesController extends Controller
->setSparklineClass('sparkline-multi');
}
+
+ /**
+ * Add a service comment
+ */
+ public function addCommentAction()
+ {
+ $this->assertPermission('monitoring/command/comment/add');
+
+ $form = new AddCommentCommandForm();
+ $form->setTitle($this->translate('Add Service Comments'));
+ $this->handleCommandForm($form);
+ }
+
+
+ /**
+ * Delete a comment
+ */
+ public function deleteCommentAction()
+ {
+ $this->assertPermission('monitoring/command/comment/delete');
+
+ $form = new DeleteCommentCommandForm();
+ $form->setTitle($this->translate('Delete Service Comments'));
+ $this->handleCommandForm($form);
+ }
+
+
/**
* Acknowledge service problems
*/
diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml
index 9dc865010..cd941df4d 100644
--- a/modules/monitoring/application/views/scripts/services/show.phtml
+++ b/modules/monitoring/application/views/scripts/services/show.phtml
@@ -14,6 +14,11 @@ use Icinga\Web\Url;
+
+ = $this->icon('reschedule') ?>
+ = $this->translate('Commands') ?>
+
+
= $this->translate('No services matching the filter'); ?>
@@ -41,6 +46,12 @@ use Icinga\Web\Url;
null,
array('icon' => 'reply')
); ?>
+ = $this->qlink(
+ $this->translate('Add a comment'),
+ $addCommentLink,
+ null,
+ array('icon' => 'comment')
+ ); ?>
0): ?>
@@ -127,10 +138,6 @@ use Icinga\Web\Url;
array('icon' => 'plug')
);?>
-
-
- = $removeDowntimeForm ?> Delete All
-
@@ -145,44 +152,60 @@ use Icinga\Web\Url;
$commentCount
), $commentCount);
?>
+
+
+
+ fetchComments(); ?>
+ comments as $comment): ?>
+
+
+ populate(
+ array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url))
+ );
+ $delCommentForm->setAction(
+ $this->url(
+ 'monitoring/service/delete-comment',
+ array('host' => $service->getHost()->getName(), 'service' => $service->getName())
+ )
+ );
+ echo $delCommentForm;
+ ?>
+ (= ucfirst($comment->type) ?>):
+ |
+
+ = nl2br($comment->comment) ?>
+ |
+
+
+
+
+
+
+
= $this->qlink(
$this->translate('List all'),
$commentsLink,
null,
array('icon' => 'comment')
- ); ?>
+ ); ?>
+
-
-
- fetchComments(); ?>
+
- comments as $comment): ?>
-
-
- populate(
- array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url))
- );
- $delCommentForm->setAction(
- $this->url(
- 'monitoring/service/delete-comment',
- array('host' => $service->getHost()->getName(), 'service' => $service->getName())
- )
- );
- echo $delCommentForm;
- ?>
- (= ucfirst($comment->type) ?>):
- |
-
- = nl2br($comment->comment) ?>
- |
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+