forked from projects/fipamo
updated AdminAPI for remote use, removed UtilityAPI from public library (methods should only be local)
This commit is contained in:
parent
b9056b64df
commit
2785ef6982
5 changed files with 33 additions and 30 deletions
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,6 @@
|
||||||
import FipamoAdminAPI from "../libraries/FipamoAdminAPI";
|
import FipamoAdminAPI from "../libraries/FipamoAdminAPI";
|
||||||
import FipamoUtilityAPI from "../libraries/FipamoUtilityAPI";
|
//import FipamoUtilityAPI from "../libraries/FipamoUtilityAPI";
|
||||||
|
import Maintenance from "./controllers/MaintenanceManager";
|
||||||
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";
|
||||||
|
@ -90,10 +91,9 @@ export default class Base {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let setUpForm = data.formDataToJSON(document.getElementById("init-form"));
|
let setUpForm = data.formDataToJSON(document.getElementById("init-form"));
|
||||||
let api = new FipamoUtilityAPI();
|
let mm = new Maintenance();
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
api
|
mm.create(setUpForm)
|
||||||
.create(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;
|
||||||
|
@ -117,11 +117,10 @@ export default class Base {
|
||||||
let self = this;
|
let self = this;
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let api = new FipamoUtilityAPI();
|
let mm = new Maintenance();
|
||||||
var form = document.getElementById("init-restore");
|
var form = document.getElementById("init-restore");
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
api
|
mm.restore(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;
|
||||||
|
@ -144,15 +143,14 @@ export default class Base {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let self = this;
|
let self = this;
|
||||||
let api = new FipamoUtilityAPI();
|
let mm = new Maintenance();
|
||||||
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
|
mm.secret(data)
|
||||||
.secret(data)
|
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
if (response.secret) {
|
if (response.secret) {
|
||||||
|
@ -176,8 +174,7 @@ export default class Base {
|
||||||
newPassConfirm: document.getElementById("new_password2").value,
|
newPassConfirm: document.getElementById("new_password2").value,
|
||||||
secret: document.getElementById("secret").value
|
secret: document.getElementById("secret").value
|
||||||
};
|
};
|
||||||
api
|
mm.newPass(data)
|
||||||
.newPass(data)
|
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
if (response.type == "passNotCreated") {
|
if (response.type == "passNotCreated") {
|
||||||
|
|
|
@ -27,7 +27,6 @@ export const TASK_RESET_PASS = "resetPassword";
|
||||||
export const TASK_UPLOAD_FILES = "uploadFiles";
|
export const TASK_UPLOAD_FILES = "uploadFiles";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fipamo Utility API
|
|
||||||
* A tub of methods for creating/restoring installs, resetting passwords and uploading images.
|
* A tub of methods for creating/restoring installs, resetting passwords and uploading images.
|
||||||
*/
|
*/
|
||||||
class FipamoUtilityAPI {
|
class FipamoUtilityAPI {
|
|
@ -4,7 +4,7 @@ import FipamoAdminAPI, {
|
||||||
TASK_PAGE_EDIT,
|
TASK_PAGE_EDIT,
|
||||||
TASK_PAGE_DELETE
|
TASK_PAGE_DELETE
|
||||||
} from "../../libraries/FipamoAdminAPI";
|
} from "../../libraries/FipamoAdminAPI";
|
||||||
import FipamoUtilityAPI from "../../libraries/FipamoUtilityAPI";
|
import Maintenance from "MaintenanceManager";
|
||||||
import * as DataEvent from "../events/DataEvent";
|
import * as DataEvent from "../events/DataEvent";
|
||||||
import PageActions from "../actions/PageActions";
|
import PageActions from "../actions/PageActions";
|
||||||
import * as EditorEvent from "../events/EditorEvent";
|
import * as EditorEvent from "../events/EditorEvent";
|
||||||
|
@ -250,9 +250,8 @@ export default class PostEditor {
|
||||||
handleImageUpload(type, files) {
|
handleImageUpload(type, files) {
|
||||||
let self = this;
|
let self = this;
|
||||||
notify.alert("Uploading Image", null);
|
notify.alert("Uploading Image", null);
|
||||||
let utils = new FipamoUtilityAPI();
|
let mm = new Maintenance();
|
||||||
utils
|
mm.imageUpload(type, files)
|
||||||
.imageUpload(type, files)
|
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
if (r.type == DataEvent.POST_IMAGE_ADDED)
|
if (r.type == DataEvent.POST_IMAGE_ADDED)
|
||||||
self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, r.url);
|
self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, r.url);
|
||||||
|
|
|
@ -32,13 +32,14 @@ export const API_ACCESS_GOOD = "apiConnected";
|
||||||
export const API_ACCESS_BAD = "apiNotConnected";
|
export const API_ACCESS_BAD = "apiNotConnected";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fipamo Administration API
|
* A can of methods used to edit install settings, navigation pages.
|
||||||
* A pocket full of methods used to edit install settings, navigation pages.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FipamoAdminAPI {
|
class FipamoAdminAPI {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @param {string} baseURL - url of site; uses local when empty
|
||||||
|
* @param {string} key - user api key
|
||||||
*/
|
*/
|
||||||
constructor(baseURL = null, key = null) {
|
constructor(baseURL = null, key = null) {
|
||||||
this.percentComplete = 0; //for later
|
this.percentComplete = 0; //for later
|
||||||
|
@ -58,9 +59,9 @@ class FipamoAdminAPI {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Method for retrieving user authorizing user login
|
* Method for retrieving user authorizing user login
|
||||||
|
* @param {object} data - json object that contains data for set up
|
||||||
* @property {string} handle - handle for site user
|
* @property {string} handle - handle for site user
|
||||||
* @property {string} password - password for site user
|
* @property {string} password - password for site user
|
||||||
* @param {object} data - json object that contains data for set up
|
|
||||||
*/
|
*/
|
||||||
login(data) {
|
login(data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -108,7 +109,7 @@ class FipamoAdminAPI {
|
||||||
syncSettings(data) {
|
syncSettings(data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_SETTINGS_SYNC,
|
this.baseURL ? this.baseURL + API_SETTINGS_SYNC : API_SETTINGS_SYNC,
|
||||||
TASK_SETTINGS_WRITE,
|
TASK_SETTINGS_WRITE,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_POST,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
|
@ -131,7 +132,8 @@ class FipamoAdminAPI {
|
||||||
publishSite(data) {
|
publishSite(data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_PUBLISH_PAGES,
|
//API_PUBLISH_PAGES,
|
||||||
|
this.baseURL ? this.baseURL + API_PUBLISH_PAGES : API_PUBLISH_PAGES,
|
||||||
TASK_PUBLISH_SITE,
|
TASK_PUBLISH_SITE,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_POST,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
|
@ -189,7 +191,13 @@ class FipamoAdminAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(url, event, REQUEST_TYPE_POST, content, data)
|
this._request(
|
||||||
|
this.baseURL ? this.baseURL + url : url,
|
||||||
|
event,
|
||||||
|
REQUEST_TYPE_POST,
|
||||||
|
content,
|
||||||
|
data
|
||||||
|
)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
resolve(result);
|
resolve(result);
|
||||||
})
|
})
|
||||||
|
@ -210,7 +218,7 @@ class FipamoAdminAPI {
|
||||||
syncNav(data) {
|
syncNav(data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_NAV_SYNC,
|
this.baseURL ? this.baseURL + API_NAV_SYNC : API_NAV_SYNC,
|
||||||
TASK_SETTINGS_WRITE,
|
TASK_SETTINGS_WRITE,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_POST,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
|
@ -232,7 +240,7 @@ class FipamoAdminAPI {
|
||||||
sendMail(message) {
|
sendMail(message) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_SEND_MAIL,
|
this.baseURL ? this.baseURL + API_SEND_MAIL : API_SEND_MAIL,
|
||||||
TASK_SEND_MAIL,
|
TASK_SEND_MAIL,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_POST,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
|
@ -253,7 +261,7 @@ class FipamoAdminAPI {
|
||||||
reindexPages(data) {
|
reindexPages(data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._request(
|
this._request(
|
||||||
API_REINDEX_PAGES,
|
this.baseURL ? this.baseURL + API_REINDEX_PAGES : API_REINDEX_PAGES,
|
||||||
TASK_REINDEX_PAGE,
|
TASK_REINDEX_PAGE,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_POST,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
|
|
Loading…
Reference in a new issue