Skip to content

Commit

Permalink
further work
Browse files Browse the repository at this point in the history
  • Loading branch information
Krande committed Sep 30, 2024
1 parent 9d82116 commit 1952566
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/ada/comms/msg_handling/run_procedure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def run_procedure(server: WebSocketAsyncServer, client: ConnectedClient, message
params[param.name] = param.value

procedure(**procedure.params)
logger.info(f"Procedure {procedure.name} ran successfully")
logger.info(f"Procedure {procedure.name} ran successfully")
21 changes: 18 additions & 3 deletions src/frontend/src/components/node_editor/customFileObjectNode.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import React, {memo} from 'react';
import {Handle, NodeProps, Position, Connection} from '@xyflow/react';
import {run_sequence} from "../../utils/node_editor/run_sequence";
import {get_file_object_from_server} from "../../utils/scene/get_file_object_from_server";


const doc_icon = <svg width="12px" height="24px" viewBox="0 0 24 24" strokeWidth="1.5" fill="none" xmlns="http://www.w3.org/2000/svg" color="#000000"><path d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z" stroke="#000000" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"></path><path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" stroke="#000000" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"></path></svg>

function CustomFileObjectNode(props: { id: string, data: Record<string, string> }) {
// Custom connection validation function for `file_object` handle
const isValidConnection = () => {
console.log("isValidConnection");
return true;
};
// console.log("ProcedureNode data:", data);
return (
<div className="bg-gray-200 text-gray-800 rounded-md min-w-24">
{/* Header Row */}
<div className="flex justify-center items-center mb-4">
<div className="font-bold text-center text-xs">"{props.data.label}"</div>
<div className="flex flex-row justify-center items-center p-2">
<div className={"flex-1"}>{doc_icon} </div>
<div className={"flex-1 text-center text-xs"}>{props.data.label}</div>
<div className={"flex-1 text-xs"}> [{props.data.filetype}]</div>
</div>
<div className={"flex justify-center items-center text-xs"}>
<button
className="bg-blue-500 hover:bg-blue-700 text-white p-2 rounded"
onClick={() => {
get_file_object_from_server(props.data.fileobject);
}}
>
View
</button>
</div>

{/* Handle Rows */}
Expand Down
24 changes: 20 additions & 4 deletions src/frontend/src/components/node_editor/customProcedureNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@ import React, {memo} from 'react';
import {Handle, NodeProps, Position, Connection} from '@xyflow/react';
import {run_sequence} from "../../utils/node_editor/run_sequence";

function ProcedureNode(props:{id: string, data:Record<string, string>}) {
const procedure_icon = <svg width="12px" height="12px" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M17 15H14.5H12" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round"/>
<path
d="M7 10L7.2344 10.1953C8.51608 11.2634 9.15693 11.7974 9.15693 12.5C9.15693 13.2026 8.51608 13.7366 7.2344 14.8047L7 15"
stroke="#1C274C" stroke-width="1.5" stroke-linecap="round"/>
<path
d="M22 12C22 16.714 22 19.0711 20.5355 20.5355C19.0711 22 16.714 22 12 22C7.28595 22 4.92893 22 3.46447 20.5355C2 19.0711 2 16.714 2 12C2 7.28595 2 4.92893 3.46447 3.46447C4.92893 2 7.28595 2 12 2C16.714 2 19.0711 2 20.5355 3.46447C21.5093 4.43821 21.8356 5.80655 21.9449 8"
stroke="#1C274C" stroke-width="1.5" stroke-linecap="round"/>
</svg>


function ProcedureNode(props: { id: string, data: Record<string, string> }) {
// Custom connection validation function for `file_object` handle
const isValidConnection = () => {
console.log("isValidConnection");
return true;
};
// console.log("ProcedureNode data:", data);
return (
<div className="bg-gray-200 text-gray-800 rounded-md w-56 h-30">
<div className="bg-gray-200 text-gray-800 rounded-md min-w-40 h-30">
{/* Header Row */}
<div className="flex flex-col justify-center items-center mb-4">
<div className="font-bold text-center text-xs">{props.data.label}</div>
<div className={"flex flex-row"}>
<div>{procedure_icon}</div>
<div className="font-bold text-center text-xs">{props.data.label}</div>
</div>

<button
className={"flex relative bg-blue-700 hover:bg-blue-700/50 text-white text-xs px-4 rounded"}
onClick={() => run_sequence(props.id)}
Expand Down Expand Up @@ -64,7 +80,7 @@ function ProcedureNode(props:{id: string, data:Record<string, string>}) {
</div>
</div>
</div>
);
);
}

export default memo(ProcedureNode);
4 changes: 2 additions & 2 deletions src/frontend/src/utils/fb_handling/handle_incoming_buffers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CommandType, Message} from '../../flatbuffers/wsock'
import * as flatbuffers from "flatbuffers";
import {reply_ping} from "./reply_ping";
import {update_scene} from "../scene/update_scene";
import {update_scene_from_message} from "../scene/update_scene_from_message";
import {receive_mesh_info_reply} from "../mesh_select/receive_mesh_info_reply";
import {update_nodes} from "../node_editor/update_nodes";

Expand All @@ -14,7 +14,7 @@ export const handleFlatbufferMessage = (buffer: ArrayBuffer) => {
if (command_type === CommandType.PING) {
reply_ping(message);
} else if (command_type === CommandType.UPDATE_SCENE) {
update_scene(message);
update_scene_from_message(message);
update_nodes(message);
} else if (command_type === CommandType.MESH_INFO_REPLY) {
receive_mesh_info_reply(message);
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/src/utils/node_editor/update_nodes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Message} from '../../flatbuffers/wsock';
import {FileType, Message} from '../../flatbuffers/wsock';
import {useNodeEditorStore} from '../../state/useNodeEditorStore'; // Import the node editor Zustand store


Expand Down Expand Up @@ -31,7 +31,8 @@ export const update_nodes = (message: Message) => {
label: fileObject.name(),
description: fileObject.fileType().toString(),
filepath: fileObject.filepath(),
filetype: fileObject.fileType().toString(),
filetype: FileType[fileObject.fileType()].toString(),
fileobject: fileObject,
},
};
newNodes.push(node);
Expand Down
5 changes: 5 additions & 0 deletions src/frontend/src/utils/scene/get_file_object_from_server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {FileObject} from "../../flatbuffers/wsock/file-object";

export function get_file_object_from_server(fileobject_name: string) {
console.log("get_file_object_from_server" + fileobject_name);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Message} from "../../flatbuffers/wsock/message";
import {useModelStore} from "../../state/modelStore";

export const update_scene = (message: Message) => {
export const update_scene_from_message = (message: Message) => {
console.log('Received scene update message from server');
let scene = message.scene();
if (!scene) {
Expand Down

0 comments on commit 1952566

Please sign in to comment.