Add history inserts, add controllers

This commit is contained in:
Jonathan Jenne
2023-11-02 16:30:57 +01:00
parent 3f4f4681b5
commit 47d02aefee
14 changed files with 428 additions and 135 deletions

View File

@@ -39,6 +39,17 @@ var Rect = PSPDFKit.Geometry.Rect;
var SignatureFormField = PSPDFKit.FormFields.SignatureFormField;
var _a = PSPDFKit.ElectronicSignatureCreationMode, DRAW = _a.DRAW, TYPE = _a.TYPE;
var DISABLED = PSPDFKit.AutoSaveMode.DISABLED;
var ActionType;
(function (ActionType) {
ActionType[ActionType["Created"] = 0] = "Created";
ActionType[ActionType["Saved"] = 1] = "Saved";
ActionType[ActionType["Sent"] = 2] = "Sent";
ActionType[ActionType["EmailSent"] = 3] = "EmailSent";
ActionType[ActionType["Delivered"] = 4] = "Delivered";
ActionType[ActionType["Seen"] = 5] = "Seen";
ActionType[ActionType["Signed"] = 6] = "Signed";
ActionType[ActionType["Rejected"] = 7] = "Rejected";
})(ActionType || (ActionType = {}));
var App = /** @class */ (function () {
function App() {
}
@@ -46,7 +57,7 @@ var App = /** @class */ (function () {
// and will trigger loading of the Editor Interface
App.init = function (container, envelopeKey) {
return __awaiter(this, void 0, void 0, function () {
var envelopeObject, arrayBuffer, e_1, _a, annotations, createdAnnotations;
var envelopeObject, arrayBuffer, e_1, _a, annotations, createdAnnotations, description;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
@@ -90,6 +101,10 @@ var App = /** @class */ (function () {
return [4 /*yield*/, App.Instance.create(annotations)];
case 7:
createdAnnotations = _b.sent();
description = "Umschlag wurde geöffnet";
return [4 /*yield*/, App.Network.postHistory(App.envelopeKey, ActionType.Seen, description)];
case 8:
_b.sent();
return [2 /*return*/];
}
});
@@ -136,7 +151,7 @@ var App = /** @class */ (function () {
};
App.handleFinish = function (event) {
return __awaiter(this, void 0, void 0, function () {
var e_2, json, postEnvelopeResult, e_3, buffer, postDocumentResult, e_4;
var e_2, json, postEnvelopeResult, e_3, buffer, postDocumentResult, e_4, description, e_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
@@ -181,7 +196,18 @@ var App = /** @class */ (function () {
e_4 = _a.sent();
console.error(e_4);
return [2 /*return*/, false];
case 11: return [2 /*return*/, true];
case 11:
_a.trys.push([11, 13, , 14]);
description = "Dokument wurde signiert";
return [4 /*yield*/, App.Network.postHistory(App.envelopeKey, ActionType.Signed, description)];
case 12:
_a.sent();
return [3 /*break*/, 14];
case 13:
e_5 = _a.sent();
console.error(e_5);
return [2 /*return*/, false];
case 14: return [2 /*return*/, true];
}
});
});
@@ -318,7 +344,7 @@ var Network = /** @class */ (function () {
.then(function (res) { return res.arrayBuffer(); });
};
Network.prototype.postDocument = function (envelopeKey, documentId, buffer) {
var url = "/api/document/".concat(envelopeKey, "/").concat(documentId);
var url = "/api/document/".concat(envelopeKey, "?index=").concat(documentId);
var options = {
credentials: "include",
method: "POST",
@@ -353,6 +379,31 @@ var Network = /** @class */ (function () {
return true;
});
};
Network.prototype.postHistory = function (envelopeKey, actionType, actionDescription) {
var url = "/api/history/".concat(envelopeKey);
var data = {
actionDescription: actionDescription,
actionType: actionType.toString()
};
var options = {
credentials: "include",
method: "POST",
headers: {
'Content-Type': "application/json; charset=utf-8"
},
body: JSON.stringify(data)
};
console.debug("PostHistory/Calling url: " + url);
return fetch(url, options)
.then(this.handleResponse)
.then(function (res) {
if (!res.ok) {
return false;
}
;
return true;
});
};
Network.prototype.handleResponse = function (res) {
if (!res.ok) {
console.log("Request failed with status ".concat(res.status));