chore: now it works
This commit is contained in:
@@ -172,41 +172,6 @@ function VisualProgrammingUI() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// currently outputs the prepared program to the console
|
|
||||||
function runProgram() {
|
|
||||||
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.");
|
|
||||||
|
|
||||||
// store reduced program in global program store for further use in the UI
|
|
||||||
// when the program was sent to the backend successfully:
|
|
||||||
useProgramStore.getState().setProgramState(structuredClone(program));
|
|
||||||
}).catch(() => console.log("Failed to send program to the backend."));
|
|
||||||
console.log(program);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reduces the graph into its phases' information and recursively calls their reducing function
|
|
||||||
*/
|
|
||||||
function graphReducer() {
|
|
||||||
const { nodes } = useFlowStore.getState();
|
|
||||||
return orderPhaseNodeArray(nodes.filter((n) => n.type == 'phase') as PhaseNode [])
|
|
||||||
.map((n) => {
|
|
||||||
const reducer = NodeReduces['phase'];
|
|
||||||
return reducer(n, nodes)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const checkPhaseChain = (): boolean => {
|
const checkPhaseChain = (): boolean => {
|
||||||
const {nodes, edges} = useFlowStore.getState();
|
const {nodes, edges} = useFlowStore.getState();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user