From 48f0c248866ef29c23f3ba292f523bdd77106ebf Mon Sep 17 00:00:00 2001 From: Felix Kaspar Date: Tue, 7 Nov 2023 02:20:44 +0100 Subject: [PATCH] Dynamic Workflows in Frontend --- client-vanilla/index.html | 20 +++++++++----------- client-vanilla/index.js | 28 ++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/client-vanilla/index.html b/client-vanilla/index.html index e49d315d..b3b9c68f 100644 --- a/client-vanilla/index.html +++ b/client-vanilla/index.html @@ -17,19 +17,17 @@ - - - +
+ +
+ +
- - + +
+ +
\ No newline at end of file diff --git a/client-vanilla/index.js b/client-vanilla/index.js index 741ba0aa..5673e4fe 100644 --- a/client-vanilla/index.js +++ b/client-vanilla/index.js @@ -4,7 +4,28 @@ import * as exampleWorkflows from "./exampleWorkflows.js"; import { traverseOperations } from "./traverseOperations.js"; import * as Functions from "./functions.js"; -(async (workflow) => { +(async () => { + const workflowField = document.getElementById("workflow"); + + const dropdown = document.getElementById("pdfOptions"); + // Clear existing options (if any) + dropdown.innerHTML = ''; + + console.log(exampleWorkflows); + // Iterate over the keys of the object and create an option for each key + for (const key in exampleWorkflows) { + const option = document.createElement('option'); + option.value = key; + option.text = key; + dropdown.appendChild(option); + } + + const loadButton = document.getElementById("loadButton"); + loadButton.addEventListener("click", (e) => { + workflowField.value = JSON.stringify(exampleWorkflows[dropdown.value], null, 2); + }); + loadButton.click(); + const pdfFileInput = document.getElementById('pdfFile'); const doneButton = document.getElementById("doneButton"); @@ -21,6 +42,8 @@ import * as Functions from "./functions.js"; })); console.log(inputs); + const workflow = JSON.parse(workflowField.value); + console.log(workflow); const traverse = traverseOperations(workflow.operations, inputs, Functions); let pdfResults; @@ -35,8 +58,9 @@ import * as Functions from "./functions.js"; console.log(`data: ${iteration.value}\n\n`); } + // TODO: Zip if wanted pdfResults.forEach(result => { download(result.buffer, result.fileName, "application/pdf"); }); }); -})(exampleWorkflows.splitOnQR); \ No newline at end of file +})(); \ No newline at end of file