From 274f2e7410d568394ae9553633e3257e62da930d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 19 Sep 2014 14:34:42 +0200 Subject: [PATCH] monitoring/commands: Fix remove commands in the list comments and list downtimes views refs #6593 --- .../views/scripts/list/comments.phtml | 36 +++++++------------ .../views/scripts/list/downtimes.phtml | 34 +++++++----------- .../Controller/MonitoredObjectController.php | 29 +++++++++++++++ 3 files changed, 53 insertions(+), 46 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 6093adb35..fb3408f16 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -1,9 +1,3 @@ -getHelper('CommandForm'); - -?> - compact): ?>
tabs->render($this); ?> @@ -56,7 +50,7 @@ $helper = $this->getHelper('CommandForm'); objecttype === 'service'): ?> - icon('service.png'); ?> href('monitoring/service/show', array( 'host' => $comment->host, 'service' => $comment->service, )); ?>"> @@ -66,7 +60,7 @@ $helper = $this->getHelper('CommandForm'); translate('on') . ' ' . $comment->host; ?> - icon('host.png'); ?> href('monitoring/host/show', array( 'host' => $comment->host )); ?>"> host; ?> @@ -89,23 +83,17 @@ $helper = $this->getHelper('CommandForm'); date('H:i', $comment->expiration) ) : $this->translate('This comment does not expire.'); ?> - $comment->id, - 'host' => $comment->host - ); - if ($comment->objecttype === 'service') { - $data['service'] = $comment->service; - } - ?> - labelSubmitForm( - 'X', - $this->translate('Remove Comment'), - 'link-like', - 'removecomment', - $data - ); ?> + 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; + ?> diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index babb76074..956427b77 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -1,7 +1,3 @@ -getHelper('CommandForm'); -?> - compact): ?>
tabs->render($this); ?> @@ -37,7 +33,7 @@ $helper = $this->getHelper('CommandForm'); service)): ?> - href('monitoring/service/show', array( 'host' => $downtime->host, 'service' => $downtime->service )); ?>"> @@ -47,7 +43,7 @@ $helper = $this->getHelper('CommandForm'); translate('on'); ?> host; ?> - href('monitoring/host/show', array( 'host' => $downtime->host )); ?>"> host; ?> @@ -96,23 +92,17 @@ $helper = $this->getHelper('CommandForm'); - $downtime->id, - 'host' => $downtime->host - ); - if (isset($downtime->service)) { - $data['service'] = $downtime->service; - } - ?> - labelSubmitForm( - 'X', - 'Remove Downtime', - 'link-like', - 'removedowntime', - $data - ); ?> + 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; + ?> diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 4ad204e5c..ae257e9f1 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -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()); + } }