Newer
Older
return formatdatas;
}),
exhaustMap((data) => this.http.put(`../rest/resources/${this.resId}?onlyDocument=true`, data)),
tap(() => {
this.closeEditor();
this.loadRessource(this.resId);
resolve(true);
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
resolve(false);
return of(false);
})
).subscribe();
});
}
loadTmpDocument(base64Content: string, format: string) {
return new Promise((resolve, reject) => {
this.http.post(`../rest/convertedFile/encodedFile`, { format: format, encodedFile: base64Content }).pipe(
tap((data: any) => {
console.log(data);
this.file = {
name: 'maarch',
format: format,
type: 'application/pdf',
contentMode: 'base64',
content: base64Content,
src: this.base64ToArrayBuffer(data.encodedResource)
};
}),
// exhaustMap((data) => this.http.post(`../rest/convertedFile/encodedFile`, data.content)),
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
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' } });
}