Style summary page

Dropped also the layout logic as it was too generic.

refs #7163
This commit is contained in:
Johannes Meyer 2014-10-16 14:52:26 +02:00
parent 16ce2eb425
commit d73423ceee
3 changed files with 258 additions and 230 deletions

View File

@ -1,6 +1,14 @@
<?php
use Icinga\Web\Wizard;
use Icinga\Application\Config;
$summary = $form->getSummary();
$prefType = $summary['setup_preferences_type']['type'];
$authType = $summary['setup_authentication_type']['type'];
$adminType = $summary['setup_admin_account']['user_type'];
$loggingType = $summary['setup_general_config']['logging_type'];
$loggingLevel = $summary['setup_general_config']['logging_level'];
?>
<p><?= t(
@ -9,48 +17,202 @@ use Icinga\Web\Wizard;
. ' 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 ?>
<?php if ($authType !== 'autologin' || $prefType === 'db'): ?>
<div class="page">
<h2><?= $authType === 'ldap' && $prefType === 'db' ? t('Resources') : t('Resource'); ?></h2>
<?php if ($authType === 'db' || $prefType === 'db'): ?>
<div class="topic">
<p>
<?= $authType === 'db' && $prefType === 'db'
? t('The following database will be used to authenticate users and to store preferences.') : (
$authType === 'db' ? t('The following database will be used to authenticate users.') : (
t('The following database will be used to store preferences.')
)
);
?>
</p>
<h3><?= t('Database'); ?></h3>
<table>
<tbody>
<tr>
<td><strong><?= t('Resource Name'); ?></strong></td>
<td><?= $summary['setup_db_resource']['name']; ?></td>
</tr>
<tr>
<td><strong><?= t('Database Type'); ?></strong></td>
<td><?= $summary['setup_db_resource']['db']; ?></td>
</tr>
<tr>
<td><strong><?= t('Host'); ?></strong></td>
<td><?= $summary['setup_db_resource']['host']; ?></td>
</tr>
<tr>
<td><strong><?= t('Port'); ?></strong></td>
<td><?= $summary['setup_db_resource']['port']; ?></td>
</tr>
<tr>
<td><strong><?= t('Database Name'); ?></strong></td>
<td><?= $summary['setup_db_resource']['dbname']; ?></td>
</tr>
<tr>
<td><strong><?= t('Username'); ?></strong></td>
<td><?= $summary['setup_db_resource']['username']; ?></td>
</tr>
<tr>
<td><strong><?= t('Password'); ?></strong></td>
<td><?= str_repeat('*', strlen($summary['setup_db_resource']['password'])); ?></td>
</tr>
</tbody>
</table>
</div>
<?php endforeach ?>
<?php endif ?>
<?php if ($authType === 'ldap'): ?>
<div class="topic">
<p><?= t('The following LDAP connection will be used to authenticate users.'); ?></p>
<h3>LDAP</h3>
<table>
<tbody>
<tr>
<td><strong><?= t('Resource Name'); ?></strong></td>
<td><?= $summary['setup_ldap_resource']['name']; ?></td>
</tr>
<tr>
<td><strong><?= t('Host'); ?></strong></td>
<td><?= $summary['setup_ldap_resource']['hostname']; ?></td>
</tr>
<tr>
<td><strong><?= t('Port'); ?></strong></td>
<td><?= $summary['setup_ldap_resource']['port']; ?></td>
</tr>
<tr>
<td><strong><?= t('Root DN'); ?></strong></td>
<td><?= $summary['setup_ldap_resource']['root_dn']; ?></td>
</tr>
<tr>
<td><strong><?= t('Bind DN'); ?></strong></td>
<td><?= $summary['setup_ldap_resource']['bind_dn']; ?></td>
</tr>
<tr>
<td><strong><?= t('Bind Password'); ?></strong></td>
<td><?= str_repeat('*', strlen($summary['setup_ldap_resource']['bind_pw'])); ?></td>
</tr>
</tbody>
</table>
</div>
<?php endif ?>
</div>
<?php endif ?>
<div class="page">
<h2><?= t('Authentication'); ?></h2>
<div class="topic">
<p><?= sprintf(
t('Users will authenticate using %s.', 'setup.summary.auth'),
$authType === 'db' ? t('a database', 'setup.summary.auth.type') : (
$authType === 'ldap' ? 'LDAP' : t('webserver authentication', 'setup.summary.auth.type')
)
); ?></p>
<h3><?= t('Backend Configuration'); ?></h3>
<table>
<tbody>
<tr>
<td><strong><?= t('Backend Name'); ?></strong></td>
<td><?= $summary['setup_authentication_backend']['name']; ?></td>
</tr>
<?php if ($authType === 'ldap'): ?>
<tr>
<td><strong><?= t('User Object Class'); ?></strong></td>
<td><?= $summary['setup_authentication_backend']['user_class']; ?></td>
</tr>
<tr>
<td><strong><?= t('User Name Attribute'); ?></strong></td>
<td><?= $summary['setup_authentication_backend']['user_name_attribute']; ?></td>
</tr>
<?php elseif ($authType === 'autologin'): ?>
<tr>
<td><strong><?= t('Backend Domain Pattern'); ?></strong></td>
<td><?= $summary['setup_authentication_backend']['strip_username_regexp']; ?></td>
</tr>
<?php endif ?>
</tbody>
</table>
</div>
<div class="topic">
<h3><?= t('Initial Administrative Account'); ?></h3>
<p><?= $adminType === 'by_name' || $adminType === 'existing_user' ? sprintf(
t('Administrative rights will initially be granted to an existing account called "%s".'),
$summary['setup_admin_account'][$adminType]
) : sprintf(
t('Administrative rights will initially be granted to a new account called "%s".'),
$summary['setup_admin_account'][$adminType]
); ?>
</div>
</div>
<div class="page">
<h2><?= t('Application Configuration'); ?></h2>
<div class="topic">
<h3><?= t('General', 'app.config'); ?></h3>
<ul>
<li><?= sprintf(
t('Icinga Web 2 will look for modules at: %s'),
$summary['setup_general_config']['global_modulePath']
); ?></li>
<li><?= sprintf(
$prefType === 'ini' ? sprintf(
t('Preferences will be stored per user account in INI files at: %s'),
Config::$configDir . '/preferences'
) : (
$prefType === 'db' ? t('Preferences will be stored using a database.') : (
t('Preferences will not be persisted across browser sessions.')
)
)
); ?></li>
</ul>
</div>
<div class="topic">
<h3><?= t('Logging', 'app.config'); ?></h3>
<table>
<tbody>
<tr>
<td><strong><?= t('Level', 'app.config.logging'); ?></strong></td>
<td><?= $loggingLevel === 0 ? t('None', 'app.config.logging.level') : (
$loggingLevel === 1 ? t('Error', 'app.config.logging.level') : (
$loggingLevel === 2 ? t('Warning', 'app.config.logging.level') : (
$loggingLevel === 3 ? t('Information', 'app.config.logging.level') : (
t('Debug', 'app.config.logging.level')
)
)
)
); ?></td>
</tr>
<tr>
<td><strong><?= t('Type', 'app.config.logging'); ?></strong></td>
<td><?= $loggingType === 'syslog' ? 'Syslog' : t('File', 'app.config.logging.type'); ?></td>
</tr>
<?php if ($loggingType === 'syslog'): ?>
<tr>
<td><strong><?= t('Application Prefix'); ?></strong></td>
<td><?= $summary['setup_general_config']['logging_application']; ?></td>
</tr>
<tr>
<td><strong><?= t('Facility'); ?></strong></td>
<td><?= $summary['setup_general_config']['logging_facility']; ?></td>
</tr>
<?php else: ?>
<tr>
<td><strong><?= t('Filepath'); ?></strong></td>
<td><?= $summary['setup_general_config']['logging_target']; ?></td>
</tr>
<?php endif ?>
</tbody>
</table>
</div>
</div>
<?php if (isset($summary['setup_db_resource'])): ?>
<div class="page">
<h2><?= t('Database Setup'); ?></h2>
<p><?= $summary['database_info']; ?></p>
</div>
<?php endif ?>
<form id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>">
<?= $form->getElement($form->getTokenElementName()); ?>
<?= $form->getElement($form->getUidElementName()); ?>

View File

@ -391,210 +391,64 @@ class WebInstaller implements Installer
*/
public function getSummary()
{
$summary = array();
$prefType = $this->pageData['setup_preferences_type']['type'];
$authType = $this->pageData['setup_authentication_type']['type'];
if ($authType !== 'autologin' || $prefType === 'db') {
$resourceInfo = array();
if ($authType === 'db' || $prefType === 'db') {
if ($authType === 'db' && $prefType === 'db') {
$resourceInfo[] = t(
'The following database will be used to authenticate users and to store preferences.'
);
} elseif ($authType === 'db') {
$resourceInfo[] = t('The following database will be used to authenticate users.');
} else { // $prefType === 'db'
$resourceInfo[] = t('The following database will be used to store preferences.');
}
$resourceInfo[t('Database')] = array(
sprintf(t('Resource Name: %s'), $this->pageData['setup_db_resource']['name']),
sprintf(t('Database Type: %s'), $this->pageData['setup_db_resource']['db']),
sprintf(t('Host: %s'), $this->pageData['setup_db_resource']['host']),
sprintf(t('Port: %s'), $this->pageData['setup_db_resource']['port']),
sprintf(t('Database Name: %s'), $this->pageData['setup_db_resource']['dbname']),
sprintf(t('Username: %s'), $this->pageData['setup_db_resource']['username']),
sprintf(
t('Password: %s'),
str_repeat('*', strlen($this->pageData['setup_db_resource']['password']))
)
);
}
if ($authType === 'ldap') {
$resourceInfo[] = t('The following LDAP connection will be used to authenticate users.');
$resourceInfo['LDAP'] = array(
sprintf(t('Resource Name: %s'), $this->pageData['setup_ldap_resource']['name']),
sprintf(t('Host: %s'), $this->pageData['setup_ldap_resource']['hostname']),
sprintf(t('Port: %s'), $this->pageData['setup_ldap_resource']['port']),
sprintf(t('Root DN: %s'), $this->pageData['setup_ldap_resource']['root_dn']),
sprintf(t('Bind DN: %s'), $this->pageData['setup_ldap_resource']['bind_dn']),
sprintf(
t('Bind Password: %s'),
str_repeat('*', strlen($this->pageData['setup_ldap_resource']['bind_pw']))
)
);
}
$summary[tp('Resource', 'Resources', count($resourceInfo) / 2)] = $resourceInfo;
}
$adminType = $this->pageData['setup_admin_account']['user_type'];
$summary[t('Authentication')] = array(
sprintf(
t('Users will authenticate using %s.', 'setup.summary.auth'),
$authType === 'db' ? t('a database', 'setup.summary.auth.type') : (
$authType === 'ldap' ? 'LDAP' : t('webserver authentication', 'setup.summary.auth.type')
)
),
t('Backend Configuration') => $authType === 'db' ? array(
sprintf(t('Backend Name: %s'), $this->pageData['setup_authentication_backend']['name'])
) : ($authType === 'ldap' ? array(
sprintf(t('Backend Name: %s'), $this->pageData['setup_authentication_backend']['name']),
sprintf(
t('LDAP User Object Class: %s'),
$this->pageData['setup_authentication_backend']['user_class']
),
sprintf(
t('LDAP User Name Attribute: %s'),
$this->pageData['setup_authentication_backend']['user_name_attribute']
)
) : array(
sprintf(t('Backend Name: %s'), $this->pageData['setup_authentication_backend']['name']),
sprintf(
t('Backend Domain Pattern: %s'),
$this->pageData['setup_authentication_backend']['strip_username_regexp']
)
)
),
t('Initial Administrative Account') => $adminType === 'by_name' || $adminType === 'existing_user'
? sprintf(
t('Administrative rights will initially be granted to an existing account called "%s".'),
$this->pageData['setup_admin_account'][$adminType]
) : sprintf(
t('Administrative rights will initially be granted to a new account called "%s".'),
$this->pageData['setup_admin_account'][$adminType]
)
);
$loggingLevel = $this->pageData['setup_general_config']['logging_level'];
$loggingType = $this->pageData['setup_general_config']['logging_type'];
$summary[t('Application Configuration')] = array(
t('General', 'app.config') => array(
sprintf(
t('Icinga Web 2 will look for modules at: %s'),
$this->pageData['setup_general_config']['global_modulePath']
),
sprintf(
$prefType === 'ini' ? sprintf(
t('Preferences will be stored per user account in INI files at: %s'),
Config::$configDir . '/preferences'
) : (
$prefType === 'db' ? t('Preferences will be stored using a database.') : (
t('Preferences will not be persisted across browser sessions.')
)
)
)
),
t('Logging', 'app.config') => array_merge(
array(
sprintf(
t('Level: %s', 'app.config.logging'),
$loggingLevel === 0 ? t('None', 'app.config.logging.level') : (
$loggingLevel === 1 ? t('Error', 'app.config.logging.level') : (
$loggingLevel === 2 ? t('Warning', 'app.config.logging.level') : (
$loggingLevel === 3 ? t('Information', 'app.config.logging.level') : (
t('Debug', 'app.config.logging.level')
)
)
)
)
),
sprintf(
t('Type: %s', 'app.config.logging'),
$loggingType === 'syslog' ? 'Syslog' : t('File', 'app.config.logging.type')
)
),
$this->pageData['setup_general_config']['logging_type'] === 'syslog' ? array(
sprintf(
t('Application Prefix: %s'),
$this->pageData['setup_general_config']['logging_application']
),
sprintf(
t('Facility: %s'),
$this->pageData['setup_general_config']['logging_facility']
)
) : array(
sprintf(
t('Filepath: %s'),
$this->pageData['setup_general_config']['logging_target']
)
)
)
);
$summary = $this->pageData;
if (isset($this->pageData['setup_db_resource'])) {
$setupDatabase = true;
$resourceConfig = $this->pageData['setup_db_resource'];
if (isset($this->pageData['setup_database_creation'])) {
$resourceConfig['username'] = $this->pageData['setup_database_creation']['username'];
$resourceConfig['password'] = $this->pageData['setup_database_creation']['password'];
}
if ($setupDatabase) {
$db = new DbTool($resourceConfig);
$db = new DbTool($resourceConfig);
try {
$db->connectToDb();
if (array_search('account', $db->listTables()) === false) {
$message = sprintf(
t(
'The database user "%s" will be used to setup the missing'
. ' schema required by Icinga Web 2 in database "%s".'
),
$resourceConfig['username'],
$resourceConfig['dbname']
);
} else {
$message = sprintf(
t('The database "%s" already seems to be fully set up. No action required.'),
$resourceConfig['dbname']
);
}
} catch (PDOException $e) {
try {
$db->connectToDb();
if (array_search('account', $db->listTables()) === false) {
$db->connectToHost();
if ($db->hasLogin($this->pageData['setup_db_resource']['username'])) {
$message = sprintf(
t(
'The database user "%s" will be used to setup the missing'
. ' schema required by Icinga Web 2 in database "%s".'
'The database user "%s" will be used to create the missing '
. 'database "%s" with the schema required by Icinga Web 2.'
),
$resourceConfig['username'],
$resourceConfig['dbname']
);
} else {
$message = sprintf(
t('The database "%s" already seems to be fully set up. No action required.'),
$resourceConfig['dbname']
t(
'The database user "%s" will be used to create the missing database "%s" '
. 'with the schema required by Icinga Web 2 and a new login called "%s".'
),
$resourceConfig['username'],
$resourceConfig['dbname'],
$this->pageData['setup_db_resource']['username']
);
}
} catch (PDOException $e) {
try {
$db->connectToHost();
if ($db->hasLogin($this->pageData['setup_db_resource']['username'])) {
$message = sprintf(
t(
'The database user "%s" will be used to create the missing '
. 'database "%s" with the schema required by Icinga Web 2.'
),
$resourceConfig['username'],
$resourceConfig['dbname']
);
} else {
$message = sprintf(
t(
'The database user "%s" will be used to create the missing database "%s" '
. 'with the schema required by Icinga Web 2 and a new login called "%s".'
),
$resourceConfig['username'],
$resourceConfig['dbname'],
$this->pageData['setup_db_resource']['username']
);
}
} catch (PDOException $e) {
$message = t(
'No connection to database host possible. You\'ll need to setup the'
. ' database with the schema required by Icinga Web 2 manually.'
);
}
$message = t(
'No connection to database host possible. You\'ll need to setup the'
. ' database with the schema required by Icinga Web 2 manually.'
);
}
$summary[t('Database Setup')] = $message;
}
$summary['database_info'] = $message;
}
return $summary;

View File

@ -198,28 +198,40 @@
#setup div.summary {
div.page {
float: left;
width: 30em;
padding: 0 1em 1em;
margin: 1em 2em 2em;
border-radius: 0.5em;
border: 1px dashed lightgrey;
h2 {
font-size: 1.2em;
}
.paragraph {
div.topic {
margin-left: 2em;
h3 {
font-size: 1em;
}
.topic {
h4 {
font-size: 0.8em;
}
ul {
list-style-type: circle;
}
div.topic {
table {
border-spacing: 0.5em;
border-collapse: separate;
font-size: 0.9em;
margin-left: 2em;
}
}
}
form {
clear: left;
}
}
#setup div.report {