mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +02:00
Services/ObjectsController: rough integration...
...for multiselect on services
This commit is contained in:
parent
200d00d092
commit
d877949e60
@ -6,6 +6,10 @@ use Icinga\Module\Director\Web\Controller\ObjectsController;
|
|||||||
|
|
||||||
class ServicesController extends ObjectsController
|
class ServicesController extends ObjectsController
|
||||||
{
|
{
|
||||||
|
protected $multiEdit = array(
|
||||||
|
'disabled'
|
||||||
|
);
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
|
@ -164,7 +164,29 @@ abstract class ObjectsController extends ActionController
|
|||||||
}
|
}
|
||||||
$formName = 'icinga' . $type;
|
$formName = 'icinga' . $type;
|
||||||
|
|
||||||
|
$objects = $this->loadMultiObjectsFromParams();
|
||||||
$this->singleTab($this->translate('Multiple objects'));
|
$this->singleTab($this->translate('Multiple objects'));
|
||||||
|
|
||||||
|
$this->view->title = sprintf(
|
||||||
|
$this->translate('Modify %d objects'),
|
||||||
|
count($objects)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->view->form = $form = $this->loadForm('IcingaMultiEdit')
|
||||||
|
->setObjects($objects)
|
||||||
|
->pickElementsFrom($this->loadForm($formName), $this->multiEdit);
|
||||||
|
if ($type === 'Service') {
|
||||||
|
$form->setListUrl('director/servicetemplate/hosts');
|
||||||
|
}
|
||||||
|
|
||||||
|
$form->handleRequest();
|
||||||
|
$this->view->totalUndeployedChanges = $this->db()
|
||||||
|
->countActivitiesSinceLastDeployedConfig();
|
||||||
|
$this->setViewScript('objects/form');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadMultiObjectsFromParams()
|
||||||
|
{
|
||||||
$filter = Filter::fromQueryString($this->params->toString());
|
$filter = Filter::fromQueryString($this->params->toString());
|
||||||
$dummy = $this->dummyObject();
|
$dummy = $this->dummyObject();
|
||||||
$objects = array();
|
$objects = array();
|
||||||
@ -174,24 +196,20 @@ abstract class ObjectsController extends ActionController
|
|||||||
/** @var $sub FilterChain */
|
/** @var $sub FilterChain */
|
||||||
foreach ($sub->filters() as $ex) {
|
foreach ($sub->filters() as $ex) {
|
||||||
/** @var $ex FilterChain|FilterExpression */
|
/** @var $ex FilterChain|FilterExpression */
|
||||||
if ($ex->isExpression() && $ex->getColumn() === 'name') {
|
$col = $ex->getColumn();
|
||||||
$name = $ex->getExpression();
|
if ($ex->isExpression()) {
|
||||||
$objects[$name] = $dummy::load($name, $db);
|
if ($col === 'name') {
|
||||||
|
$name = $ex->getExpression();
|
||||||
|
$objects[$name] = $dummy::load($name, $db);
|
||||||
|
} elseif ($col === 'id') {
|
||||||
|
$name = $ex->getExpression();
|
||||||
|
$objects[$name] = $dummy::load(['id' => $name], $db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->view->title = sprintf(
|
|
||||||
$this->translate('Modify %d objects'),
|
|
||||||
count($objects)
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->view->form = $this->loadForm('IcingaMultiEdit')
|
return $objects;
|
||||||
->setObjects($objects)
|
|
||||||
->pickElementsFrom($this->loadForm($formName), $this->multiEdit)
|
|
||||||
->handleRequest();
|
|
||||||
$this->view->totalUndeployedChanges = $this->db()
|
|
||||||
->countActivitiesSinceLastDeployedConfig();
|
|
||||||
$this->setViewScript('objects/form');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function templatesAction()
|
public function templatesAction()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user