save annotation data as json and sent to server

This commit is contained in:
Jonathan Jenne
2023-10-09 13:05:31 +02:00
parent 8c629691d9
commit dfadcff710
5 changed files with 75 additions and 22 deletions

View File

@@ -122,7 +122,7 @@ var App = /** @class */ (function () {
};
App.handleFinish = function (event) {
return __awaiter(this, void 0, void 0, function () {
var json, buffer, result;
var json, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, App.Instance.save()];
@@ -132,13 +132,17 @@ var App = /** @class */ (function () {
case 2:
json = _a.sent();
console.log(json);
return [4 /*yield*/, App.Instance.exportPDF({ flatten: true })];
console.log(JSON.stringify(json));
return [4 /*yield*/, 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)
*/
];
case 3:
buffer = _a.sent();
return [4 /*yield*/, App.Network.postDocument(App.envelopeKey, App.currentDocument.id, buffer)];
case 4:
result = _a.sent();
console.log(result);
return [2 /*return*/];
}
});
@@ -148,7 +152,7 @@ var App = /** @class */ (function () {
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
if (confirm("Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?")) {
if (confirm("Wollen Sie das Dokument und alle erstellten Signaturen zur<EFBFBD>cksetzen?")) {
result = App.Annotation.deleteAnnotations(App.Instance);
}
return [2 /*return*/];
@@ -275,9 +279,17 @@ var Network = /** @class */ (function () {
return fetch("/api/document/".concat(envelopeKey, "/").concat(documentId), { credentials: "include", method: "POST", body: buffer })
.then(function (res) { return res.json(); });
};
Network.prototype.postEnvelope = function (envelopeKey, documentId, buffer) {
return fetch("/api/envelope/".concat(envelopeKey, "/").concat(documentId), { credentials: "include", method: "POST", body: buffer })
.then(function (res) { return res.json(); });
Network.prototype.postEnvelope = function (envelopeKey, documentId, jsonString) {
var options = {
credentials: "include",
method: "POST",
body: jsonString
};
return fetch("/api/envelope/".concat(envelopeKey, "?index=").concat(documentId), options)
.then(function (res) {
console.log(res);
res.json();
});
};
return Network;
}());
@@ -300,7 +312,7 @@ var UI = /** @class */ (function () {
{
type: "custom",
id: "button-reset",
title: "Zurücksetzen",
title: "Zur<EFBFBD>cksetzen",
onPress: function () {
callback("RESET");
},
@@ -309,7 +321,7 @@ var UI = /** @class */ (function () {
{
type: "custom",
id: "button-finish",
title: "Abschließen",
title: "Abschlie<EFBFBD>en",
onPress: function () {
callback("FINISH");
},