Newer
Older
//exhaustMap((data) => this.http.post(`../rest/convertedFile/encodedFile`, data.content)),
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
catchError((err: any) => {
this.notify.handleSoftErrors(err);
resolve(false);
return of(false);
})
).subscribe();
});
}
saveTmpDocument() {
return new Promise((resolve, reject) => {
this.getFile().pipe(
tap((data: any) => {
this.file = {
name: 'maarch',
format: data.format,
type: 'application/pdf',
contentMode: 'base64',
content: data.content,
src: null
};
}),
exhaustMap((data) => this.http.post(`../rest/convertedFile/encodedFile`, { format: data.format, encodedFile: data.content })),
tap((data: any) => {
this.file.src = this.base64ToArrayBuffer(data.encodedResource);
this.closeEditor();
resolve(true);
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
resolve(false);
return of(false);
})
).subscribe();
});
openResourceVersion(version: number, type: string) {
const title = type !== 'PDF' ? this.lang[type + '_version'] : `${this.lang.version} ${version}`;
// TO SHOW ORIGINAL DOC (because autoload signed doc)
type = type === 'SIGN' ? 'PDF' : type;
this.http.get(`../rest/resources/${this.resId}/content/${version}?type=${type}`).pipe(
tap((data: any) => {
this.dialog.open(DocumentViewerModalComponent, { autoFocus: false, panelClass: 'maarch-full-height-modal', data: { title: `${title}`, base64: data.encodedDocument } });
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
this.dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.lang.UNSIGN, msg: this.lang.confirmAction } });
this.dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'),
exhaustMap(() => this.http.put(`../rest/resources/${this.resId}/unsign`, {})),
tap(() => {
this.notify.success(this.lang.documentUnsigned);
this.loadRessource(this.resId);
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
isEditorLoaded() {
if (this.isEditingTemplate()) {
return this.isEditingTemplate() && this.isDocModified;
} else {
return true;
}
}
openMaarchParapheurWorkflow() {
this.dialog.open(VisaWorkflowModalComponent, { panelClass: 'maarch-modal', data: { id: this.resId, type: 'resource' } });
}