Show module requirements as a separate table

refs #8508
This commit is contained in:
Johannes Meyer 2015-03-10 10:56:05 +01:00
parent c44d5d2a73
commit 59f43a0f5e
4 changed files with 50 additions and 58 deletions

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Setup\Forms;
use Icinga\Web\Form;
use Icinga\Module\Setup\RequirementSet;
use Icinga\Module\Setup\SetupWizard;
/**
* Wizard page to list setup requirements
@ -12,11 +12,11 @@ use Icinga\Module\Setup\RequirementSet;
class RequirementsPage extends Form
{
/**
* The requirements to list
* The wizard
*
* @var RequirementSet
* @var SetupWizard
*/
protected $set;
protected $wizard;
/**
* Initialize this page
@ -28,30 +28,30 @@ class RequirementsPage extends Form
}
/**
* Set the requirements to list
* Set the wizard
*
* @param RequirementSet $set
* @param SetupWizard $wizard
*
* @return self
*/
public function setRequirements(RequirementSet $set)
public function setWizard(SetupWizard $wizard)
{
$this->set = $set;
$this->wizard = $wizard;
return $this;
}
/**
* Return the requirements to list
* Return the wizard
*
* @return RequirementSet
* @return SetupWizard
*/
public function getRequirements()
public function getWizard()
{
return $this->set;
return $this->wizard;
}
/**
* Validate the given form data and check whether the requirements are fulfilled
* Validate the given form data and check whether the wizard's requirements are fulfilled
*
* @param array $data The data to validate
*
@ -63,6 +63,6 @@ class RequirementsPage extends Form
return false;
}
return $this->set->fulfilled();
return $this->wizard->getRequirements()->fulfilled();
}
}

View File

@ -2,23 +2,13 @@
use Icinga\Web\Wizard;
$requirements = $form->getRequirements();
echo $requirements;
?>
<div class="buttons requirements-refresh">
<?php $title = $this->translate('You may also need to restart the web-server for the changes to take effect!'); ?>
<?= $this->qlink(
$this->translate('Refresh'),
null,
null,
array(
'class' => 'button-like',
'title' => $title,
'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title)
)
); ?>
</div>
<h1>Icinga Web 2</h1>
<?= $form->getWizard()->getRequirements(true); ?>
<?php foreach ($form->getWizard()->getPage('setup_modules')->getModuleWizards() as $moduleName => $wizard): ?>
<h1><?= ucwords($moduleName) . ' ' . $this->translate('Module'); ?></h1>
<?= $wizard->getRequirements(); ?>
<?php endforeach ?>
<form id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>" action="<?= $form->getAction(); ?>">
<?= $form->getElement($form->getTokenElementName()); ?>
<?= $form->getElement($form->getUidElementName()); ?>
@ -26,10 +16,23 @@ echo $requirements;
<?= $form->getElement(Wizard::BTN_PREV); ?>
<?php
$btn = $form->getElement(Wizard::BTN_NEXT);
if (! $requirements->fulfilled()) {
if (! $form->getWizard()->getRequirements()->fulfilled()) {
$btn->setAttrib('disabled', 1);
}
echo $btn;
?>
<div class="requirements-refresh">
<?php $title = $this->translate('You may also need to restart the web-server for the changes to take effect!'); ?>
<?= $this->qlink(
$this->translate('Refresh'),
null,
null,
array(
'class' => 'button-like',
'title' => $title,
'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title)
)
); ?>
</div>
</div>
</form>

View File

@ -115,7 +115,7 @@ class WebWizard extends Wizard implements SetupWizard
public function setupPage(Form $page, Request $request)
{
if ($page->getName() === 'setup_requirements') {
$page->setRequirements($this->getRequirements());
$page->setWizard($this);
} elseif ($page->getName() === 'setup_preferences_type') {
$authData = $this->getPageData('setup_authentication_type');
if ($authData['type'] === 'db') {
@ -355,7 +355,7 @@ class WebWizard extends Wizard implements SetupWizard
/**
* @see SetupWizard::getRequirements()
*/
public function getRequirements()
public function getRequirements($skipModules = false)
{
$set = new RequirementSet();
@ -502,8 +502,10 @@ class WebWizard extends Wizard implements SetupWizard
)
)));
foreach ($this->getWizards() as $wizard) {
$set->merge($wizard->getRequirements());
if (! $skipModules) {
foreach ($this->getWizards() as $wizard) {
$set->merge($wizard->getRequirements());
}
}
return $set;

View File

@ -168,14 +168,19 @@
}
form#setup_requirements {
margin-top: 2em;
padding-top: 0.5em;
border-top: 2px solid @colorPetrol;
}
div.requirements-refresh {
width: 25%;
margin-left: 75%;
text-align: center;
div.buttons div.requirements-refresh {
width: 25%;
float: right;
text-align: center;
a.button-like {
padding: 0.1em 0.4em;
}
}
}
#setup > table.requirements {
@ -230,24 +235,6 @@ div.requirements-refresh {
background-color: @colorCritical;
}
}
&.btn-update {
padding-top: 0.3em;
text-align: center;
div.buttons {
margin: 0;
a.button-like {
padding: 0.2em 0.5em;
background-color: @colorPetro;
&:hover, &:focus {
background-color: #666;
}
}
}
}
}
}