From 32006420c549f3dd02bfa6494cdab32c9d31590b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 29 Oct 2014 11:36:03 +0100 Subject: [PATCH] Fix WelcomePage There were some grammar- and layout-errors as well as information missing :( --- application/forms/Setup/WelcomePage.php | 12 +- .../views/scripts/form/setup-welcome.phtml | 131 +++++++++--------- library/Icinga/Application/Platform.php | 15 ++ public/css/icinga/setup.less | 51 +++++-- 4 files changed, 124 insertions(+), 85 deletions(-) diff --git a/application/forms/Setup/WelcomePage.php b/application/forms/Setup/WelcomePage.php index e79e13189..941d74548 100644 --- a/application/forms/Setup/WelcomePage.php +++ b/application/forms/Setup/WelcomePage.php @@ -6,7 +6,6 @@ namespace Icinga\Form\Setup; use Icinga\Application\Icinga; use Icinga\Web\Form; -use Icinga\Web\Form\Element\Note; use Icinga\Web\Form\Validator\TokenValidator; /** @@ -14,13 +13,6 @@ use Icinga\Web\Form\Validator\TokenValidator; */ 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 */ @@ -28,7 +20,6 @@ class WelcomePage extends Form { $this->setName('setup_welcome'); $this->setViewScript('form/setup-welcome.phtml'); - $this->configDir = preg_replace('_/$_', '', Icinga::app()->getConfigDir()); } /** @@ -43,7 +34,8 @@ class WelcomePage extends Form 'required' => true, 'label' => t('Setup Token'), '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')) ) diff --git a/application/views/scripts/form/setup-welcome.phtml b/application/views/scripts/form/setup-welcome.phtml index d30081c79..8188d95e2 100644 --- a/application/views/scripts/form/setup-welcome.phtml +++ b/application/views/scripts/form/setup-welcome.phtml @@ -1,74 +1,75 @@ form->configDir . '/setup.token'; + +$setupTokenPath = rtrim(Icinga::app()->getConfigDir(), '/') . '/setup.token'; + ?> - -
-

- - -
- Icinga Web 2 is still in development and not meant for production deployment. - Watch the development roadmap and - Icinga website for release schedule updates! -
- -
-

- ' . t('Icinga Project') . '' - ); ?> -

-

-

-

- ' - . t('insights', 'setup.welcome.screenshots.label') . '' - ) ?> -

-
-

- -

- getElement('token') ?> - getElement($form->getTokenElementName()) ?> - getElement($form->getUidElementName()) ?> +
+

+ +
+ Icinga Web 2 is still in development and not meant for production deployment. + Watch the development roadmap and + Icinga website for release schedule updates! +
+
+

' . t('Icinga Project') . '' + ); ?>

+

+

' + . t('insights', 'setup.welcome.screenshots.label') . '' + ); ?>

+
+

+ + getElement('token'); ?> + getElement($form->getTokenElementName()); ?> + getElement($form->getUidElementName()); ?>
- getElement(Wizard::BTN_NEXT); - ?> + getElement(Wizard::BTN_NEXT); ?>
-
- - - -
-
- - Generating a new Security Token: + +
+
+ <?= t('Note'); ?> + Generating a New Setup Token
-

- -

- sudo icingacli setup generateToken -

- -

- - head -c 12 /dev/urandom | base64 | sudo -u 'apache' tee ;
- sudo chmod 0660 ;
-

-

- IcingaWeb2 Documentation on this topic.') ?> -

+

+

+
+ sudo icingacli setup createConfigDirectory ; + sudo icingacli setup generateToken; +
+

+
+ sudo mkdir -m 2775 && sudo chgrp ; + head -c 12 /dev/urandom | base64 | sudo -u '' tee ; + sudo chmod 0660 ; +
+

' . t('Icinga Web 2 documentation') . '' + ); ?>

+
\ No newline at end of file diff --git a/library/Icinga/Application/Platform.php b/library/Icinga/Application/Platform.php index d31fce70e..62efdf40e 100644 --- a/library/Icinga/Application/Platform.php +++ b/library/Icinga/Application/Platform.php @@ -141,6 +141,21 @@ class Platform 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 * diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index f3bee2cda..4e9837dfd 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -290,7 +290,8 @@ } } -#setup_welcome { +.welcome-page { + margin-top: 3em; text-align: center; h2 { @@ -304,6 +305,45 @@ background-color: #eee; 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 { @@ -373,12 +413,3 @@ } } } - -.code { - font-family: monospace; - display: inline-block; - padding: 1 1em; - border-radius: 1em; - min-width: 42em; - text-align: left; -} \ No newline at end of file