Wizard: Show a textarea on the finish page instead of multiple paragraphs

refs #7911
This commit is contained in:
Johannes Meyer 2015-07-03 16:31:11 +02:00
parent cef9b58029
commit c8c0e13184
13 changed files with 146 additions and 126 deletions

View File

@ -136,28 +136,35 @@ class BackendStep extends Step
public function getReport()
{
$report = '';
$report = array();
if ($this->backendIniError === false) {
$message = mt('monitoring', 'Monitoring backend configuration has been successfully written to: %s');
$report .= '<p>' . sprintf($message, Config::resolvePath('modules/monitoring/backends.ini')) . '</p>';
} elseif ($this->backendIniError !== null) {
$message = mt(
'monitoring',
'Monitoring backend configuration could not be written to: %s; An error occured:'
);
$report .= '<p class="error">' . sprintf(
$message,
$report[] = sprintf(
mt('monitoring', 'Monitoring backend configuration has been successfully written to: %s'),
Config::resolvePath('modules/monitoring/backends.ini')
) . '</p><p>' . $this->backendIniError->getMessage() . '</p>';
);
} elseif ($this->backendIniError !== null) {
$report[] = sprintf(
mt(
'monitoring',
'Monitoring backend configuration could not be written to: %s. An error occured:'
),
Config::resolvePath('modules/monitoring/backends.ini')
);
$report[] = sprintf(mt('setup', 'ERROR: %s'), $this->backendIniError->getMessage());
}
if ($this->resourcesIniError === false) {
$message = mt('monitoring', 'Resource configuration has been successfully updated: %s');
$report .= '<p>' . sprintf($message, Config::resolvePath('resources.ini')) . '</p>';
$report[] = sprintf(
mt('monitoring', 'Resource configuration has been successfully updated: %s'),
Config::resolvePath('resources.ini')
);
} elseif ($this->resourcesIniError !== null) {
$message = mt('monitoring', 'Resource configuration could not be udpated: %s; An error occured:');
$report .= '<p class="error">' . sprintf($message, Config::resolvePath('resources.ini')) . '</p>'
. '<p>' . $this->resourcesIniError->getMessage() . '</p>';
$report[] = sprintf(
mt('monitoring', 'Resource configuration could not be udpated: %s. An error occured:'),
Config::resolvePath('resources.ini')
);
$report[] = sprintf(mt('setup', 'ERROR: %s'), $this->resourcesIniError->getMessage());
}
return $report;

View File

@ -85,15 +85,21 @@ class InstanceStep extends Step
public function getReport()
{
if ($this->error === false) {
$message = mt('monitoring', 'Monitoring instance configuration has been successfully created: %s');
return '<p>' . sprintf($message, Config::resolvePath('modules/monitoring/instances.ini')) . '</p>';
return array(sprintf(
mt('monitoring', 'Monitoring instance configuration has been successfully created: %s'),
Config::resolvePath('modules/monitoring/instances.ini')
));
} elseif ($this->error !== null) {
$message = mt(
'monitoring',
'Monitoring instance configuration could not be written to: %s; An error occured:'
return array(
sprintf(
mt(
'monitoring',
'Monitoring instance configuration could not be written to: %s. An error occured:'
),
Config::resolvePath('modules/monitoring/instances.ini')
),
sprintf(mt('setup', 'ERROR: %s'), $this->error->getMessage())
);
return '<p class="error">' . sprintf($message, Config::resolvePath('modules/monitoring/instances.ini'))
. '</p><p>' . $this->error->getMessage() . '</p>';
}
}
}

View File

@ -63,15 +63,21 @@ class SecurityStep extends Step
public function getReport()
{
if ($this->error === false) {
$message = mt('monitoring', 'Monitoring security configuration has been successfully created: %s');
return '<p>' . sprintf($message, Config::resolvePath('modules/monitoring/config.ini')) . '</p>';
return array(sprintf(
mt('monitoring', 'Monitoring security configuration has been successfully created: %s'),
Config::resolvePath('modules/monitoring/config.ini')
));
} elseif ($this->error !== null) {
$message = mt(
'monitoring',
'Monitoring security configuration could not be written to: %s; An error occured:'
return array(
sprintf(
mt(
'monitoring',
'Monitoring security configuration could not be written to: %s. An error occured:'
),
Config::resolvePath('modules/monitoring/config.ini')
),
sprintf(mt('setup', 'ERROR: %s'), $this->error->getMessage())
);
return '<p class="error">' . sprintf($message, Config::resolvePath('modules/monitoring/config.ini'))
. '</p><p>' . $this->error->getMessage() . '</p>';
}
}
}

View File

@ -1,22 +1,10 @@
<div id="setup-finish">
<div class="report">
<?php $firstLine = true; ?>
<?php foreach ($report as $entry): ?>
<?php if ($entry): ?>
<?php if (false === $firstLine): ?>
<div class="line-separator"></div>
<?php endif ?>
<?= $entry; ?>
<?php $firstLine = false; ?>
<?php endif ?>
<?php endforeach ?>
<?php if ($success): ?>
<p class="success"><?= $this->translate('Congratulations! Icinga Web 2 has been successfully set up.'); ?></p>
<?php else: ?>
<p class="failure"><?= $this->translate('Sorry! Failed to set up Icinga Web 2 successfully.'); ?></p>
<?php endif ?>
</div>
<div class="buttons">
<?php if ($success): ?>
<h2 class="success"><?= $this->translate('Congratulations! Icinga Web 2 has been successfully set up.'); ?></h2>
<?php else: ?>
<h2 class="failure"><?= $this->translate('Sorry! Failed to set up Icinga Web 2 successfully.'); ?></h2>
<?php endif ?>
<div class="buttons pull-right">
<?php if ($success): ?>
<?= $this->qlink(
$this->translate('Login to Icinga Web 2'),
@ -39,4 +27,7 @@
); ?>
<?php endif ?>
</div>
<textarea class="report" readonly><?= join("\n\n", array_map(function($a) {
return join("\n", $a);
}, $report)); ?></textarea>
</div>

View File

@ -81,13 +81,16 @@ class Setup implements IteratorAggregate
/**
* Return a report of all actions that were run
*
* @return array An array of HTML strings
* @return array An array of arrays of strings
*/
public function getReport()
{
$reports = array();
foreach ($this->steps as $step) {
$reports[] = $step->getReport();
$report = $step->getReport();
if (! empty($report)) {
$reports[] = $report;
}
}
return $reports;

View File

@ -23,9 +23,9 @@ abstract class Step
abstract public function getSummary();
/**
* Return a HTML representation of this step's configuration changes that were made
* Return a textual summary of all configuration changes made
*
* @return string
* @return array
*/
abstract public function getReport();
}

View File

@ -161,32 +161,45 @@ class AuthenticationStep extends Step
public function getReport()
{
$report = '';
$report = array();
if ($this->authIniError === false) {
$message = mt('setup', 'Authentication configuration has been successfully written to: %s');
$report .= '<p>' . sprintf($message, Config::resolvePath('authentication.ini')) . '</p>';
$report[] = sprintf(
mt('setup', 'Authentication configuration has been successfully written to: %s'),
Config::resolvePath('authentication.ini')
);
} elseif ($this->authIniError !== null) {
$message = mt('setup', 'Authentication configuration could not be written to: %s; An error occured:');
$report .= '<p class="error">' . sprintf($message, Config::resolvePath('authentication.ini')) . '</p>'
. '<p>' . $this->authIniError->getMessage() . '</p>';
$report[] = sprintf(
mt('setup', 'Authentication configuration could not be written to: %s. An error occured:'),
Config::resolvePath('authentication.ini')
);
$report[] = sprintf(mt('setup', 'ERROR: %s'), $this->authIniError->getMessage());
}
if ($this->dbError === false) {
$message = mt('setup', 'Account "%s" has been successfully created.');
$report .= '<p>' . sprintf($message, $this->data['adminAccountData']['username']) . '</p>';
$report[] = sprintf(
mt('setup', 'Account "%s" has been successfully created.'),
$this->data['adminAccountData']['username']
);
} elseif ($this->dbError !== null) {
$message = mt('setup', 'Unable to create account "%s". An error occured:');
$report .= '<p class="error">' . sprintf($message, $this->data['adminAccountData']['username']) . '</p>'
. '<p>' . $this->dbError->getMessage() . '</p>';
$report[] = sprintf(
mt('setup', 'Unable to create account "%s". An error occured:'),
$this->data['adminAccountData']['username']
);
$report[] = sprintf(mt('setup', 'ERROR: %s'), $this->dbError->getMessage());
}
if ($this->permIniError === false) {
$message = mt('setup', 'Account "%s" has been successfully defined as initial administrator.');
$report .= '<p>' . sprintf($message, $this->data['adminAccountData']['username']) . '</p>';
$report[] = sprintf(
mt('setup', 'Account "%s" has been successfully defined as initial administrator.'),
$this->data['adminAccountData']['username']
);
} elseif ($this->permIniError !== null) {
$message = mt('setup', 'Unable to define account "%s" as initial administrator. An error occured:');
$report .= '<p class="error">' . sprintf($message, $this->data['adminAccountData']['username']) . '</p>'
. '<p>' . $this->permIniError->getMessage() . '</p>';
$report[] = sprintf(
mt('setup', 'Unable to define account "%s" as initial administrator. An error occured:'),
$this->data['adminAccountData']['username']
);
$report[] = sprintf(mt('setup', 'ERROR: %s'), $this->permIniError->getMessage());
}
return $report;

View File

@ -247,12 +247,14 @@ class DatabaseStep extends Step
public function getReport()
{
if ($this->error === false) {
return '<p>' . join('</p><p>', $this->messages) . '</p>'
. '<p>' . mt('setup', 'The database has been fully set up!') . '</p>';
$report = $this->messages;
$report[] = mt('setup', 'The database has been fully set up!');
return $report;
} elseif ($this->error !== null) {
$message = mt('setup', 'Failed to fully setup the database. An error occured:');
return '<p>' . join('</p><p>', $this->messages) . '</p>'
. '<p class="error">' . $message . '</p><p>' . $this->error->getMessage() . '</p>';
$report = $this->messages;
$report[] = mt('setup', 'Failed to fully setup the database. An error occured:');
$report[] = sprintf(mt('setup', 'ERROR: %s'), $this->error->getMessage());
return $report;
}
}

View File

@ -102,12 +102,18 @@ class GeneralConfigStep extends Step
public function getReport()
{
if ($this->error === false) {
$message = mt('setup', 'General configuration has been successfully written to: %s');
return '<p>' . sprintf($message, Config::resolvePath('config.ini')) . '</p>';
return array(sprintf(
mt('setup', 'General configuration has been successfully written to: %s'),
Config::resolvePath('config.ini')
));
} elseif ($this->error !== null) {
$message = mt('setup', 'General configuration could not be written to: %s; An error occured:');
return '<p class="error">' . sprintf($message, Config::resolvePath('config.ini')) . '</p>'
. '<p>' . $this->error->getMessage() . '</p>';
return array(
sprintf(
mt('setup', 'General configuration could not be written to: %s. An error occured:'),
Config::resolvePath('config.ini')
),
sprintf(mt('setup', 'ERROR: %s'), $this->error->getMessage())
);
}
}
}

View File

@ -133,12 +133,18 @@ class ResourceStep extends Step
public function getReport()
{
if ($this->error === false) {
$message = mt('setup', 'Resource configuration has been successfully written to: %s');
return '<p>' . sprintf($message, Config::resolvePath('resources.ini')) . '</p>';
return array(sprintf(
mt('setup', 'Resource configuration has been successfully written to: %s'),
Config::resolvePath('resources.ini')
));
} elseif ($this->error !== null) {
$message = mt('setup', 'Resource configuration could not be written to: %s; An error occured:');
return '<p class="error">' . sprintf($message, Config::resolvePath('resources.ini')) . '</p>'
. '<p>' . $this->error->getMessage() . '</p>';
return array(
sprintf(
mt('setup', 'Resource configuration could not be written to: %s. An error occured:'),
Config::resolvePath('resources.ini')
),
sprintf(mt('setup', 'ERROR: %s'), $this->error->getMessage())
);
}
}
}

View File

@ -53,13 +53,13 @@ class EnableModuleStep extends Step
$okMessage = mt('setup', 'Module "%s" has been successfully enabled.');
$failMessage = mt('setup', 'Module "%s" could not be enabled. An error occured:');
$report = '';
$report = array();
foreach ($this->moduleNames as $moduleName) {
if (isset($this->errors[$moduleName])) {
$report .= '<p class="error">' . sprintf($failMessage, $moduleName) . '</p>'
. '<p>' . $this->errors[$moduleName]->getMessage() . '</p>';
$report[] = sprintf($failMessage, $moduleName);
$report[] = sprintf(mt('setup', 'ERROR: %s'), $this->errors[$moduleName]->getMessage());
} else {
$report .= '<p>' . sprintf($okMessage, $moduleName) . '</p>';
$report[] = sprintf($okMessage, $moduleName);
}
}

View File

@ -53,14 +53,14 @@ class MakeDirStep extends Step
$okMessage = mt('setup', 'Directory "%s" in "%s" has been successfully created.');
$failMessage = mt('setup', 'Unable to create directory "%s" in "%s". An error occured:');
$report = '';
$report = array();
foreach ($this->paths as $path) {
if (array_key_exists($path, $this->errors)) {
if (is_array($this->errors[$path])) {
$report .= '<p class="error">' . sprintf($failMessage, basename($path), dirname($path)) . '</p>'
. '<p>' . $this->errors[$path]['message'] . '</p>';
$report[] = sprintf($failMessage, basename($path), dirname($path));
$report[] = sprintf(mt('setup', 'ERROR: %s'), $this->errors[$path]['message']);
} else {
$report .= '<p>' . sprintf($okMessage, basename($path), dirname($path)) . '</p>';
$report[] = sprintf($okMessage, basename($path), dirname($path));
}
}
}

View File

@ -300,48 +300,28 @@ form#setup_requirements {
}
}
.conspicuous-state-notification {
width: 66%;
margin: 0 auto;
padding: 0.5em;
color: white;
font-weight: bold;
}
#setup-finish {
div.report {
padding: 1em;
border: 1px solid lightgrey;
border-radius: 0em;
h2 {
padding: 0.5em;
border-bottom: 0;
font-variant: normal;
font-weight: bold;
color: white;
div.line-separator {
width: 50%;
height: 1px;
margin: 0 auto;
background-color: white;
&.success {
background-color: @colorOk;
}
p {
margin: 1em;
color: #444;
text-align: center;
&.error {
color: red;
}
&.failure {
.conspicuous-state-notification;
background-color: @colorCritical;
}
&.success {
.conspicuous-state-notification;
background-color: @colorOk;
}
&.failure {
background-color: @colorCritical;
}
}
textarea.report {
width: 66%;
height: 25em;
}
div.buttons {
text-align: center;
}