|
|
@ -18,8 +18,9 @@ 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_CREATE_BACKUP = '/api/v1/settings/create-backup';
|
|
|
|
export const API_CREATE_BACKUP = '/api/v1/backup/create';
|
|
|
|
export const API_DOWNLOAD_BACKUP = '/api/v1/settings/download-backup';
|
|
|
|
export const API_DOWNLOAD_BACKUP = '/api/v1/backup/download';
|
|
|
|
|
|
|
|
export const API_RESTORE_BACKUP = '/api/v1/backup/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 {
|
|
|
@ -190,19 +191,32 @@ export default class APIUtils {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleBackup(data) {
|
|
|
|
handleBackup(id, files) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
var url, event, method;
|
|
|
|
var url, event, method, type, data;
|
|
|
|
if (data.task === '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;
|
|
|
|
|
|
|
|
data = { task: 'create_backup' };
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
url = API_DOWNLOAD_BACKUP;
|
|
|
|
url = API_RESTORE_BACKUP;
|
|
|
|
event = DataEvent.API_BACKUP_DOWNLOAD;
|
|
|
|
event = DataEvent.API_BACKUP_RESTORE;
|
|
|
|
method = REQUEST_TYPE_GET;
|
|
|
|
method = REQUEST_TYPE_POST;
|
|
|
|
|
|
|
|
type = CONTENT_TYPE_FORM;
|
|
|
|
|
|
|
|
data = new FormData();
|
|
|
|
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
|
|
|
|
var file = files[i];
|
|
|
|
|
|
|
|
// Check the file type.
|
|
|
|
|
|
|
|
if (!file.type.match('application.zip')) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
data.append('backup_upload', file, file.name);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this._request(url, event, method, CONTENT_TYPE_JSON, data)
|
|
|
|
this._request(url, event, method, type, data)
|
|
|
|
.then(result => {
|
|
|
|
.then(result => {
|
|
|
|
resolve(result);
|
|
|
|
resolve(result);
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -242,7 +256,8 @@ export default class APIUtils {
|
|
|
|
eventType === DataEvent.API_SETTINGS_WRITE ||
|
|
|
|
eventType === DataEvent.API_SETTINGS_WRITE ||
|
|
|
|
eventType === DataEvent.API_PAGE_DELETE ||
|
|
|
|
eventType === DataEvent.API_PAGE_DELETE ||
|
|
|
|
eventType === DataEvent.API_RENDER_PAGES ||
|
|
|
|
eventType === DataEvent.API_RENDER_PAGES ||
|
|
|
|
eventType === DataEvent.API_BACKUP_CREATE
|
|
|
|
eventType === DataEvent.API_BACKUP_CREATE ||
|
|
|
|
|
|
|
|
eventType === DataEvent.API_BACKUP_RESTORE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
request.setRequestHeader('x-access-token', self.token);
|
|
|
|
request.setRequestHeader('x-access-token', self.token);
|
|
|
|
|
|
|
|
|
|
|
|