From e64ed917842515dd861c1617b6cb4e87a86c0399 Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Wed, 17 Dec 2025 11:40:27 +0530 Subject: [PATCH] feat: Enhance ElementEditor with product and analysis store integration, conditional rendering for element types, and improved data mapping UI --- .../components/element/ElementEditor.tsx | 251 +++++++++--------- 1 file changed, 131 insertions(+), 120 deletions(-) diff --git a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx index 3424281..946d5f1 100644 --- a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx +++ b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx @@ -51,7 +51,10 @@ const ElementEditor: React.FC = ({ setShowSwapUI, dataModelManager, }) => { - const { simulationDashBoardStore } = useSceneContext(); + const { simulationDashBoardStore, productStore, analysisStore } = useSceneContext(); + const { products, selectedProduct, getProductById } = productStore(); + const { analysis } = analysisStore(); + const product = getProductById(selectedProduct.productName); const { getElementById } = simulationDashBoardStore(); const element = getElementById(selectedBlock, selectedElement); const [selectType, setSelectType] = useState("design"); @@ -105,40 +108,44 @@ const ElementEditor: React.FC = ({ -
-
setSelectType("design")}> - Design + {(element?.type === "graph" || element?.type === "label-value") && ( +
+
setSelectType("design")}> + Design +
+
setSelectType("data")}> + Data +
-
setSelectType("data")}> - Data -
-
+ )} {selectType === "design" && ( <> - { - if (newValue === "Line Chart") { - updateGraphType(selectedBlock, selectedElement, "line"); - return; - } else if (newValue === "Bar Chart") { - updateGraphType(selectedBlock, selectedElement, "bar"); - return; - } else if (newValue === "Pie Chart") { - updateGraphType(selectedBlock, selectedElement, "pie"); - return; - } else if (newValue === "Area Chart") { - updateGraphType(selectedBlock, selectedElement, "area"); - return; - } else if (newValue === "Radar Chart") { - updateGraphType(selectedBlock, selectedElement, "radar"); - return; - } - }} - showEyeDropper={false} - /> +
+ { + if (newValue === "Line Chart") { + updateGraphType(selectedBlock, selectedElement, "line"); + return; + } else if (newValue === "Bar Chart") { + updateGraphType(selectedBlock, selectedElement, "bar"); + return; + } else if (newValue === "Pie Chart") { + updateGraphType(selectedBlock, selectedElement, "pie"); + return; + } else if (newValue === "Area Chart") { + updateGraphType(selectedBlock, selectedElement, "area"); + return; + } else if (newValue === "Radar Chart") { + updateGraphType(selectedBlock, selectedElement, "radar"); + return; + } + }} + showEyeDropper={false} + /> +
Position
@@ -323,105 +330,109 @@ const ElementEditor: React.FC = ({ )} {selectType === "data" && (
-
- {}} /> -
- }], - }, - { - title: "Assets", - items: [ - { id: "cmm-001", label: "CMM-001", icon: }, - { id: "cnc-1", label: "CNC-Lathe-0001", icon: }, - { id: "cnc-2", label: "CNC-drilling-tapping-3Axis", icon: }, - { id: "cnc-3", label: "CNC_0001", icon: }, - ], - }, - ]} - value={null} - onChange={() => {}} - dropDownHeader={"RT-Data"} - eyedroper={true} - /> -
+ {element?.type === "label-value" && ( +
+ {}} /> +
+ }], + }, + { + title: "Assets", + items: [ + { id: "cmm-001", label: "CMM-001", icon: }, + { id: "cnc-1", label: "CNC-Lathe-0001", icon: }, + { id: "cnc-2", label: "CNC-drilling-tapping-3Axis", icon: }, + { id: "cnc-3", label: "CNC_0001", icon: }, + ], + }, + ]} + value={null} + onChange={() => {}} + dropDownHeader={"RT-Data"} + eyedroper={true} + /> +
-
- }, - { id: "measurementDeviation", label: "measurementDeviation", icon: }, - { id: "powerConsumption", label: "powerConsumption", icon: }, - { id: "probeX", label: "probePositionX", icon: }, - { id: "probeY", label: "probePositionY", icon: }, - { id: "probeZ", label: "probePositionZ", icon: }, - ], - }, - ]} - value={null} - onChange={() => {}} - dropDownHeader={"RT-Data-Value"} - /> +
+ }, + { id: "measurementDeviation", label: "measurementDeviation", icon: }, + { id: "powerConsumption", label: "powerConsumption", icon: }, + { id: "probeX", label: "probePositionX", icon: }, + { id: "probeY", label: "probePositionY", icon: }, + { id: "probeZ", label: "probePositionZ", icon: }, + ], + }, + ]} + value={null} + onChange={() => {}} + dropDownHeader={"RT-Data-Value"} + /> +
-
- + )} + <>{console.log(element)} {/* Data Mapping */} -
-
Data Mapping
+ {element?.type === "graph" && ( +
+
Data Mapping
-
-
setSelectDataMapping("singleMachine")}> - Single Machine -
-
setSelectDataMapping("multipleeMachine")}> - Multiple Machine -
-
- - {selectDataMapping === "singleMachine" && ( -
- {singleFields.map((field) => ( - {}} showEyeDropper={!!field.showEyeDropper} /> - ))} - -
-
- -
-
Add Field
+
+
setSelectDataMapping("singleMachine")}> + Single Machine +
+
setSelectDataMapping("multipleeMachine")}> + Multiple Machine
- )} - {selectDataMapping === "multipleeMachine" && ( -
- {multipleFields.map((field) => ( -
-
- {}} showEyeDropper={field.label !== "Common Value"} /> + {selectDataMapping === "singleMachine" && ( +
+ {singleFields.map((field) => ( + {}} showEyeDropper={!!field.showEyeDropper} /> + ))} + +
+
+
+
Add Field
- ))} - -
-
- -
-
Add Field
-
- )} -
+ )} + + {selectDataMapping === "multipleeMachine" && ( +
+ {multipleFields.map((field) => ( +
+
+ {}} showEyeDropper={field.label !== "Common Value"} /> +
+
+ ))} + +
+
+ +
+
Add Field
+
+
+ )} +
+ )}
)}