forked from projects/fipamo
updated src files for backup patch
This commit is contained in:
parent
15fafdf107
commit
2d96e55bc6
2 changed files with 62 additions and 1 deletions
|
@ -27,6 +27,9 @@ export const API_PAGE_WRITE = 'writingItDown';
|
||||||
export const API_PAGE_CREATE = 'writingNewEntry';
|
export const API_PAGE_CREATE = 'writingNewEntry';
|
||||||
export const API_PAGE_DELETE = 'erasingPage';
|
export const API_PAGE_DELETE = 'erasingPage';
|
||||||
export const API_SETTINGS_WRITE = 'savingSettings';
|
export const API_SETTINGS_WRITE = 'savingSettings';
|
||||||
|
export const API_BACKUP_CREATE = 'createBackup';
|
||||||
|
export const API_BACKUP_DOWNLOAD = 'downloadBackup';
|
||||||
|
export const API_BACKUP_RESTORE = 'downloadBackup';
|
||||||
export const API_IMAGES_UPLOAD = 'uploadProfileImages';
|
export const API_IMAGES_UPLOAD = 'uploadProfileImages';
|
||||||
export const API_RENDER_PAGES = 'renderPages';
|
export const API_RENDER_PAGES = 'renderPages';
|
||||||
export const API_INIT = 'blogInit';
|
export const API_INIT = 'blogInit';
|
||||||
|
|
|
@ -18,6 +18,10 @@ 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/backup/create';
|
||||||
|
export const API_DOWNLOAD_BACKUP = '/api/v1/backup/download';
|
||||||
|
export const API_RESTORE_BACKUP = '/api/v1/backup/restore';
|
||||||
|
export const API_INIT_RESTORE_BACKUP = '/api/v1/backup/init-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 {
|
||||||
|
@ -188,6 +192,58 @@ export default class APIUtils {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
handleBackup(id, files) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var url, event, method, type, data;
|
||||||
|
|
||||||
|
if (id === 'create-backup') {
|
||||||
|
url = API_CREATE_BACKUP;
|
||||||
|
event = DataEvent.API_BACKUP_CREATE;
|
||||||
|
method = REQUEST_TYPE_POST;
|
||||||
|
type = CONTENT_TYPE_JSON;
|
||||||
|
data = { task: 'create_backup' };
|
||||||
|
} else {
|
||||||
|
url = API_RESTORE_BACKUP;
|
||||||
|
event = DataEvent.API_BACKUP_RESTORE;
|
||||||
|
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, type, data)
|
||||||
|
.then(result => {
|
||||||
|
resolve(result);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
handleInitRestore(form) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var url, event, method, type, data;
|
||||||
|
|
||||||
|
url = API_INIT_RESTORE_BACKUP;
|
||||||
|
event = DataEvent.API_BACKUP_RESTORE;
|
||||||
|
method = REQUEST_TYPE_POST;
|
||||||
|
type = CONTENT_TYPE_FORM;
|
||||||
|
data = new FormData(form);
|
||||||
|
this._request(url, event, method, type, data)
|
||||||
|
.then(result => {
|
||||||
|
resolve(result);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// private
|
// private
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -218,7 +274,9 @@ export default class APIUtils {
|
||||||
eventType === DataEvent.API_IMAGES_UPLOAD ||
|
eventType === DataEvent.API_IMAGES_UPLOAD ||
|
||||||
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_RESTORE
|
||||||
)
|
)
|
||||||
request.setRequestHeader('x-access-token', self.token);
|
request.setRequestHeader('x-access-token', self.token);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue