Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
asilvafx committed Dec 14, 2024
1 parent 69f5533 commit 63ee431
Show file tree
Hide file tree
Showing 34 changed files with 133 additions and 128 deletions.
6 changes: 2 additions & 4 deletions app/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
if ($site->dry()) {
$f3->set('SITE.wizzard', true);
$f3->route('GET|POST /', 'Setup->wizzard');
$f3->route('GET|POST /*', 'Setup->wizzard');
$f3->route('GET|POST /setup/@slug*', 'Setup->wizzard');
} else {
$f3->set('SITE.wizzard', false);
Expand Down Expand Up @@ -194,10 +195,7 @@
// Accepted languages
$languages = array(
"en" => "en",
"es" => "es",
"fr" => "fr",
"pt" => "pt",
"de" => "de",
// Add more languages here if you wish
);

// Get 2 char lang code
Expand Down
89 changes: 89 additions & 0 deletions app/data/db/setup.$ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
CREATE TABLE IF NOT EXISTS api (
id INTEGER PRIMARY KEY AUTOINCREMENT,
api_key TEXT,
api_slug TEXT,
api_usage INTEGER DEFAULT 0,
api_allowed_domains TEXT,
status INTEGER DEFAULT 1,
created_by TEXT,
created_at TIMESTAMP DEFAULT (strftime('%s',CURRENT_TIMESTAMP,'localtime'))
);

CREATE TABLE IF NOT EXISTS permissions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
"default" INTEGER DEFAULT 0
);

CREATE TABLE IF NOT EXISTS roles (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
description TEXT,
access TEXT,
color TEXT,
"default" INTEGER DEFAULT 0,
is_admin INTEGER DEFAULT 0
);

INSERT INTO roles (id, name, description, access, color, is_admin)
VALUES (0, 'Member', NULL, NULL, NULL, 0);

INSERT INTO roles (id, name, description, access, color, is_admin)
VALUES (1, 'Admin', NULL, '*', NULL, 1);

CREATE TABLE IF NOT EXISTS site (
id INTEGER PRIMARY KEY AUTOINCREMENT,
site_name TEXT,
site_title TEXT,
site_description TEXT,
site_keywords TEXT,
site_logo TEXT,
smtp_host TEXT,
smtp_mail TEXT,
smtp_port TEXT,
smtp_scheme TEXT,
smtp_user TEXT,
smtp_pass TEXT,
uri_backend TEXT,
uri_auth TEXT,
base_url TEXT,
color_primary TEXT,
color_primary_text TEXT,
color_dark TEXT,
color_light TEXT,
color_dark_secondary TEXT,
color_light_secondary TEXT,
setup_wizzard INTEGER DEFAULT 1,
enable_frontend INTEGER DEFAULT 1,
enable_api INTEGER DEFAULT 1,
enable_register INTEGER DEFAULT 0
);

CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id TEXT,
displayName TEXT,
avatar TEXT,
phone TEXT,
email TEXT,
bio TEXT,
address TEXT,
dob TEXT,
crypt TEXT,
confirmed INTEGER DEFAULT 0,
nonce TEXT,
role INTEGER DEFAULT 0,
ip_address TEXT,
last_online TEXT,
login_alerts INTEGER DEFAULT 0,
twofactor INTEGER DEFAULT 0,
twofactor_sk TEXT,
passkey INTEGER DEFAULT 0,
pin INTEGER DEFAULT 0,
login_count INTEGER DEFAULT 0,
is_admin INTEGER DEFAULT 0,
is_super_admin INTEGER DEFAULT 0,
is_developer INTEGER DEFAULT 0,
created_at TIMESTAMP,
status INTEGER DEFAULT 0
);
89 changes: 0 additions & 89 deletions app/data/db/setup.sql

This file was deleted.

7 changes: 4 additions & 3 deletions app/views/admin/routes/settings/view.htm
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ <h5 class="modal-title" id="confirmModalLabel">Enter your password</h5>
},
}).then(response => {
const data = response.data;
if (data === "success") {
if (data.status === "success") {
sendUpdateRequest();
return false;
} else {
} else {
showAlert("error", response.data.message);
submitBtn.innerText = submitOrignalTxt;
submitBtn.disabled = false;
Expand Down Expand Up @@ -466,7 +466,7 @@ <h5 class="modal-title" id="confirmModalLabel">Enter your password</h5>
}

// Add Event Listeners
async function fetchRequest(formData, url, formEl, reload=null) {
async function fetchRequest(formData, url) {
event.preventDefault();

try {
Expand All @@ -485,6 +485,7 @@ <h5 class="modal-title" id="confirmModalLabel">Enter your password</h5>
}

} else {
console.log(response);
showAlert("error", response.data.message);
}
}).finally(() => {
Expand Down
64 changes: 35 additions & 29 deletions app/views/setup/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
<meta name="author" content="PIGMIL.COM">
<meta name="keyword" content="Fatfree,Admin,Open,Source,CMS,Dashboard,PHP,CSS,JS,HTML,SQL">
<meta name="theme-color" content="currentColor">
<title>Setup Wizard</title>
<link href="public/client/app.css?v={{time()}}" rel="stylesheet">
<script src="public/client/app.js?v={{time()}}"></script>
<style>
<title>Setup Wizard</title>
<style>
:root {
--app-dark-color:#1d222b;
--app-light-color:#dfe2e7;
}
.hidden {
display: none;
}
Expand All @@ -28,15 +30,15 @@
.data-forms {
margin-top: 2rem;
}
.form-group {
position: relative;
}
</style>

<link href="public/client/app.css?v={{time()}}" rel="stylesheet">
<script src="public/client/app.js?v={{time()}}"></script>
</head>
<body>
<div class="min-vh-100 d-flex flex-row align-items-center">
<div class="container">
<div id="progressBarContainer">
<div id="progressBarContainer" class="border rounded">
<div id="progressBar" class="progress"></div>
</div>
<section class="data-forms">
Expand All @@ -48,10 +50,9 @@ <h2 class="text-2xl font-semibold text-gray-700 mb-4">Site Information</h2>
<p class="text-sm text-gray-500 mt-2">Please enter the name and URL of your site.</p>
<div class="input-group mb-3">
<input class="form-control" id="logoFile" type="file">
<label class="input-group-text" for="logoFile">Upload logo</label>
</div>
<div class="flex justify-between mt-6">
<button class="btn btn-primary px-4" onclick="nextStep()">Next</button>
<div class="flex justify-end mt-6">
<button class="btn btn-secondary px-4 py-2 border" onclick="nextStep()">Next</button>
</div>
</div>

Expand All @@ -68,8 +69,8 @@ <h2 class="text-2xl font-semibold text-gray-700 mb-4">SMTP Settings</h2>
</select>
<p class="text-sm text-gray-500 mt-2">Provide your SMTP settings for email configuration.</p>
<div class="flex justify-between mt-6">
<button class="btn btn-secondary px-4" onclick="prevStep()">Back</button>
<button class="btn btn-primary px-4" onclick="nextStep()">Next</button>
<button class="btn px-4 py-2 border" onclick="prevStep()">Back</button>
<button class="btn btn-secondary px-4 py-2 border" onclick="nextStep()">Next</button>
</div>
</div>

Expand All @@ -82,8 +83,8 @@ <h2 class="text-2xl font-semibold text-gray-700 mb-4">User Credentials</h2>
<input type="password" id="confirmPassword" placeholder="Confirm Password" class="form-control px-4 py-2" />
<p class="text-sm text-gray-500 mt-2">Enter your email and password for the setup.</p>
<div class="flex justify-between mt-6">
<button class="btn btn-secondary px-4" onclick="prevStep()">Back</button>
<button class="btn btn-primary px-4" onclick="nextStep()">Next</button>
<button class="btn px-4 py-2 border" onclick="prevStep()">Back</button>
<button class="btn btn-secondary px-4 py-2 border" onclick="nextStep()">Next</button>
</div>
</div>

Expand All @@ -96,8 +97,8 @@ <h2 class="text-2xl font-semibold text-gray-700 mb-4">Summary</h2>
<p id="summaryUserEmail" class="text-lg text-gray-700 mb-2"></p>
<p class="text-sm text-gray-500 mb-4">Review your settings and finish the setup.</p>
<div class="flex justify-between mt-6">
<button class="btn btn-secondary px-4" onclick="prevStep()">Back</button>
<button class="btn btn-primary px-4" onclick="finishSetup()">Finish</button>
<button class="btn px-4 py-2 border" onclick="prevStep()">Back</button>
<button class="btn btn-secondary px-4 py-2 border" onclick="finishSetup()">Finish</button>
</div>
</div>
</section>
Expand Down Expand Up @@ -155,19 +156,24 @@ <h2 class="text-2xl font-semibold text-gray-700 mb-4">Summary</h2>
return false;
}
} else if (step === 2) {
formData.smtpHost = document.getElementById('smtpHost').value;
formData.smtpPort = document.getElementById('smtpPort').value;
formData.smtpUser = document.getElementById('smtpUser').value;
formData.smtpPassword = document.getElementById('smtpPassword').value;
formData.smtpScheme = document.getElementById('smtpScheme').value;
if (!formData.smtpHost || !formData.smtpPort || !formData.smtpUser || !formData.smtpPassword) {
alert('Please fill out all SMTP fields.');
return false;
}
if (!isValidEmail(formData.smtpUser)) {
alert('Please enter a valid SMTP email.');
return false;
var check_smtp = false;

if(check_smtp){
formData.smtpHost = document.getElementById('smtpHost').value;
formData.smtpPort = document.getElementById('smtpPort').value;
formData.smtpUser = document.getElementById('smtpUser').value;
formData.smtpPassword = document.getElementById('smtpPassword').value;
formData.smtpScheme = document.getElementById('smtpScheme').value;
if (!formData.smtpHost || !formData.smtpPort || !formData.smtpUser || !formData.smtpPassword) {
alert('Please fill out all SMTP fields.');
return false;
}
if (!isValidEmail(formData.smtpUser)) {
alert('Please enter a valid SMTP email.');
return false;
}
}

} else if (step === 3) {
formData.userName = document.getElementById('userName').value;
formData.userEmail = document.getElementById('userEmail').value;
Expand Down
2 changes: 1 addition & 1 deletion app/views/setup/routes/post/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$createdAt = isset($inputData['createdAt']) ? htmlspecialchars($inputData['createdAt']) : $f3->get('POST.createdAt');

// Validate required fields
if (!$siteName || !$siteUrl || !$smtpHost || !$smtpUser || !$smtpPassword || !$userName || !$userEmail || !$userPassword) {
if (!$siteName || !$siteUrl || !$userName || !$userEmail || !$userPassword) {
$response->json('error', 'Missing required fields.');
exit;
}
Expand Down
Binary file removed public/assets/img/icon-66f30220a761a.png
Binary file not shown.
Binary file removed public/assets/img/icon.png
Binary file not shown.
Binary file modified public/manifest/.original
Binary file not shown.
2 changes: 1 addition & 1 deletion public/manifest/.settings
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"compression":25,"cropmethod":0,"apple-background":"2d89ef","apple-margin":15,"android-background":"00a300","android-margin":15,"android-name":"Test","android-url":"https:\/\/host.local","android-orientation":"portrait","ms-background":"00a300"}
{"compression":25,"cropmethod":0,"apple-background":"2d89ef","apple-margin":15,"android-background":"00a300","android-margin":15,"android-name":"Tests","android-url":"https:\/\/api.local","android-orientation":"portrait","ms-background":"00a300"}
Binary file modified public/manifest/android-chrome-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/android-chrome-36x36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/android-chrome-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/android-chrome-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/android-chrome-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/apple-touch-icon-114x114.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/apple-touch-icon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/apple-touch-icon-57x57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/apple-touch-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/apple-touch-icon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/manifest/manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"Test","start_url":"https:\/\/host.local","display":"standalone","orientation":"portrait","icons":[{"src":"public\/manifest\/android-chrome-36x36.png","sizes":"36x36","type":"image\/png","density":"0.75"},{"src":"public\/manifest\/android-chrome-48x48.png","sizes":"48x48","type":"image\/png","density":"1.0"},{"src":"public\/manifest\/android-chrome-72x72.png","sizes":"72x72","type":"image\/png","density":"1.5"},{"src":"public\/manifest\/android-chrome-96x96.png","sizes":"96x96","type":"image\/png","density":"2.0"},{"src":"public\/manifest\/android-chrome-144x144.png","sizes":"144x144","type":"image\/png","density":"3.0"},{"src":"public\/manifest\/android-chrome-192x192.png","sizes":"192x192","type":"image\/png","density":"4.0"}]}
{"name":"Tests","start_url":"https:\/\/api.local","display":"standalone","orientation":"portrait","icons":[{"src":"public\/manifest\/android-chrome-36x36.png","sizes":"36x36","type":"image\/png","density":"0.75"},{"src":"public\/manifest\/android-chrome-48x48.png","sizes":"48x48","type":"image\/png","density":"1.0"},{"src":"public\/manifest\/android-chrome-72x72.png","sizes":"72x72","type":"image\/png","density":"1.5"},{"src":"public\/manifest\/android-chrome-96x96.png","sizes":"96x96","type":"image\/png","density":"2.0"},{"src":"public\/manifest\/android-chrome-144x144.png","sizes":"144x144","type":"image\/png","density":"3.0"},{"src":"public\/manifest\/android-chrome-192x192.png","sizes":"192x192","type":"image\/png","density":"4.0"}]}
Binary file modified public/manifest/mstile-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/mstile-310x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/mstile-310x310.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/manifest/mstile-70x70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 63ee431

Please sign in to comment.