Fix WelcomePage

There were some grammar- and layout-errors
as well as information missing :(
This commit is contained in:
Johannes Meyer 2014-10-29 11:36:03 +01:00
parent c6b18d2f3d
commit 32006420c5
4 changed files with 124 additions and 85 deletions

View File

@ -6,7 +6,6 @@ namespace Icinga\Form\Setup;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Form\Element\Note;
use Icinga\Web\Form\Validator\TokenValidator; use Icinga\Web\Form\Validator\TokenValidator;
/** /**
@ -14,13 +13,6 @@ use Icinga\Web\Form\Validator\TokenValidator;
*/ */
class WelcomePage extends Form class WelcomePage extends Form
{ {
/**
* The configuration directory displayed to the user in the "generate security token" infobox
*
* @var string
*/
public $configDir = '/etc/icingaweb';
/** /**
* Initialize this page * Initialize this page
*/ */
@ -28,7 +20,6 @@ class WelcomePage extends Form
{ {
$this->setName('setup_welcome'); $this->setName('setup_welcome');
$this->setViewScript('form/setup-welcome.phtml'); $this->setViewScript('form/setup-welcome.phtml');
$this->configDir = preg_replace('_/$_', '', Icinga::app()->getConfigDir());
} }
/** /**
@ -43,7 +34,8 @@ class WelcomePage extends Form
'required' => true, 'required' => true,
'label' => t('Setup Token'), 'label' => t('Setup Token'),
'description' => t( 'description' => t(
'For security reasons, we need to check that you are permitted to execute this setup. Please provide the token from the file "setup.token".' 'For security reasons we need to ensure that you are permitted to run this wizard.'
. ' Please provide a token by following the instructions below.'
), ),
'validators' => array(new TokenValidator(Icinga::app()->getConfigDir() . '/setup.token')) 'validators' => array(new TokenValidator(Icinga::app()->getConfigDir() . '/setup.token'))
) )

View File

@ -1,74 +1,75 @@
<?php <?php
use Icinga\Application\Icinga;
use Icinga\Application\Platform;
use Icinga\Web\Wizard; use Icinga\Web\Wizard;
$setupToken = $this->form->configDir . '/setup.token';
$setupTokenPath = rtrim(Icinga::app()->getConfigDir(), '/') . '/setup.token';
?> ?>
<div class="welcome-page">
<form style="margin-top: 4em;" id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>" action="<?= $form->getAction(); ?>"> <h2><?= t('Welcome to the installation of Icinga Web 2!') ?></h2>
<h2><?= t('Welcome to the installation of Icinga Web 2!') ?></h2> <!-- TODO: Remove this once we release the first public version -->
<div style="border:1px solid #777;border-radius:1em;background-color:beige;padding:1em;margin-bottom:1em;display:inline-block;">
<!-- TODO: Remove this once we release the first public version --> Icinga Web 2 is still in development and not meant for production deployment.
<div style="border:1px solid #777;border-radius:1em;background-color:beige;padding:1em;margin-bottom:1em;display:inline-block;"> Watch the <a href="https://dev.icinga.org/projects/icingaweb2/roadmap">development roadmap</a> and
Icinga Web 2 is still in development and not meant for production deployment. <a href="https://www.icinga.org/">Icinga website</a> for release schedule updates!
Watch the <a href="https://dev.icinga.org/projects/icingaweb2/roadmap">development roadmap</a> and </div>
<a href="https://www.icinga.org/">Icinga website</a> for release schedule updates! <div class="info">
</div> <p><?= sprintf(
t(
<div class="info"> 'Icinga Web 2 is the next generation monitoring web interface,'
<p> . ' framework and CLI tool developed by the %s.'
<?= sprintf( ),
t( '<a href="https://www.icinga.org/community/team/">' . t('Icinga Project') . '</a>'
'Icinga Web 2 is the next generation monitoring web interface,' ); ?></p>
. ' framework and CLI tool developed by the %s.' <p><?= t(
), 'Responsive and fast, rewritten from scratch supporting multiple backends and'
'<a href="https://www.icinga.org/community/team/">' . t('Icinga Project') . '</a>' . ' providing a CLI tool. Compatible with Icinga Core 2.x and 1.x.'
); ?> ); ?></p>
</p> <p><?= sprintf(
<p><?= t('Responsive and fast, rewritten from scratch supporting multiple backends and providing a CLI tool. ' . t('Check the Icinga website for some %s.', 'setup.welcome.screenshots'),
' Compatible with Icinga Core 2.x and 1.x.') ?> '<a href="https://www.icinga.org/icinga/screenshots/icinga-web-2/">'
</p> . t('insights', 'setup.welcome.screenshots.label') . '</a>'
<p> ); ?></p>
<?= sprintf( </div>
t('Check the Icinga website for some %s.', 'setup.welcome.screenshots'), <p><?= t(
'<a href="https://www.icinga.org/icinga/screenshots/icinga-web-2/">' 'This wizard will guide you through the installation of Icinga Web 2. Once completed and successfully'
. t('insights', 'setup.welcome.screenshots.label') . '</a>' . ' finished you are able to log in and to explore all the new and stunning features!'
) ?> ); ?></p>
</p> <form id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>" action="<?= $form->getAction(); ?>">
</div> <?= $form->getElement('token'); ?>
<p> <?= $form->getElement($form->getTokenElementName()); ?>
<?= t('This wizard will guide you through the installation of Icinga Web 2. Once completed and successfully ' . <?= $form->getElement($form->getUidElementName()); ?>
'finished you are able to log in and to explore all the new and stunning features!') ?>
</p>
<?= $form->getElement('token') ?>
<?= $form->getElement($form->getTokenElementName()) ?>
<?= $form->getElement($form->getUidElementName()) ?>
<div class="buttons"> <div class="buttons">
<?php <?= $form->getElement(Wizard::BTN_NEXT); ?>
echo $form->getElement(Wizard::BTN_NEXT);
?>
</div> </div>
<br> </form>
</form> <div class="note">
<div class="title">
<img src="<?= $this->href('img/icons/comment.png'); ?>" alt="<?= t('Note'); ?>">
<div style="border-radius: 0.2em; margin: auto; margin-top: 3em; text-align: center; max-width: 46em; border: 1px solid #eeeeee;"> <strong>Generating a New Setup Token</strong>
<div style="border-radius: 0.2em; padding: 0.1em; background-color: #eeeeee; ">
<img style="float: right;" src="<?= $this->href('img/icons/comment.png') ?>"/>
Generating a new Security Token:
</div> </div>
<div> <div>
<p style="margin: 1em"> <p><?=
<?= t('As the Icinga Web 2 administrator you need set a security token, so the installer can authorize its user:') ?> t('To run this wizard a user needs to authenticate using a token which is usually'
</p> . ' provided to him by an administrator who\'d followed the instructions below.'
<span class="code"> sudo icingacli setup generateToken </span> ); ?></p>
<p style="margin: 1em"> <p><?= t('If you\'ve got the IcingaCLI installed you can do the following:'); ?></p>
<?= t('If you don\'t have IcingaCLI available, you can set it yourself:') ?> <div class="code">
</p> <span>sudo icingacli setup createConfigDirectory <?= Platform::getPhpUser(); ?>;</span>
<span class="code"> <span>sudo icingacli setup generateToken;</span>
head -c 12 /dev/urandom | base64 | sudo -u 'apache' tee <?= $setupToken ?>; <br/> </div>
sudo chmod 0660 <?= $setupToken ?>; <br/> <p><?= t('In case the IcingaCLI is missing you can create the token manually:'); ?></p>
</span> <br/> <div class="code">
<p> <span>sudo mkdir -m 2775 <?= dirname($setupTokenPath); ?> && sudo chgrp <?= Platform::getPhpUser(); ?> <?= dirname($setupTokenPath); ?>;</span>
<?= t('For further help, please check out the <a href="#">IcingaWeb2 Documentation</a> on this topic.') ?> <span>head -c 12 /dev/urandom | base64 | sudo -u '<?= Platform::getPhpUser(); ?>' tee <?= $setupTokenPath; ?>;</span>
</p> <span>sudo chmod 0660 <?= $setupTokenPath; ?>;</span>
</div>
<p style="font-size: 85%;"><?= sprintf(
t('Please see the %s for an extensive description on how to access and use this wizard.'),
'<a href="http://docs.icinga.org/">' . t('Icinga Web 2 documentation') . '</a>'
); ?></p>
</div> </div>
</div>
</div> </div>

View File

@ -141,6 +141,21 @@ class Platform
return phpversion(); return phpversion();
} }
/**
* Return the username PHP is running as
*
* @return string
*/
public static function getPhpUser()
{
if (static::isWindows()) {
return get_current_user(); // http://php.net/manual/en/function.get-current-user.php#75059
}
$userInfo = posix_getpwuid(posix_geteuid());
return $userInfo['name'];
}
/** /**
* Test for php extension * Test for php extension
* *

View File

@ -290,7 +290,8 @@
} }
} }
#setup_welcome { .welcome-page {
margin-top: 3em;
text-align: center; text-align: center;
h2 { h2 {
@ -304,6 +305,45 @@
background-color: #eee; background-color: #eee;
border: 1px solid lightgrey; border: 1px solid lightgrey;
} }
div.note {
width: 40%;
padding: 1em;
margin: 3em auto 0;
text-align: left;
border-radius: 0.5em;
border: 1px solid #eee;
div.title {
padding: 0.2em;
margin: -1em -1em 1em;
text-align: center;
background-color: #eee;
border-top-left-radius: 0.5em;
border-top-right-radius: 0.5em;
}
img {
float: right;
}
p {
margin: 2em 0 1em 0;
&:first-child {
margin-top: 1em;
}
}
div.code {
margin: 0 2em;
span {
display: block;
font-family: monospace;
}
}
}
} }
#setup { #setup {
@ -373,12 +413,3 @@
} }
} }
} }
.code {
font-family: monospace;
display: inline-block;
padding: 1 1em;
border-radius: 1em;
min-width: 42em;
text-align: left;
}