clean up API, re-connected API to front end, base template tweak

beta
Ro 4 years ago
parent 083faa7c1d
commit 5ad1118244

@ -0,0 +1,70 @@
{
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module",
"ecmaFeatures": {}
},
"rules": {
"constructor-super": 2,
"for-direction": 2,
"getter-return": 2,
"no-case-declarations": 2,
"no-class-assign": 2,
"no-compare-neg-zero": 2,
"no-cond-assign": 2,
"no-console": 1,
"no-const-assign": 2,
"no-constant-condition": 2,
"no-control-regex": 1,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty": 2,
"no-empty-character-class": 2,
"no-empty-pattern": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast": 2,
"no-extra-semi": 2,
"no-fallthrough": 2,
"no-func-assign": 2,
"no-global-assign": 2,
"no-inner-declarations": 2,
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-mixed-spaces-and-tabs": 2,
"no-new-symbol": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-self-assign": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-undef": 2,
"no-unexpected-multiline": 2,
"no-unreachable": 2,
"no-unsafe-finally": 2,
"no-unsafe-negation": 2,
"no-unused-labels": 2,
"no-unused-vars": 2,
"no-useless-escape": 1,
"require-yield": 2,
"use-isnan": 2,
"valid-typeof": 2,
"no-duplicate-imports": 2
},
"env": {
"node": true,
"browser": true,
"es6": true
},
"globals": {
"_": false,
"hljs": false,
"Sortable": false,
"Prism": false
}
}

1
.gitignore vendored

@ -1,4 +1,5 @@
node_modules/ node_modules/
src/node_modules/
.sass-cache/ .sass-cache/
.cache/ .cache/
.nova/ .nova/

@ -6,7 +6,23 @@ use Psr\Http\Message\ServerRequestInterface;
class APIControl class APIControl
{ {
public static function start( public static function get(
ServerRequestInterface $request,
ResponseInterface $response,
array $args
): ResponseInterface {
switch (isset($args["third"]) ? $args["third"] : "none") {
case "status":
$result = Auth::status();
break;
default:
break;
}
$response->getBody()->write(json_encode($result));
return $response->withHeader("Content-Type", "application/json");
}
public static function post(
ServerRequestInterface $request, ServerRequestInterface $request,
ResponseInterface $response, ResponseInterface $response,
array $args array $args
@ -24,7 +40,6 @@ class APIControl
switch (isset($args["third"]) ? $args["third"] : "none") { switch (isset($args["third"]) ? $args["third"] : "none") {
case "login": case "login":
$result = Auth::login($body); $result = Auth::login($body);
break; break;
case "logout": case "logout":
$result = Auth::logout($body); $result = Auth::logout($body);
@ -38,7 +53,6 @@ class APIControl
} }
$response->getBody()->write(json_encode($result)); $response->getBody()->write(json_encode($result));
return $response->withHeader("Content-Type", "application/json"); return $response->withHeader("Content-Type", "application/json");
} }
} }

@ -17,6 +17,9 @@ class RouteControl
case "dashboard": case "dashboard":
return DashControl::start($request, $response, $args); return DashControl::start($request, $response, $args);
break; break;
case "api":
return APIControl::get($request, $response, $args);
break;
default: default:
return IndexControl::start($request, $response, $args); return IndexControl::start($request, $response, $args);
break; break;
@ -30,7 +33,7 @@ class RouteControl
): ResponseInterface { ): ResponseInterface {
switch (isset($args["first"]) ? $args["first"] : "index") { switch (isset($args["first"]) ? $args["first"] : "index") {
case "api": case "api":
return APIControl::start($request, $response, $args); return APIControl::post($request, $response, $args);
break; break;
default: default:
//echo "YES"; //echo "YES";

@ -19,6 +19,25 @@ class Auth
//return $this->secret; //return $this->secret;
} }
public static function status()
{
$result = [];
if (Session::active()) {
$result = [
"message" => "Authorized",
"type" => "apiUseAuthorized",
"token" => Session::get("token"),
];
} else {
$result = [
"message" => "Not Authorized",
"type" => "apiUseNotAuthorized",
];
}
return $result;
}
public static function login($who) public static function login($who)
{ {
//grab member list //grab member list
@ -47,19 +66,19 @@ class Auth
$result = [ $result = [
"message" => "Welcome back", "message" => "Welcome back",
"type" => "TASK_LOGIN", "type" => "requestGood",
]; ];
} else { } else {
$result = [ $result = [
"message" => "Check your password, sport", "message" => "Check your password, sport",
"type" => "TASK_LOGIN", "type" => "requestLame",
]; ];
} }
} else { } else {
//if name is not found //if name is not found
$result = [ $result = [
"message" => "Need to see some id, champ", "message" => "Need to see some id, champ",
"type" => "TASK_LOGIN", "type" => "requestLame",
]; ];
} }
return $result; return $result;

@ -17,7 +17,7 @@ class Settings
); );
} }
public function getFolks($key) public function getFolks($key = null)
{ {
if (isset($key)) { if (isset($key)) {
$member = Session::get("member"); $member = Session::get("member");

@ -13,14 +13,15 @@
<div id="notifications" class="notifications"> <div id="notifications" class="notifications">
<div id="notifyMessage" class="notifyMessage"> <div id="notifyMessage" class="notifyMessage">
<div id="notify-good" class="notify-icon"> <div id="notify-good" class="notify-icon">
<svg class="menu-icon"><use xlink:href="/images/global/sprite.svg#entypo-emoji-flirt"/></svg> <svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-emoji-flirt"/></svg>
</div> </div>
<div id="notify-lame" class="notify-icon"> <div id="notify-lame" class="notify-icon">
<svg class="menu-icon"><use xlink:href="/images/global/sprite.svg#entypo-emoji-sad"/></svg> <svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-emoji-sad"/></svg>
</div> </div>
<div id="notify-working" class="notify-icon"> <div id="notify-working" class="notify-icon">
<svg class="menu-icon"><use xlink:href="/images/global/sprite.svg#entypo-cog"/></svg> <svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-cog"/></svg>
</div> </div>
<p id="message-text"></p>
</div> </div>
</div> </div>
<div id="main-content" class="main-container"> <div id="main-content" class="main-container">
@ -41,24 +42,7 @@
</div> </div>
<footer> <footer></footer>
{% if options['showFooter'] is defined %}
<!-- NO FOOTER -->
{% else %}
<div class="inner">
<div class="columns">
<div id="footer_left" class="column">
<a href="#">About</a><br/>
</div>
<div id="footer_right " class="column">
<a href="#">FAQ</a><br/>
</div>
</div>
</div>
{% endif %}
</footer>
{% block javascripts %}{% endblock %} {% block javascripts %}{% endblock %}
</body> </body>
</html> </html>

@ -11,8 +11,6 @@
{% block mainContent %} {% block mainContent %}
<div id="dash-index"> <div id="dash-index">
<div id="dash-index-wrapper"> <div id="dash-index-wrapper">
STATUS:
{{ status }}
{% if status %} {% if status %}
DASH INDEX DASH INDEX
{% else %} {% else %}

@ -1,9 +1,9 @@
import FipamoApi from '../libraries/FipamoAPI'; import FipamoApi from "../libraries/FipamoAPI";
import FipamoAdminAPI from '../libraries/FipamoAdminAPI'; import FipamoAdminAPI from "../libraries/FipamoAdminAPI";
import DataUitls from './utils/DataUtils'; import DataUitls from "./utils/DataUtils";
import * as DataEvent from './events/DataEvent'; import * as DataEvent from "./events/DataEvent";
import DashManager from './controllers/DashManager'; import DashManager from "./controllers/DashManager";
import Notfications from './ui/Notifications'; import Notfications from "./ui/Notifications";
const api = new FipamoApi(); const api = new FipamoApi();
const admin = new FipamoAdminAPI(); const admin = new FipamoAdminAPI();
@ -22,22 +22,26 @@ export default class Base {
// methods // methods
//-------------------------- //--------------------------
start() { start() {
if (document.getElementById('dash-form') || document.getElementById('dash-init')) { if (
var options = document.getElementsByClassName('init-option'); document.getElementById("dash-form") ||
document.getElementById("dash-init")
) {
console.log("GET THAT ID, boss");
var options = document.getElementsByClassName("init-option");
for (let index = 0; index < options.length; index++) { for (let index = 0; index < options.length; index++) {
options[index].addEventListener('click', e => this.handleOptions(e)); options[index].addEventListener("click", (e) => this.handleOptions(e));
} }
if (document.getElementById('dash-form')) { if (document.getElementById("dash-form")) {
document document
.getElementById('login-btn') .getElementById("login-btn")
.addEventListener('click', e => this.handleLogin(e)); .addEventListener("click", (e) => this.handleLogin(e));
} else { } else {
document document
.getElementById('init-blog') .getElementById("init-blog")
.addEventListener('click', e => this.handleSetup(e)); .addEventListener("click", (e) => this.handleSetup(e));
document document
.getElementById('blog-restore') .getElementById("blog-restore")
.addEventListener('click', e => this.handleRestore(e)); .addEventListener("click", (e) => this.handleRestore(e));
} }
} else { } else {
new DashManager(); new DashManager();
@ -49,21 +53,22 @@ export default class Base {
handleLogin(e) { handleLogin(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
let authForm = data.formDataToJSON(document.getElementById('login')); let authForm = data.formDataToJSON(document.getElementById("login"));
notify.alert('Looking, hold up', null); notify.alert("Looking, hold up", null);
api.login(authForm) api
.then(response => { .login(authForm)
.then((response) => {
if (response.type === DataEvent.REQUEST_LAME) { if (response.type === DataEvent.REQUEST_LAME) {
notify.alert(response.message, false); notify.alert(response.message, false);
} else { } else {
notify.alert(response.message, true); notify.alert(response.message, true);
e.target.innerHTML = response.message; e.target.innerHTML = response.message;
setTimeout(() => { setTimeout(() => {
window.location = '/@/dashboard'; window.location = "/dashboard";
}, 500); }, 500);
} }
}) })
.catch(err => { .catch((err) => {
notify.alert(err, false); notify.alert(err, false);
}); });
} }
@ -71,29 +76,30 @@ export default class Base {
handleSetup(e) { handleSetup(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
let setUpForm = data.formDataToJSON(document.getElementById('init-form')); let setUpForm = data.formDataToJSON(document.getElementById("init-form"));
api.init(setUpForm) api
.then(response => { .init(setUpForm)
.then((response) => {
if (response.type === DataEvent.API_INIT_LAME) { if (response.type === DataEvent.API_INIT_LAME) {
notify.alert(response.message, false); notify.alert(response.message, false);
} else { } else {
notify.alert(response.message, true); notify.alert(response.message, true);
setTimeout(() => { setTimeout(() => {
window.location = '/@/dashboard'; window.location = "/@/dashboard";
}, 700); }, 700);
} }
}) })
.catch(err => { .catch((err) => {
notify.alert(err, false); notify.alert(err, false);
}); });
} }
handleRestore(e) { handleRestore(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
var form = document.getElementById('init-restore'); var form = document.getElementById("init-restore");
admin admin
.handleInitRestore(form) .handleInitRestore(form)
.then(response => { .then((response) => {
if (response.type === DataEvent.REQUEST_LAME) { if (response.type === DataEvent.REQUEST_LAME) {
notify.alert(response.message, false); notify.alert(response.message, false);
} else { } else {
@ -103,27 +109,27 @@ export default class Base {
}, 700); }, 700);
} }
}) })
.catch(err => { .catch((err) => {
notify.alert(err, false); notify.alert(err, false);
}); });
} }
handleOptions(e) { handleOptions(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
let init = document.getElementById('dash-init'); let init = document.getElementById("dash-init");
let restore = document.getElementById('dash-restore'); let restore = document.getElementById("dash-restore");
if (e.target.id === 'init-switch-restore') { if (e.target.id === "init-switch-restore") {
init.style.display = 'none'; init.style.display = "none";
init.style.visibility = 'hidden'; init.style.visibility = "hidden";
restore.style.display = 'block'; restore.style.display = "block";
restore.style.visibility = 'visible'; restore.style.visibility = "visible";
} else { } else {
init.style.display = 'block'; init.style.display = "block";
init.style.visibility = 'visible'; init.style.visibility = "visible";
restore.style.display = 'none'; restore.style.display = "none";
restore.style.visibility = 'hidden'; restore.style.visibility = "hidden";
} }
} }
} }

@ -1,7 +1,7 @@
import Base from './Base'; import Base from "./Base";
document.addEventListener( document.addEventListener(
'DOMContentLoaded', "DOMContentLoaded",
function () { function () {
new Base(); new Base();
}, },

@ -1,15 +1,15 @@
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";
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";
export const API_STATUS = '/api/v1/auth/status'; export const API_STATUS = "/api/v1/status";
export const API_INIT = '/api/v1/auth/init'; export const API_INIT = "/api/v1/init";
export const API_LOGIN = '/api/v1/auth/login'; export const API_LOGIN = "/api/v1/login";
export const API_GET_PAGES = '/api/v1/page/published'; export const API_GET_PAGES = "/api/v1/page/published";
export const API_GET_PAGE = '/api/v1/page/single'; export const API_GET_PAGE = "/api/v1/page/single";
import * as DataEvent from '../com/events/DataEvent'; import * as DataEvent from "../com/events/DataEvent";
export default class APIUtils { export default class APIUtils {
//-------------------------- //--------------------------
// constructor // constructor
@ -27,34 +27,44 @@ export default class APIUtils {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
data data
) )
.then(result => { .then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
} }
init(data) { init(data) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._request(API_INIT, DataEvent.API_INIT, REQUEST_TYPE_POST, CONTENT_TYPE_JSON, data) this._request(
.then(result => { API_INIT,
DataEvent.API_INIT,
REQUEST_TYPE_POST,
CONTENT_TYPE_JSON,
data
)
.then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
} }
getPages(num) { getPages(num) {
let pageNum = num; let pageNum = num;
if (pageNum === null || pageNum === '' || !pageNum) pageNum = 1; if (pageNum === null || pageNum === "" || !pageNum) pageNum = 1;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._request(API_GET_PAGES + '/' + pageNum, DataEvent.API_GET_PAGES, REQUEST_TYPE_GET) this._request(
.then(result => { API_GET_PAGES + "/" + pageNum,
DataEvent.API_GET_PAGES,
REQUEST_TYPE_GET
)
.then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
@ -62,11 +72,15 @@ export default class APIUtils {
getPage(id) { getPage(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._request(API_GET_PAGE + '/' + id, DataEvent.API_GET_PAGES, REQUEST_TYPE_GET) this._request(
.then(result => { API_GET_PAGE + "/" + id,
DataEvent.API_GET_PAGES,
REQUEST_TYPE_GET
)
.then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
@ -88,17 +102,20 @@ export default class APIUtils {
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) {
switch (contentType) { switch (contentType) {
case CONTENT_TYPE_JSON: case CONTENT_TYPE_JSON:
request.setRequestHeader('Content-type', 'application/' + contentType); request.setRequestHeader(
"Content-type",
"application/" + contentType
);
request.send(JSON.stringify(requestData)); request.send(JSON.stringify(requestData));
break; break;
case CONTENT_TYPE_FORM: case CONTENT_TYPE_FORM:

@ -1,30 +1,30 @@
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";
export const TASK_PAGE_CREATE = 'createNewPage'; export const TASK_PAGE_CREATE = "createNewPage";
export const TASK_PAGE_EDIT = 'editPage'; export const TASK_PAGE_EDIT = "editPage";
export const TASK_PAGE_DELETE = 'deletePage'; export const TASK_PAGE_DELETE = "deletePage";
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";
export const API_STATUS = '/api/v1/auth/status'; export const API_STATUS = "/api/v1/status";
export const API_GET_NAV = '/api/settings/nav'; export const API_GET_NAV = "/api/settings/nav";
export const API_NEW_PAGE = '/api/v1/page/write/new'; export const API_NEW_PAGE = "/api/v1/page/write/new";
export const API_EDIT_PAGE = '/api/v1/page/write'; export const API_EDIT_PAGE = "/api/v1/page/write";
export const API_DELETE_PAGE = '/api/v1/page/delete'; export const API_DELETE_PAGE = "/api/v1/page/delete";
export const API_IMAGE_UPLOAD = '/api/v1/page/add-post-image'; export const API_IMAGE_UPLOAD = "/api/v1/page/add-post-image";
export const API_SETTINGS_SYNC = '/api/v1/settings/sync'; export const API_SETTINGS_SYNC = "/api/v1/settings/sync";
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_PUBLISH_PAGES = '/api/v1/settings/publish-pages'; export const API_PUBLISH_PAGES = "/api/v1/settings/publish-pages";
export const API_NAV_SYNC = '/api/v1/settings/nav-sync'; export const API_NAV_SYNC = "/api/v1/settings/nav-sync";
export const API_REINDEX_PAGES = '/api/v1/settings/reindex'; export const API_REINDEX_PAGES = "/api/v1/settings/reindex";
export const API_CREATE_BACKUP = '/api/v1/backup/create'; export const API_CREATE_BACKUP = "/api/v1/backup/create";
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_INIT_RESTORE_BACKUP = '/api/v1/backup/init-restore'; export const API_INIT_RESTORE_BACKUP = "/api/v1/backup/init-restore";
export const API_SEND_MAIL = '/api/v1/mailer'; export const API_SEND_MAIL = "/api/v1/mailer";
import * as DataEvent from '../com/events/DataEvent'; import * as DataEvent from "../com/events/DataEvent";
export default class APIUtils { export default class APIUtils {
//-------------------------- //--------------------------
// constructor // constructor
@ -34,7 +34,7 @@ export default class APIUtils {
this.token = null; this.token = null;
//checks backend to see if user is logged in //checks backend to see if user is logged in
//and requests encrypted token for api calls //and requests encrypted token for api calls
this._request(API_STATUS).then(response => { this._request(API_STATUS).then((response) => {
if (response.type === DataEvent.API_REQUEST_GOOD) { if (response.type === DataEvent.API_REQUEST_GOOD) {
this.token = response.token; this.token = response.token;
} else { } else {
@ -54,22 +54,22 @@ export default class APIUtils {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
data data
) )
.then(result => { .then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
} }
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:
@ -80,15 +80,15 @@ export default class APIUtils {
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(
@ -98,10 +98,10 @@ export default class APIUtils {
CONTENT_TYPE_FORM, CONTENT_TYPE_FORM,
imageData imageData
) )
.then(r => { .then((r) => {
resolve(r); resolve(r);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
@ -115,10 +115,10 @@ export default class APIUtils {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
data data
) )
.then(result => { .then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
@ -150,10 +150,10 @@ export default class APIUtils {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._request(url, event, REQUEST_TYPE_POST, content, data) this._request(url, event, REQUEST_TYPE_POST, content, data)
.then(result => { .then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
@ -168,10 +168,10 @@ export default class APIUtils {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
data data
) )
.then(result => { .then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
@ -185,10 +185,10 @@ export default class APIUtils {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
message message
) )
.then(result => { .then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
@ -197,12 +197,12 @@ export default class APIUtils {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var url, event, method, type, data; var url, event, method, type, data;
if (id === 'create-backup') { if (id === "create-backup") {
url = API_CREATE_BACKUP; url = API_CREATE_BACKUP;
event = DataEvent.API_BACKUP_CREATE; event = DataEvent.API_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" };
} else { } else {
url = API_RESTORE_BACKUP; url = API_RESTORE_BACKUP;
event = DataEvent.API_BACKUP_RESTORE; event = DataEvent.API_BACKUP_RESTORE;
@ -212,17 +212,17 @@ export default class APIUtils {
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('application.zip')) { if (!file.type.match("application.zip")) {
continue; continue;
} }
data.append('backup_upload', file, file.name); data.append("backup_upload", file, file.name);
} }
} }
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);
}); });
}); });
@ -237,10 +237,10 @@ export default class APIUtils {
type = CONTENT_TYPE_FORM; type = CONTENT_TYPE_FORM;
data = new FormData(form); data = new FormData(form);
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);
}); });
}); });
@ -255,10 +255,10 @@ export default class APIUtils {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
data data
) )
.then(result => { .then((result) => {
resolve(result); resolve(result);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
}); });
@ -280,10 +280,10 @@ export default class APIUtils {
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);
} }
}; };
@ -298,11 +298,14 @@ export default class APIUtils {
eventType === DataEvent.API_BACKUP_RESTORE || eventType === DataEvent.API_BACKUP_RESTORE ||
eventType === DataEvent.API_REINDEX_PAGES eventType === DataEvent.API_REINDEX_PAGES
) )
request.setRequestHeader('x-access-token', self.token); request.setRequestHeader("x-access-token", self.token);
switch (contentType) { switch (contentType) {
case CONTENT_TYPE_JSON: case CONTENT_TYPE_JSON:
request.setRequestHeader('Content-type', 'application/' + contentType); request.setRequestHeader(
"Content-type",
"application/" + contentType
);
request.send(JSON.stringify(requestData)); request.send(JSON.stringify(requestData));
break; break;
case CONTENT_TYPE_FORM: case CONTENT_TYPE_FORM:

@ -0,0 +1,23 @@
{
"name": "codekit-project",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"animejs": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/animejs/-/animejs-3.2.1.tgz",
"integrity": "sha512-sWno3ugFryK5nhiDm/2BKeFCpZv7vzerWUcUPyAZLDhMek3+S/p418ldZJbJXo5ZUOpfm2kP2XRO4NJcULMy9A=="
},
"caret-pos": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/caret-pos/-/caret-pos-2.0.0.tgz",
"integrity": "sha512-cOIiBS1SjzXg+LXSiQAzGg89dHDKq/y4c30+tB5hkVN7GbtXh1BNypOmjti4LwAWQrvP4y+bNG7RJFxLGoL3bA=="
},
"sortablejs": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.13.0.tgz",
"integrity": "sha512-RBJirPY0spWCrU5yCmWM1eFs/XgX2J5c6b275/YyxFRgnzPhKl/TDeU2hNR8Dt7ITq66NRPM4UlOt+e5O4CFHg=="
}
}
}

@ -0,0 +1,15 @@
{
"name": "fipamo-dash",
"version": "1.2.4",
"description": "Front end script for the most chill blog framework ever.",
"scripts": {},
"author": "Are0h",
"license": "UNLICENSED",
"repository": "https://code.playvicio.us/Are0h/Fipamo",
"private": true,
"dependencies": {
"animejs": "^3.2.1",
"caret-pos": "^2.0.0",
"sortablejs": "^1.13.0"
}
}
Loading…
Cancel
Save