diff --git a/app/src/components/SimulationDashboard/DashboardEditor.tsx b/app/src/components/SimulationDashboard/DashboardEditor.tsx index 1950622..69e7b26 100644 --- a/app/src/components/SimulationDashboard/DashboardEditor.tsx +++ b/app/src/components/SimulationDashboard/DashboardEditor.tsx @@ -625,7 +625,6 @@ const DashboardEditor: React.FC = () => { }} setSwapSource={setSwapSource} setShowSwapUI={setShowSwapUI} - dataModelManager={dataModelManager} /> )} diff --git a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx index 3654735..f11c141 100644 --- a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx +++ b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx @@ -1,14 +1,11 @@ -import { useCallback, useEffect, useMemo, useState, type RefObject } from "react"; +import { useCallback, useMemo, useState, type RefObject } from "react"; import { ExtendedCSSProperties, UIElement } from "../../../../types/exportedTypes"; -import { getCurrentElementStyleValue } from "../../functions/helpers/getCurrentElementStyleValue"; -import type { DataModelManager } from "../../data/dataModel"; import { DeleteIcon } from "../../../icons/ContextMenuIcons"; import DataSourceSelector from "../../../ui/inputs/DataSourceSelector"; import InputWithDropDown from "../../../ui/inputs/InputWithDropDown"; import InputRange from "../../../ui/inputs/InputRange"; import RenameInput from "../../../ui/inputs/RenameInput"; -import { AddIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, DeviceIcon, FlexColumnIcon, FlexRowIcon, FlexRowReverseIcon, ParametersIcon } from "../../../icons/ExportCommonIcons"; -import { getAlphaFromRgba, rgbaToHex, hexToRgba } from "../../functions/helpers/colorHandlers"; +import { AddIcon, DeviceIcon, ParametersIcon } from "../../../icons/ExportCommonIcons"; import DataDetailedDropdown from "../../../ui/inputs/DataDetailedDropdown"; import { useSceneContext } from "../../../../modules/scene/sceneContext"; import ElementDesign from "./ElementDesign"; @@ -34,7 +31,6 @@ interface ElementEditorProps { handleRemoveElement: (blockId: string, elementId: string) => void; setSwapSource: (source: string | null) => void; setShowSwapUI: (show: boolean) => void; - dataModelManager: DataModelManager; } const ElementEditor: React.FC = ({ @@ -58,7 +54,6 @@ const ElementEditor: React.FC = ({ handleRemoveElement, setSwapSource, setShowSwapUI, - dataModelManager, }) => { const { simulationDashBoardStore, productStore, analysisStore } = useSceneContext(); const { products, selectedProduct, getProductById, getEventByModelUuid } = productStore(); @@ -69,7 +64,6 @@ const ElementEditor: React.FC = ({ const [selectType, setSelectType] = useState("design"); const [selectDataMapping, setSelectDataMapping] = useState(element?.type === "graph" && element.dataType === "multiple-machine" ? "multipleMachine" : "singleMachine"); - // Get asset dropdown items from product const getAssetDropdownItems = useCallback(() => { if (!product?.eventDatas) return []; @@ -84,7 +78,6 @@ const ElementEditor: React.FC = ({ (assetId: string | undefined) => { if (!product || !assetId) return []; - // Global system metrics (available for all assets) const globalItems = [ { title: "System Performance", @@ -261,7 +254,6 @@ const ElementEditor: React.FC = ({ [product] ); - // Get common value dropdown items (available across all assets) const getCommonValueDropdownItems = useCallback(() => { const commonItems = [ { id: "timeMetrics.uptime", label: "Uptime", icon: }, @@ -282,13 +274,10 @@ const ElementEditor: React.FC = ({ const singleValueFields = useMemo(() => { if (element?.type === "graph" && element.dataType === "single-machine") { - // Get the dataValue array - ensure it's always an array const dataValues = Array.isArray(element.dataValue) ? element.dataValue : []; - // Generate dropdown options based on the selected data source const valueOptions = element.dataSource ? getLableValueDropdownItems(element.dataSource).flatMap((section) => section.items.map((item) => ({ id: item.id, label: item.label }))) : []; - // Create fields based on the number of data values in the element return dataValues.map((value, index) => ({ id: `data-value-${index}`, label: `Data Value ${index + 1}`, @@ -297,7 +286,6 @@ const ElementEditor: React.FC = ({ })); } - // Return default field if not a graph with single-machine data type return [ { id: "data-value", @@ -336,30 +324,23 @@ const ElementEditor: React.FC = ({ setSelectDataMapping(newDataType); - // Convert the element data type when switching if (newDataType === "singleMachine" && element.dataType === "multiple-machine") { - // Convert from multiple-machine to single-machine updateDataType(selectedBlock, selectedElement, "single-machine"); } else if (newDataType === "multipleMachine" && element.dataType === "single-machine") { - // Convert from single-machine to multiple-machine updateDataType(selectedBlock, selectedElement, "multiple-machine"); } }; const addField = () => { if (selectDataMapping === "singleMachine" && element?.type === "graph" && element.dataType === "single-machine") { - // For single machine, add new data value field const currentDataValue = Array.isArray(element.dataValue) ? element.dataValue : []; - const newDataValue = [...currentDataValue, ""]; // Add empty string for new field + const newDataValue = [...currentDataValue, ""]; - // Update the element's dataValue updateDataValue(selectedBlock, selectedElement, newDataValue); } else if (selectDataMapping === "multipleMachine" && element?.type === "graph" && element.dataType === "multiple-machine") { - // For multiple machine, add new data source field const currentDataSource = Array.isArray(element.dataSource) ? element.dataSource : []; - const newDataSource = [...currentDataSource, ""]; // Add empty string for new field + const newDataSource = [...currentDataSource, ""]; - // Update the element's dataSource updateDataSource(selectedBlock, selectedElement, newDataSource); } };