Skip to content

Commit

Permalink
Add auto completion (#387)
Browse files Browse the repository at this point in the history
resolves #295 

requires Icinga/ipl-web#179
requires Icinga/ipl-web#178
  • Loading branch information
nilmerg authored Aug 10, 2023
2 parents ff0cb21 + b8d5f0d commit a30f85d
Show file tree
Hide file tree
Showing 18 changed files with 1,250 additions and 1,046 deletions.
37 changes: 28 additions & 9 deletions application/controllers/ProcessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Icinga\Date\DateFormatter;
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\Forms\AddNodeForm;
use Icinga\Module\Businessprocess\Forms\EditNodeForm;
use Icinga\Module\Businessprocess\Node;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
use Icinga\Module\Businessprocess\Renderer\Breadcrumb;
Expand Down Expand Up @@ -269,27 +271,41 @@ protected function loadActionForm(BpConfig $bp, Node $node = null)
$canEdit = $bp->getMetadata()->canModify();

if ($action === 'add' && $canEdit) {
$form = $this->loadForm('AddNode')
->setSuccessUrl(Url::fromRequest()->without('action'))
->setStorage($this->storage())
$form = (new AddNodeForm())
->setProcess($bp)
->setParentNode($node)
->setStorage($this->storage())
->setSession($this->session())
->handleRequest();
->on(AddNodeForm::ON_SUCCESS, function () {
$this->redirectNow(Url::fromRequest()->without('action'));
})
->handleRequest($this->getServerRequest());

if ($form->hasElement('children')) {
foreach ($form->getElement('children')->prepareMultipartUpdate($this->getServerRequest()) as $update) {
if (! is_array($update)) {
$update = [$update];
}

$this->addPart(...$update);
}
}
} elseif ($action === 'cleanup' && $canEdit) {
$form = $this->loadForm('CleanupNode')
->setSuccessUrl(Url::fromRequest()->without('action'))
->setProcess($bp)
->setSession($this->session())
->handleRequest();
} elseif ($action === 'editmonitored' && $canEdit) {
$form = $this->loadForm('EditNode')
->setSuccessUrl(Url::fromRequest()->without('action'))
$form = (new EditNodeForm())
->setProcess($bp)
->setNode($bp->getNode($this->params->get('editmonitorednode')))
->setParentNode($node)
->setSession($this->session())
->handleRequest();
->on(EditNodeForm::ON_SUCCESS, function () {
$this->redirectNow(Url::fromRequest()->without(['action', 'editmonitorednode']));
})
->handleRequest($this->getServerRequest());
} elseif ($action === 'delete' && $canEdit) {
$form = $this->loadForm('DeleteNode')
->setSuccessUrl(Url::fromRequest()->without('action'))
Expand Down Expand Up @@ -349,8 +365,11 @@ protected function setDynamicAutorefresh()
return;
}

if ($this->params->get('action')) {
$this->setAutorefreshInterval(45);
if ($this->params->has('action')) {
if ($this->params->get('action') !== 'add') {
// The new add form uses the term input, which doesn't support value persistence across refreshes
$this->setAutorefreshInterval(45);
}
} else {
$this->setAutorefreshInterval(10);
}
Expand Down
Loading

0 comments on commit a30f85d

Please sign in to comment.