feat: Update ElementEditor to handle data value changes and refactor data source initialization in simulation store
This commit is contained in:
@@ -19,7 +19,7 @@ interface SimulationDashboardStore {
|
||||
setSelectedElement: (elementId: string | null) => void;
|
||||
|
||||
// Block operations
|
||||
addBlock: (newBlock : Block) => void;
|
||||
addBlock: (newBlock: Block) => void;
|
||||
removeBlock: (blockId: string) => void;
|
||||
updateBlock: (blockId: string, updates: Partial<Block>) => void;
|
||||
clearBlocks: () => void;
|
||||
@@ -252,8 +252,8 @@ export const createSimulationDashboardStore = () => {
|
||||
...commonProps,
|
||||
type: "label-value",
|
||||
title: "Label Value",
|
||||
dataSource: "machine-1",
|
||||
dataValue: "metric-1",
|
||||
dataSource: "",
|
||||
dataValue: "",
|
||||
style: {
|
||||
color: "#ffffff",
|
||||
fontSize: 14,
|
||||
@@ -301,16 +301,16 @@ export const createSimulationDashboardStore = () => {
|
||||
...baseGraphProps,
|
||||
dataType: "multiple-machine" as const,
|
||||
title: "Multi Machine Chart",
|
||||
dataSource: ["machine-1", "machine-2", "machine-3"],
|
||||
commonValue: "metric-1",
|
||||
dataSource: ["", "", ""],
|
||||
commonValue: "",
|
||||
};
|
||||
} else {
|
||||
newElement = {
|
||||
...baseGraphProps,
|
||||
dataType: "single-machine" as const,
|
||||
title: "Single Machine Chart",
|
||||
dataSource: "machine-1",
|
||||
dataValue: ["metric-1", "metric-2", "metric-3"],
|
||||
dataSource: "",
|
||||
dataValue: ["", "", ""],
|
||||
};
|
||||
}
|
||||
break;
|
||||
@@ -619,7 +619,7 @@ export const createSimulationDashboardStore = () => {
|
||||
...commonProps,
|
||||
type: "label-value",
|
||||
title: "Label Value",
|
||||
dataSource: "machine-1",
|
||||
dataSource: "",
|
||||
dataValue: "metric-1",
|
||||
style: {
|
||||
color: "#ffffff",
|
||||
@@ -668,16 +668,16 @@ export const createSimulationDashboardStore = () => {
|
||||
...baseGraphProps,
|
||||
dataType: "multiple-machine" as const,
|
||||
title: "Multi Machine Chart",
|
||||
dataSource: ["machine-1", "machine-2", "machine-3"],
|
||||
commonValue: "metric-1",
|
||||
dataSource: ["", "", ""],
|
||||
commonValue: "",
|
||||
};
|
||||
} else {
|
||||
newElement = {
|
||||
...baseGraphProps,
|
||||
dataType: "single-machine" as const,
|
||||
title: "Single Machine Chart",
|
||||
dataSource: "machine-1",
|
||||
dataValue: ["metric-1", "metric-2", "metric-3"],
|
||||
dataSource: "",
|
||||
dataValue: ["", "", ""],
|
||||
};
|
||||
}
|
||||
break;
|
||||
@@ -882,6 +882,8 @@ export const createSimulationDashboardStore = () => {
|
||||
const element = block.elements.find((el) => el.elementUuid === elementId);
|
||||
if (element && element.type === "graph" && element.dataType === "single-machine") {
|
||||
element.dataValue = dataValue as string[];
|
||||
} else if (element && element.type === "label-value") {
|
||||
element.dataValue = dataValue as string;
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
@@ -892,6 +894,9 @@ export const createSimulationDashboardStore = () => {
|
||||
const block = blocks.find((b) => b.blockUuid === blockId);
|
||||
if (block) {
|
||||
const element = block.elements.find((el) => el.elementUuid === elementId);
|
||||
if (element?.type === "label-value") {
|
||||
element.dataValue = "";
|
||||
}
|
||||
if (element) {
|
||||
element.dataSource = dataSource;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user