monitoring/commands: Fix remove commands in the list comments and list downtimes views

refs #6593
This commit is contained in:
Eric Lippmann 2014-09-19 14:34:42 +02:00
parent 90dbcdbbfb
commit 274f2e7410
3 changed files with 53 additions and 46 deletions

View File

@ -1,9 +1,3 @@
<?php
$helper = $this->getHelper('CommandForm');
?>
<?php if (false === $this->compact): ?> <?php if (false === $this->compact): ?>
<div class="controls"> <div class="controls">
<?= $this->tabs->render($this); ?> <?= $this->tabs->render($this); ?>
@ -56,7 +50,7 @@ $helper = $this->getHelper('CommandForm');
</td> </td>
<td> <td>
<?php if ($comment->objecttype === 'service'): ?> <?php if ($comment->objecttype === 'service'): ?>
<?= $this->icon('service.png'); ?> <a href="<?= $this->href('monitoring/show/service', array( <?= $this->icon('service.png'); ?> <a href="<?= $this->href('monitoring/service/show', array(
'host' => $comment->host, 'host' => $comment->host,
'service' => $comment->service, 'service' => $comment->service,
)); ?>"> )); ?>">
@ -66,7 +60,7 @@ $helper = $this->getHelper('CommandForm');
<?= $this->translate('on') . ' ' . $comment->host; ?> <?= $this->translate('on') . ' ' . $comment->host; ?>
</small> </small>
<?php else: ?> <?php else: ?>
<?= $this->icon('host.png'); ?> <a href="<?= $this->href('monitoring/show/host', array( <?= $this->icon('host.png'); ?> <a href="<?= $this->href('monitoring/host/show', array(
'host' => $comment->host 'host' => $comment->host
)); ?>"> )); ?>">
<?= $comment->host; ?> <?= $comment->host; ?>
@ -89,23 +83,17 @@ $helper = $this->getHelper('CommandForm');
date('H:i', $comment->expiration) date('H:i', $comment->expiration)
) : $this->translate('This comment does not expire.'); ?> ) : $this->translate('This comment does not expire.'); ?>
</td> </td>
<?php
$data = array(
'commentid' => $comment->id,
'host' => $comment->host
);
if ($comment->objecttype === 'service') {
$data['service'] = $comment->service;
}
?>
<td style="width: 2em"> <td style="width: 2em">
<?= $helper->labelSubmitForm( <?php
'X', $delCommentForm = clone $delCommentForm;
$this->translate('Remove Comment'), $delCommentForm->populate(array('comment_id' => $comment->id, 'redirect' => $this->url));
'link-like', if ($comment->objecttype === 'host') {
'removecomment', $delCommentForm->setAction($this->url('monitoring/host/remove-comment', array('host' => $comment->host)));
$data } else {
); ?> $delCommentForm->setAction($this->url('monitoring/service/remove-comment', array('host' => $comment->host, 'service' => $comment->service)));
}
echo $delCommentForm;
?>
</td> </td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>

View File

@ -1,7 +1,3 @@
<?php
$helper = $this->getHelper('CommandForm');
?>
<?php if (false === $this->compact): ?> <?php if (false === $this->compact): ?>
<div class="controls"> <div class="controls">
<?= $this->tabs->render($this); ?> <?= $this->tabs->render($this); ?>
@ -37,7 +33,7 @@ $helper = $this->getHelper('CommandForm');
</td> </td>
<td> <td>
<?php if (isset($downtime->service)): ?> <?php if (isset($downtime->service)): ?>
<a href="<?= $this->href('monitoring/show/service', array( <a href="<?= $this->href('monitoring/service/show', array(
'host' => $downtime->host, 'host' => $downtime->host,
'service' => $downtime->service 'service' => $downtime->service
)); ?>"> )); ?>">
@ -47,7 +43,7 @@ $helper = $this->getHelper('CommandForm');
<?= $this->translate('on'); ?> <?= $downtime->host; ?> <?= $this->translate('on'); ?> <?= $downtime->host; ?>
</small> </small>
<?php else: ?> <?php else: ?>
<a href="<?= $this->href('monitoring/show/host', array( <a href="<?= $this->href('monitoring/host/show', array(
'host' => $downtime->host 'host' => $downtime->host
)); ?>"> )); ?>">
<?= $downtime->host; ?> <?= $downtime->host; ?>
@ -96,23 +92,17 @@ $helper = $this->getHelper('CommandForm');
<?php endif ?> <?php endif ?>
</small> </small>
</td> </td>
<?php
$data = array(
'downtimeid' => $downtime->id,
'host' => $downtime->host
);
if (isset($downtime->service)) {
$data['service'] = $downtime->service;
}
?>
<td style="width: 2em"> <td style="width: 2em">
<?= $helper->labelSubmitForm( <?php
'X', $delDowntimeForm = clone $delDowntimeForm;
'Remove Downtime', $delDowntimeForm->populate(array('downtime_id' => $downtime->id, 'redirect' => $this->url));
'link-like', if (! isset($downtime->service)) {
'removedowntime', $delDowntimeForm->setAction($this->url('monitoring/host/delete-downtime', array('host' => $downtime->host)));
$data } else {
); ?> $delDowntimeForm->setAction($this->url('monitoring/service/delete-downtime', array('host' => $downtime->host, 'service' => $downtime->service)));
}
echo $delDowntimeForm;
?>
</td> </td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>

View File

@ -119,4 +119,33 @@ abstract class MonitoredObjectController extends Controller
* Schedule a downtime * Schedule a downtime
*/ */
abstract public function scheduleDowntimeAction(); abstract public function scheduleDowntimeAction();
/**
* Remove a comment
*/
public function removeCommentAction()
{
/*
* TODO(el): This is here because monitoring/list/comments has buttons to remove comments. Because of the nature
* of an action, the form is accessible via GET which does not make much sense because the form requires
* us to populate the ID of the comment which is to be deleted. We may introduce a combo box for choosing
* the comment ID on GET or deny GET access.
*/
$this->handleCommandForm(new DeleteCommentCommandForm());
}
/**
* Remove a downtime
*/
public function deleteDowntimeAction()
{
/*
* TODO(el): This is here because monitoring/list/downtimes has buttons to remove comments. Because of the
* nature of an action, the form is accessible via GET which does not make much sense because the form requires
* us to populate the ID of the downtime which is to be deleted. We may introduce a combo box for choosing
* the downtime ID on GET or deny GET access.
*/
$this->handleCommandForm(new DeleteDowntimeCommandForm());
}
} }