Merge branch 'feat/send-program' into 'dev'

Send program to backend in the latest form

See merge request ics/sp/2025/n25b/pepperplus-ui!22
This commit was merged in pull request #22.
This commit is contained in:
Björn Otgaar
2025-12-02 15:56:27 +00:00
2 changed files with 31 additions and 11 deletions

View File

@@ -109,9 +109,20 @@ function VisualProgrammingUI() {
// currently outputs the prepared program to the console
function runProgram() {
const program = graphReducer();
console.log(program);
const phases = graphReducer();
const program = {phases}
console.log(JSON.stringify(program, null, 2));
fetch(
"http://localhost:8000/program",
{
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify(program),
}
).then((res) => {
if (!res.ok) throw new Error("Failed communicating with the backend.")
console.log("Successfully sent the program to the backend.");
}).catch(() => console.log("Failed to send program to the backend."));
}
/**

View File

@@ -88,10 +88,20 @@ export function TriggerReduce(node: Node, nodes: Node[]) {
if (nodes.length <= -1) {
console.warn("Impossible nodes length in TriggerReduce")
}
const data = node.data as TriggerNodeData;
const data = node.data;
switch (data.triggerType) {
case "keywords":
return {
id: node.id,
type: "keywords",
label: data.label,
list: data.triggers,
keywords: data.triggers,
};
default:
return {
...data,
id: node.id,
};
}
}
@@ -129,7 +139,6 @@ export type KeywordTriggerNodeProps = {
/** Union type for all possible Trigger node configurations. */
export type TriggerNodeProps = EmotionTriggerNodeProps | KeywordTriggerNodeProps;
/**
* Renders an input element that allows users to add new keyword triggers.
*