More work on setup form
This commit is contained in:
parent
acaf47c592
commit
6fd3acf651
|
@ -71,18 +71,4 @@ function airtimeCheckDatabaseConfiguration() {
|
||||||
*/
|
*/
|
||||||
function airtimeConfigureDatabase() {
|
function airtimeConfigureDatabase() {
|
||||||
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
|
Propel::init(CONFIG_PATH . 'airtime-conf-production.php');
|
||||||
}
|
|
||||||
|
|
||||||
function airtimeValidateDatabaseSettings($settings) {
|
|
||||||
global $airtimeSetup;
|
|
||||||
if (!$airtimeSetup) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$dbUser = $settings["dbUser"];
|
|
||||||
$dbPass = $settings["dbPass"];
|
|
||||||
$dbName = $settings["dbName"];
|
|
||||||
$dbHost = $settings["dbHost"];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once ROOT_PATH . 'public/setup/functions.php';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<html style="background-color: #111141;">
|
<html style="background-color: #111141;">
|
||||||
|
@ -36,8 +38,36 @@
|
||||||
$("#dbSettingsForm").submit(function(e) {
|
$("#dbSettingsForm").submit(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var d = $('#dbSettingsForm').serializeArray();
|
var d = $('#dbSettingsForm').serializeArray();
|
||||||
$.post('setup/functions.php?fn=airtimeValidateDatabaseSettings', d, function(data) {
|
// First, check if the db user exists (if not, we're done)
|
||||||
console.log(data);
|
$.post('setup/functions.php?fn=airtimeValidateDatabaseUser', d, function(result) {
|
||||||
|
if (result == true) {
|
||||||
|
// We know that the user credentials check out, so check if the database exists
|
||||||
|
$.post('setup/functions.php?fn=airtimeValidateDatabaseSettings', d, function(result) {
|
||||||
|
if (result == true) {
|
||||||
|
// The database already exists, so we can just set up the schema
|
||||||
|
// TODO change alerts to actually useful things
|
||||||
|
alert("Setting up airtime schema...");
|
||||||
|
} else {
|
||||||
|
// The database doesn't exist, so check if the user can create databases
|
||||||
|
$.post('setup/functions.php?fn=airtimeCheckUserCanCreateDb', d, function(result) {
|
||||||
|
if (result == true) {
|
||||||
|
// The user can create a database, so ask if they want to create it
|
||||||
|
if (confirm("Create database '" + $("#dbName").val() + "' on " + $("#dbHost").val()
|
||||||
|
+ " as user " + $("#dbUser").val() + "?")) {
|
||||||
|
// TODO create the database...
|
||||||
|
alert("Creating airtime database...");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// The user can't create databases, so we're done
|
||||||
|
alert("No database " + $("#dbName").val() + " exists; user " + $("#dbUser").val()
|
||||||
|
+ " does not have permission to create databases on " + $("#dbHost").val());
|
||||||
|
}
|
||||||
|
}, "json");
|
||||||
|
}
|
||||||
|
}, "json");
|
||||||
|
} else {
|
||||||
|
alert("User credentials are invalid!");
|
||||||
|
}
|
||||||
}, "json");
|
}, "json");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue