removed data events from fipamo api, added content api methods, cleaned up front end js
This commit is contained in:
parent
6cd28c06c0
commit
a542b2d884
12 changed files with 267 additions and 187 deletions
|
@ -29,7 +29,7 @@ class App
|
||||||
$app->add(TwigMiddleware::create($app, $twig));
|
$app->add(TwigMiddleware::create($app, $twig));
|
||||||
//set up routing
|
//set up routing
|
||||||
$app->get(
|
$app->get(
|
||||||
"/[{first}[/{second}[/{third}[/{fourth}]]]]",
|
"/[{first}[/{second}[/{third}[/{fourth}[/{fifth}]]]]]",
|
||||||
"\RouteControl:get"
|
"\RouteControl:get"
|
||||||
);
|
);
|
||||||
$app->post(
|
$app->post(
|
||||||
|
|
|
@ -6,6 +6,29 @@ class PagesAPI
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getPageContent($request, $args)
|
||||||
|
{
|
||||||
|
$task = $args["fourth"];
|
||||||
|
|
||||||
|
switch ($task) {
|
||||||
|
case "published":
|
||||||
|
$pageNum = $args["fifth"];
|
||||||
|
$result = (new Book("../content/pages"))->getPages($pageNum, 4, $task);
|
||||||
|
break;
|
||||||
|
case "single":
|
||||||
|
$uuid = $args["fifth"];
|
||||||
|
$result = (new Book("../content/pages"))->findPageById($uuid);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$result = [
|
||||||
|
"message" => "Hm, no task. That's unfortunate",
|
||||||
|
"type" => "TASK_NONE",
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public static function handlePageTask($request, $args)
|
public static function handlePageTask($request, $args)
|
||||||
{
|
{
|
||||||
$task = $args["fourth"];
|
$task = $args["fourth"];
|
||||||
|
|
|
@ -17,9 +17,22 @@ class APIControl
|
||||||
array $args
|
array $args
|
||||||
): ResponseInterface {
|
): ResponseInterface {
|
||||||
$filename = "";
|
$filename = "";
|
||||||
|
|
||||||
switch (isset($args["third"]) ? $args["third"] : "none") {
|
switch (isset($args["third"]) ? $args["third"] : "none") {
|
||||||
case "status":
|
case "status":
|
||||||
$result = AuthAPI::status();
|
$result = AuthAPI::status();
|
||||||
|
break;
|
||||||
|
case "page":
|
||||||
|
//echo
|
||||||
|
if (Member::verifyKey($_GET["key"])) {
|
||||||
|
$result = PagesAPI::getPageContent($request, $args);
|
||||||
|
} else {
|
||||||
|
$result = [
|
||||||
|
"message" => "API access denied, homie",
|
||||||
|
"type" => "API_ERROR",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "files":
|
case "files":
|
||||||
if (Session::active()) {
|
if (Session::active()) {
|
||||||
|
|
|
@ -7,6 +7,21 @@ class Member
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function verifyKey(string $key)
|
||||||
|
{
|
||||||
|
if (isset($key)) {
|
||||||
|
$folks = (new Settings())->getFolks();
|
||||||
|
$found = find($folks, ["key" => $key]);
|
||||||
|
if ($found) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function updateData(string $key, string $data, $secret = null)
|
public static function updateData(string $key, string $data, $secret = null)
|
||||||
{
|
{
|
||||||
$folks = (new Settings())->getFolks();
|
$folks = (new Settings())->getFolks();
|
||||||
|
|
8
public/assets/scripts/dash.min.js
vendored
8
public/assets/scripts/dash.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
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";
|
||||||
|
@ -148,7 +148,7 @@ export default class Base {
|
||||||
if (e.target.id == "get-secret-btn") {
|
if (e.target.id == "get-secret-btn") {
|
||||||
let data = {
|
let data = {
|
||||||
email: document.getElementById("email").value,
|
email: document.getElementById("email").value,
|
||||||
task: "retrieveSecret",
|
task: "retrieveSecret"
|
||||||
};
|
};
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
api
|
api
|
||||||
|
@ -174,7 +174,7 @@ export default class Base {
|
||||||
let data = {
|
let data = {
|
||||||
newPass: document.getElementById("new_password").value,
|
newPass: document.getElementById("new_password").value,
|
||||||
newPassConfirm: document.getElementById("new_password2").value,
|
newPassConfirm: document.getElementById("new_password2").value,
|
||||||
secret: document.getElementById("secret").value,
|
secret: document.getElementById("secret").value
|
||||||
};
|
};
|
||||||
api
|
api
|
||||||
.setNewPass(data)
|
.setNewPass(data)
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default class Mailer {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
sendMail() {
|
sendMail() {
|
||||||
let mailData = {
|
let mailData = {
|
||||||
content: "This is a test email",
|
content: "This is a test email"
|
||||||
};
|
};
|
||||||
let admin = new FipamoAdminAPI();
|
let admin = new FipamoAdminAPI();
|
||||||
admin
|
admin
|
||||||
|
@ -26,7 +26,7 @@ export default class Mailer {
|
||||||
testMail() {
|
testMail() {
|
||||||
let mailData = {
|
let mailData = {
|
||||||
content: "This is a test email",
|
content: "This is a test email",
|
||||||
mail_task: "TESTING",
|
mail_task: "TESTING"
|
||||||
};
|
};
|
||||||
let admin = new FipamoAdminAPI();
|
let admin = new FipamoAdminAPI();
|
||||||
admin
|
admin
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default class NavActions {
|
||||||
id: items[index].id,
|
id: items[index].id,
|
||||||
slug: items[index].getAttribute("data-slug"),
|
slug: items[index].getAttribute("data-slug"),
|
||||||
uuid: items[index].getAttribute("data-uuid"),
|
uuid: items[index].getAttribute("data-uuid"),
|
||||||
path: items[index].getAttribute("data-path"),
|
path: items[index].getAttribute("data-path")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default class NavIndex {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
var nav = document.querySelectorAll(".nav-btn");
|
var nav = document.querySelectorAll(".nav-btn");
|
||||||
for (var i = 0, length = nav.length; i < length; i++) {
|
for (var i = 0, length = nav.length; i < length; i++) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import FipamoAdminAPI, {
|
import FipamoAdminAPI, {
|
||||||
TASK_PAGE_CREATE,
|
TASK_PAGE_CREATE,
|
||||||
TASK_PAGE_EDIT,
|
TASK_PAGE_EDIT,
|
||||||
TASK_PAGE_DELETE,
|
TASK_PAGE_DELETE
|
||||||
} from "../../libraries/FipamoAdminAPI";
|
} from "../../libraries/FipamoAdminAPI";
|
||||||
import * as DataEvent from "../events/DataEvent";
|
import * as DataEvent from "../events/DataEvent";
|
||||||
import PageActions from "../actions/PageActions";
|
import PageActions from "../actions/PageActions";
|
||||||
|
@ -235,7 +235,7 @@ export default class PostEditor {
|
||||||
f.target.result,
|
f.target.result,
|
||||||
'" title="',
|
'" title="',
|
||||||
escape(theFile.name),
|
escape(theFile.name),
|
||||||
'"/>',
|
'"/>'
|
||||||
].join("");
|
].join("");
|
||||||
document.getElementById("featured-image-drop").innerHTML = "";
|
document.getElementById("featured-image-drop").innerHTML = "";
|
||||||
document.getElementById("featured-image-drop").appendChild(image);
|
document.getElementById("featured-image-drop").appendChild(image);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as DataEvent from '../events/DataEvent';
|
import * as DataEvent from "../events/DataEvent";
|
||||||
import { position } from 'caret-pos';
|
import { position } from "caret-pos";
|
||||||
import EventEmitter from '../events/EventEmitter';
|
import EventEmitter from "../events/EventEmitter";
|
||||||
import * as EditorEvent from '../events/EditorEvent';
|
import * as EditorEvent from "../events/EditorEvent";
|
||||||
class TextEditor extends EventEmitter {
|
class TextEditor extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Text Editor UI Component
|
* Text Editor UI Component
|
||||||
|
@ -18,9 +18,9 @@ class TextEditor extends EventEmitter {
|
||||||
this.textEditor = textEditor;
|
this.textEditor = textEditor;
|
||||||
this.fixLimit = scrollLimit;
|
this.fixLimit = scrollLimit;
|
||||||
this.caretPos = null;
|
this.caretPos = null;
|
||||||
this.url = '';
|
this.url = "";
|
||||||
this.setInputs();
|
this.setInputs();
|
||||||
window.addEventListener('scroll', () => {
|
window.addEventListener("scroll", () => {
|
||||||
//var fixLimit = this.fixLimit;
|
//var fixLimit = this.fixLimit;
|
||||||
/**
|
/**
|
||||||
* edit scroller needs work
|
* edit scroller needs work
|
||||||
|
@ -38,15 +38,19 @@ class TextEditor extends EventEmitter {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
setInputs() {
|
setInputs() {
|
||||||
let self = this;
|
let self = this;
|
||||||
var editorButtons = document.querySelectorAll('.editor-button');
|
var editorButtons = document.querySelectorAll(".editor-button");
|
||||||
for (var i = 0, length = editorButtons.length; i < length; i++) {
|
for (var i = 0, length = editorButtons.length; i < length; i++) {
|
||||||
editorButtons[i].addEventListener('click', e => this.handleEditorOption(e), false);
|
editorButtons[i].addEventListener(
|
||||||
|
"click",
|
||||||
|
(e) => this.handleEditorOption(e),
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.textEditor.addEventListener('input', e => {
|
this.textEditor.addEventListener("input", (e) => {
|
||||||
let htmlTagRe = /<[a-z][\s\S]*>/g;
|
let htmlTagRe = /<[a-z][\s\S]*>/g;
|
||||||
let text = this.textEditor.innerText;
|
let text = this.textEditor.innerText;
|
||||||
if (e.inputType == 'insertParagraph') return; //cursor setting gets weird on return, so just back out
|
if (e.inputType == "insertParagraph") return; //cursor setting gets weird on return, so just back out
|
||||||
|
|
||||||
if (text.search(htmlTagRe) > -1) {
|
if (text.search(htmlTagRe) > -1) {
|
||||||
let caret = position(this.textEditor).pos;
|
let caret = position(this.textEditor).pos;
|
||||||
|
@ -58,27 +62,31 @@ class TextEditor extends EventEmitter {
|
||||||
refresh() {
|
refresh() {
|
||||||
//var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;
|
//var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;
|
||||||
var spiffed = this.textEditor.innerText;
|
var spiffed = this.textEditor.innerText;
|
||||||
spiffed = spiffed.replace(new RegExp('\r?\n', 'g'), '<br>');
|
spiffed = spiffed.replace(new RegExp("\r?\n", "g"), "<br>");
|
||||||
var temp = document.createElement('div');
|
var temp = document.createElement("div");
|
||||||
temp.innerText = spiffed;
|
temp.innerText = spiffed;
|
||||||
this.textEditor.innerHTML = temp.innerText;
|
this.textEditor.innerHTML = temp.innerText;
|
||||||
this.textEditor.style.maxWidth = '900px';
|
this.textEditor.style.maxWidth = "900px";
|
||||||
}
|
}
|
||||||
notify(type, data) {
|
notify(type, data) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DataEvent.POST_UPDATED:
|
case DataEvent.PAGE_UPDATED:
|
||||||
document.getElementById('submit-update').classList.add('icon-hide');
|
document.getElementById("submit-update").classList.add("icon-hide");
|
||||||
document.getElementById('submit-good').classList.remove('icon-hide');
|
document.getElementById("submit-good").classList.remove("icon-hide");
|
||||||
document.getElementById('edit-update').classList.remove('submit-start');
|
document.getElementById("edit-update").classList.remove("submit-start");
|
||||||
document.getElementById('edit-update').classList.add('submit-cool');
|
document.getElementById("edit-update").classList.add("submit-cool");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.getElementById('submit-update').classList.remove('icon-hide');
|
document
|
||||||
document.getElementById('submit-good').classList.add('icon-hide');
|
.getElementById("submit-update")
|
||||||
document.getElementById('edit-update').classList.add('submit-start');
|
.classList.remove("icon-hide");
|
||||||
document.getElementById('edit-update').classList.remove('submit-cool');
|
document.getElementById("submit-good").classList.add("icon-hide");
|
||||||
|
document.getElementById("edit-update").classList.add("submit-start");
|
||||||
|
document
|
||||||
|
.getElementById("edit-update")
|
||||||
|
.classList.remove("submit-cool");
|
||||||
}, 2000);
|
}, 2000);
|
||||||
break;
|
break;
|
||||||
case DataEvent.POST_ADDED:
|
case DataEvent.PAGE_ADDED:
|
||||||
// do nothing
|
// do nothing
|
||||||
break;
|
break;
|
||||||
case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:
|
case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:
|
||||||
|
@ -92,7 +100,9 @@ class TextEditor extends EventEmitter {
|
||||||
//pulled = sel.getRangeAt(0).toString();
|
//pulled = sel.getRangeAt(0).toString();
|
||||||
range.deleteContents();
|
range.deleteContents();
|
||||||
range.insertNode(
|
range.insertNode(
|
||||||
document.createTextNode('![image alt text](' + data + " 'image title')")
|
document.createTextNode(
|
||||||
|
"![image alt text](" + data + " 'image title')"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
@ -111,40 +121,44 @@ class TextEditor extends EventEmitter {
|
||||||
pulled = sel.getRangeAt(0).toString();
|
pulled = sel.getRangeAt(0).toString();
|
||||||
range.deleteContents();
|
range.deleteContents();
|
||||||
switch (e.target.id) {
|
switch (e.target.id) {
|
||||||
case 'edit-bold':
|
case "edit-bold":
|
||||||
range.insertNode(document.createTextNode('**' + pulled + '**'));
|
range.insertNode(document.createTextNode("**" + pulled + "**"));
|
||||||
break;
|
break;
|
||||||
case 'edit-italic':
|
case "edit-italic":
|
||||||
range.insertNode(document.createTextNode('*' + pulled + '*'));
|
range.insertNode(document.createTextNode("*" + pulled + "*"));
|
||||||
break;
|
break;
|
||||||
case 'edit-strikethrough':
|
case "edit-strikethrough":
|
||||||
range.insertNode(document.createTextNode('<del>' + pulled + '</del>'));
|
range.insertNode(
|
||||||
|
document.createTextNode("<del>" + pulled + "</del>")
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 'edit-header1':
|
case "edit-header1":
|
||||||
range.insertNode(document.createTextNode('# ' + pulled));
|
range.insertNode(document.createTextNode("# " + pulled));
|
||||||
break;
|
break;
|
||||||
case 'edit-header2':
|
case "edit-header2":
|
||||||
range.insertNode(document.createTextNode('## ' + pulled));
|
range.insertNode(document.createTextNode("## " + pulled));
|
||||||
break;
|
break;
|
||||||
case 'edit-header3':
|
case "edit-header3":
|
||||||
range.insertNode(document.createTextNode('### ' + pulled));
|
range.insertNode(document.createTextNode("### " + pulled));
|
||||||
break;
|
break;
|
||||||
case 'edit-image':
|
case "edit-image":
|
||||||
this.caretPos = position(this.textEditor).pos;
|
this.caretPos = position(this.textEditor).pos;
|
||||||
this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE);
|
this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE);
|
||||||
break;
|
break;
|
||||||
case 'submit-save':
|
case "submit-save":
|
||||||
case 'edit-save':
|
case "edit-save":
|
||||||
this.emitEvent(EditorEvent.EDITOR_SAVE);
|
this.emitEvent(EditorEvent.EDITOR_SAVE);
|
||||||
break;
|
break;
|
||||||
case 'submit-update':
|
case "submit-update":
|
||||||
case 'edit-update':
|
case "edit-update":
|
||||||
this.emitEvent(EditorEvent.EDITOR_UPDATE);
|
this.emitEvent(EditorEvent.EDITOR_UPDATE);
|
||||||
break;
|
break;
|
||||||
case 'edit-link':
|
case "edit-link":
|
||||||
range.insertNode(document.createTextNode('[' + pulled + '](PASTE URL HERE)'));
|
range.insertNode(
|
||||||
|
document.createTextNode("[" + pulled + "](PASTE URL HERE)")
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 'edit-delete':
|
case "edit-delete":
|
||||||
this.emitEvent(EditorEvent.EDITOR_DELETE);
|
this.emitEvent(EditorEvent.EDITOR_DELETE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
|
//** 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 **//
|
||||||
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 **//
|
||||||
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";
|
||||||
|
@ -12,20 +15,29 @@ 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";
|
||||||
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";
|
||||||
import * as DataEvent from "../com/events/DataEvent";
|
//** API TASKS **//
|
||||||
|
export const AUTH_STATUS = "getAuthStatus";
|
||||||
|
export const TASK_SITE_INIT = "blogInit";
|
||||||
|
export const TASK_BACKUP_RESTORE = "downloadBackup";
|
||||||
|
export const TASK_GET_SECRET = "retrieveSecret";
|
||||||
|
export const TASK_RESET_PASS = "resetPassword";
|
||||||
|
export const TASK_GET_CONTENT = "retrieveContent";
|
||||||
|
|
||||||
export default class FipamoAPI {
|
export default class FipamoAPI {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {}
|
constructor() {}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// public
|
// methods
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
|
||||||
|
//** MEMBER AUTH METHODS **//
|
||||||
login(data) {
|
login(data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_LOGIN,
|
API_LOGIN,
|
||||||
DataEvent.AUTH_STATUS,
|
AUTH_STATUS,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_POST,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
data
|
data
|
||||||
|
@ -42,7 +54,7 @@ export default class FipamoAPI {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_INIT,
|
API_INIT,
|
||||||
DataEvent.API_INIT,
|
TASK_SITE_INIT,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_POST,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
data
|
data
|
||||||
|
@ -61,7 +73,7 @@ export default class FipamoAPI {
|
||||||
var url, event, method, type, data;
|
var url, event, method, type, data;
|
||||||
|
|
||||||
url = API_RESTORE;
|
url = API_RESTORE;
|
||||||
event = DataEvent.API_BACKUP_RESTORE;
|
event = TASK_BACKUP_RESTORE;
|
||||||
method = REQUEST_TYPE_POST;
|
method = REQUEST_TYPE_POST;
|
||||||
type = CONTENT_TYPE_FORM;
|
type = CONTENT_TYPE_FORM;
|
||||||
data = new FormData(form);
|
data = new FormData(form);
|
||||||
|
@ -74,29 +86,12 @@ export default class FipamoAPI {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getPages(num) {
|
|
||||||
let pageNum = num;
|
|
||||||
if (pageNum === null || pageNum === "" || !pageNum) pageNum = 1;
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this._request(
|
|
||||||
API_GET_PAGES + "/" + pageNum,
|
|
||||||
DataEvent.API_GET_PAGES,
|
|
||||||
REQUEST_TYPE_GET
|
|
||||||
)
|
|
||||||
.then((result) => {
|
|
||||||
resolve(result);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getSecret(data) {
|
getSecret(data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_GET_SECRET,
|
API_GET_SECRET,
|
||||||
DataEvent.API_GET_SECRET,
|
TASK_GET_SECRET,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_POST,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
data
|
data
|
||||||
|
@ -114,7 +109,7 @@ export default class FipamoAPI {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_RESET_PASS,
|
API_RESET_PASS,
|
||||||
DataEvent.API_RESET_PASS,
|
TASK_RESET_PASS,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_POST,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
data
|
data
|
||||||
|
@ -128,11 +123,31 @@ export default class FipamoAPI {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getPage(id) {
|
//** CONTENT API METHODS **//
|
||||||
|
|
||||||
|
getPages(num, key) {
|
||||||
|
let pageNum = num;
|
||||||
|
if (pageNum === null || pageNum === "" || !pageNum) pageNum = 1;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_GET_PAGE + "/" + id,
|
API_GET_PAGES + "/" + pageNum + "?key=" + key,
|
||||||
DataEvent.API_GET_PAGES,
|
TASK_GET_CONTENT,
|
||||||
|
REQUEST_TYPE_GET
|
||||||
|
)
|
||||||
|
.then((result) => {
|
||||||
|
resolve(result);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getPage(id, key) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this._request(
|
||||||
|
API_GET_PAGE + "/" + id + "?key=" + key,
|
||||||
|
TASK_GET_CONTENT,
|
||||||
REQUEST_TYPE_GET
|
REQUEST_TYPE_GET
|
||||||
)
|
)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
|
Loading…
Reference in a new issue