edited method names for Content and Utility API, updated base class

pull/84/head
Ro 3 years ago
parent 45fd8be25f
commit 8101b16cf9

File diff suppressed because one or more lines are too long

@ -93,7 +93,7 @@ export default class Base {
let api = new FipamoUtilityAPI(); let api = new FipamoUtilityAPI();
this.processing = true; this.processing = true;
api api
.init(setUpForm) .restore(setUpForm)
.then((response) => { .then((response) => {
if (response.type === DataEvent.API_INIT_LAME) { if (response.type === DataEvent.API_INIT_LAME) {
self.processing = false; self.processing = false;
@ -121,7 +121,7 @@ export default class Base {
var form = document.getElementById("init-restore"); var form = document.getElementById("init-restore");
this.processing = true; this.processing = true;
api api
.handleInitRestore(form) .restore(form)
.then((response) => { .then((response) => {
if (response.type === DataEvent.REQUEST_LAME) { if (response.type === DataEvent.REQUEST_LAME) {
self.processing = false; self.processing = false;
@ -152,7 +152,7 @@ export default class Base {
}; };
this.processing = true; this.processing = true;
api api
.getSecret(data) .secret(data)
.then((response) => { .then((response) => {
self.processing = false; self.processing = false;
if (response.secret) { if (response.secret) {
@ -177,7 +177,7 @@ export default class Base {
secret: document.getElementById("secret").value secret: document.getElementById("secret").value
}; };
api api
.setNewPass(data) .newPass(data)
.then((response) => { .then((response) => {
self.processing = false; self.processing = false;
if (response.type == "passNotCreated") { if (response.type == "passNotCreated") {

@ -11,8 +11,8 @@ export const CONTENT_TYPE_FORM = "x-www-form-urlencoded";
//** API URLS **// //** API URLS **//
export const API_GET_PAGES = "/api/v1/page/published"; export const API_GET_PAGES = "/api/v1/page/published";
export const API_GET_FEATURED = "/api/v1/page/featured"; export const API_GET_FEATURED = "/api/v1/page/featured";
export const API_GET_MENU = "/api/v1/page/menu";
export const API_GET_PAGE = "/api/v1/page/single"; export const API_GET_PAGE = "/api/v1/page/single";
export const API_GET_MENU = "/api/v1/page/menu";
export const API_GET_TAGS = "/api/v1/page/tags"; export const API_GET_TAGS = "/api/v1/page/tags";
//** API TASKS **// //** API TASKS **//
@ -20,15 +20,12 @@ export const TASK_GET_CONTENT = "retrieveContent";
/** /**
* Fipamo Content API * Fipamo Content API
* class for retrieving page data from install
*/ */
export default class FipamoAPI { export default class FipamoAPI {
//--------------------------
// constructor
//--------------------------
/** /**
* @constructor * @constructor
* @param {string} baseURL - url of site * @param {string} baseURL - url of site; uses local when empty
* @param {string} key - user api key * @param {string} key - user api key
*/ */
constructor(baseURL = null, key = null) { constructor(baseURL = null, key = null) {
@ -41,32 +38,29 @@ export default class FipamoAPI {
// methods // methods
//-------------------------- //--------------------------
getPages(key) { /**
return new Promise((resolve, reject) => { * Method for retrieving page data
this._request( * @param {string} type - type of pages being retrieved; defaults to published
this.baseURL */
? this.baseURL + API_GET_PAGES + "?key=" + key pages(type = null) {
: API_GET_PAGES, //set url based on request type
TASK_GET_CONTENT, let requestURL = "";
REQUEST_TYPE_GET switch (type) {
) default:
.then((result) => { case "published":
resolve(result); requestURL = API_GET_PAGES + "?key=" + this.key;
}) break;
.catch((err) => { case "featured":
reject(err); requestURL = API_GET_FEATURED + "?key=" + this.key;
}); break;
}); case "menu":
requestURL = API_GET_MENU + "?key=" + this.key;
break;
} }
getFeatured(key) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._request( this._request(
this.baseURL this.baseURL ? this.baseURL + requestURL : requestURL,
? this.baseURL + API_GET_FEATURED + "?key=" + key TASK_GET_CONTENT
: API_GET_FEATURED,
TASK_GET_CONTENT,
REQUEST_TYPE_GET
) )
.then((result) => { .then((result) => {
resolve(result); resolve(result);
@ -76,13 +70,16 @@ export default class FipamoAPI {
}); });
}); });
} }
/**
getMenu(key) { * Method for retrieving single page
* @param {string} id - uuid of desired page
*/
page(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._request( this._request(
this.baseURL this.baseURL
? this.baseURL + API_GET_MENU + "?key=" + key ? this.baseURL + API_GET_PAGE + "/" + id + "?key=" + this.key
: API_GET_MENU, : API_GET_PAGE + "/" + id + "?key=" + this.key,
TASK_GET_CONTENT, TASK_GET_CONTENT,
REQUEST_TYPE_GET REQUEST_TYPE_GET
) )
@ -95,12 +92,15 @@ export default class FipamoAPI {
}); });
} }
getTags(key) { /**
* Method for retrieving all tags used by pages
*/
tags() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._request( this._request(
this.baseURL this.baseURL
? this.baseURL + API_GET_TAGS + "?key=" + key ? this.baseURL + API_GET_TAGS + "?key=" + this.key
: API_GET_TAGS, : API_GET_TAGS + "?key=" + this.key,
TASK_GET_CONTENT, TASK_GET_CONTENT,
REQUEST_TYPE_GET REQUEST_TYPE_GET
) )
@ -113,24 +113,6 @@ export default class FipamoAPI {
}); });
} }
getPage(id, key) {
return new Promise((resolve, reject) => {
this._request(
//API_GET_PAGE + "/" + id + "?key=" + key,
this.baseURL
? this.baseURL + API_GET_PAGE + "/" + id + "?key=" + key
: API_GET_PAGE,
TASK_GET_CONTENT,
REQUEST_TYPE_GET
)
.then((result) => {
resolve(result);
})
.catch((err) => {
reject(err);
});
});
}
//-------------------------- //--------------------------
// private // private
//-------------------------- //--------------------------
@ -162,12 +144,6 @@ export default class FipamoAPI {
"Content-type", "Content-type",
"application/" + contentType "application/" + contentType
); );
/**
request.setRequestHeader(
"Access-Control-Allow-Origin",
self.baseURL
);
**/
request.send(JSON.stringify(requestData)); request.send(JSON.stringify(requestData));
break; break;
case CONTENT_TYPE_FORM: case CONTENT_TYPE_FORM:

@ -46,7 +46,7 @@ export default class FipamoUtilityAPI {
//** MEMBER AUTH METHODS **// //** MEMBER AUTH METHODS **//
initNew(data) { create(data) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._request( this._request(
API_INIT, API_INIT,
@ -64,7 +64,7 @@ export default class FipamoUtilityAPI {
}); });
} }
initRestore(form) { restore(form) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var url, event, method, type, data; var url, event, method, type, data;

1295
src/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -8,9 +8,15 @@
"repository": "https://code.playvicio.us/Are0h/Fipamo", "repository": "https://code.playvicio.us/Are0h/Fipamo",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@babel/core": "^7.14.6",
"@babel/eslint-parser": "^7.14.5",
"animejs": "^3.2.1", "animejs": "^3.2.1",
"bulma": "^0.9.2", "bulma": "^0.9.2",
"caret-pos": "^2.0.0", "caret-pos": "^2.0.0",
"sortablejs": "^1.13.0" "sortablejs": "^1.13.0"
},
"devDependencies": {
"eslint": "^7.28.0",
"eslint-plugin-babel": "^5.3.1"
} }
} }

Loading…
Cancel
Save