HostsController: renew multiselect action, clean up

This commit is contained in:
Thomas Gelf 2017-07-13 16:30:04 +02:00
parent b9fd1f42d9
commit 4830a2a879
1 changed files with 9 additions and 18 deletions

View File

@ -5,8 +5,10 @@ namespace Icinga\Module\Director\Controllers;
use Icinga\Data\Filter\Filter;
use Icinga\Data\Filter\FilterChain;
use Icinga\Data\Filter\FilterExpression;
use Icinga\Module\Director\Forms\IcingaAddServiceToMultipleHostsForm;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Web\Controller\ObjectsController;
use ipl\Html\Link;
class HostsController extends ObjectsController
{
@ -28,27 +30,17 @@ class HostsController extends ObjectsController
parent::editAction();
$this->addActionLink($this->view->qlink(
$this->actions()->add(Link::create(
$this->translate('Add Service'),
$url,
null,
array('class' => 'icon-plus')
['class' => 'icon-plus']
));
}
protected function addActionLink($link)
{
if (! is_array($this->view->actionLinks)) {
$this->view->actionLinks = array();
}
$this->view->actionLinks[] = $link;
return $this;
}
public function addserviceAction()
{
$this->singleTab($this->translate('Add Service'));
$this->addSingleTab($this->translate('Add Service'));
$filter = Filter::fromQueryString($this->params->toString());
$objects = array();
@ -64,16 +56,15 @@ class HostsController extends ObjectsController
}
}
}
$this->view->title = sprintf(
$this->addTitle(
$this->translate('Add service to %d hosts'),
count($objects)
);
$this->view->form = $this->loadForm('IcingaAddServiceToMultipleHosts')
$this->content()->add(IcingaAddServiceToMultipleHostsForm::load()
->setHosts($objects)
->setDb($this->db())
->handleRequest();
$this->setViewScript('objects/form');
->handleRequest()
);
}
}