- {selectedItem && (
- <>
-
-
Edit Name:
-
setEditedName(e.target.value)}
- />
+
+
+
+
Actions
+
- {/* Add other Properties Like:
- * Object Selection Dropdown
- * Buffer Time
- * Get Value From Object
- * Action
- * etc.
- */}
-
Update
{/* remove this */}
- >
- )}
-
-
-
- By Selecting Path, you can create Object Triggers.
+
+
+
+ {actionList.map((action, index) => (
+
+
handleSelectItem("action", action)}
+ >
+
+
+
handleRemoveAction(index)}
+ >
+
+
+
+ ))}
+
+
handleResize(e, actionsContainerRef)}
+ >
+
+
+
+
+
+
+
+
+ {triggerList.map((trigger, index) => (
+
+
handleSelectItem("trigger", trigger)}
+ >
+
+
+
handleRemoveTrigger(index)}
+ >
+
+
+
+ ))}
+
+
handleResize(e, triggersContainerRef)}
+ >
+
+
+
+
+
+ {selectedItem && (
+ <>
+
{selectedItem.name}
+
+
+ >
+ )}
+
+
+
+ By Selecting Path, you can create Object Triggers.
+
);
diff --git a/app/src/components/layout/sidebarRight/visualization/Visualization.tsx b/app/src/components/layout/sidebarRight/visualization/Visualization.tsx
new file mode 100644
index 0000000..f47cc27
--- /dev/null
+++ b/app/src/components/layout/sidebarRight/visualization/Visualization.tsx
@@ -0,0 +1,27 @@
+import { useState } from "react";
+import ToggleHeader from "../../../ui/inputs/ToggleHeader";
+import Data from "./data/Data";
+import Design from "./design/Design";
+
+const Visualization = () => {
+ const [activeOption, setActiveOption] = useState("Data");
+
+ const handleToggleClick = (option: string) => {
+ setActiveOption(option); // Update the active option
+ };
+
+ return (
+
+
+
+ {activeOption === "Data" ? : }
+
+
+ );
+};
+
+export default Visualization;
diff --git a/app/src/components/layout/sidebarRight/visualization/data/Data.tsx b/app/src/components/layout/sidebarRight/visualization/data/Data.tsx
new file mode 100644
index 0000000..cd20aea
--- /dev/null
+++ b/app/src/components/layout/sidebarRight/visualization/data/Data.tsx
@@ -0,0 +1,175 @@
+import { useEffect, useState } from "react";
+import { useWidgetStore } from "../../../../../store/useWidgetStore";
+import { AddIcon, RemoveIcon } from "../../../../icons/ExportCommonIcons";
+import MultiLevelDropDown from "../../../../ui/inputs/MultiLevelDropDown";
+
+// Define the data structure for demonstration purposes
+const DATA_STRUCTURE = {
+ furnace: {
+ coolingRate: "coolingRate",
+ furnaceTemperature: "furnaceTemperature",
+ heatingRate: "heatingRate",
+ machineId: "machineId",
+ powerConsumption: "powerConsumption",
+ status: "status",
+ timestamp: "timestamp",
+ vacuumLevel: "vacuumLevel",
+ },
+ testDevice: {
+ abrasiveLevel: {
+ data1: "Data 1",
+ data2: "Data 2",
+ data3: "Data 3",
+ },
+ airPressure: "airPressure",
+ machineId: "machineId",
+ powerConsumption: "powerConsumption",
+ status: "status",
+ temperature: {
+ data1: "Data 1",
+ data2: "Data 2",
+ data3: "Data 3",
+ },
+ timestamp: {
+ data1: {
+ Data01: "Data 01",
+ Data02: "Data 02",
+ Data03: "Data 03",
+ },
+ data2: "Data 2",
+ data3: "Data 3",
+ },
+ },
+};
+
+interface Child {
+ id: number;
+ easing: string;
+}
+
+interface Group {
+ id: number;
+ easing: string;
+ children: Child[];
+}
+
+const Data = () => {
+ const { selectedChartId } = useWidgetStore();
+
+ // State to store groups for all widgets (using Widget.id as keys)
+ const [chartDataGroups, setChartDataGroups] = useState<
+ Record
+ >({});
+
+ useEffect(() => {
+ // Initialize data groups for the newly selected widget if it doesn't exist
+ if (selectedChartId && !chartDataGroups[selectedChartId.id]) {
+ setChartDataGroups((prev) => ({
+ ...prev,
+ [selectedChartId.id]: [
+ {
+ id: Date.now(),
+ easing: "Connecter 1",
+ children: [{ id: Date.now(), easing: "Linear" }],
+ },
+ ],
+ }));
+ }
+ }, [selectedChartId]);
+
+ // Handle adding a new child to the group
+ const handleAddClick = (groupId: number) => {
+ setChartDataGroups((prevGroups) => {
+ const currentGroups = prevGroups[selectedChartId.id] || [];
+ const group = currentGroups.find((g) => g.id === groupId);
+
+ if (group && group.children.length < 7) {
+ const newChild = { id: Date.now(), easing: "Linear" };
+ return {
+ ...prevGroups,
+ [selectedChartId.id]: currentGroups.map((g) =>
+ g.id === groupId ? { ...g, children: [...g.children, newChild] } : g
+ ),
+ };
+ }
+ return prevGroups;
+ });
+ };
+
+ // Remove a child from a group
+ const removeChild = (groupId: number, childId: number) => {
+ setChartDataGroups((currentGroups) => {
+ const currentChartData = currentGroups[selectedChartId.id] || [];
+
+ return {
+ ...currentGroups,
+ [selectedChartId.id]: currentChartData.map((group) =>
+ group.id === groupId
+ ? {
+ ...group,
+ children: group.children.filter(
+ (child) => child.id !== childId
+ ),
+ }
+ : group
+ ),
+ };
+ });
+ };
+
+ return (
+
+ {selectedChartId?.title && (
+
{selectedChartId?.title}
+ )}
+ {/* Render groups dynamically */}
+ {chartDataGroups[selectedChartId?.id]?.map((group) => (
+
+ {group.children.map((child, index) => (
+
+
Input {index + 1}
+
+
+ {/* Add Icon */}
+ {group.children.length < 7 && (
+
handleAddClick(group.id)} // Pass groupId to handleAddClick
+ >
+
+
+ )}
+ {/* Remove Icon */}
+
+
1 ? "" : "disable"
+ }`}
+ onClick={(e) => {
+ e.stopPropagation(); // Prevent event bubbling
+ removeChild(group.id, child.id); // Pass groupId and childId to removeChild
+ }}
+ >
+
+
+
+
+ ))}
+
+ ))}
+
+ {/* Info Box */}
+
+
i
+
+
+ By adding templates and widgets, you create a customizable and
+ dynamic environment.
+
+
+
+
+ );
+};
+
+export default Data;
diff --git a/app/src/components/layout/sidebarRight/visualization/design/Design.tsx b/app/src/components/layout/sidebarRight/visualization/design/Design.tsx
new file mode 100644
index 0000000..89e1682
--- /dev/null
+++ b/app/src/components/layout/sidebarRight/visualization/design/Design.tsx
@@ -0,0 +1,209 @@
+import { useState } from "react";
+import { useWidgetStore } from "../../../../../store/useWidgetStore";
+import ChartComponent from "../../../sidebarLeft/visualization/widgets/ChartComponent";
+import RegularDropDown from "../../../../ui/inputs/RegularDropDown";
+
+// Define Props Interface
+interface Widget {
+ id: string;
+ type: string; // Chart type (e.g., "bar", "line")
+ panel: "top" | "bottom" | "left" | "right"; // Panel location
+ title: string;
+ fontFamily?: string;
+ fontSize?: string;
+ fontWeight?: string;
+ data: {
+ labels: string[];
+ datasets: {
+ data: number[];
+ backgroundColor: string;
+ borderColor: string;
+ borderWidth: number;
+ }[];
+ }; // Data for the chart
+}
+
+const Design = () => {
+ const [selectedName, setSelectedName] = useState("drop down");
+ console.log("selectedName: ", selectedName);
+
+ const [selectedElement, setSelectedElement] = useState("drop down");
+ console.log("selectedElement: ", selectedElement);
+
+ const [selectedFont, setSelectedFont] = useState("drop down");
+ console.log("selectedFont: ", selectedFont);
+
+ const [selectedSize, setSelectedSize] = useState("drop down");
+ console.log("selectedSize: ", selectedSize);
+
+ const [selectedWeight, setSelectedWeight] = useState("drop down");
+ console.log("selectedWeight: ", selectedWeight);
+
+ const [elementColor, setElementColor] = useState("#6f42c1"); // Default color for elements
+ const [showColorPicker, setShowColorPicker] = useState(false); // Manage visibility of the color picker
+
+ // Zustand Store Hooks
+ const { selectedChartId, setSelectedChartId, widgets, setWidgets } =
+ useWidgetStore();
+
+ // Handle Widget Updates
+ const handleUpdateWidget = (updatedProperties: Partial) => {
+ if (!selectedChartId) return;
+
+ // Update the selectedChartId
+ const updatedChartId = {
+ ...selectedChartId,
+ ...updatedProperties,
+ };
+ setSelectedChartId(updatedChartId);
+
+ // Update the widgets array
+ const updatedWidgets = widgets.map((widget) =>
+ widget.id === selectedChartId.id
+ ? { ...widget, ...updatedProperties }
+ : widget
+ );
+ setWidgets(updatedWidgets);
+ };
+
+ // Default Chart Data
+ const defaultChartData = {
+ labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"],
+ datasets: [
+ {
+ data: [65, 59, 80, 81, 56, 55, 40],
+ backgroundColor: elementColor, // Default background color
+ borderColor: "#ffffff", // Default border color
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ return (
+
+ {/* Title of the Selected Widget */}
+
+ {selectedChartId?.title || "Widget 1"}
+
+
+ {/* Chart Component */}
+
+ {selectedChartId && (
+
+ )}
+
+
+ {/* Options Container */}
+
+ {/* Name Dropdown */}
+
+ Name
+ {
+ setSelectedName(value);
+ handleUpdateWidget({ title: value });
+ }}
+ />
+
+
+ {/* Element Dropdown */}
+
+ Element
+ {
+ setSelectedElement(value);
+ handleUpdateWidget({ type: value });
+ }}
+ />
+
+
+ {/* Font Family Dropdown */}
+
+ Font Family
+ {
+ setSelectedFont(value);
+ handleUpdateWidget({ fontFamily: value });
+ }}
+ />
+
+
+ {/* Size Dropdown */}
+
+ Size
+ {
+ setSelectedSize(value);
+ handleUpdateWidget({ fontSize: value });
+ }}
+ />
+
+
+ {/* Weight Dropdown */}
+
+ Weight
+ {
+ setSelectedWeight(value);
+ handleUpdateWidget({ fontWeight: value });
+ }}
+ />
+
+
+ {/* Element Color Picker */}
+
+
setShowColorPicker((prev) => !prev)}
+ >
+
Element Color
+
▾
{" "}
+ {/* Change icon based on the visibility */}
+
+
+ {/* Show color picker only when 'showColorPicker' is true */}
+ {showColorPicker && (
+
+ {
+ setElementColor(e.target.value);
+ handleUpdateWidget({
+ data: {
+ labels: selectedChartId?.data?.labels || [],
+ datasets: [
+ {
+ ...selectedChartId?.data?.datasets[0],
+ backgroundColor: e.target.value, // Update the element color
+ },
+ ],
+ },
+ });
+ }}
+ />
+ {/* Display the selected color value */}
+ {elementColor}
+
+ )}
+
+
+
+ );
+};
+
+export default Design;
diff --git a/app/src/components/ui/ModuleToggle.tsx b/app/src/components/ui/ModuleToggle.tsx
index cbe64e3..bea9c43 100644
--- a/app/src/components/ui/ModuleToggle.tsx
+++ b/app/src/components/ui/ModuleToggle.tsx
@@ -2,6 +2,7 @@ import React from "react";
import useModuleStore from "../../store/useModuleStore";
import {
BuilderIcon,
+ CartIcon,
SimulationIcon,
VisualizationIcon,
} from "../icons/ExportModuleIcons";
@@ -40,6 +41,17 @@ const ModuleToggle: React.FC = () => {