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

View File

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

View File

@ -119,4 +119,33 @@ abstract class MonitoredObjectController extends Controller
* Schedule a downtime
*/
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());
}
}