diff --git a/app/api/signatureUpload.json b/app/api/signatureUpload.json index 281790b..0660f87 100644 --- a/app/api/signatureUpload.json +++ b/app/api/signatureUpload.json @@ -1,10 +1,52 @@ { - "name": "fileUpload", - "module": "upload", - "action": "upload", - "options": { - "fields": "" + "meta": { + "$_POST": [ + { + "type": "text", + "name": "imageData" + } + ] }, - "meta": [], - "outputType": "array" + "exec": { + "steps": { + "name": "fileUpload", + "module": "upload", + "action": "upload", + "options": { + "fields": "{{$_POST.imageData}}", + "path": "/uploads", + "replaceSpace": true, + "replaceDiacritics": true, + "asciiOnly": true + }, + "meta": [ + { + "name": "name", + "type": "text" + }, + { + "name": "path", + "type": "text" + }, + { + "name": "url", + "type": "text" + }, + { + "name": "type", + "type": "text" + }, + { + "name": "size", + "type": "text" + }, + { + "name": "error", + "type": "number" + } + ], + "outputType": "array", + "output": true + } + } } \ No newline at end of file diff --git a/app/api/uploadSignature.json b/app/api/uploadSignature.json index d2b60cc..6976a18 100644 --- a/app/api/uploadSignature.json +++ b/app/api/uploadSignature.json @@ -3,7 +3,7 @@ "$_POST": [ { "type": "text", - "name": "image" + "name": "imageData" } ] }, @@ -14,14 +14,14 @@ "module": "core", "action": "setvalue", "options": { - "key": "image", - "value": "image.replace(/^data:image\\/\\w+;base64,/, \"\")" + "value": "{{$_POST.imageData.replace(/^data:image\\/\\w+;base64,/, \"\")}}" }, "meta": [], - "outputType": "text" + "outputType": "text", + "output": true }, { - "name": "upload", + "name": "saveSignatureBinary", "module": "upload", "action": "upload", "options": { diff --git a/public/PDF/dummyFunctions.js b/public/PDF/dummyFunctions.js index f38bbda..9ae3db9 100644 --- a/public/PDF/dummyFunctions.js +++ b/public/PDF/dummyFunctions.js @@ -1,5 +1,5 @@ // JavaScript Document - +console.log("LIBRARY: dummyFunctions.js") function myFunction() { let myVar = 'Hello, Wappler!'; return myVar; @@ -22,7 +22,7 @@ async function toBase64(filePath) { } - +/** const terminal = document.getElementById('terminal'); @@ -41,4 +41,6 @@ function addLine(text) { let lineCount = 0; setInterval(() => { addLine(`Line ${++lineCount}: This is a test log.`); -}, 500); // Add a new line every 500ms \ No newline at end of file +}, 500); // Add a new line every 500ms + +*/ \ No newline at end of file diff --git a/public/PDF/pdfLibSignature.js b/public/PDF/pdfLibSignature.js index 1542100..1501776 100644 --- a/public/PDF/pdfLibSignature.js +++ b/public/PDF/pdfLibSignature.js @@ -1,5 +1,5 @@ // JavaScript Document v1.3 - +console.log("LIBRARY: pdfLibSignature.js") //let dynamicSignatureElementId = dmx.global.data.signatureElementName // Gets the DYNAMIC ID for the canvas ID const canvas = document.getElementById('signatureCanvas'); // const canvas = document.getElementById('signatureCanvasIndex'); const ctx = canvas.getContext('2d'); diff --git a/public/dmxAppConnect/config.js b/public/dmxAppConnect/config.js index 6478ec0..f9413f1 100644 --- a/public/dmxAppConnect/config.js +++ b/public/dmxAppConnect/config.js @@ -57,6 +57,10 @@ dmx.config({ { "type": "text", "name": "Points" + }, + { + "type": "text", + "name": "section" } ] }, @@ -65,6 +69,10 @@ dmx.config({ { "type": "text", "name": "file" + }, + { + "type": "text", + "name": "imageData" } ], "flowRunPageId": { @@ -87,6 +95,26 @@ dmx.config({ }, "runPageId": { "outputType": "text" + }, + "flow1": { + "meta": [ + { + "name": "saveSignatureFlow", + "type": "text" + } + ], + "local": [ + { + "name": "", + "type": "object", + "metaData": { + "alertMessage": { + "meta": null, + "outputType": "text" + } + } + } + ] } } }); diff --git a/public/example.db b/public/example.db new file mode 100644 index 0000000..6ea19b6 Binary files /dev/null and b/public/example.db differ diff --git a/public/js/libProcessScript.js b/public/js/libProcessScript.js index 9739c0c..0bebd83 100644 --- a/public/js/libProcessScript.js +++ b/public/js/libProcessScript.js @@ -1,24 +1,40 @@ // JavaScript Document // Replaces libPDFscripts.js // NEW - Process Scripts +// +// ** OFFICIAL SCRIPT TO USE WHEN IN PRODUCTION +// // Utility to fetch PDF bytes + +console.log("LIBRARY: libProcessScript.js") + //const path = FileSystemHandle.require('node:path') let showLog = true; -const dd = createDebugLogger(showLog, "dd"); +const dd = createDebugLogger(showLog, "dd"); // code function at bottom of the page -function createDebugLogger(debug, prefix = "") { - return function (message, ...optionalParams) { - if (debug) { - console.log( - `[${prefix}]`.toUpperCase(), `${message}`, - ...optionalParams - ); - } - }; + + +// Wrapper function to fetch, update, and download PDF +async function processAndDownloadPdf(filePath, ...dataSources) { + try { + const pdfBytes = await fetchPdfBytes(filePath); + const updatedPdfBytes = await updatePdfFields(pdfBytes, dataSources); + const fileName = generateRandomFilename(8, "ERT_", ".pdf"); + //const saveFilePath = await savePdfToFile(pdfBytes); + //dd("[PDF PATH]", saveFilePath); + downloadPdf(updatedPdfBytes, fileName); + } catch (err) { + dd("Error Processing PDF", err) + //console.error("Error processing the PDF:", err); + } } + + + + async function fetchPdfBytes(filePath) { dd(filePath); @@ -95,19 +111,7 @@ function generateRandomFilename(length = 8, prefix = "", suffix = "") { // Example Usage: -// Wrapper function to fetch, update, and download PDF -async function processAndDownloadPdf(filePath, ...dataSources) { - try { - const pdfBytes = await fetchPdfBytes(filePath); - const updatedPdfBytes = await updatePdfFields(pdfBytes, dataSources); - const fileName = generateRandomFilename(8, "ERT_", ".pdf"); - //const saveFilePath = await savePdfToFile(pdfBytes); - //dd("[PDF PATH]", saveFilePath); - downloadPdf(updatedPdfBytes, fileName); - } catch (err) { - console.error("Error processing the PDF:", err); - } -} + async function savePdfToFile(pdfBytes) { @@ -121,3 +125,33 @@ async function savePdfToFile(pdfBytes) { // Return a URL or file path based on your server setup return `/PDF/${randomFilename}`; } + +function createDebugLogger(debug, prefix = "DD") { + return function (message, ...optionalParams) { + + switch (debug) { + case true: + console.log( + `[${prefix}]`.toUpperCase(), `${message}`, ...optionalParams); + break + } + }; +} + +function saveSignature() { + const canvas = document.getElementById('signatureCanvas'); + const imageData = canvas.toDataURL('image/png'); + dd(imageData.length) + // Trigger the server action and handle the response + dmx.parse('serverconnect_sign.load({ image: imageData })'); + /** + dmx.parse('serverconnect_sign.load', { image: imageData }).then((response) => { + //dmx.parse('serverconnect_sign.load({image: "' + imageData + '"})').then((response) => { + const uploadedSignature = document.getElementById('uploadedSignature'); + uploadedSignature.src = response.fileUrl; // Use the file path returned from the server + dd(response.fileUrl) + }).catch((error) => { + console.error("Error uploading signature:", error); + }); +*/ +} diff --git a/public/terminal.html b/public/terminal.html new file mode 100644 index 0000000..30d040f --- /dev/null +++ b/public/terminal.html @@ -0,0 +1,56 @@ + + + +
+- +
Who you are grading
- +| - - |