Rework redirect to config page at the end of the web install

This commit is contained in:
Duncan Sommerville 2015-01-12 14:40:22 -05:00
parent 23f33cd8da
commit d07195f048
2 changed files with 42 additions and 27 deletions

View file

@ -24,7 +24,6 @@
<script>
$("#finishSettingsForm").submit(function(e) {
window.location.replace("/?config");
// submitForm(e, "FinishSetup");
window.location.assign("/?config");
});
</script>

View file

@ -1,11 +1,12 @@
<?php
define("BUILD_PATH", dirname(dirname(__DIR__)) . "/build/");
define("AIRTIME_CONF_TEMP_PATH", "/tmp/airtime.conf.temp");
/**
* Class Setup
*
* @author sourcefabric
*
* Abstract superclass for the setup and installation process
*/
abstract class Setup {
@ -14,6 +15,14 @@ abstract class Setup {
abstract function runSetup();
/**
* Write new property values to a given section in airtime.conf.temp
*
* @param string $section
* the configuration section to write to
* @param array $properties
* the configuration properties and values to overwrite
*/
protected function writeToTemp($section, $properties) {
if (!file_exists(AIRTIME_CONF_TEMP_PATH)) {
copy(BUILD_PATH . "airtime.example.conf", AIRTIME_CONF_TEMP_PATH);
@ -45,14 +54,15 @@ abstract class Setup {
/**
* Generates a random string.
*
* @param integer $p_len length of the output string
* @param string $p_chars characters to use in the output string
* @param integer $p_len
* length of the output string
* @param string $p_chars
* characters to use in the output string
* @return string the generated random string
*/
protected function generateRandomString($p_len = 20, $p_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') {
$string = '';
for ($i = 0; $i < $p_len; $i++)
{
for($i = 0; $i < $p_len; $i++) {
$pos = mt_rand(0, strlen($p_chars) - 1);
$string .= $p_chars{$pos};
}
@ -61,6 +71,13 @@ abstract class Setup {
}
/**
* Class AirtimeDatabaseException
*
* @author sourcefabric
*
* Exception class for database setup errors
*/
class AirtimeDatabaseException extends Exception {
protected $message = "Unknown Airtime database exception";
@ -78,7 +95,6 @@ class AirtimeDatabaseException extends Exception {
}
// Import Setup subclasses
require_once ('database-setup.php');
require_once ('rabbitmq-setup.php');
require_once ('general-setup.php');
@ -94,7 +110,7 @@ if (!file_exists("/etc/airtime/airtime.conf")) {
} catch (AirtimeDatabaseException $e) {
$response = array(
"message" => $e->getMessage(),
"errors" => $e->getErrorFields(),
"errors" => $e->getErrorFields()
);
}