Added error messages with more information for the installation page (#452)

This commit is contained in:
alext 2018-03-28 14:36:28 +02:00
parent 4d6b452dd6
commit 5147d0ad68
2 changed files with 27 additions and 36 deletions

View file

@ -93,7 +93,7 @@ class Installation extends CI_Controller {
// Insert admin // Insert admin
$this->load->model('admins_model'); $this->load->model('admins_model');
$admin = json_decode($this->input->post('admin'), TRUE); $admin = $this->input->post('admin');
$admin['settings']['username'] = $admin['username']; $admin['settings']['username'] = $admin['username'];
$admin['settings']['password'] = $admin['password']; $admin['settings']['password'] = $admin['password'];
$admin['settings']['calendar_view'] = CALENDAR_VIEW_DEFAULT; $admin['settings']['calendar_view'] = CALENDAR_VIEW_DEFAULT;
@ -108,7 +108,7 @@ class Installation extends CI_Controller {
// Save company settings // Save company settings
$this->load->model('settings_model'); $this->load->model('settings_model');
$company = json_decode($this->input->post('company'), TRUE); $company = $this->input->post('company');
$this->settings_model->set_setting('company_name', $company['company_name']); $this->settings_model->set_setting('company_name', $company['company_name']);
$this->settings_model->set_setting('company_email', $company['company_email']); $this->settings_model->set_setting('company_email', $company['company_email']);
$this->settings_model->set_setting('company_link', $company['company_link']); $this->settings_model->set_setting('company_link', $company['company_link']);

View file

@ -9,12 +9,12 @@
* @since v1.0.0 * @since v1.0.0
* ---------------------------------------------------------------------------- */ * ---------------------------------------------------------------------------- */
$(document).ready(function () { $(function () {
'use strict'; 'use strict';
var MIN_PASSWORD_LENGTH = 7; var MIN_PASSWORD_LENGTH = 7;
var AJAX_SUCCESS = 'SUCCESS';
var AJAX_FAILURE = 'FAILURE'; var $alert = $('.alert');
$(document).ajaxStart(function () { $(document).ajaxStart(function () {
$('#loading').removeClass('hidden'); $('#loading').removeClass('hidden');
@ -32,45 +32,34 @@ $(document).ready(function () {
return; return;
} }
var postUrl = GlobalVariables.baseUrl + '/index.php/installation/ajax_install'; var url = GlobalVariables.baseUrl + '/index.php/installation/ajax_install';
var postData = { var data = {
csrfToken: GlobalVariables.csrfToken, csrfToken: GlobalVariables.csrfToken,
admin: JSON.stringify(getAdminData()), admin: getAdminData(),
company: JSON.stringify(getCompanyData()) company: getCompanyData()
}; };
$.ajax({ $.ajax({
url: postUrl, url: url,
type: 'POST', type: 'POST',
data: postData, data: data,
dataType: 'json', dataType: 'json'
success: function (response) { })
.done(function (response) {
if (!GeneralFunctions.handleAjaxExceptions(response)) { if (!GeneralFunctions.handleAjaxExceptions(response)) {
return; return;
} }
$('.alert').text('Easy!Appointments has been successfully installed!'); $alert
$('.alert').addClass('alert-success'); .text('Easy!Appointments has been successfully installed!')
$('.alert').show(); .addClass('alert-success')
.show();
setTimeout(function () { setTimeout(function () {
window.location.href = GlobalVariables.baseUrl + '/index.php/backend'; window.location.href = GlobalVariables.baseUrl + '/index.php/backend';
}, 1000); }, 1000);
},
error: function (jqXHR, textStatus, errorThrown) {
// Treat the error the same way as php exceptions.
var exc = {
exceptions: [
JSON.stringify({
message: 'The installation could not be completed due to an ' +
'unexpected issue. Please check the browser\'s console for ' +
'more information.'
}) })
] .fail(GeneralFunctions.ajaxFailureHandler);
};
GeneralFunctions.handleAjaxExceptions(exc);
console.log(exc.exceptions[0].message, jqXHR, textStatus, errorThrown);
}
});
}); });
/** /**
@ -82,7 +71,7 @@ $(document).ready(function () {
*/ */
function validate() { function validate() {
try { try {
$('.alert').hide(); $alert.hide();
$('input').closest('.form-group').removeClass('has-error'); $('input').closest('.form-group').removeClass('has-error');
// Check for empty fields. // Check for empty fields.
@ -123,9 +112,11 @@ $(document).ready(function () {
} }
return true; return true;
} catch (exc) { } catch (error) {
$('.alert').text(exc); $alert
$('.alert').show(); .text(error)
.show();
return false; return false;
} }
} }