From f29705fc59b1c2b3246aefdd19e3c8b8ef099d0d Mon Sep 17 00:00:00 2001 From: Johannes Meyer <johannes.meyer@netways.de> Date: Thu, 2 Oct 2014 17:11:00 +0200 Subject: [PATCH] Add summary page refs #7163 --- application/forms/Setup/SummaryPage.php | 52 ++++++++++++++++ .../views/scripts/form/setup-summary.phtml | 60 +++++++++++++++++++ library/Icinga/Application/WebSetup.php | 4 ++ public/css/icinga/wizard.less | 26 ++++++++ 4 files changed, 142 insertions(+) create mode 100644 application/forms/Setup/SummaryPage.php create mode 100644 application/views/scripts/form/setup-summary.phtml diff --git a/application/forms/Setup/SummaryPage.php b/application/forms/Setup/SummaryPage.php new file mode 100644 index 000000000..c44899b58 --- /dev/null +++ b/application/forms/Setup/SummaryPage.php @@ -0,0 +1,52 @@ +<?php +// {{{ICINGA_LICENSE_HEADER}}} +// {{{ICINGA_LICENSE_HEADER}}} + +namespace Icinga\Form\Setup; + +use Icinga\Web\Form; + +/** + * Wizard page that displays a summary of what is going to be "done" + */ +class SummaryPage extends Form +{ + /** + * The summary to show + * + * @var array + */ + protected $summary; + + /** + * Initialize this page + */ + public function init() + { + $this->setName('setup_summary'); + $this->setViewScript('form/setup-summary.phtml'); + } + + /** + * Set the summary to show + * + * @param array $summary + * + * @return self + */ + public function setSummary(array $summary) + { + $this->summary = $summary; + return $this; + } + + /** + * Return the summary to show + * + * @return array + */ + public function getSummary() + { + return $this->summary; + } +} diff --git a/application/views/scripts/form/setup-summary.phtml b/application/views/scripts/form/setup-summary.phtml new file mode 100644 index 000000000..4380866ed --- /dev/null +++ b/application/views/scripts/form/setup-summary.phtml @@ -0,0 +1,60 @@ +<?php + +use Icinga\Web\Wizard; + +?> +<p><?= t( + 'The wizard is now complete. You can review the changes supposed to be made before issuing the actual installation' + . ' of Icinga Web 2. Make sure that everything is correct (Feel free to navigate back to make any corrections!) so' + . ' that you can start using Icinga Web 2 right after the installation has been finished.' +); ?></p> +<div class="summary"> + <?php foreach ($form->getSummary() as $pageTitle => $pageContent): ?> + <div class="page"> + <h2><?= $pageTitle; ?></h2> + <?php if (is_array($pageContent)): ?> + <?php foreach ($pageContent as $paragraphTitle => $paragraphContent): ?> + <div class="paragraph"> + <?php if (false === is_int($paragraphTitle)): ?> + <h3><?= $paragraphTitle; ?></h3> + <?php endif ?> + <?php if (is_array($paragraphContent)): ?> + <?php if (is_int(key($paragraphContent))): ?> + <ul class="topic"> + <?php foreach ($paragraphContent as $listItem): ?> + <li><?= $listItem; ?></li> + <?php endforeach ?> + </ul> + <?php else: ?> + <?php foreach ($paragraphContent as $topicTitle => $topicContent): ?> + <div class="topic"> + <h4><?= $topicTitle; ?></h4> + <?php if (is_array($topicContent)): ?> + <ul> + <?php foreach ($topicContent as $listItem): ?> + <li><?= $listItem; ?></li> + <?php endforeach ?> + </ul> + <?php else: ?> + <p><?= $topicContent; ?></p> + <?php endif ?> + </div> + <?php endforeach ?> + <?php endif ?> + <?php else: ?> + <p class="topic"><?= $paragraphContent; ?></p> + <?php endif ?> + </div> + <?php endforeach ?> + <?php else: ?> + <p class="paragraph"><?= $pageContent; ?></p> + <?php endif ?> + </div> + <?php endforeach ?> + <form id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>"> + <?= $form->getElement($form->getTokenElementName()); ?> + <?= $form->getElement($form->getUidElementName()); ?> + <?= $form->getElement(Wizard::BTN_PREV); ?> + <?= $form->getElement(Wizard::BTN_NEXT)->setLabel(t('Install Icinga Web 2')); ?> + </form> +</div> \ No newline at end of file diff --git a/library/Icinga/Application/WebSetup.php b/library/Icinga/Application/WebSetup.php index cedc58e90..cce64a462 100644 --- a/library/Icinga/Application/WebSetup.php +++ b/library/Icinga/Application/WebSetup.php @@ -6,6 +6,7 @@ namespace Icinga\Application; use PDOException; use Icinga\Form\Setup\WelcomePage; +use Icinga\Form\Setup\SummaryPage; use Icinga\Form\Setup\DbResourcePage; use Icinga\Form\Setup\PreferencesPage; use Icinga\Form\Setup\AuthBackendPage; @@ -68,6 +69,7 @@ class WebSetup extends Wizard implements SetupWizard $this->addPage(new AdminAccountPage()); $this->addPage(new GeneralConfigPage()); $this->addPage(new DatabaseCreationPage()); + $this->addPage(new SummaryPage()); } /** @@ -109,6 +111,8 @@ class WebSetup extends Wizard implements SetupWizard } elseif ($page->getName() === 'setup_database_creation') { $page->setDatabasePrivileges($this->databaseSetupPrivileges); $page->setResourceConfig($this->getPageData('setup_db_resource')); + } elseif ($page->getName() === 'setup_summary') { + $page->setSummary($this->getInstaller()->getSummary()); } } diff --git a/public/css/icinga/wizard.less b/public/css/icinga/wizard.less index af280208d..b95993841 100644 --- a/public/css/icinga/wizard.less +++ b/public/css/icinga/wizard.less @@ -25,4 +25,30 @@ display: inline-block; padding: 0.4em 0.2em 0; } +} + +#wizard div.summary { + div.page { + h2 { + font-size: 1.2em; + } + + .paragraph { + margin-left: 2em; + + h3 { + font-size: 1em; + } + + .topic { + h4 { + font-size: 0.8em; + } + } + + div.topic { + margin-left: 2em; + } + } + } } \ No newline at end of file