Preserve quick actions in a command form view

refs #2675
This commit is contained in:
Alexander A. Klimov 2017-02-14 13:07:31 +01:00
parent b0221c5e13
commit fe72973e6e
2 changed files with 26 additions and 18 deletions

View File

@ -11,6 +11,7 @@
} else { } else {
echo $this->render('partials/object/service-header.phtml'); echo $this->render('partials/object/service-header.phtml');
} ?> } ?>
<?= $this->render('partials/object/quick-actions.phtml') ?>
</div> </div>
<div class="content object-command"> <div class="content object-command">
<?= $form ?> <?= $form ?>

View File

@ -55,25 +55,8 @@ abstract class MonitoredObjectController extends Controller
public function showAction() public function showAction()
{ {
$this->setAutorefreshInterval(10); $this->setAutorefreshInterval(10);
$this->setupQuickActionForms();
$auth = $this->Auth(); $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->object->populate();
$this->handleFormatRequest(); $this->handleFormatRequest();
$toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(array( $toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(array(
@ -132,6 +115,7 @@ abstract class MonitoredObjectController extends Controller
$this->view->tabs->remove('dashboard'); $this->view->tabs->remove('dashboard');
$this->view->tabs->remove('menu-entry'); $this->view->tabs->remove('menu-entry');
$this->_helper->viewRenderer('partials/command/object-command-form', null, true); $this->_helper->viewRenderer('partials/command/object-command-form', null, true);
$this->setupQuickActionForms();
return $form; return $form;
} }
@ -256,4 +240,27 @@ abstract class MonitoredObjectController extends Controller
} }
$tabs->extend(new DashboardAction())->extend(new MenuAction()); $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();
}
}
} }