This commit is contained in:
Jonathan Jenne 2023-11-27 16:36:23 +01:00
parent e52eca809e
commit 38577f66e0
8 changed files with 99 additions and 53 deletions

View File

@ -447,7 +447,7 @@
<value>0, 0</value> <value>0, 0</value>
</data> </data>
<metadata name="EnvelopeReceiverBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="EnvelopeReceiverBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 95</value> <value>338, 17</value>
</metadata> </metadata>
<data name="GridReceivers.Location" type="System.Drawing.Point, System.Drawing"> <data name="GridReceivers.Location" type="System.Drawing.Point, System.Drawing">
<value>14, 35</value> <value>14, 35</value>
@ -787,13 +787,13 @@
<value>0</value> <value>0</value>
</data> </data>
<metadata name="FrmEditorBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="FrmEditorBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 173</value> <value>801, 17</value>
</metadata> </metadata>
<metadata name="EnvelopeDocumentBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="EnvelopeDocumentBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 134</value> <value>564, 17</value>
</metadata> </metadata>
<metadata name="OpenFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="OpenFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 56</value> <value>196, 17</value>
</metadata> </metadata>
<data name="OpenFileDialog1.Filter" xml:space="preserve"> <data name="OpenFileDialog1.Filter" xml:space="preserve">
<value>PDF Files|*.pdf</value> <value>PDF Files|*.pdf</value>

View File

@ -5,7 +5,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - EnvelopeGenerator.Web</title> <title>@ViewData["Title"] - EnvelopeGenerator.Web</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/lib/sweetalert2/sweetalert2.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /> <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/EnvelopeGenerator.Web.styles.css" asp-append-version="true" /> <link rel="stylesheet" href="~/EnvelopeGenerator.Web.styles.css" asp-append-version="true" />
</head> </head>
<body> <body>
@ -15,6 +17,7 @@
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/lib/sweetalert2/sweetalert2.min.js"></script>
<script src="~/js/ui.js" asp-append-version="true"></script> <script src="~/js/ui.js" asp-append-version="true"></script>
<script src="~/js/annotation.js" asp-append-version="true"></script> <script src="~/js/annotation.js" asp-append-version="true"></script>
<script src="~/js/network.js" asp-append-version="true"></script> <script src="~/js/network.js" asp-append-version="true"></script>

View File

@ -74,13 +74,11 @@
left, left,
page page
) )
console.log(annotation)
const formField = new PSPDFKit.FormFields.SignatureFormField({ const formField = new PSPDFKit.FormFields.SignatureFormField({
name: id, name: id,
annotationIds: PSPDFKit.Immutable.List([annotation.id]), annotationIds: PSPDFKit.Immutable.List([annotation.id]),
}) })
console.log(formField)
return [annotation, formField] return [annotation, formField]
} }

View File

@ -30,41 +30,47 @@ class App {
async init() { async init() {
// Load the envelope from the database // Load the envelope from the database
console.debug('Loading envelope from database..') console.debug('Loading envelope from database..')
const envelopeObject = await this.Network.getEnvelope(this.envelopeKey) const envelopeResponse = await this.Network.getEnvelope(this.envelopeKey)
this.currentDocument = envelopeObject.envelope.documents[0] const envelopeError = !!envelopeResponse.error
this.currentReceiver = envelopeObject.receiver
console.log(envelopeObject) if (envelopeError) {
return Swal.fire({
title: "Fehler",
text: "Umschlag konnte nicht geladen werden!",
icon: "error"
})
}
this.currentDocument = envelopeResponse.data.envelope.documents[0]
this.currentReceiver = envelopeResponse.data.receiver
// Load the document from the filestore // Load the document from the filestore
console.debug('Loading document from filestore') console.debug('Loading document from filestore')
let arrayBuffer const documentResponse = await this.Network.getDocument(
try { this.envelopeKey,
arrayBuffer = await this.Network.getDocument( this.currentDocument.id
this.envelopeKey, )
this.currentDocument.id const documentError = !!documentResponse.error
)
} catch (e) { if (documentError) {
console.error(e) console.error(documentResponse.error)
return Swal.fire({
title: "Fehler",
text: "Dokument konnte nicht geladen werden!",
icon: "error"
})
} }
const arrayBuffer = documentResponse.data
// Load PSPDFKit // Load PSPDFKit
console.debug('Loading PSPDFKit..') console.debug('Loading PSPDFKit..')
this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container) this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container)
this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this)) this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this))
this.Instance.addEventListener( this.Instance.addEventListener('annotations.load', this.handleAnnotationsLoad)
'annotations.load', this.Instance.addEventListener('annotations.change', this.handleAnnotationsChange)
this.handleAnnotationsLoad this.Instance.addEventListener('annotations.create', this.handleAnnotationsCreate.bind(this))
)
this.Instance.addEventListener(
'annotations.change',
this.handleAnnotationsChange
)
this.Instance.addEventListener(
'annotations.create',
this.handleAnnotationsCreate.bind(this)
)
// Load annotations into PSPDFKit // Load annotations into PSPDFKit
console.debug('Loading annotations..') console.debug('Loading annotations..')
@ -124,9 +130,17 @@ class App {
result = await this.handleReset(null) result = await this.handleReset(null)
if (result == true) { if (result == true) {
alert('Dokument zurückgesetzt!') Swal.fire({
title: "Erfolg",
text: "Dokument wurde zurückgesetzt",
icon: "info"
})
} else { } else {
alert('Fehler beim Zurücksetzen des Dokuments!') Swal.fire({
title: "Fehler",
text: "Dokument konnte nicht zurückgesetzt werden!",
icon: "error"
})
} }
break break
@ -180,15 +194,21 @@ class App {
} }
async handleReset(event) { async handleReset(event) {
if ( const result = await Swal.fire({
confirm( title: "Sind sie sicher?",
'Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?' text: "Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?",
) icon: "question"
) { })
if (result.isConfirmed) {
const result = this.Annotation.deleteAnnotations(this.Instance) const result = this.Annotation.deleteAnnotations(this.Instance)
return true return true
} else { }
if (result.isDimissed) {
return true return true
} }
return false
} }
} }

View File

@ -1,16 +1,13 @@
class Network { class Network {
getEnvelope(envelopeKey) { getEnvelope(envelopeKey) {
return fetch( return fetch(`/api/envelope/${envelopeKey}`, this.withCSRFToken({ credentials: 'include' }))
`/api/envelope/${envelopeKey}`, .then(this.wrapJsonResponse.bind(this))
this.withCSRFToken({ credentials: 'include' })
).then((res) => res.json())
} }
getDocument(envelopeKey, documentId) { getDocument(envelopeKey, documentId) {
return fetch( return fetch(`/api/document/${envelopeKey}?index=${documentId}`, this.withCSRFToken({ credentials: 'include' }))
`/api/document/${envelopeKey}?index=${documentId}`, .then(this.wrapBinaryResponse.bind(this))
this.withCSRFToken({ credentials: 'include' })
).then((res) => res.arrayBuffer())
} }
postEnvelope(envelopeKey, documentId, jsonString) { postEnvelope(envelopeKey, documentId, jsonString) {
@ -39,8 +36,6 @@
actionType: actionType, actionType: actionType,
} }
console.log(data)
const options = { const options = {
credentials: 'include', credentials: 'include',
method: 'POST', method: 'POST',
@ -71,6 +66,28 @@
return options return options
} }
async wrapJsonResponse(response) {
return await this.wrapResponse(response, async (res) => await res.json())
}
async wrapBinaryResponse(response) {
return await this.wrapResponse(response, async (res) => await res.arrayBuffer())
}
async wrapResponse(response, responseHandler) {
let wrappedResponse
if (response.ok) {
const data = await responseHandler(response)
wrappedResponse = new WrappedResponse(data, null)
} else {
const error = await response.json()
wrappedResponse = new WrappedResponse(null, error)
}
return wrappedResponse
}
handleResponse(res) { handleResponse(res) {
if (!res.ok) { if (!res.ok) {
console.log(`Request failed with status ${res.status}`) console.log(`Request failed with status ${res.status}`)
@ -80,3 +97,10 @@
} }
} }
} }
class WrappedResponse {
constructor(data, error) {
this.data = data
this.error = error
}
}

View File

@ -29,8 +29,6 @@
isEditableAnnotation: function (annotation) { isEditableAnnotation: function (annotation) {
// Check if the annotation is a signature // Check if the annotation is a signature
// This will allow new signatures, but not allow edits. // This will allow new signatures, but not allow edits.
console.log(annotation.isSignature, annotation.description)
if ( if (
annotation.isSignature || annotation.isSignature ||
annotation.description == 'FRAME' annotation.description == 'FRAME'
@ -56,9 +54,6 @@
} }
annotationRenderer(data) { annotationRenderer(data) {
console.log(data)
console.log(data.annotation.toJS())
// leave everything as is // leave everything as is
return null return null
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long