improve finish handling
This commit is contained in:
@@ -50,7 +50,7 @@ export class App {
|
||||
// Load PSPDFKit
|
||||
console.debug("Loading PSPDFKit..")
|
||||
App.Instance = await App.UI.loadPSPDFKit(arrayBuffer, container)
|
||||
App.UI.configurePSPDFKit(this.Instance, App.handleClick)
|
||||
App.UI.configurePSPDFKit(this.Instance, App.handleClick)
|
||||
|
||||
// Load annotations into PSPDFKit
|
||||
console.debug("Loading annotations..")
|
||||
@@ -71,14 +71,18 @@ export class App {
|
||||
}
|
||||
|
||||
public static async handleFinish(event: any) {
|
||||
|
||||
|
||||
await App.Instance.save();
|
||||
|
||||
// Export annotation data and save to database
|
||||
const json = await App.Instance.exportInstantJSON()
|
||||
console.log(json);
|
||||
console.log(JSON.stringify(json));
|
||||
const result = await App.Network.postEnvelope(App.envelopeKey, App.currentDocument.id, JSON.stringify(json))
|
||||
const result: boolean = await App.Network.postEnvelope(App.envelopeKey, App.currentDocument.id, JSON.stringify(json))
|
||||
|
||||
if (result == true) {
|
||||
alert("Dokument erfolgreich signiert!")
|
||||
}
|
||||
|
||||
// Flatten the annotations and save the document to disk
|
||||
/*
|
||||
@@ -91,7 +95,7 @@ export class App {
|
||||
public static async handleReset(event: any) {
|
||||
if (confirm("Wollen Sie das Dokument und alle erstellten Signaturen zur<75>cksetzen?")) {
|
||||
const result = App.Annotation.deleteAnnotations(App.Instance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static async downloadDocument() {
|
||||
@@ -202,7 +206,7 @@ class Network {
|
||||
.then(res => res.json());
|
||||
}
|
||||
|
||||
public postEnvelope(envelopeKey: string, documentId: number, jsonString: string): Promise<any> {
|
||||
public postEnvelope(envelopeKey: string, documentId: number, jsonString: string): Promise<boolean> {
|
||||
const options: RequestInit = {
|
||||
credentials: "include",
|
||||
method: "POST",
|
||||
@@ -210,11 +214,23 @@ class Network {
|
||||
}
|
||||
|
||||
return fetch(`/api/envelope/${envelopeKey}?index=${documentId}`, options)
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
res.json()
|
||||
.then(this.handleResponse)
|
||||
.then((res: Response) => {
|
||||
if (!res.ok) {
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private handleResponse(res: Response) {
|
||||
if (!res.ok) {
|
||||
console.log(`Request failed with status ${res.status}`)
|
||||
return res
|
||||
} else {
|
||||
return res
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +246,7 @@ class UI {
|
||||
"zoom-mode",
|
||||
"spacer",
|
||||
"search"
|
||||
]
|
||||
]
|
||||
|
||||
// Load the PSPDFKit UI by setting a target element as the container to render in
|
||||
// and a arraybuffer which represents the document that should be displayed.
|
||||
|
||||
Reference in New Issue
Block a user