Add services to command controller
Move resource parameters for commands to get params.
This commit is contained in:
parent
b616b652bc
commit
2142bb59d1
|
@ -30,6 +30,8 @@
|
|||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Module\Monitoring\DataView\HostStatus;
|
||||
use Icinga\Module\Monitoring\DataView\ServiceStatus;
|
||||
use Icinga\Module\Monitoring\Form\Command\DisableNotificationWithExpireForm;
|
||||
use Icinga\Module\Monitoring\Form\Command\SingleArgumentCommandForm;
|
||||
use Icinga\Web\Form;
|
||||
|
@ -164,25 +166,31 @@ class Monitoring_CommandController extends ActionController
|
|||
private function selectCommandTargets($hostOnly = false)
|
||||
{
|
||||
$query = null;
|
||||
|
||||
$fields = array(
|
||||
'host_name',
|
||||
'host_state'
|
||||
);
|
||||
|
||||
try {
|
||||
$hostname = $this->getParam('host', null);
|
||||
$servicename = $this->getParam('service', null);
|
||||
$filter = array();
|
||||
|
||||
if (!$hostname && !$servicename) {
|
||||
throw new MissingParameterException("No target given for this command");
|
||||
}
|
||||
|
||||
if ($hostname) {
|
||||
$view = \Icinga\Module\Monitoring\DataView\HostStatus::fromRequest($this->getRequest());
|
||||
$view = HostStatus::fromRequest($this->_request);
|
||||
}
|
||||
|
||||
if ($servicename && !$hostOnly) {
|
||||
$view = \Icinga\Module\Monitoring\DataView\ServiceStatus::fromRequest($this->getRequest());
|
||||
$fields[] = 'service_description';
|
||||
$view = ServiceStatus::fromRequest($this->_request);
|
||||
}
|
||||
|
||||
$query = $view->getQuery()->from("status", $fields);
|
||||
|
||||
return $data = $query->fetchAll();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
@ -11,6 +11,14 @@ use Icinga\Web\Form;
|
|||
*/
|
||||
class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract
|
||||
{
|
||||
private static $getArguments = array(
|
||||
'host',
|
||||
'service',
|
||||
'global',
|
||||
'commentid',
|
||||
'downtimeid'
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates a simple form without additional input fields
|
||||
*
|
||||
|
@ -27,7 +35,21 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract
|
|||
$form->setAttrib('class', 'inline-form');
|
||||
|
||||
$form->setRequest(Zend_Controller_Front::getInstance()->getRequest());
|
||||
$form->setAction($this->view->href('monitoring/command/' . $commandName));
|
||||
|
||||
// Filter work only from get parts. Put important
|
||||
// fields in the action URL
|
||||
$getParts = array();
|
||||
foreach (self::$getArguments as $argumentName) {
|
||||
if (array_key_exists($argumentName, $arguments) === true) {
|
||||
if ($arguments[$argumentName]) {
|
||||
$getParts[$argumentName] = $arguments[$argumentName];
|
||||
}
|
||||
|
||||
unset($arguments[$argumentName]);
|
||||
}
|
||||
}
|
||||
|
||||
$form->setAction($this->view->href('monitoring/command/' . $commandName, $getParts));
|
||||
|
||||
foreach ($arguments as $elementName => $elementValue) {
|
||||
$hiddenField = new Zend_Form_Element_Hidden($elementName);
|
||||
|
|
Loading…
Reference in New Issue