mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
[WIP] Backup process outline
This commit is contained in:
parent
8bbb0d3e82
commit
4094677792
18 changed files with 678 additions and 220 deletions
|
@ -17,15 +17,36 @@ export default Component.extend(Notifier, {
|
|||
appMeta: service(),
|
||||
browserSvc: service('browser'),
|
||||
buttonLabel: 'Run Backup',
|
||||
backupSpec: null,
|
||||
backupFilename: '',
|
||||
backupError: false,
|
||||
backupSuccess: false,
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
this.set('backupSpec', {
|
||||
retain: true,
|
||||
org: '*'
|
||||
// org: this.get('appMeta.orgId')
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
onBackup() {
|
||||
this.showWait();
|
||||
this.set('buttonLabel', 'Please wait, backup running...');
|
||||
this.set('backupFilename', '');
|
||||
this.set('backupSuccess', false);
|
||||
this.set('backupFailed', false);
|
||||
|
||||
this.get('onBackup')({}).then(() => {
|
||||
this.get('onBackup')(this.get('backupSpec')).then((filename) => {
|
||||
this.set('buttonLabel', 'Run Backup');
|
||||
this.showDone();
|
||||
this.set('backupSuccess', true);
|
||||
this.set('backupFilename', filename);
|
||||
}, ()=> {
|
||||
this.set('buttonLabel', 'Run Backup');
|
||||
this.set('backupFailed', true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
{{#if session.isGlobalAdmin}}
|
||||
{{#link-to 'customize.license' activeClass='selected' class="tab tab-vertical" tagName="li" }}Product{{/link-to}}
|
||||
{{/if}}
|
||||
{{#link-to 'customize.backup' activeClass='selected' class="tab tab-vertical" tagName="li" }}Backup & Restore{{/link-to}}
|
||||
</ul>
|
||||
</div>
|
||||
{{/layout/middle-zone-sidebar}}
|
||||
|
|
|
@ -143,7 +143,7 @@ export default Service.extend({
|
|||
|
||||
// Run tenant level backup.
|
||||
backup(spec) {
|
||||
return new EmberPromise((resolve) => {
|
||||
return new EmberPromise((resolve, reject) => {
|
||||
let url = this.get('appMeta.endpoint');
|
||||
let token = this.get('sessionService.session.content.authenticated.token');
|
||||
let uploadUrl = `${url}/global/backup?token=${token}`;
|
||||
|
@ -162,18 +162,26 @@ export default Service.extend({
|
|||
a.style = "display: none";
|
||||
document.body.appendChild(a);
|
||||
|
||||
let filename = xhr.getResponseHeader('x-documize-filename').replace('"', '');
|
||||
|
||||
let url = window.URL.createObjectURL(blob);
|
||||
a.href = url;
|
||||
a.download = xhr.getResponseHeader('x-documize-filename').replace('"', '');
|
||||
a.download = filename;
|
||||
a.click();
|
||||
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
|
||||
resolve();
|
||||
resolve(filename);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
|
||||
xhr.onerror= function() {
|
||||
reject();
|
||||
}
|
||||
|
||||
xhr.send(JSON.stringify(spec));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="view-customize">
|
||||
|
@ -12,7 +11,14 @@
|
|||
<form class="mt-5 ">
|
||||
<div class="form-group">
|
||||
<p>It can take several minutes to complete the backup process — please be patient while the backup is running.</p>
|
||||
<div class="btn btn-success mt-3" {{action 'onBackup'}}>{{buttonLabel}}</div>
|
||||
<div class="btn btn-success my-5" {{action 'onBackup'}}>{{buttonLabel}}</div>
|
||||
{{#if backupFailed}}
|
||||
<p class="text-danger">Backup failed — please check server logs</p>
|
||||
{{/if}}
|
||||
{{#if backupSuccess}}
|
||||
<p>Backup successful ({{backupFilename}})</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue