From b49cbcd84fd8e4b8ac56fd6d7e722d0aa8c6078c Mon Sep 17 00:00:00 2001 From: grandeljay Date: Wed, 12 Oct 2022 19:45:26 +0200 Subject: [PATCH] Improve installer --- src/api/database-test.php | 44 +++++++++++++++++++++++++ src/assets/css/install.css | 4 +++ src/assets/js/install.js | 36 +++++++++++++++++++++ src/pages/install.php | 66 ++++++++++++++++++++++++++------------ 4 files changed, 129 insertions(+), 21 deletions(-) create mode 100644 src/api/database-test.php create mode 100644 src/assets/css/install.css create mode 100644 src/assets/js/install.js diff --git a/src/api/database-test.php b/src/api/database-test.php new file mode 100644 index 00000000..dd04861d --- /dev/null +++ b/src/api/database-test.php @@ -0,0 +1,44 @@ +getMessage(); + } + + $response['success'] = $success; + break; +} + +$response['warning'] = ob_get_clean(); + +header('Content-type: application/json; charset=utf-8'); +echo json_encode($response); +die(); diff --git a/src/assets/css/install.css b/src/assets/css/install.css new file mode 100644 index 00000000..41a166cd --- /dev/null +++ b/src/assets/css/install.css @@ -0,0 +1,4 @@ +svg#logo { + width: 100%; + height: 5vh; +} diff --git a/src/assets/js/install.js b/src/assets/js/install.js new file mode 100644 index 00000000..49b37f53 --- /dev/null +++ b/src/assets/js/install.js @@ -0,0 +1,36 @@ +$(function() { + + /** + * Step 1 + */ + $(document).on('click', '#database-test', function(event) { + var form = $(this).closest('form'); + var formDatabase = new URLSearchParams(new FormData(form[0])); + + form.addClass('loading'); + + fetch('/src/api/database-test.php', { + method : 'POST', + body : formDatabase + }) + .then(handleFetchError) + .then(handleFetchResponse) + .then(function(response) { + if (response.success) { + $('input[type="submit"]').removeClass('disabled'); + + form.form('remove errors'); + + $('body').toast({ message : 'Database connection succeeded.' }); + } else { + $('input[type="submit"]').addClass('disabled'); + + form.form('add errors', ['Database connection failed.']); + } + }) + .finally(function() { + form.removeClass('loading'); + }); + }); + +}); diff --git a/src/pages/install.php b/src/pages/install.php index c1e2b6af..1665af0c 100644 --- a/src/pages/install.php +++ b/src/pages/install.php @@ -26,41 +26,61 @@ switch ($step) {
+ + +

title ?>

+
-

title ?>

+

+
+ +
+

+

-
- - +
+ +
+
+ + +
+ +
+ + +
-
- - +
+
+ + +
+ +
+ + +
-
- - +
+ +
- -
- - -
- -
@@ -69,6 +89,10 @@ switch ($step) { break; case 2: + /** + * Set sitemap path in robots.txt + */ + /** * Cache */