More work on web installer

This commit is contained in:
Duncan Sommerville 2014-12-09 17:48:16 -05:00
parent 9fed113f74
commit f5b4928538
23 changed files with 728 additions and 186 deletions

View file

@ -6,12 +6,12 @@
<span id="helpBlock" class="help-block help-message"></span>
<div class="form-group">
<label class="control-label" for="dbUser">Username</label>
<input required class="form-control" type="text" name="dbUser" id="dbUser" placeholder="Username"/>
<input required class="form-control" type="text" name="dbUser" id="dbUser" placeholder="Username" value="airtime"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="dbPass">Password</label>
<input required class="form-control" type="password" name="dbPass" id="dbPass" placeholder="Password"/>
<input required class="form-control" type="password" name="dbPass" id="dbPass" placeholder="Password" value="airtime"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
@ -26,25 +26,12 @@
<input class="form-control" type="hidden" name="dbErr" id="dbErr" aria-describedby="helpBlock"/>
<div>
<input type="submit" formtarget="dbSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;"/>
<input type="button" class="btn btn-primary btn-back btn-disabled" value="&#10096; Back"/>
<input type="button" class="btn btn-default btn-skip" value="Skip this step &#10097;"/>
</div>
</form>
<script>
$("#dbSettingsForm").submit(function(e) {
resetFeedback();
e.preventDefault();
var d = $('#dbSettingsForm').serializeArray();
addOverlay();
// Append .promise().done() rather than using a
// callback to avoid weird alert duplication
$("#overlay, #loadingImage").fadeIn(500).promise().done(function() {
// Proxy function for passing the event to the cleanup function
var cleanupProxy = function(data) {
cleanupStep.call(this, data, e);
};
$.post('setup/setup-functions.php?obj=DatabaseSetup', d, cleanupProxy, "json");
});
submitForm(e, "DatabaseSetup");
});
</script>

View file

@ -0,0 +1,22 @@
<?php
?>
<form action="#" role="form" id="finishSettingsForm">
<h3 class="form-title">Media Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
Looks like you're almost done! Click "Done!" to bring up the Airtime configuration checklist; if
your configuration is all green, you're ready to get started with your personal Airtime station!
</p>
<div>
<input type="submit" formtarget="finishSettingsForm" class="btn btn-primary btn-next" value="Done!"/>
<input type="button" class="btn btn-primary btn-back" value="&#10096; Back"/>
</div>
</form>
<script>
$("#finishSettingsForm").submit(function(e) {
submitForm(e, "FinishSetup");
// window.location.replace("/?config");
});
</script>

View file

@ -0,0 +1,31 @@
<?php
?>
<form action="#" role="form" id="generalSettingsForm">
<h3 class="form-title">General Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<div id="generalFormBody">
<div class="form-group">
<label class="control-label" for="generalHost">Webserver Host</label>
<input required class="form-control" type="text" name="generalHost" id="generalHost" placeholder="Host" value="localhost"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="generalPort">Webserver Port</label>
<input required class="form-control" type="text" name="generalPort" id="generalPort" placeholder="Port" value="80"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<input class="form-control" type="hidden" name="generalErr" id="generalErr" aria-describedby="helpBlock"/>
</div>
<div>
<input type="submit" formtarget="generalSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;"/>
<input type="button" class="btn btn-primary btn-back" value="&#10096; Back"/>
<input type="button" class="btn btn-default btn-skip" value="Skip this step &#10097;"/>
</div>
</form>
<script>
$("#generalSettingsForm").submit(function(e) {
submitForm(e, "GeneralSetup");
});
</script>

View file

@ -0,0 +1,31 @@
<?php
?>
<form action="#" role="form" id="mediaSettingsForm">
<h3 class="form-title">Media Settings</h3>
<span id="helpBlock" class="help-block help-message"></span>
<p>
Here you can set the default media storage directory for Airtime. If left blank, we'll create a new
directory located at <code>/srv/airtime/stor/</code> for you.
</p>
<div class="form-group">
<label class="control-label" for="mediaFolder">Media folder</label>
<input class="form-control" type="text" name="mediaFolder" id="mediaFolder" placeholder="/path/to/my/airtime/music/directory/"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
<span id="mediaHelpBlock" class="help-block">
Note that you need to enter the <strong>fully qualified</strong> path name!
</span>
</div>
<input class="form-control" type="hidden" name="mediaErr" id="mediaErr" aria-describedby="helpBlock"/>
<div>
<input type="submit" formtarget="mediaSettingsForm" class="btn btn-primary btn-next" value="Next &#10097;"/>
<input type="button" class="btn btn-primary btn-back" value="&#10096; Back"/>
<input type="button" class="btn btn-default btn-skip" value="Skip this step &#10097;"/>
</div>
</form>
<script>
$("#mediaSettingsForm").submit(function(e) {
submitForm(e, "MediaSetup");
});
</script>

View file

@ -33,10 +33,12 @@
<div class="form-group">
<label class="control-label" for="rmqHost">Host</label>
<input required class="form-control" type="text" name="rmqHost" id="rmqHost" placeholder="Host" value="127.0.0.1"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqPort">Port</label>
<input required class="form-control" type="text" name="rmqPort" id="rmqPort" placeholder="Port" value="5672"/>
<span class="glyphicon glyphicon-remove form-control-feedback"></span>
</div>
<div class="form-group">
<label class="control-label" for="rmqVHost">Virtual Host</label>
@ -59,18 +61,6 @@
});
$("#rmqSettingsForm").submit(function(e) {
resetFeedback();
e.preventDefault();
var d = $('#rmqSettingsForm').serializeArray();
addOverlay();
// Append .promise().done() rather than using a
// callback to avoid weird alert duplication
$("#overlay, #loadingImage").fadeIn(500).promise().done(function() {
// Proxy function for passing the event to the cleanup function
var cleanupProxy = function(data) {
cleanupStep.call(this, data, e);
};
$.post('setup/setup-functions.php?obj=RabbitMQSetup', d, cleanupProxy, "json");
});
submitForm(e, "RabbitMQSetup");
});
</script>

View file

@ -1,5 +1,8 @@
<?php
define("RMQ_INI_SECTION", "rabbitmq");
require_once dirname(dirname( __DIR__)) . '/library/php-amqplib/amqp.inc';
/**
* Check to see if Airtime is properly configured.
*
@ -8,7 +11,8 @@
*/
function checkConfiguration() {
return checkPhpDependencies()
&& checkDatabaseConfiguration();
&& checkDatabaseConfiguration()
&& checkRMQConnection();
}
/**
@ -73,6 +77,23 @@ function configureDatabase() {
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
}
function validateDatabaseSchema() {
/**
* Check that we can connect to RabbitMQ
*/
function checkRMQConnection() {
// Check for airtime.conf in /etc/airtime/ first, then check in the build directory,
if (file_exists(AIRTIME_CONFIG_STOR . AIRTIME_CONFIG)) {
$ini = parse_ini_file(AIRTIME_CONFIG_STOR . AIRTIME_CONFIG, true);
} else if (file_exists(BUILD_PATH . AIRTIME_CONFIG)) {
$ini = parse_ini_file(BUILD_PATH . AIRTIME_CONFIG, true);
} else {
$ini = parse_ini_file(BUILD_PATH . "airtime.example.conf", true);
}
$conn = new AMQPConnection($ini[RMQ_INI_SECTION]["host"],
$ini[RMQ_INI_SECTION]["port"],
$ini[RMQ_INI_SECTION]["user"],
$ini[RMQ_INI_SECTION]["password"],
$ini[RMQ_INI_SECTION]["vhost"]);
return isset($conn);
}

View file

@ -1,5 +1,4 @@
<?php
?>
<html>
@ -17,7 +16,7 @@
<img src="css/images/airtime_logo_jp.png" id="airtimeLogo" /><br/>
<strong>Setup</strong>
</h3>
<strong>Step <span id="stepCount">1</span> of 4</strong>
<strong>Step <span id="stepCount">1</span> of 5</strong>
</div>
<div class="viewport">
@ -32,6 +31,21 @@
require_once SETUP_PATH . "forms/rabbitmq-settings.php";
?>
</div>
<div id="generalSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/general-settings.php";
?>
</div>
<div id="mediaSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/media-settings.php";
?>
</div>
<div id="finishSettings" class="form-wrapper">
<?php
require_once SETUP_PATH . "forms/finish-settings.php";
?>
</div>
</div>
</div>