forked from projects/fipamo
edited method names for Content and Utility API, updated base class
This commit is contained in:
parent
45fd8be25f
commit
8101b16cf9
6 changed files with 1358 additions and 81 deletions
4
public/assets/scripts/dash.min.js
vendored
4
public/assets/scripts/dash.min.js
vendored
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,12 +38,48 @@ export default class FipamoAPI {
|
||||||
// methods
|
// methods
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
|
||||||
getPages(key) {
|
/**
|
||||||
|
* Method for retrieving page data
|
||||||
|
* @param {string} type - type of pages being retrieved; defaults to published
|
||||||
|
*/
|
||||||
|
pages(type = null) {
|
||||||
|
//set url based on request type
|
||||||
|
let requestURL = "";
|
||||||
|
switch (type) {
|
||||||
|
default:
|
||||||
|
case "published":
|
||||||
|
requestURL = API_GET_PAGES + "?key=" + this.key;
|
||||||
|
break;
|
||||||
|
case "featured":
|
||||||
|
requestURL = API_GET_FEATURED + "?key=" + this.key;
|
||||||
|
break;
|
||||||
|
case "menu":
|
||||||
|
requestURL = API_GET_MENU + "?key=" + this.key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this._request(
|
||||||
|
this.baseURL ? this.baseURL + requestURL : requestURL,
|
||||||
|
TASK_GET_CONTENT
|
||||||
|
)
|
||||||
|
.then((result) => {
|
||||||
|
resolve(result);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 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_PAGES + "?key=" + key
|
? this.baseURL + API_GET_PAGE + "/" + id + "?key=" + this.key
|
||||||
: API_GET_PAGES,
|
: API_GET_PAGE + "/" + id + "?key=" + this.key,
|
||||||
TASK_GET_CONTENT,
|
TASK_GET_CONTENT,
|
||||||
REQUEST_TYPE_GET
|
REQUEST_TYPE_GET
|
||||||
)
|
)
|
||||||
|
@ -59,12 +92,15 @@ export default class FipamoAPI {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getFeatured(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_FEATURED + "?key=" + key
|
? this.baseURL + API_GET_TAGS + "?key=" + this.key
|
||||||
: API_GET_FEATURED,
|
: API_GET_TAGS + "?key=" + this.key,
|
||||||
TASK_GET_CONTENT,
|
TASK_GET_CONTENT,
|
||||||
REQUEST_TYPE_GET
|
REQUEST_TYPE_GET
|
||||||
)
|
)
|
||||||
|
@ -77,60 +113,6 @@ export default class FipamoAPI {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getMenu(key) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this._request(
|
|
||||||
this.baseURL
|
|
||||||
? this.baseURL + API_GET_MENU + "?key=" + key
|
|
||||||
: API_GET_MENU,
|
|
||||||
TASK_GET_CONTENT,
|
|
||||||
REQUEST_TYPE_GET
|
|
||||||
)
|
|
||||||
.then((result) => {
|
|
||||||
resolve(result);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getTags(key) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this._request(
|
|
||||||
this.baseURL
|
|
||||||
? this.baseURL + API_GET_TAGS + "?key=" + key
|
|
||||||
: API_GET_TAGS,
|
|
||||||
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,
|
|
||||||
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
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…
Reference in a new issue