Merge branch 'feature/allow-to-restart-the-wizard-9658'

resolves #9658
This commit is contained in:
Noah Hilverling 2017-01-09 11:08:23 +01:00
commit 642015c294
4 changed files with 75 additions and 6 deletions

View File

@ -5,6 +5,8 @@ namespace Icinga\Module\Setup\Controllers;
use Icinga\Module\Setup\WebWizard; use Icinga\Module\Setup\WebWizard;
use Icinga\Web\Controller; use Icinga\Web\Controller;
use Icinga\Web\Form;
use Icinga\Web\Url;
class IndexController extends Controller class IndexController extends Controller
{ {
@ -42,8 +44,47 @@ class IndexController extends Controller
$this->view->report = $setup->getReport(); $this->view->report = $setup->getReport();
} else { } else {
$wizard->handleRequest(); $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; $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(false);
}
));
$form->setUidDisabled();
$form->setRedirectUrl('setup');
$form->setSubmitLabel('btn_submit');
$form->handleRequest();
}
} }

View File

@ -52,6 +52,9 @@ if ($notifications->hasMessages()) {
<td class="middle"><div class="bubble <?= $stateClass; ?>"></div></td> <td class="middle"><div class="bubble <?= $stateClass; ?>"></div></td>
<td class="right"><div class="line right <?= $stateClass; ?>"></div></td> <td class="right"><div class="line right <?= $stateClass; ?>"></div></td>
</tr></tbody></table> </tr></tbody></table>
<?php if (($maxProgress < $currentPos && $currentPos === 1) || ($maxProgress >= $currentPos && $maxProgress === 1)): ?>
<?= $this->restartForm ?>
<?php endif ?>
</div> </div>
<div class="step" style="width: 10%;"> <div class="step" style="width: 10%;">
<h1><?= $this->translate('Requirements', 'setup.progress'); ?></h1> <h1><?= $this->translate('Requirements', 'setup.progress'); ?></h1>
@ -65,6 +68,9 @@ if ($notifications->hasMessages()) {
<td class="middle"><div class="bubble<?= $stateClass; ?>"></div></td> <td class="middle"><div class="bubble<?= $stateClass; ?>"></div></td>
<td class="right"><div class="line right<?= $stateClass; ?>"></div></td> <td class="right"><div class="line right<?= $stateClass; ?>"></div></td>
</tr></tbody></table> </tr></tbody></table>
<?php if (($maxProgress < $currentPos && $currentPos === 2) || ($maxProgress >= $currentPos && $maxProgress === 2)): ?>
<?= $this->restartForm ?>
<?php endif ?>
</div> </div>
<div class="step" style="width: 60%;"> <div class="step" style="width: 60%;">
<h1><?= $this->translate('Configuration', 'setup.progress'); ?></h1> <h1><?= $this->translate('Configuration', 'setup.progress'); ?></h1>
@ -122,6 +128,9 @@ if ($notifications->hasMessages()) {
<?php endforeach ?> <?php endforeach ?>
</td> </td>
</tr></tbody></table> </tr></tbody></table>
<?php if ($maxProgress > 2 || $currentPos > 2): ?>
<?= $this->restartForm ?>
<?php endif ?>
</div> </div>
<div class="step" style="width: 10%;"> <div class="step" style="width: 10%;">
<h1><?= $this->translate('Finish', 'setup.progress'); ?></h1> <h1><?= $this->translate('Finish', 'setup.progress'); ?></h1>

View File

@ -380,15 +380,19 @@ class WebWizard extends Wizard implements SetupWizard
} }
/** /**
* Clear the session being used by this wizard and drop the setup token * Clear the session being used by this wizard
*
* @param bool $removeToken If true, the setup token will be removed
*/ */
public function clearSession() public function clearSession($removeToken = true)
{ {
parent::clearSession(); parent::clearSession();
$tokenPath = Config::resolvePath('setup.token'); if ($removeToken) {
if (file_exists($tokenPath)) { $tokenPath = Config::resolvePath('setup.token');
@unlink($tokenPath); if (file_exists($tokenPath)) {
@unlink($tokenPath);
}
} }
} }

View File

@ -20,6 +20,21 @@
float: left; 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 { .progress-bar {
overflow: hidden; overflow: hidden;
padding-top: 1em; padding-top: 1em;
@ -36,7 +51,7 @@
} }
table { table {
margin-top: 0.7em; margin-top: 0.3em;
td { td {
padding: 0; padding: 0;