Skip to content

Commit

Permalink
Wizard: Add restart button
Browse files Browse the repository at this point in the history
refs #9658
  • Loading branch information
N-o-X committed Dec 22, 2016
1 parent 361bfc5 commit 9164e40
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
41 changes: 41 additions & 0 deletions modules/setup/application/controllers/IndexController.php
Expand Up @@ -5,6 +5,8 @@

use Icinga\Module\Setup\WebWizard;
use Icinga\Web\Controller;
use Icinga\Web\Form;
use Icinga\Web\Url;

class IndexController extends Controller
{
Expand Down Expand Up @@ -42,8 +44,47 @@ public function indexAction()
$this->view->report = $setup->getReport();
} else {
$wizard->handleRequest();

$restartForm = new Form();
$restartForm->setUidDisabled();
$restartForm->setName('setup_restart_form');
$restartForm->setAction(Url::fromPath('setup/index/restart'));
$restartForm->setAttrib('class', 'restart-form');
$restartForm->addElement(
'button',
'btn_submit',
array(
'type' => 'submit',
'value' => 'btn_submit',
'escape' => false,
'label' => $this->view->icon('reply-all'),
'title' => $this->translate('Restart the setup'),
'decorators' => array('ViewHelper')
)
);

$this->view->restartForm = $restartForm;
}

$this->view->wizard = $wizard;
}

/**
* Reset session and restart the wizard
*/
public function restartAction()
{
$this->assertHttpMethod('POST');

$form = new Form(array(
'onSuccess' => function () {
$wizard = new WebWizard();
$wizard->clearSession();
}
));
$form->setUidDisabled();
$form->setRedirectUrl('setup');
$form->setSubmitLabel('btn_submit');
$form->handleRequest();
}
}
9 changes: 9 additions & 0 deletions modules/setup/application/views/scripts/index/index.phtml
Expand Up @@ -52,6 +52,9 @@ if ($notifications->hasMessages()) {
<td class="middle"><div class="bubble <?= $stateClass; ?>"></div></td>
<td class="right"><div class="line right <?= $stateClass; ?>"></div></td>
</tr></tbody></table>
<?php if (($maxProgress < $currentPos && $currentPos === 1) || ($maxProgress >= $currentPos && $maxProgress === 1)): ?>
<?= $restartForm ?>
<?php endif ?>
</div>
<div class="step" style="width: 10%;">
<h1><?= $this->translate('Requirements', 'setup.progress'); ?></h1>
Expand All @@ -65,6 +68,9 @@ if ($notifications->hasMessages()) {
<td class="middle"><div class="bubble<?= $stateClass; ?>"></div></td>
<td class="right"><div class="line right<?= $stateClass; ?>"></div></td>
</tr></tbody></table>
<?php if (($maxProgress < $currentPos && $currentPos === 2) || ($maxProgress >= $currentPos && $maxProgress === 2)): ?>
<?= $restartForm ?>
<?php endif ?>
</div>
<div class="step" style="width: 60%;">
<h1><?= $this->translate('Configuration', 'setup.progress'); ?></h1>
Expand Down Expand Up @@ -122,6 +128,9 @@ if ($notifications->hasMessages()) {
<?php endforeach ?>
</td>
</tr></tbody></table>
<?php if ($maxProgress > 2 || $currentPos > 2): ?>
<?= $restartForm ?>
<?php endif ?>
</div>
<div class="step" style="width: 10%;">
<h1><?= $this->translate('Finish', 'setup.progress'); ?></h1>
Expand Down
17 changes: 16 additions & 1 deletion public/css/icinga/setup.less
Expand Up @@ -20,6 +20,21 @@
float: left;
}

form[name='setup_restart_form'] button {
background: none;
border: none;
color: #ffffff;
cursor: pointer;
outline: none;
font-size: 1.4em;
margin-right: 0.6em;
-moz-transform: scale(1, -1);
-webkit-transform: scale(1, -1);
-o-transform: scale(1, -1);
-ms-transform: scale(1, -1);
transform: scale(1, -1);
}

.progress-bar {
overflow: hidden;
padding-top: 1em;
Expand All @@ -36,7 +51,7 @@
}

table {
margin-top: 0.7em;
margin-top: 0.3em;

td {
padding: 0;
Expand Down

0 comments on commit 9164e40

Please sign in to comment.