diff --git a/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml index 1359e5f36..b4e5a9cc8 100644 --- a/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml @@ -11,6 +11,7 @@ } else { echo $this->render('partials/object/service-header.phtml'); } ?> +<?= $this->render('partials/object/quick-actions.phtml') ?> </div> <div class="content object-command"> <?= $form ?> diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 52cd4afbd..1a12c8131 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -56,25 +56,8 @@ abstract class MonitoredObjectController extends Controller public function showAction() { $this->setAutorefreshInterval(10); + $this->setupQuickActionForms(); $auth = $this->Auth(); - if ($auth->hasPermission('monitoring/command/schedule-check')) { - $checkNowForm = new CheckNowCommandForm(); - $checkNowForm - ->setObjects($this->object) - ->handleRequest(); - $this->view->checkNowForm = $checkNowForm; - } - if (! in_array((int) $this->object->state, array(0, 99))) { - if ((bool) $this->object->acknowledged) { - if ($auth->hasPermission('monitoring/command/remove-acknowledgement')) { - $removeAckForm = new RemoveAcknowledgementCommandForm(); - $removeAckForm - ->setObjects($this->object) - ->handleRequest(); - $this->view->removeAckForm = $removeAckForm; - } - } - } $this->object->populate(); $this->handleFormatRequest(); $toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(array( @@ -139,6 +122,7 @@ abstract class MonitoredObjectController extends Controller $this->view->tabs->remove('dashboard'); $this->view->tabs->remove('menu-entry'); $this->_helper->viewRenderer('partials/command/object-command-form', null, true); + $this->setupQuickActionForms(); return $form; } @@ -263,4 +247,27 @@ abstract class MonitoredObjectController extends Controller } $tabs->extend(new DashboardAction())->extend(new MenuAction()); } + + /** + * Create quick action forms and pass them to the view + */ + protected function setupQuickActionForms() + { + $auth = $this->Auth(); + if ($auth->hasPermission('monitoring/command/schedule-check')) { + $this->view->checkNowForm = $checkNowForm = new CheckNowCommandForm(); + $checkNowForm + ->setObjects($this->object) + ->handleRequest(); + } + if (! in_array((int) $this->object->state, array(0, 99)) + && $this->object->acknowledged + && $auth->hasPermission('monitoring/command/remove-acknowledgement') + ) { + $this->view->removeAckForm = $removeAckForm = new RemoveAcknowledgementCommandForm(); + $removeAckForm + ->setObjects($this->object) + ->handleRequest(); + } + } }