[icinga-checkins] icinga.org: icingaweb2/feature/allow-to-restart-the-wizard-9658: Wizard: Add restart button

git at icinga.org git at icinga.org
Mon Jan 9 11:06:35 CET 2017


Module: icingaweb2
Branch: feature/allow-to-restart-the-wizard-9658
Commit: 19f2c813f1d73a8d2db6317b6a0f735cc6c02d51
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=19f2c813f1d73a8d2db6317b6a0f735cc6c02d51

Author: Noah Hilverling <noah.hilverling at netways.de>
Date:   Thu Dec 22 14:17:30 2016 +0100

Wizard: Add restart button

refs #9658

---

 .../application/controllers/IndexController.php    |   41 ++++++++++++++++++++
 .../application/views/scripts/index/index.phtml    |    9 +++++
 public/css/icinga/setup.less                       |   17 +++++++-
 3 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/modules/setup/application/controllers/IndexController.php b/modules/setup/application/controllers/IndexController.php
index 8f6718d..a4d5076 100644
--- a/modules/setup/application/controllers/IndexController.php
+++ b/modules/setup/application/controllers/IndexController.php
@@ -5,6 +5,8 @@ namespace Icinga\Module\Setup\Controllers;
 
 use Icinga\Module\Setup\WebWizard;
 use Icinga\Web\Controller;
+use Icinga\Web\Form;
+use Icinga\Web\Url;
 
 class IndexController extends Controller
 {
@@ -42,8 +44,47 @@ class IndexController extends Controller
             $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();
+    }
 }
diff --git a/modules/setup/application/views/scripts/index/index.phtml b/modules/setup/application/views/scripts/index/index.phtml
index 2c07e69..1c4280c 100644
--- a/modules/setup/application/views/scripts/index/index.phtml
+++ b/modules/setup/application/views/scripts/index/index.phtml
@@ -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)): ?>
+          <?= $this->restartForm ?>
+        <?php endif ?>
       </div>
       <div class="step" style="width: 10%;">
         <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="right"><div class="line right<?= $stateClass; ?>"></div></td>
         </tr></tbody></table>
+        <?php if (($maxProgress < $currentPos && $currentPos === 2) || ($maxProgress >= $currentPos && $maxProgress === 2)): ?>
+          <?= $this->restartForm ?>
+        <?php endif ?>
       </div>
       <div class="step" style="width: 60%;">
         <h1><?= $this->translate('Configuration', 'setup.progress'); ?></h1>
@@ -122,6 +128,9 @@ if ($notifications->hasMessages()) {
           <?php endforeach ?>
           </td>
         </tr></tbody></table>
+        <?php if ($maxProgress > 2 || $currentPos > 2): ?>
+          <?= $this->restartForm ?>
+        <?php endif ?>
       </div>
       <div class="step" style="width: 10%;">
         <h1><?= $this->translate('Finish', 'setup.progress'); ?></h1>
diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less
index fa5a327..864ac55 100644
--- a/public/css/icinga/setup.less
+++ b/public/css/icinga/setup.less
@@ -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;
@@ -36,7 +51,7 @@
         }
 
         table {
-          margin-top: 0.7em;
+          margin-top: 0.3em;
 
           td {
             padding: 0;



More information about the icinga-checkins mailing list