feat: Update ElementEditor to handle data value changes and refactor data source initialization in simulation store
This commit is contained in:
@@ -566,7 +566,9 @@ const ElementEditor: React.FC<ElementEditorProps> = ({
|
|||||||
placeholder="Select Value"
|
placeholder="Select Value"
|
||||||
sections={getLableValueDropdownItems(element.dataSource as string | undefined)}
|
sections={getLableValueDropdownItems(element.dataSource as string | undefined)}
|
||||||
value={element.dataValue ? { id: element.dataValue, label: element.dataValue, icon: <ParametersIcon /> } : null}
|
value={element.dataValue ? { id: element.dataValue, label: element.dataValue, icon: <ParametersIcon /> } : null}
|
||||||
onChange={() => {}}
|
onChange={(value) => {
|
||||||
|
updateDataValue(selectedBlock, selectedElement, value.id);
|
||||||
|
}}
|
||||||
dropDownHeader={"RT-Data-Value"}
|
dropDownHeader={"RT-Data-Value"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,15 +11,7 @@ import { useFrame, useThree } from "@react-three/fiber";
|
|||||||
|
|
||||||
import { useSceneContext } from "../scene/sceneContext";
|
import { useSceneContext } from "../scene/sceneContext";
|
||||||
import { useBuilderStore } from "../../store/builder/useBuilderStore";
|
import { useBuilderStore } from "../../store/builder/useBuilderStore";
|
||||||
import {
|
import { useToggleView, useWallVisibility, useRoofVisibility, useShadows, useToolMode, useRenderDistance, useLimitDistance } from "../../store/builder/store";
|
||||||
useToggleView,
|
|
||||||
useWallVisibility,
|
|
||||||
useRoofVisibility,
|
|
||||||
useShadows,
|
|
||||||
useToolMode,
|
|
||||||
useRenderDistance,
|
|
||||||
useLimitDistance,
|
|
||||||
} from "../../store/builder/store";
|
|
||||||
|
|
||||||
////////// 3D Function Imports //////////
|
////////// 3D Function Imports //////////
|
||||||
|
|
||||||
@@ -98,7 +90,7 @@ export default function Builder() {
|
|||||||
<AssetsGroup plane={plane} />
|
<AssetsGroup plane={plane} />
|
||||||
|
|
||||||
<mesh name="Walls-And-WallAssets-Group">
|
<mesh name="Walls-And-WallAssets-Group">
|
||||||
<Geometry ref={csgRef} useGroups>
|
<Geometry ref={csgRef} useGroups computeVertexNormals>
|
||||||
<WallGroup />
|
<WallGroup />
|
||||||
|
|
||||||
<WallAssetGroup />
|
<WallAssetGroup />
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ interface SimulationDashboardStore {
|
|||||||
setSelectedElement: (elementId: string | null) => void;
|
setSelectedElement: (elementId: string | null) => void;
|
||||||
|
|
||||||
// Block operations
|
// Block operations
|
||||||
addBlock: (newBlock : Block) => void;
|
addBlock: (newBlock: Block) => void;
|
||||||
removeBlock: (blockId: string) => void;
|
removeBlock: (blockId: string) => void;
|
||||||
updateBlock: (blockId: string, updates: Partial<Block>) => void;
|
updateBlock: (blockId: string, updates: Partial<Block>) => void;
|
||||||
clearBlocks: () => void;
|
clearBlocks: () => void;
|
||||||
@@ -252,8 +252,8 @@ export const createSimulationDashboardStore = () => {
|
|||||||
...commonProps,
|
...commonProps,
|
||||||
type: "label-value",
|
type: "label-value",
|
||||||
title: "Label Value",
|
title: "Label Value",
|
||||||
dataSource: "machine-1",
|
dataSource: "",
|
||||||
dataValue: "metric-1",
|
dataValue: "",
|
||||||
style: {
|
style: {
|
||||||
color: "#ffffff",
|
color: "#ffffff",
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
@@ -301,16 +301,16 @@ export const createSimulationDashboardStore = () => {
|
|||||||
...baseGraphProps,
|
...baseGraphProps,
|
||||||
dataType: "multiple-machine" as const,
|
dataType: "multiple-machine" as const,
|
||||||
title: "Multi Machine Chart",
|
title: "Multi Machine Chart",
|
||||||
dataSource: ["machine-1", "machine-2", "machine-3"],
|
dataSource: ["", "", ""],
|
||||||
commonValue: "metric-1",
|
commonValue: "",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
newElement = {
|
newElement = {
|
||||||
...baseGraphProps,
|
...baseGraphProps,
|
||||||
dataType: "single-machine" as const,
|
dataType: "single-machine" as const,
|
||||||
title: "Single Machine Chart",
|
title: "Single Machine Chart",
|
||||||
dataSource: "machine-1",
|
dataSource: "",
|
||||||
dataValue: ["metric-1", "metric-2", "metric-3"],
|
dataValue: ["", "", ""],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -619,7 +619,7 @@ export const createSimulationDashboardStore = () => {
|
|||||||
...commonProps,
|
...commonProps,
|
||||||
type: "label-value",
|
type: "label-value",
|
||||||
title: "Label Value",
|
title: "Label Value",
|
||||||
dataSource: "machine-1",
|
dataSource: "",
|
||||||
dataValue: "metric-1",
|
dataValue: "metric-1",
|
||||||
style: {
|
style: {
|
||||||
color: "#ffffff",
|
color: "#ffffff",
|
||||||
@@ -668,16 +668,16 @@ export const createSimulationDashboardStore = () => {
|
|||||||
...baseGraphProps,
|
...baseGraphProps,
|
||||||
dataType: "multiple-machine" as const,
|
dataType: "multiple-machine" as const,
|
||||||
title: "Multi Machine Chart",
|
title: "Multi Machine Chart",
|
||||||
dataSource: ["machine-1", "machine-2", "machine-3"],
|
dataSource: ["", "", ""],
|
||||||
commonValue: "metric-1",
|
commonValue: "",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
newElement = {
|
newElement = {
|
||||||
...baseGraphProps,
|
...baseGraphProps,
|
||||||
dataType: "single-machine" as const,
|
dataType: "single-machine" as const,
|
||||||
title: "Single Machine Chart",
|
title: "Single Machine Chart",
|
||||||
dataSource: "machine-1",
|
dataSource: "",
|
||||||
dataValue: ["metric-1", "metric-2", "metric-3"],
|
dataValue: ["", "", ""],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -882,6 +882,8 @@ export const createSimulationDashboardStore = () => {
|
|||||||
const element = block.elements.find((el) => el.elementUuid === elementId);
|
const element = block.elements.find((el) => el.elementUuid === elementId);
|
||||||
if (element && element.type === "graph" && element.dataType === "single-machine") {
|
if (element && element.type === "graph" && element.dataType === "single-machine") {
|
||||||
element.dataValue = dataValue as string[];
|
element.dataValue = dataValue as string[];
|
||||||
|
} else if (element && element.type === "label-value") {
|
||||||
|
element.dataValue = dataValue as string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return blocks;
|
return blocks;
|
||||||
@@ -892,6 +894,9 @@ export const createSimulationDashboardStore = () => {
|
|||||||
const block = blocks.find((b) => b.blockUuid === blockId);
|
const block = blocks.find((b) => b.blockUuid === blockId);
|
||||||
if (block) {
|
if (block) {
|
||||||
const element = block.elements.find((el) => el.elementUuid === elementId);
|
const element = block.elements.find((el) => el.elementUuid === elementId);
|
||||||
|
if (element?.type === "label-value") {
|
||||||
|
element.dataValue = "";
|
||||||
|
}
|
||||||
if (element) {
|
if (element) {
|
||||||
element.dataSource = dataSource;
|
element.dataSource = dataSource;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user