mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-10 10:02:33 +03:00
Refactored the installation page functionality
This commit is contained in:
parent
037c3037e6
commit
bd412eba8e
4 changed files with 73 additions and 65 deletions
|
@ -46,7 +46,7 @@ class Installation extends EA_Controller {
|
|||
return;
|
||||
}
|
||||
|
||||
$this->load->view('pages/instance_installation_page', [
|
||||
$this->load->view('pages/installation', [
|
||||
'base_url' => config('base_url')
|
||||
]);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class Installation extends EA_Controller {
|
|||
/**
|
||||
* Installs Easy!Appointments on the server.
|
||||
*/
|
||||
public function ajax_install()
|
||||
public function perform()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
|
||||
<title>Installation | Easy!Appointments</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/vendor/bootstrap/bootstrap.min.css') ?>">
|
||||
<link rel="icon" type="image/x-icon" href="<?= asset_url('assets/img/favicon.ico') ?>">
|
||||
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/vendor/bootstrap/bootstrap.min.css') ?>">
|
||||
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/vendor/jquery-ui-dist/jquery-ui.min.css') ?>">
|
||||
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/css/instance_installation_page.css') ?>">
|
||||
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/css/general.css') ?>">
|
||||
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/css/pages/installation.css') ?>">
|
||||
</head>
|
||||
<body>
|
||||
<div id="loading" class="d-none">
|
||||
<img src="<?= base_url('assets/img/loading.gif') ?>">
|
||||
<img src="<?= base_url('assets/img/loading.gif') ?>" alt="loading">
|
||||
</div>
|
||||
|
||||
<header>
|
||||
|
@ -26,15 +26,15 @@
|
|||
<div class="welcome">
|
||||
<h3>Welcome to the Easy!Appointments installation page.</h3>
|
||||
<p>
|
||||
This page will help you set the main settings of your Easy!Appointments installation.
|
||||
You will be able to edit these settings and many more in the backend session of your
|
||||
system. Remember to use the <strong class="text-primary"><?= site_url('backend') ?></strong>
|
||||
url to connect to the backend section of Easy!Appointments.
|
||||
This page will help you set the main settings of your Easy!Appointments installation. You will be able to
|
||||
edit these settings and many more in the backend session of your system. Remember to use the
|
||||
<strong class="text-primary"><?= site_url('calendar') ?></strong> URL to connect to the backend section
|
||||
of Easy!Appointments.
|
||||
|
||||
If you face any problems during the usage of Easy!Appointments you can always check the
|
||||
<a href="http://easyappointments.org/docs.html">Documentation</a>
|
||||
and <a href="http://groups.google.com/group/easy-appointments">Support Group</a> for getting help. You
|
||||
may also submit new issues on
|
||||
<a href="https://easyappointments.org/docs.html">Documentation</a> and
|
||||
<a href="https://groups.google.com/group/easy-appointments">Support Group</a> for getting help. You may also
|
||||
submit new issues on
|
||||
<a href="https://github.com/alextselegidis/easyappointments/issues">GitHub Issues</a>
|
||||
in order to help our development process.
|
||||
</p>
|
||||
|
@ -105,21 +105,19 @@
|
|||
<br>
|
||||
|
||||
<p>
|
||||
You will be able to set your business logic in the backend settings page
|
||||
after the installation is complete.
|
||||
You will be able to set your business logic in the backend settings page after the installation is complete.
|
||||
<br>
|
||||
Press the following button to complete the installation process.
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
<p>
|
||||
<h3>License</h3>
|
||||
Easy!Appointments is licensed under the <span class="badge bg-secondary">GPL-3.0 license</span>.
|
||||
By using the code of Easy!Appointments in any way <br> you agree with the terms described in the
|
||||
following url:
|
||||
<a href="https://www.gnu.org/licenses/gpl-3.0.en.html">https://www.gnu.org/licenses/gpl-3.0.en.html</a>
|
||||
</p>
|
||||
<div class="mb-2">
|
||||
<h3>License</h3>
|
||||
Easy!Appointments is licensed under the <span class="badge bg-secondary">GPL-3.0 license</span>. By using the code
|
||||
of Easy!Appointments in any way <br> you agree with the terms described in the following url:
|
||||
<a href="https://www.gnu.org/licenses/gpl-3.0.en.html">https://www.gnu.org/licenses/gpl-3.0.en.html</a>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -134,20 +132,19 @@
|
|||
</footer>
|
||||
|
||||
<script>
|
||||
var GlobalVariables = {
|
||||
const GlobalVariables = {
|
||||
csrfToken: <?= json_encode($this->security->get_csrf_hash()) ?>,
|
||||
baseUrl: <?= json_encode(config('base_url')) ?>
|
||||
};
|
||||
|
||||
var EALang = <?= json_encode($this->lang->language) ?>;
|
||||
const EALang = <?= json_encode($this->lang->language) ?>;
|
||||
</script>
|
||||
|
||||
<script src="<?= asset_url('assets/vendor/jquery/jquery.min.js') ?>"></script>
|
||||
<script src="<?= asset_url('assets/vendor/jquery-ui-dist/jquery-ui.min.js') ?>"></script>
|
||||
<script src="<?= asset_url('assets/vendor/@popperjs-core/popper.min.js') ?>"></script>
|
||||
<script src="<?= asset_url('assets/vendor/bootstrap/bootstrap.min.js') ?>"></script>
|
||||
<script src="<?= asset_url('assets/vendor/datejs/date.min.js') ?>"></script>
|
||||
<script src="<?= asset_url('assets/js/utils/general_functions.js') ?>"></script>
|
||||
<script src="<?= asset_url('assets/js/installation.js') ?>"></script>
|
||||
<script src="<?= asset_url('assets/js/pages/installation.js') ?>"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -9,20 +9,28 @@
|
|||
* @since v1.0.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
'use strict';
|
||||
|
||||
var MIN_PASSWORD_LENGTH = 7;
|
||||
|
||||
var $install = $('#install');
|
||||
var $alert = $('.alert');
|
||||
(function () {
|
||||
const MIN_PASSWORD_LENGTH = 7;
|
||||
const $install = $('#install');
|
||||
const $alert = $('.alert');
|
||||
const $loading = $('#loading');
|
||||
const $firstName = $('#first-name');
|
||||
const $lastName = $('#last-name');
|
||||
const $email = $('#email');
|
||||
const $phoneNumber = $('#phone-number');
|
||||
const $username = $('#username');
|
||||
const $password = $('#password');
|
||||
const $retypePassword = $('#retype-password');
|
||||
const $companyName = $('#company-name');
|
||||
const $companyEmail = $('#company-email');
|
||||
const $companyLink = $('#company-link');
|
||||
|
||||
$(document).ajaxStart(function () {
|
||||
$('#loading').removeClass('d-none');
|
||||
$loading.removeClass('d-none');
|
||||
});
|
||||
|
||||
$(document).ajaxStop(function () {
|
||||
$('#loading').addClass('d-none');
|
||||
$loading.addClass('d-none');
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -33,9 +41,9 @@ $(function () {
|
|||
return;
|
||||
}
|
||||
|
||||
var url = GlobalVariables.baseUrl + '/index.php/installation/ajax_install';
|
||||
const url = GlobalVariables.baseUrl + '/index.php/installation/perform';
|
||||
|
||||
var data = {
|
||||
const data = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
admin: getAdminData(),
|
||||
company: getCompanyData()
|
||||
|
@ -46,14 +54,14 @@ $(function () {
|
|||
type: 'POST',
|
||||
data: data,
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
}).done(() => {
|
||||
$alert
|
||||
.text('Easy!Appointments has been successfully installed!')
|
||||
.addClass('alert-success')
|
||||
.prop('hidden', false);
|
||||
|
||||
setTimeout(function () {
|
||||
window.location.href = GlobalVariables.baseUrl + '/index.php/backend';
|
||||
window.location.href = GlobalVariables.baseUrl + '/index.php/calendar';
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
|
@ -61,18 +69,22 @@ $(function () {
|
|||
/**
|
||||
* Validates the user input.
|
||||
*
|
||||
* Use this before executing the installation procedure.
|
||||
* Use this before executing the installation procedure.
|
||||
*
|
||||
* @return {Boolean} Returns the validation result.
|
||||
*/
|
||||
function validate() {
|
||||
try {
|
||||
const $fields = $('input');
|
||||
|
||||
$alert.removeClass('alert-danger').prop('hidden', true);
|
||||
$('input').removeClass('is-invalid');
|
||||
|
||||
$fields.removeClass('is-invalid');
|
||||
|
||||
// Check for empty fields.
|
||||
var missingRequired = false;
|
||||
$('input').each(function (index, field) {
|
||||
let missingRequired = false;
|
||||
|
||||
$fields.each((index, field) => {
|
||||
if (!$(field).val()) {
|
||||
$(field).addClass('is-invalid');
|
||||
missingRequired = true;
|
||||
|
@ -84,26 +96,26 @@ $(function () {
|
|||
}
|
||||
|
||||
// Validate Passwords
|
||||
if ($('#password').val() !== $('#retype-password').val()) {
|
||||
$('#password').addClass('is-invalid');
|
||||
$('#retype-password').addClass('is-invalid');
|
||||
if ($password.val() !== $retypePassword.val()) {
|
||||
$password.addClass('is-invalid');
|
||||
$retypePassword.addClass('is-invalid');
|
||||
throw new Error('Passwords do not match!');
|
||||
}
|
||||
|
||||
if ($('#password').val().length < MIN_PASSWORD_LENGTH) {
|
||||
$('#password').addClass('is-invalid');
|
||||
$('#retype-password').addClass('is-invalid');
|
||||
throw new Error('The password must be at least ' + MIN_PASSWORD_LENGTH + ' characters long.');
|
||||
if ($password.val().length < MIN_PASSWORD_LENGTH) {
|
||||
$password.addClass('is-invalid');
|
||||
$retypePassword.addClass('is-invalid');
|
||||
throw new Error(`The password must be at least ${MIN_PASSWORD_LENGTH} characters long.`);
|
||||
}
|
||||
|
||||
// Validate Email
|
||||
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
||||
$('#email').addClass('is-invalid');
|
||||
if (!GeneralFunctions.validateEmail($email.val())) {
|
||||
$email.addClass('is-invalid');
|
||||
throw new Error('The email address is invalid!');
|
||||
}
|
||||
|
||||
if (!GeneralFunctions.validateEmail($('#company-email').val())) {
|
||||
$('#company-email').addClass('is-invalid');
|
||||
if (!GeneralFunctions.validateEmail($companyEmail.val())) {
|
||||
$companyEmail.addClass('is-invalid');
|
||||
throw new Error('The email address is invalid!');
|
||||
}
|
||||
|
||||
|
@ -122,12 +134,12 @@ $(function () {
|
|||
*/
|
||||
function getAdminData() {
|
||||
return {
|
||||
first_name: $('#first-name').val(),
|
||||
last_name: $('#last-name').val(),
|
||||
email: $('#email').val(),
|
||||
phone_number: $('#phone-number').val(),
|
||||
username: $('#username').val(),
|
||||
password: $('#password').val()
|
||||
first_name: $firstName.val(),
|
||||
last_name: $lastName.val(),
|
||||
email: $email.val(),
|
||||
phone_number: $phoneNumber.val(),
|
||||
username: $username.val(),
|
||||
password: $password.val()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -138,18 +150,17 @@ $(function () {
|
|||
*/
|
||||
function getCompanyData() {
|
||||
return {
|
||||
company_name: $('#company-name').val(),
|
||||
company_email: $('#company-email').val(),
|
||||
company_link: $('#company-link').val()
|
||||
company_name: $companyName.val(),
|
||||
company_email: $companyEmail.val(),
|
||||
company_link: $companyLink.val()
|
||||
};
|
||||
}
|
||||
|
||||
// Validate the base URL setting (must not contain any trailing slash).
|
||||
if (GlobalVariables.baseUrl.slice(-1) === '/') {
|
||||
GeneralFunctions.displayMessageBox(
|
||||
'Misconfiguration Detected',
|
||||
'Please remove any trailing ' +
|
||||
'slashes from your BASE_URL setting of the root config.php file and try again.'
|
||||
'Invalid Configuration Detected',
|
||||
'Please remove any trailing slashes from your "BASE_URL" setting of the root "config.php" file and try again.'
|
||||
);
|
||||
$install.prop('disabled', true).fadeTo('0.4');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue