fixes for site init
This commit is contained in:
parent
2b7db3cc88
commit
6279ad4730
4 changed files with 8840 additions and 312 deletions
|
@ -56,6 +56,7 @@ class SetUp
|
|||
"uuid" => StringTools::createUUID(),
|
||||
"title" => "FIRST!",
|
||||
"feature" => "/assets/images/global/default-bg.jpg",
|
||||
"files" => "",
|
||||
"path" => "content/pages/start",
|
||||
"layout" => "index",
|
||||
"tags" => "start, welcome",
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<div id="dash-index">
|
||||
<div id="dash-index-wrapper">
|
||||
<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"/>
|
||||
<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"/>
|
||||
|
@ -26,7 +26,7 @@
|
|||
|
||||
</div>
|
||||
<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"/>
|
||||
<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>
|
||||
|
@ -44,5 +44,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
<script src="/assets/scripts/Start.js" type="text/javascript"></script>
|
||||
<script src="/assets/scripts/Start.js?=sdfsdf" type="text/javascript"></script>
|
||||
{% endblock %}
|
File diff suppressed because it is too large
Load diff
|
@ -1,33 +1,33 @@
|
|||
//** REQUEST TYPES **//
|
||||
export const REQUEST_TYPE_POST = "POST";
|
||||
export const REQUEST_TYPE_GET = "GET";
|
||||
export const REQUEST_TYPE_PUT = "PUT";
|
||||
export const REQUEST_TYPE_DELETE = "DELETE";
|
||||
export const REQUEST_TYPE_POST = 'POST';
|
||||
export const REQUEST_TYPE_GET = 'GET';
|
||||
export const REQUEST_TYPE_PUT = 'PUT';
|
||||
export const REQUEST_TYPE_DELETE = 'DELETE';
|
||||
//** POST CONTENT TYPES **//
|
||||
export const CONTENT_TYPE_JSON = "json";
|
||||
export const CONTENT_TYPE_FORM = "x-www-form-urlencoded";
|
||||
export const CONTENT_TYPE_JSON = 'json';
|
||||
export const CONTENT_TYPE_FORM = 'x-www-form-urlencoded';
|
||||
//** API URLS **//
|
||||
export const API_STATUS = "/api/v1/status";
|
||||
export const API_INIT = "/api/v1/init";
|
||||
export const API_RESTORE = "/api/v1/restore";
|
||||
export const API_GET_SECRET = "/api/v1/get-secret";
|
||||
export const API_RESET_PASS = "/api/v1/reset-password";
|
||||
export const API_CREATE_BACKUP = "/api/v1/backup";
|
||||
export const API_DOWNLOAD_BACKUP = "/api/v1/backup/download";
|
||||
export const API_RESTORE_BACKUP = "/api/v1/backup/restore";
|
||||
export const API_UPLOAD_AVATAR = "/api/v1/settings/add-avatar";
|
||||
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_STATUS = '/api/v1/status';
|
||||
export const API_INIT = '/api/v1/init';
|
||||
export const API_RESTORE = '/api/v1/restore';
|
||||
export const API_GET_SECRET = '/api/v1/get-secret';
|
||||
export const API_RESET_PASS = '/api/v1/reset-password';
|
||||
export const API_CREATE_BACKUP = '/api/v1/backup';
|
||||
export const API_DOWNLOAD_BACKUP = '/api/v1/backup/download';
|
||||
export const API_RESTORE_BACKUP = '/api/v1/backup/restore';
|
||||
export const API_UPLOAD_AVATAR = '/api/v1/settings/add-avatar';
|
||||
export const API_UPLOAD_BACKGROUND = '/api/v1/settings/add-feature-background';
|
||||
export const API_IMAGE_UPLOAD = '/api/v1/page/add-entry-image';
|
||||
//** API TASKS **//
|
||||
export const TASK_SITE_INIT = "blogInit";
|
||||
export const TASK_BACKUP_RESTORE = "restoreBackup";
|
||||
export const TASK_BACKUP_CREATE = "createBackup";
|
||||
export const TASK_GET_SECRET = "retrieveSecret";
|
||||
export const TASK_RESET_PASS = "resetPassword";
|
||||
export const TASK_UPLOAD_FILES = "uploadFiles";
|
||||
export const TASK_SITE_INIT = 'blogInit';
|
||||
export const TASK_BACKUP_RESTORE = 'restoreBackup';
|
||||
export const TASK_BACKUP_CREATE = 'createBackup';
|
||||
export const TASK_GET_SECRET = 'retrieveSecret';
|
||||
export const TASK_RESET_PASS = 'resetPassword';
|
||||
export const TASK_UPLOAD_FILES = 'uploadFiles';
|
||||
//** API STATUS **//
|
||||
export const API_ACCESS_GOOD = "apiUseAuthorized";
|
||||
export const API_ACCESS_BAD = "apiUseNotAuthorized";
|
||||
export const API_ACCESS_GOOD = 'apiUseAuthorized';
|
||||
export const API_ACCESS_BAD = 'apiUseNotAuthorized';
|
||||
|
||||
/**
|
||||
* 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
|
||||
this._request(
|
||||
this.baseURL
|
||||
? this.baseURL + API_STATUS + "?key=" + this.key
|
||||
: API_STATUS + "?key=" + this.key
|
||||
).then((response) => {
|
||||
? this.baseURL + API_STATUS + '?key=' + this.key
|
||||
: API_STATUS + '?key=' + this.key
|
||||
).then(response => {
|
||||
if (response.type === API_ACCESS_GOOD) {
|
||||
this.token = response.token;
|
||||
} else {
|
||||
|
@ -78,10 +78,10 @@ class MaintenanceManager {
|
|||
CONTENT_TYPE_JSON,
|
||||
data
|
||||
)
|
||||
.then((result) => {
|
||||
.then(result => {
|
||||
resolve(result);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
@ -102,11 +102,12 @@ class MaintenanceManager {
|
|||
method = REQUEST_TYPE_POST;
|
||||
type = CONTENT_TYPE_FORM;
|
||||
data = new FormData(form);
|
||||
return;
|
||||
this._request(url, event, method, type, data)
|
||||
.then((result) => {
|
||||
.then(result => {
|
||||
resolve(result);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
@ -123,13 +124,13 @@ class MaintenanceManager {
|
|||
event = TASK_BACKUP_CREATE;
|
||||
method = REQUEST_TYPE_POST;
|
||||
type = CONTENT_TYPE_JSON;
|
||||
data = { task: "create_backup" };
|
||||
data = { task: 'create_backup' };
|
||||
|
||||
this._request(url, event, method, type, data)
|
||||
.then((result) => {
|
||||
.then(result => {
|
||||
resolve(result);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
@ -150,10 +151,10 @@ class MaintenanceManager {
|
|||
CONTENT_TYPE_JSON,
|
||||
data
|
||||
)
|
||||
.then((result) => {
|
||||
.then(result => {
|
||||
resolve(result);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
@ -175,10 +176,10 @@ class MaintenanceManager {
|
|||
CONTENT_TYPE_JSON,
|
||||
data
|
||||
)
|
||||
.then((result) => {
|
||||
.then(result => {
|
||||
resolve(result);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
@ -191,12 +192,12 @@ class MaintenanceManager {
|
|||
*/
|
||||
imageUpload(type, files) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let url = "";
|
||||
let url = '';
|
||||
switch (type) {
|
||||
case "avatar-upload":
|
||||
case 'avatar-upload':
|
||||
url = API_UPLOAD_AVATAR;
|
||||
break;
|
||||
case "background-upload":
|
||||
case 'background-upload':
|
||||
url = API_UPLOAD_BACKGROUND;
|
||||
break;
|
||||
default:
|
||||
|
@ -206,24 +207,24 @@ class MaintenanceManager {
|
|||
var imageData = new FormData();
|
||||
|
||||
if (this.baseURL) {
|
||||
imageData.append("key", this.key);
|
||||
imageData.append("remote", true);
|
||||
imageData.append('key', this.key);
|
||||
imageData.append('remote', true);
|
||||
} else {
|
||||
imageData.append("remote", false);
|
||||
imageData.append('remote', false);
|
||||
}
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var file = files[i];
|
||||
// Check the file type.
|
||||
if (!file.type.match("image.*")) {
|
||||
if (!file.type.match('image.*')) {
|
||||
continue;
|
||||
}
|
||||
if (type === "avatar-upload") {
|
||||
imageData.append("avatar_upload", file, file.name);
|
||||
} else if (type === "background-upload") {
|
||||
imageData.append("background_upload", file, file.name);
|
||||
if (type === 'avatar-upload') {
|
||||
imageData.append('avatar_upload', file, file.name);
|
||||
} else if (type === 'background-upload') {
|
||||
imageData.append('background_upload', file, file.name);
|
||||
} else {
|
||||
imageData.append("post_image", file, file.name);
|
||||
imageData.append('post_image', file, file.name);
|
||||
}
|
||||
}
|
||||
this._request(
|
||||
|
@ -233,10 +234,10 @@ class MaintenanceManager {
|
|||
CONTENT_TYPE_FORM,
|
||||
imageData
|
||||
)
|
||||
.then((r) => {
|
||||
.then(r => {
|
||||
resolve(r);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
@ -255,27 +256,27 @@ class MaintenanceManager {
|
|||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.upload.addEventListener("progress", (e) =>
|
||||
request.upload.addEventListener('progress', e =>
|
||||
self.handleLoadProgress(e, self.progressBar)
|
||||
);
|
||||
request.open(requestType, requestURL, true);
|
||||
request.onload = () => {
|
||||
if (request.status == 200) {
|
||||
let response = JSON.parse(request["response"]);
|
||||
let response = JSON.parse(request['response']);
|
||||
resolve(response);
|
||||
} else {
|
||||
let error = JSON.parse(request["response"]);
|
||||
let error = JSON.parse(request['response']);
|
||||
reject(error);
|
||||
}
|
||||
};
|
||||
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
|
||||
if (eventType === TASK_UPLOAD_FILES)
|
||||
request.setRequestHeader("fipamo-access-token", self.token);
|
||||
request.setRequestHeader('fipamo-access-token', self.token);
|
||||
switch (contentType) {
|
||||
case CONTENT_TYPE_JSON:
|
||||
request.setRequestHeader(
|
||||
"Content-type",
|
||||
"application/" + contentType
|
||||
'Content-type',
|
||||
'application/' + contentType
|
||||
);
|
||||
request.send(JSON.stringify(requestData));
|
||||
break;
|
||||
|
@ -296,7 +297,7 @@ class MaintenanceManager {
|
|||
let percent = Math.ceil((e.loaded / e.total) * 100);
|
||||
//if a progress bar element is present, talk to it
|
||||
if (progressBar != null) {
|
||||
progressBar.style.width = percent + "%";
|
||||
progressBar.style.width = percent + '%';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue