Add commands for adding comments to services

refs #8348
This commit is contained in:
Matthias Jentsch 2015-03-06 09:23:11 +01:00
parent 860cc59155
commit ef16ba5f48
2 changed files with 96 additions and 39 deletions

View File

@ -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\RemoveAcknowledgementCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm; 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\Host;
use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Service;
use Icinga\Module\Monitoring\Object\ServiceList; use Icinga\Module\Monitoring\Object\ServiceList;
@ -58,7 +59,8 @@ class Monitoring_ServicesController extends Controller
'service_is_flapping', 'service_is_flapping',
'service_notifications_enabled', 'service_notifications_enabled',
'service_output', 'service_output',
'service_last_ack' 'service_last_ack',
'service_last_comment'
)); ));
$form $form
@ -200,18 +202,23 @@ class Monitoring_ServicesController extends Controller
->handleRequest(); ->handleRequest();
$this->view->removeAckForm = $removeAckForm; $this->view->removeAckForm = $removeAckForm;
} }
/*
if (! empty($objectsInDowntime)) { if (! empty($objectsInDowntime)) {
$removeDowntimeForm = new DeleteDowntimeCommandForm(); $removeDowntimeForm = new DeleteDowntimeCommandForm();
$removeDowntimeForm->setObjects($objectsInDowntime) $removeDowntimeForm
->setObjects($objectsInDowntime)
->handleRequest(); ->handleRequest();
$this->view->removeDowntimeForm = $removeDowntimeForm; $this->view->removeDowntimeForm = $removeDowntimeForm;
} }
*/
$this->setAutorefreshInterval(15); $this->setAutorefreshInterval(15);
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check'); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check');
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath( $this->view->processCheckResultAllLink = Url::fromRequest()->setPath(
'monitoring/services/process-check-result' '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->hostStates = (object)$hostStates;
$this->view->serviceStates = (object)$serviceStates; $this->view->serviceStates = (object)$serviceStates;
$this->view->objects = $this->serviceList; $this->view->objects = $this->serviceList;
@ -250,6 +257,33 @@ class Monitoring_ServicesController extends Controller
->setSparklineClass('sparkline-multi'); ->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 * Acknowledge service problems
*/ */

View File

@ -14,6 +14,11 @@ use Icinga\Web\Url;
</div> </div>
<div class="content"> <div class="content">
<h3>
<?= $this->icon('reschedule') ?>
<?= $this->translate('Commands') ?>
</h3>
<?php if (($serviceCount = count($objects)) === 0): ?> <?php if (($serviceCount = count($objects)) === 0): ?>
<?= $this->translate('No services matching the filter'); ?> <?= $this->translate('No services matching the filter'); ?>
<?php else: ?> <?php else: ?>
@ -41,6 +46,12 @@ use Icinga\Web\Url;
null, null,
array('icon' => 'reply') array('icon' => 'reply')
); ?></div> ); ?></div>
<div><?= $this->qlink(
$this->translate('Add a comment'),
$addCommentLink,
null,
array('icon' => 'comment')
); ?></div>
</p> </p>
<?php if (($unhandledCount = count($unhandledObjects)) > 0): ?> <?php if (($unhandledCount = count($unhandledObjects)) > 0): ?>
@ -127,10 +138,6 @@ use Icinga\Web\Url;
array('icon' => 'plug') array('icon' => 'plug')
);?> );?>
</div> </div>
<div>
<?= $removeDowntimeForm ?> Delete All
</div>
</p> </p>
<?php endif ?> <?php endif ?>
@ -145,44 +152,60 @@ use Icinga\Web\Url;
$commentCount $commentCount
), $commentCount); ), $commentCount);
?> ?>
<p>
<table>
<?php foreach ($objects as $service): ?>
<?php $service->fetchComments(); ?>
<?php foreach ($service->comments as $comment): ?>
<tr>
<td style="vertical-align: top;" data-base-target="_self">
<?php
$delCommentForm = new DeleteCommentCommandForm();
$delCommentForm->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) ?>):
</td>
<td style="padding-left: .5em;">
<?= nl2br($comment->comment) ?>
</td>
</tr>
<?php endforeach ?>
<?php endforeach ?>
</table>
</p>
<div>
<?= $this->qlink( <?= $this->qlink(
$this->translate('List all'), $this->translate('List all'),
$commentsLink, $commentsLink,
null, null,
array('icon' => 'comment') array('icon' => 'comment')
); ?></p> ); ?>
</div>
<table> <!--
<?php foreach ($objects as $service): ?> TODO: implement backend functionality.
<?php $service->fetchComments(); ?>
<?php foreach ($service->comments as $comment): ?> <div><?= $this->qlink(
<tr > $this->translate('Remove all'),
<td style="vertical-align: top;" data-base-target="_self"> $deleteCommentLink,
<?php null,
$delCommentForm = new DeleteCommentCommandForm(); array('icon' => 'trash')
$delCommentForm->populate( ); ?></div>
array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) </p>
); -->
$delCommentForm->setAction(
$this->url(
'monitoring/service/delete-comment',
array('host' => $service->getHost()->getName(), 'service' => $service->getName())
)
);
echo $delCommentForm;
?>
(<?= ucfirst($comment->type) ?>):
</td>
<td style="padding-left: .5em;">
<?= nl2br($comment->comment) ?>
</td>
</tr>
<?php endforeach ?>
<?php endforeach ?>
</table> <?php endif ?>
<?php endif ?>
<?php endif ?> <?php endif ?>
</div> </div>