save annotation data as json and sent to server
This commit is contained in:
@@ -71,15 +71,21 @@ 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))
|
||||
|
||||
// Flatten the annotations and save the document to disk
|
||||
/*
|
||||
const buffer = await App.Instance.exportPDF({ flatten: true });
|
||||
const result = await App.Network.postDocument(App.envelopeKey, App.currentDocument.id, buffer);
|
||||
console.log(result)
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
public static async handleReset(event: any) {
|
||||
@@ -196,11 +202,18 @@ class Network {
|
||||
.then(res => res.json());
|
||||
}
|
||||
|
||||
public postEnvelope(envelopeKey: string, documentId: number, jsonString: string): Promise<any> {
|
||||
const options: RequestInit = {
|
||||
credentials: "include",
|
||||
method: "POST",
|
||||
body: jsonString
|
||||
}
|
||||
|
||||
|
||||
public postEnvelope(envelopeKey: string, documentId: number, buffer: ArrayBuffer): Promise<any> {
|
||||
return fetch(`/api/envelope/${envelopeKey}/${documentId}`, { credentials: "include", method: "POST", body: buffer })
|
||||
.then(res => res.json());
|
||||
return fetch(`/api/envelope/${envelopeKey}?index=${documentId}`, options)
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
res.json()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user