-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move requirement stuff into its own class and add db configuration form
Moved all the requirement stuff from the IndexController and the RequirementsForm into its own class, added the basic database configuration form and restructured some parts of the code, the layout as well as the overall "flow". refs #3761
- Loading branch information
Johannes Meyer
committed
Oct 7, 2013
1 parent
943cb44
commit 7c6d8b4
Showing
8 changed files
with
786 additions
and
290 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
/** | ||
* This file is part of Icinga 2 Web. | ||
* | ||
* Icinga 2 Web - Head for multiple monitoring backends. | ||
* Copyright (C) 2013 Icinga Development Team | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* @copyright 2013 Icinga Development Team <info@icinga.org> | ||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 | ||
* @author Icinga Development Team <info@icinga.org> | ||
*/ | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
|
||
namespace Icinga\Installer\Pages; | ||
|
||
require_once realpath(__DIR__ . '/WizardForm.php'); | ||
|
||
/** | ||
* Wizard-Page that prompts the user for database configuration details | ||
*/ | ||
class DbConfigForm extends WizardForm | ||
{ | ||
public function create() | ||
{ | ||
$this->addNote('Database configuration', 1); | ||
|
||
$this->addNote('Primary database store to use', 2); | ||
|
||
$this->addElement( | ||
'text', | ||
'resource_name', | ||
array( | ||
'label' => 'Resource name', | ||
'helptext' => 'This is the name internally used by Icinga 2 Web to identify this database store.', | ||
'required' => true, | ||
'allowEmpty' => false, | ||
'value' => 'icinga2web' | ||
) | ||
); | ||
|
||
$this->addElement( | ||
'select', | ||
'db_provider', | ||
array( | ||
'label' => 'Database provider', | ||
'helptext' => 'Specifies the type or vendor of this database.', | ||
'required' => true, | ||
'allowEmpty' => false, | ||
'multiOptions' => $this->getAvailableProviders() | ||
) | ||
); | ||
|
||
$this->addElement( | ||
'text', | ||
'db_host', | ||
array( | ||
'label' => 'Hostname', | ||
'helptext' => 'The host of this database.', | ||
'required' => true, | ||
'allowEmpty' => false, | ||
'value' => 'localhost' | ||
) | ||
); | ||
|
||
$this->addElement( | ||
'text', | ||
'db_port', | ||
array( | ||
'label' => 'Port', | ||
'helptext' => 'The port of this database. (Leave blank to use the default.)', | ||
'allowEmpty' => true | ||
) | ||
); | ||
|
||
$this->addElement( | ||
'text', | ||
'db_name', | ||
array( | ||
'label' => 'Database name', | ||
'helptext' => 'The name of this database.', | ||
'required' => true, | ||
'allowEmpty' => false, | ||
'value' => 'icinga2web' | ||
) | ||
); | ||
|
||
$this->addElement( | ||
'text', | ||
'db_username', | ||
array( | ||
'label' => 'Username', | ||
'helptext' => 'The username to use for authentication with this database.', | ||
'required' => true, | ||
'allowEmpty' => false, | ||
'value' => 'icinga2web' | ||
) | ||
); | ||
|
||
$this->addElement( | ||
'text', | ||
'db_password', | ||
array( | ||
'label' => 'Password', | ||
'helptext' => 'The password to use for authentication with this database.', | ||
'required' => true, | ||
'allowEmpty' => false, | ||
'value' => 'icinga' | ||
) | ||
); | ||
|
||
$this->setSubmitLabel('Continue'); | ||
} | ||
|
||
/** | ||
* Return a list of available database providers | ||
* | ||
* @return array | ||
*/ | ||
private function getAvailableProviders() | ||
{ | ||
$reportInfo = $this->getReport()->toArray(); | ||
$providers = array(); | ||
|
||
if ($reportInfo['hasMysqlExtension'] && $reportInfo['hasMysqlAdapter']) { | ||
array_push($providers, 'mysql'); | ||
} | ||
if ($reportInfo['hasPgsqlExtension'] && $reportInfo['hasPgsqlAdapter']) { | ||
array_push($providers, 'pgsql'); | ||
} | ||
|
||
return $providers; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
<?php $currentStep = isset($this->form) ? $this->form->getCurrentStep() : 0; ?> | ||
<table class="table" style="margin: .7em;"> | ||
<tr class="<?php echo $this->currentStep == 1 ? 'active' : ($this->currentStep > 1 ? 'success' : '') ?>"> | ||
<tr class="<?php echo $currentStep == 1 ? 'active' : ($currentStep > 1 ? 'success' : '') ?>"> | ||
<td>Start</td> | ||
</tr> | ||
<tr class="<?php echo $this->currentStep == 2 ? 'active' : ($this->currentStep > 2 ? 'success' : '') ?>"> | ||
<tr class="<?php echo $currentStep == 2 ? 'active' : ($currentStep > 2 ? 'success' : '') ?>"> | ||
<td>Requirements</td> | ||
</tr> | ||
<tr class="<?php echo $currentStep == 3 ? 'active' : ($currentStep > 3 ? 'success' : '') ?>"> | ||
<td>Database configuration</td> | ||
</tr> | ||
<tr class="<?php echo $currentStep == 4 ? 'active' : ($currentStep > 4 ? 'success' : '') ?>"> | ||
<td>Authentication & Preferences</td> | ||
</tr> | ||
<tr class="<?php echo $currentStep == 5 ? 'active' : ($currentStep > 5 ? 'success' : '') ?>"> | ||
<td>Backend configuration</td> | ||
</tr> | ||
<tr class="<?php echo $currentStep == 6 ? 'active' : ($currentStep > 6 ? 'success' : '') ?>"> | ||
<td>Overview / Confirmation</td> | ||
</tr> | ||
<tr class="<?php echo $currentStep == 7 ? 'active' : ($currentStep > 7 ? 'success' : '') ?>"> | ||
<td>End</td> | ||
</tr> | ||
</table> |