From bd412eba8e9cc062764cecbc919eae965a7c1354 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 10 Dec 2021 09:07:10 +0100 Subject: [PATCH] Refactored the installation page functionality --- application/controllers/Installation.php | 4 +- ...installation_page.php => installation.php} | 43 ++++----- ...stallation_page.scss => installation.scss} | 0 assets/js/pages/installation.js | 91 +++++++++++-------- 4 files changed, 73 insertions(+), 65 deletions(-) rename application/views/pages/{instance_installation_page.php => installation.php} (78%) rename assets/css/pages/{instance_installation_page.scss => installation.scss} (100%) diff --git a/application/controllers/Installation.php b/application/controllers/Installation.php index c627011d..35b7fc6f 100644 --- a/application/controllers/Installation.php +++ b/application/controllers/Installation.php @@ -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 { diff --git a/application/views/pages/instance_installation_page.php b/application/views/pages/installation.php similarity index 78% rename from application/views/pages/instance_installation_page.php rename to application/views/pages/installation.php index 39425697..2e90a691 100755 --- a/application/views/pages/instance_installation_page.php +++ b/application/views/pages/installation.php @@ -5,15 +5,15 @@ Installation | Easy!Appointments - + - +
- + loading
@@ -26,15 +26,15 @@

Welcome to the Easy!Appointments installation page.

- 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 - 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 + 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 - Documentation - and Support Group for getting help. You - may also submit new issues on + Documentation and + Support Group for getting help. You may also + submit new issues on GitHub Issues in order to help our development process.

@@ -105,21 +105,19 @@

- 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.
Press the following button to complete the installation process.


-

-

License

- Easy!Appointments is licensed under the GPL-3.0 license. - By using the code of Easy!Appointments in any way
you agree with the terms described in the - following url: - https://www.gnu.org/licenses/gpl-3.0.en.html -

+
+

License

+ Easy!Appointments is licensed under the GPL-3.0 license. By using the code + of Easy!Appointments in any way
you agree with the terms described in the following url: + https://www.gnu.org/licenses/gpl-3.0.en.html +

@@ -134,20 +132,19 @@ - - + diff --git a/assets/css/pages/instance_installation_page.scss b/assets/css/pages/installation.scss similarity index 100% rename from assets/css/pages/instance_installation_page.scss rename to assets/css/pages/installation.scss diff --git a/assets/js/pages/installation.js b/assets/js/pages/installation.js index 1bae05f0..c051f6bd 100644 --- a/assets/js/pages/installation.js +++ b/assets/js/pages/installation.js @@ -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'); }