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>
</data>
<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>
<data name="GridReceivers.Location" type="System.Drawing.Point, System.Drawing">
<value>14, 35</value>
@ -787,13 +787,13 @@
<value>0</value>
</data>
<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 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 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>
<data name="OpenFileDialog1.Filter" xml:space="preserve">
<value>PDF Files|*.pdf</value>

View File

@ -5,7 +5,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - EnvelopeGenerator.Web</title>
<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="~/EnvelopeGenerator.Web.styles.css" asp-append-version="true" />
</head>
<body>
@ -15,6 +17,7 @@
<script src="~/lib/jquery/dist/jquery.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/annotation.js" asp-append-version="true"></script>
<script src="~/js/network.js" asp-append-version="true"></script>

View File

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

View File

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

View File

@ -1,16 +1,13 @@
class Network {
getEnvelope(envelopeKey) {
return fetch(
`/api/envelope/${envelopeKey}`,
this.withCSRFToken({ credentials: 'include' })
).then((res) => res.json())
return fetch(`/api/envelope/${envelopeKey}`, this.withCSRFToken({ credentials: 'include' }))
.then(this.wrapJsonResponse.bind(this))
}
getDocument(envelopeKey, documentId) {
return fetch(
`/api/document/${envelopeKey}?index=${documentId}`,
this.withCSRFToken({ credentials: 'include' })
).then((res) => res.arrayBuffer())
return fetch(`/api/document/${envelopeKey}?index=${documentId}`, this.withCSRFToken({ credentials: 'include' }))
.then(this.wrapBinaryResponse.bind(this))
}
postEnvelope(envelopeKey, documentId, jsonString) {
@ -39,8 +36,6 @@
actionType: actionType,
}
console.log(data)
const options = {
credentials: 'include',
method: 'POST',
@ -71,6 +66,28 @@
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) {
if (!res.ok) {
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) {
// Check if the annotation is a signature
// This will allow new signatures, but not allow edits.
console.log(annotation.isSignature, annotation.description)
if (
annotation.isSignature ||
annotation.description == 'FRAME'
@ -56,9 +54,6 @@
}
annotationRenderer(data) {
console.log(data)
console.log(data.annotation.toJS())
// leave everything as is
return null
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long