diff --git a/EnvelopeGenerator.Common/Entities/EnvelopeHistoryEntry.vb b/EnvelopeGenerator.Common/Entities/EnvelopeHistoryEntry.vb index 23652c96..81cb8681 100644 --- a/EnvelopeGenerator.Common/Entities/EnvelopeHistoryEntry.vb +++ b/EnvelopeGenerator.Common/Entities/EnvelopeHistoryEntry.vb @@ -2,7 +2,5 @@ Public EnvelopeId As Integer Public UserReference As String Public ActionType As Constants.EnvelopeHistoryActionType - Public ActionDescription As String - Public ActionDate As DateTime - + Public ActionDate As Date End Class diff --git a/EnvelopeGenerator.Common/Models/HistoryModel.vb b/EnvelopeGenerator.Common/Models/HistoryModel.vb index c0e11286..733f4b70 100644 --- a/EnvelopeGenerator.Common/Models/HistoryModel.vb +++ b/EnvelopeGenerator.Common/Models/HistoryModel.vb @@ -7,6 +7,15 @@ Public Class HistoryModel MyBase.New(pState) End Sub + Private Function GetActionDescription(pActionType As Constants.EnvelopeHistoryActionType) + Select Case pActionType + Case Constants.EnvelopeHistoryActionType.Created + Return "Umschlag erfolgreich erstellt" + Case Else + Return pActionType.ToString() + End Select + End Function + Public Function Insert(pHistory As EnvelopeHistoryEntry) As Boolean Try Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_HISTORY] " @@ -26,7 +35,7 @@ Public Class HistoryModel oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pHistory.EnvelopeId oCommand.Parameters.Add("USER_REFERENCE", SqlDbType.NVarChar).Value = pHistory.UserReference oCommand.Parameters.Add("ACTION_TYPE", SqlDbType.Int).Value = pHistory.ActionType - oCommand.Parameters.Add("ACTION_DESCRIPTION", SqlDbType.NVarChar).Value = pHistory.ActionDescription + oCommand.Parameters.Add("ACTION_DESCRIPTION", SqlDbType.NVarChar).Value = GetActionDescription(pHistory.ActionType) oCommand.Parameters.Add("ACTION_DATE", SqlDbType.DateTime).Value = Now() If Database.ExecuteNonQuery(oCommand) Then diff --git a/EnvelopeGenerator.Form/Controllers/EnvelopeEditorController.vb b/EnvelopeGenerator.Form/Controllers/EnvelopeEditorController.vb index 2e75d7c4..2f11939b 100644 --- a/EnvelopeGenerator.Form/Controllers/EnvelopeEditorController.vb +++ b/EnvelopeGenerator.Form/Controllers/EnvelopeEditorController.vb @@ -96,7 +96,6 @@ Public Class EnvelopeEditorController Dim newHistoryEntry As New EnvelopeHistoryEntry With { .EnvelopeId = oEnvelope.Id, .ActionType = EnvelopeHistoryActionType.Created, - .ActionDescription = "Envelope wurde neu erstellt", .UserReference = oEnvelope.User.Email } diff --git a/EnvelopeGenerator.Web/Controllers/DocumentController.cs b/EnvelopeGenerator.Web/Controllers/DocumentController.cs index 963bd218..d13dbfa4 100644 --- a/EnvelopeGenerator.Web/Controllers/DocumentController.cs +++ b/EnvelopeGenerator.Web/Controllers/DocumentController.cs @@ -40,36 +40,5 @@ namespace EnvelopeGenerator.Web.Controllers return ErrorResponse(e); } } - - - //[HttpPost] - //[Route("api/document/{envelopeKey}")] - //public async Task Update(string envelopeKey) - //{ - // try - // { - // logger.Info("DocumentController/Update"); - - // // Validate Envelope Key and load envelope - // envelopeService.EnsureValidEnvelopeKey(envelopeKey); - // EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey); - - // // Load Document info - // var Request = ControllerContext.HttpContext.Request; - // var document = envelopeService.GetDocument(Request, envelopeKey); - - // // Update the document with new data - // await envelopeService.UpdateDocument(Request.Body, document.Filepath); - - // // Add history entry - // envelopeService.InsertHistoryEntrySigned(response); - - // return Ok(); - // } - // catch (Exception e) - // { - // return ErrorResponse(e); - // } - //} } } diff --git a/EnvelopeGenerator.Web/Controllers/HistoryController.cs b/EnvelopeGenerator.Web/Controllers/HistoryController.cs index 96d46be5..2e06259b 100644 --- a/EnvelopeGenerator.Web/Controllers/HistoryController.cs +++ b/EnvelopeGenerator.Web/Controllers/HistoryController.cs @@ -8,7 +8,6 @@ namespace EnvelopeGenerator.Web.Controllers public class ActionObject { public string? ActionType { get; set; } - public string? ActionDescription { get; set; } } public class HistoryController : BaseController @@ -33,7 +32,6 @@ namespace EnvelopeGenerator.Web.Controllers EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey); string actionTypeString = action.ActionType; - string actionDescription = action.ActionDescription; if (!Enum.TryParse(actionTypeString, out var actionType)) { @@ -42,7 +40,6 @@ namespace EnvelopeGenerator.Web.Controllers envelopeService.InsertHistoryEntry(new EnvelopeHistoryEntry() { - ActionDescription = actionDescription, ActionDate = DateTime.Now, ActionType = actionType, EnvelopeId = response.Envelope.Id, diff --git a/EnvelopeGenerator.Web/Services/EnvelopeService.cs b/EnvelopeGenerator.Web/Services/EnvelopeService.cs index d4811196..82a654c3 100644 --- a/EnvelopeGenerator.Web/Services/EnvelopeService.cs +++ b/EnvelopeGenerator.Web/Services/EnvelopeService.cs @@ -110,7 +110,6 @@ namespace EnvelopeGenerator.Web.Services { return historyModel.Insert(new EnvelopeHistoryEntry() { - ActionDescription = "Dokument wurde signiert", ActionDate = DateTime.Now, ActionType = EnvelopeHistoryActionType.Signed, EnvelopeId = response.Envelope.Id, diff --git a/EnvelopeGenerator.Web/package-lock.json b/EnvelopeGenerator.Web/package-lock.json new file mode 100644 index 00000000..90966259 --- /dev/null +++ b/EnvelopeGenerator.Web/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "EnvelopeGenerator.Web", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "prettier": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.0.tgz", + "integrity": "sha512-TQLvXjq5IAibjh8EpBIkNKxO749UEWABoiIZehEPiY4GNpVdhaFKqSTu+QrlU6D2dPAfubRmtJTi4K4YkQ5eXw==" + } + } +} diff --git a/EnvelopeGenerator.Web/package.json b/EnvelopeGenerator.Web/package.json new file mode 100644 index 00000000..09eb9352 --- /dev/null +++ b/EnvelopeGenerator.Web/package.json @@ -0,0 +1,15 @@ +{ + "name": "EnvelopeGenerator.Web", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "prettier": "^3.1.0" + } +} diff --git a/EnvelopeGenerator.Web/prettier.config.js b/EnvelopeGenerator.Web/prettier.config.js new file mode 100644 index 00000000..4b099337 --- /dev/null +++ b/EnvelopeGenerator.Web/prettier.config.js @@ -0,0 +1,8 @@ +const config = { + trailingComma: "es5", + tabWidth: 4, + semi: false, + singleQuote: true, +}; + +export default config; \ No newline at end of file diff --git a/EnvelopeGenerator.Web/wwwroot/js/annotation.js b/EnvelopeGenerator.Web/wwwroot/js/annotation.js index 8fddcad8..8adc01c3 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/annotation.js +++ b/EnvelopeGenerator.Web/wwwroot/js/annotation.js @@ -70,6 +70,35 @@ return annotation } + async createFrameAnnotation(annotation, receiver) { + const left = annotation.boundingBox.left - 25; + const top = annotation.boundingBox.top - 25; + const width = 150; + const height = 75; + + const imageUrl = await this.Annotation.createAnnotationFrameBlob(receiver.name, width, height); + const request = await fetch(imageUrl); + const blob = await request.blob(); + + const imageAttachmentId = await this.Instance.createAttachment(blob); + const frameAnnotation = new PSPDFKit.Annotations.ImageAnnotation({ + pageIndex: annotation.pageIndex, + isSignature: false, + readOnly: true, + locked: true, + lockedContents: true, + contentType: 'image/png', + imageAttachmentId, + description: 'FRAME', + boundingBox: new PSPDFKit.Geometry.Rect({ + left: left, + top: top, + width: width, + height: height, + }), + }); + } + async createAnnotationFrameBlob(receiverName, width, height) { const canvas = document.createElement("canvas"); canvas.width = width; diff --git a/EnvelopeGenerator.Web/wwwroot/js/app.js b/EnvelopeGenerator.Web/wwwroot/js/app.js index cd44bb98..e4ce77bb 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/app.js +++ b/EnvelopeGenerator.Web/wwwroot/js/app.js @@ -62,8 +62,7 @@ class App { const annotations = this.Annotation.createAnnotations(this.currentDocument) const createdAnnotations = await this.Instance.create(annotations) - const description = "Umschlag wurde geöffnet" - await this.Network.postHistory(this.envelopeKey, ActionType.Seen, description); + await this.Network.postHistory(this.envelopeKey, ActionType.Seen) } catch (e) { console.error(e) } @@ -77,47 +76,12 @@ class App { handleAnnotationsChange() {} async handleAnnotationsCreate(createdAnnotations) { - console.log("annotations created"); - - console.log(createdAnnotations.toJS()) - const annotation = createdAnnotations.toJS()[0]; const isFormField = !!annotation.formFieldName; const isSignature = !!annotation.isSignature; if (isFormField === false && isSignature === true) { - - const left = annotation.boundingBox.left - 25; - const top = annotation.boundingBox.top - 25; - const width = 150; - const height = 75; - - console.log(annotation.boundingBox) - - const imageUrl = await this.Annotation.createAnnotationFrameBlob(this.currentReceiver.name, width, height); - - const request = await fetch(imageUrl); - const blob = await request.blob(); - const imageAttachmentId = await this.Instance.createAttachment(blob); - const frameAnnotation = new PSPDFKit.Annotations.ImageAnnotation({ - pageIndex: annotation.pageIndex, - isSignature: false, - readOnly: true, - locked: true, - lockedContents: true, - contentType: 'image/png', - imageAttachmentId, - description: 'FRAME', - boundingBox: new PSPDFKit.Geometry.Rect({ - left: left, - top: top, - width: width, - height: height, - }), - }); - - this.Instance.create(frameAnnotation); - + await this.Annotation.createFrameAnnotation(annotation, this.currentReceiver) } } @@ -169,6 +133,9 @@ class App { return false; } + // Redirect to success page after saving to database + window.location.href = `/EnvelopeKey/${this.envelopeKey}/Success` + } catch (e) { console.error(e); return false; diff --git a/EnvelopeGenerator.Web/wwwroot/js/network.js b/EnvelopeGenerator.Web/wwwroot/js/network.js index 0251b306..7a83a3dd 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/network.js +++ b/EnvelopeGenerator.Web/wwwroot/js/network.js @@ -9,25 +9,6 @@ .then(res => res.arrayBuffer()); } - postDocument(envelopeKey, documentId, buffer) { - const url = `/api/document/${envelopeKey}?index=${documentId}`; - const options = { - credentials: "include", - method: "POST", - body: buffer - } - - console.debug("PostDocument/Calling url: " + url) - return fetch(url, this.withCSRFToken(options)) - .then(this.handleResponse) - .then((res) => { - if (!res.ok) { - return false; - }; - return true; - }); - } - postEnvelope(envelopeKey, documentId, jsonString) { const url = `/api/envelope/${envelopeKey}?index=${documentId}`; const options = { @@ -47,12 +28,11 @@ }); } - postHistory(envelopeKey, actionType, actionDescription) { + postHistory(envelopeKey, actionType) { const url = `/api/history/${envelopeKey}`; const data = { - actionDescription: actionDescription, - actionType: actionType.toString() + actionType: actionType } const options = {