fixes for site init

This commit is contained in:
Ro 2022-03-19 14:55:56 -07:00
parent 2b7db3cc88
commit 6279ad4730
4 changed files with 8840 additions and 312 deletions

View file

@ -56,6 +56,7 @@ class SetUp
"uuid" => StringTools::createUUID(), "uuid" => StringTools::createUUID(),
"title" => "FIRST!", "title" => "FIRST!",
"feature" => "/assets/images/global/default-bg.jpg", "feature" => "/assets/images/global/default-bg.jpg",
"files" => "",
"path" => "content/pages/start", "path" => "content/pages/start",
"layout" => "index", "layout" => "index",
"tags" => "start, welcome", "tags" => "start, welcome",

View file

@ -12,7 +12,7 @@
<div id="dash-index"> <div id="dash-index">
<div id="dash-index-wrapper"> <div id="dash-index-wrapper">
<div id="dash-init" class="dash-init"> <div id="dash-init" class="dash-init">
<form id="init-form"> <form id="init-form" method="POST">
<img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/> <img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/>
<input type="text" name="new_member_handle" id="new_member_handle" placeholder="handle"/> <input type="text" name="new_member_handle" id="new_member_handle" placeholder="handle"/>
<input type="text" name="new_member_email" id="new_member_email" placeholder="email"/> <input type="text" name="new_member_email" id="new_member_email" placeholder="email"/>
@ -26,7 +26,7 @@
</div> </div>
<div id="dash-restore" class="dash-restore"> <div id="dash-restore" class="dash-restore">
<form id="init-restore"> <form id="init-restore" method="POST">
<img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/> <img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/>
<input type="text" name="restore_member_handle" id="restore_member_handle" placeholder="handle"/><input type="password" name="restore_member_pass" id="restore_member_pass" placeholder="password"/> <input type="text" name="restore_member_handle" id="restore_member_handle" placeholder="handle"/><input type="password" name="restore_member_pass" id="restore_member_pass" placeholder="password"/>
<div> <div>
@ -44,5 +44,5 @@
{% endblock %} {% endblock %}
{% block javascripts %} {% block javascripts %}
<script src="/assets/scripts/Start.js" type="text/javascript"></script> <script src="/assets/scripts/Start.js?=sdfsdf" type="text/javascript"></script>
{% endblock %} {% endblock %}

File diff suppressed because it is too large Load diff

View file

@ -1,33 +1,33 @@
//** REQUEST TYPES **// //** REQUEST TYPES **//
export const REQUEST_TYPE_POST = "POST"; export const REQUEST_TYPE_POST = 'POST';
export const REQUEST_TYPE_GET = "GET"; export const REQUEST_TYPE_GET = 'GET';
export const REQUEST_TYPE_PUT = "PUT"; export const REQUEST_TYPE_PUT = 'PUT';
export const REQUEST_TYPE_DELETE = "DELETE"; export const REQUEST_TYPE_DELETE = 'DELETE';
//** POST CONTENT TYPES **// //** POST CONTENT TYPES **//
export const CONTENT_TYPE_JSON = "json"; export const CONTENT_TYPE_JSON = 'json';
export const CONTENT_TYPE_FORM = "x-www-form-urlencoded"; export const CONTENT_TYPE_FORM = 'x-www-form-urlencoded';
//** API URLS **// //** API URLS **//
export const API_STATUS = "/api/v1/status"; export const API_STATUS = '/api/v1/status';
export const API_INIT = "/api/v1/init"; export const API_INIT = '/api/v1/init';
export const API_RESTORE = "/api/v1/restore"; export const API_RESTORE = '/api/v1/restore';
export const API_GET_SECRET = "/api/v1/get-secret"; export const API_GET_SECRET = '/api/v1/get-secret';
export const API_RESET_PASS = "/api/v1/reset-password"; export const API_RESET_PASS = '/api/v1/reset-password';
export const API_CREATE_BACKUP = "/api/v1/backup"; export const API_CREATE_BACKUP = '/api/v1/backup';
export const API_DOWNLOAD_BACKUP = "/api/v1/backup/download"; export const API_DOWNLOAD_BACKUP = '/api/v1/backup/download';
export const API_RESTORE_BACKUP = "/api/v1/backup/restore"; export const API_RESTORE_BACKUP = '/api/v1/backup/restore';
export const API_UPLOAD_AVATAR = "/api/v1/settings/add-avatar"; export const API_UPLOAD_AVATAR = '/api/v1/settings/add-avatar';
export const API_UPLOAD_BACKGROUND = "/api/v1/settings/add-feature-background"; export const API_UPLOAD_BACKGROUND = '/api/v1/settings/add-feature-background';
export const API_IMAGE_UPLOAD = "/api/v1/page/add-entry-image"; export const API_IMAGE_UPLOAD = '/api/v1/page/add-entry-image';
//** API TASKS **// //** API TASKS **//
export const TASK_SITE_INIT = "blogInit"; export const TASK_SITE_INIT = 'blogInit';
export const TASK_BACKUP_RESTORE = "restoreBackup"; export const TASK_BACKUP_RESTORE = 'restoreBackup';
export const TASK_BACKUP_CREATE = "createBackup"; export const TASK_BACKUP_CREATE = 'createBackup';
export const TASK_GET_SECRET = "retrieveSecret"; export const TASK_GET_SECRET = 'retrieveSecret';
export const TASK_RESET_PASS = "resetPassword"; export const TASK_RESET_PASS = 'resetPassword';
export const TASK_UPLOAD_FILES = "uploadFiles"; export const TASK_UPLOAD_FILES = 'uploadFiles';
//** API STATUS **// //** API STATUS **//
export const API_ACCESS_GOOD = "apiUseAuthorized"; export const API_ACCESS_GOOD = 'apiUseAuthorized';
export const API_ACCESS_BAD = "apiUseNotAuthorized"; export const API_ACCESS_BAD = 'apiUseNotAuthorized';
/** /**
* A tub of methods for creating/restoring installs, resetting passwords and uploading images. * A tub of methods for creating/restoring installs, resetting passwords and uploading images.
@ -49,9 +49,9 @@ class MaintenanceManager {
//if key is valid, checks to see if a session is active and returns //if key is valid, checks to see if a session is active and returns
this._request( this._request(
this.baseURL this.baseURL
? this.baseURL + API_STATUS + "?key=" + this.key ? this.baseURL + API_STATUS + '?key=' + this.key
: API_STATUS + "?key=" + this.key : API_STATUS + '?key=' + this.key
).then((response) => { ).then(response => {
if (response.type === API_ACCESS_GOOD) { if (response.type === API_ACCESS_GOOD) {
this.token = response.token; this.token = response.token;
} else { } else {
@ -78,10 +78,10 @@ class MaintenanceManager {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
data data
) )
.then((result) => { .then(result => {
resolve(result); resolve(result);
}) })
.catch((err) => { .catch(err => {
reject(err); reject(err);
}); });
}); });
@ -102,11 +102,12 @@ class MaintenanceManager {
method = REQUEST_TYPE_POST; method = REQUEST_TYPE_POST;
type = CONTENT_TYPE_FORM; type = CONTENT_TYPE_FORM;
data = new FormData(form); data = new FormData(form);
return;
this._request(url, event, method, type, data) this._request(url, event, method, type, data)
.then((result) => { .then(result => {
resolve(result); resolve(result);
}) })
.catch((err) => { .catch(err => {
reject(err); reject(err);
}); });
}); });
@ -123,13 +124,13 @@ class MaintenanceManager {
event = TASK_BACKUP_CREATE; event = TASK_BACKUP_CREATE;
method = REQUEST_TYPE_POST; method = REQUEST_TYPE_POST;
type = CONTENT_TYPE_JSON; type = CONTENT_TYPE_JSON;
data = { task: "create_backup" }; data = { task: 'create_backup' };
this._request(url, event, method, type, data) this._request(url, event, method, type, data)
.then((result) => { .then(result => {
resolve(result); resolve(result);
}) })
.catch((err) => { .catch(err => {
reject(err); reject(err);
}); });
}); });
@ -150,10 +151,10 @@ class MaintenanceManager {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
data data
) )
.then((result) => { .then(result => {
resolve(result); resolve(result);
}) })
.catch((err) => { .catch(err => {
reject(err); reject(err);
}); });
}); });
@ -175,10 +176,10 @@ class MaintenanceManager {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
data data
) )
.then((result) => { .then(result => {
resolve(result); resolve(result);
}) })
.catch((err) => { .catch(err => {
reject(err); reject(err);
}); });
}); });
@ -191,12 +192,12 @@ class MaintenanceManager {
*/ */
imageUpload(type, files) { imageUpload(type, files) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let url = ""; let url = '';
switch (type) { switch (type) {
case "avatar-upload": case 'avatar-upload':
url = API_UPLOAD_AVATAR; url = API_UPLOAD_AVATAR;
break; break;
case "background-upload": case 'background-upload':
url = API_UPLOAD_BACKGROUND; url = API_UPLOAD_BACKGROUND;
break; break;
default: default:
@ -206,24 +207,24 @@ class MaintenanceManager {
var imageData = new FormData(); var imageData = new FormData();
if (this.baseURL) { if (this.baseURL) {
imageData.append("key", this.key); imageData.append('key', this.key);
imageData.append("remote", true); imageData.append('remote', true);
} else { } else {
imageData.append("remote", false); imageData.append('remote', false);
} }
for (var i = 0; i < files.length; i++) { for (var i = 0; i < files.length; i++) {
var file = files[i]; var file = files[i];
// Check the file type. // Check the file type.
if (!file.type.match("image.*")) { if (!file.type.match('image.*')) {
continue; continue;
} }
if (type === "avatar-upload") { if (type === 'avatar-upload') {
imageData.append("avatar_upload", file, file.name); imageData.append('avatar_upload', file, file.name);
} else if (type === "background-upload") { } else if (type === 'background-upload') {
imageData.append("background_upload", file, file.name); imageData.append('background_upload', file, file.name);
} else { } else {
imageData.append("post_image", file, file.name); imageData.append('post_image', file, file.name);
} }
} }
this._request( this._request(
@ -233,10 +234,10 @@ class MaintenanceManager {
CONTENT_TYPE_FORM, CONTENT_TYPE_FORM,
imageData imageData
) )
.then((r) => { .then(r => {
resolve(r); resolve(r);
}) })
.catch((err) => { .catch(err => {
reject(err); reject(err);
}); });
}); });
@ -255,27 +256,27 @@ class MaintenanceManager {
var self = this; var self = this;
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
request.upload.addEventListener("progress", (e) => request.upload.addEventListener('progress', e =>
self.handleLoadProgress(e, self.progressBar) self.handleLoadProgress(e, self.progressBar)
); );
request.open(requestType, requestURL, true); request.open(requestType, requestURL, true);
request.onload = () => { request.onload = () => {
if (request.status == 200) { if (request.status == 200) {
let response = JSON.parse(request["response"]); let response = JSON.parse(request['response']);
resolve(response); resolve(response);
} else { } else {
let error = JSON.parse(request["response"]); let error = JSON.parse(request['response']);
reject(error); reject(error);
} }
}; };
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) { if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
if (eventType === TASK_UPLOAD_FILES) if (eventType === TASK_UPLOAD_FILES)
request.setRequestHeader("fipamo-access-token", self.token); request.setRequestHeader('fipamo-access-token', self.token);
switch (contentType) { switch (contentType) {
case CONTENT_TYPE_JSON: case CONTENT_TYPE_JSON:
request.setRequestHeader( request.setRequestHeader(
"Content-type", 'Content-type',
"application/" + contentType 'application/' + contentType
); );
request.send(JSON.stringify(requestData)); request.send(JSON.stringify(requestData));
break; break;
@ -296,7 +297,7 @@ class MaintenanceManager {
let percent = Math.ceil((e.loaded / e.total) * 100); let percent = Math.ceil((e.loaded / e.total) * 100);
//if a progress bar element is present, talk to it //if a progress bar element is present, talk to it
if (progressBar != null) { if (progressBar != null) {
progressBar.style.width = percent + "%"; progressBar.style.width = percent + '%';
} }
} }
} }