|
@@ -7,94 +7,120 @@ settings = {}
|
|
|
|
|
|
settings.createConfig = function() {
|
|
|
|
|
|
- var dbName,
|
|
|
- dbUser,
|
|
|
- dbPassword,
|
|
|
- dbHost,
|
|
|
- dbTablePrefix,
|
|
|
- buttons,
|
|
|
- params;
|
|
|
+ var msg,
|
|
|
+ action;
|
|
|
|
|
|
- buttons = [
|
|
|
- ['Connect', function() {
|
|
|
+ action = function(data) {
|
|
|
|
|
|
- dbHost = $('.message input.text#dbHost').val();
|
|
|
- dbUser = $('.message input.text#dbUser').val();
|
|
|
- dbPassword = $('.message input.text#dbPassword').val();
|
|
|
- dbName = $('.message input.text#dbName').val();
|
|
|
- dbTablePrefix = $('.message input.text#dbTablePrefix').val();
|
|
|
+ var dbName = data.dbName || '',
|
|
|
+ dbUser = data.dbUser || '',
|
|
|
+ dbPassword = data.dbPassword || '',
|
|
|
+ dbHost = data.dbHost || '',
|
|
|
+ dbTablePrefix = data.dbTablePrefix || '',
|
|
|
+ params;
|
|
|
|
|
|
- if (dbHost.length<1) dbHost = 'localhost';
|
|
|
- if (dbName.length<1) dbName = 'lychee';
|
|
|
+ if (dbHost.length<1) dbHost = 'localhost';
|
|
|
+ if (dbName.length<1) dbName = 'lychee';
|
|
|
|
|
|
- params = 'dbCreateConfig&dbName=' + escape(dbName) + '&dbUser=' + escape(dbUser) + '&dbPassword=' + escape(dbPassword) + '&dbHost=' + escape(dbHost) + '&dbTablePrefix=' + escape(dbTablePrefix);
|
|
|
- lychee.api(params, function(data) {
|
|
|
+ params = 'dbCreateConfig&dbName=' + escape(dbName) + '&dbUser=' + escape(dbUser) + '&dbPassword=' + escape(dbPassword) + '&dbHost=' + escape(dbHost) + '&dbTablePrefix=' + escape(dbTablePrefix);
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- if (data!==true) {
|
|
|
+ if (data!==true) {
|
|
|
|
|
|
- // Configuration failed
|
|
|
- setTimeout(function() {
|
|
|
+ // Connection failed
|
|
|
+ if (data.indexOf('Warning: Connection failed!')!==-1) {
|
|
|
|
|
|
- // Connection failed
|
|
|
- if (data.indexOf('Warning: Connection failed!')!==-1) {
|
|
|
+ basicModal.show({
|
|
|
+ body: '<p>Unable to connect to host database because access was denied. Double-check your host, username and password and ensure that access from your current location is permitted.</p>',
|
|
|
+ buttons: {
|
|
|
+ action: {
|
|
|
+ title: 'Retry',
|
|
|
+ fn: settings.createConfig
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- buttons = [
|
|
|
- ['Retry', function() { setTimeout(settings.createConfig, 400) }],
|
|
|
- ['', function() {}]
|
|
|
- ];
|
|
|
- modal.show('Connection Failed', 'Unable to connect to host database because access was denied. Double-check your host, username and password and ensure that access from your current location is permitted.', buttons, null, false);
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ // Creation failed
|
|
|
+ if (data.indexOf('Warning: Creation failed!')!==-1) {
|
|
|
+
|
|
|
+ basicModal.show({
|
|
|
+ body: '<p>Unable to create the database. Double-check your host, username and password and ensure that the specified user has the rights to modify and add content to the database.</p>',
|
|
|
+ buttons: {
|
|
|
+ action: {
|
|
|
+ title: 'Retry',
|
|
|
+ fn: settings.createConfig
|
|
|
+ }
|
|
|
}
|
|
|
+ });
|
|
|
|
|
|
- // Creation failed
|
|
|
- if (data.indexOf('Warning: Creation failed!')!==-1) {
|
|
|
+ return false;
|
|
|
|
|
|
- buttons = [
|
|
|
- ['Retry', function() { setTimeout(settings.createConfig, 400) }],
|
|
|
- ['', function() {}]
|
|
|
- ];
|
|
|
- modal.show('Creation Failed', 'Unable to create the database. Double-check your host, username and password and ensure that the specified user has the rights to modify and add content to the database.', buttons, null, false);
|
|
|
- return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Could not create file
|
|
|
+ if (data.indexOf('Warning: Could not create file!')!==-1) {
|
|
|
|
|
|
+ basicModal.show({
|
|
|
+ body: "<p>Unable to save this configuration. Permission denied in <b>'data/'</b>. Please set the read, write and execute rights for others in <b>'data/'</b> and <b>'uploads/'</b>. Take a look at the readme for more information.</p>",
|
|
|
+ buttons: {
|
|
|
+ action: {
|
|
|
+ title: 'Retry',
|
|
|
+ fn: settings.createConfig
|
|
|
+ }
|
|
|
}
|
|
|
+ });
|
|
|
|
|
|
- // Could not create file
|
|
|
- if (data.indexOf('Warning: Could not create file!')!==-1) {
|
|
|
+ return false;
|
|
|
|
|
|
- buttons = [
|
|
|
- ['Retry', function() { setTimeout(settings.createConfig, 400) }],
|
|
|
- ['', function() {}]
|
|
|
- ];
|
|
|
- modal.show('Saving Failed', "Unable to save this configuration. Permission denied in <b>'data/'</b>. Please set the read, write and execute rights for others in <b>'data/'</b> and <b>'uploads/'</b>. Take a look the readme for more information.", buttons, null, false);
|
|
|
- return false;
|
|
|
+ }
|
|
|
|
|
|
+ // Something went wrong
|
|
|
+ basicModal.show({
|
|
|
+ body: '<p>Something unexpected happened. Please try again and check your installation and server. Take a look at the readme for more information.</p>',
|
|
|
+ buttons: {
|
|
|
+ action: {
|
|
|
+ title: 'Retry',
|
|
|
+ fn: settings.createConfig
|
|
|
}
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- // Something went wrong
|
|
|
- buttons = [
|
|
|
- ['Retry', function() { setTimeout(settings.createConfig, 400) }],
|
|
|
- ['', function() {}]
|
|
|
- ];
|
|
|
- modal.show('Configuration Failed', 'Something unexpected happened. Please try again and check your installation and server. Take a look the readme for more information.', buttons, null, false);
|
|
|
- return false;
|
|
|
-
|
|
|
- }, 400);
|
|
|
+ return false;
|
|
|
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
|
|
|
- // Configuration successful
|
|
|
- window.location.reload();
|
|
|
+ // Configuration successful
|
|
|
+ window.location.reload();
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
+ });
|
|
|
|
|
|
- }],
|
|
|
- ['', function() {}]
|
|
|
- ];
|
|
|
+ }
|
|
|
|
|
|
- modal.show('Configuration', "Enter your database connection details below: <input id='dbHost' class='text less' type='text' placeholder='Database Host (optional)' value=''><input id='dbUser' class='text less' type='text' placeholder='Database Username' value=''><input id='dbPassword' class='text more' type='password' placeholder='Database Password' value=''><br>Lychee will create its own database. If required, you can enter the name of an existing database instead:<input id='dbName' class='text less' type='text' placeholder='Database Name (optional)' value=''><input id='dbTablePrefix' class='text more' type='text' placeholder='Table prefix (optional)' value=''>", buttons, -235, false);
|
|
|
+ msg = "<p>Enter your database connection details below:";
|
|
|
+ msg += "<input data-name='dbHost' class='text less' type='text' placeholder='Database Host (optional)' value=''>";
|
|
|
+ msg += "<input data-name='dbUser' class='text less' type='text' placeholder='Database Username' value=''>";
|
|
|
+ msg += "<input data-name='dbPassword' class='text more' type='password' placeholder='Database Password' value=''>";
|
|
|
+ msg += "</p>";
|
|
|
+ msg += "<p>Lychee will create its own database. If required, you can enter the name of an existing database instead:";
|
|
|
+ msg += "<input data-name='dbName' class='text less' type='text' placeholder='Database Name (optional)' value=''>";
|
|
|
+ msg += "<input data-name='dbTablePrefix' class='text more' type='text' placeholder='Table prefix (optional)' value=''>";
|
|
|
+ msg += "</p>";
|
|
|
+
|
|
|
+ basicModal.show({
|
|
|
+ body: msg,
|
|
|
+ buttons: {
|
|
|
+ action: {
|
|
|
+ title: 'Connect',
|
|
|
+ fn: action
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|