Merge remote-tracking branch 'origin/main' into simulation-arm
This commit is contained in:
commit
372bfc7727
|
@ -48,6 +48,7 @@
|
|||
"zustand": "^5.0.0-rc.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/html2canvas": "^1.0.0",
|
||||
"@types/node": "^22.9.1",
|
||||
"@types/three": "^0.169.0",
|
||||
"axios": "^1.8.4",
|
||||
|
@ -2020,7 +2021,7 @@
|
|||
"version": "0.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
||||
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/trace-mapping": "0.3.9"
|
||||
},
|
||||
|
@ -2032,7 +2033,7 @@
|
|||
"version": "0.3.9",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
|
||||
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/resolve-uri": "^3.0.3",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
|
@ -4135,6 +4136,26 @@
|
|||
"url": "https://github.com/sponsors/gregberge"
|
||||
}
|
||||
},
|
||||
"node_modules/@testing-library/dom": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz",
|
||||
"integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.10.4",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@types/aria-query": "^5.0.1",
|
||||
"aria-query": "5.3.0",
|
||||
"chalk": "^4.1.0",
|
||||
"dom-accessibility-api": "^0.5.9",
|
||||
"lz-string": "^1.5.0",
|
||||
"pretty-format": "^27.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@testing-library/jest-dom": {
|
||||
"version": "5.17.0",
|
||||
"resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.17.0.tgz",
|
||||
|
@ -4246,25 +4267,25 @@
|
|||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
|
||||
"integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==",
|
||||
"dev": true
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/@tsconfig/node12": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
|
||||
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
|
||||
"dev": true
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/@tsconfig/node14": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
|
||||
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
|
||||
"dev": true
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/@tsconfig/node16": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
|
||||
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
|
||||
"dev": true
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/@turf/along": {
|
||||
"version": "7.2.0",
|
||||
|
@ -6470,6 +6491,17 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz",
|
||||
"integrity": "sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg=="
|
||||
},
|
||||
"node_modules/@types/html2canvas": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/html2canvas/-/html2canvas-1.0.0.tgz",
|
||||
"integrity": "sha512-BJpVf+FIN9UERmzhbtUgpXj6XBZpG67FMgBLLoj9HZKd9XifcCpSV+UnFcwTZfEyun4U/KmCrrVOG7829L589w==",
|
||||
"deprecated": "This is a stub types definition. html2canvas provides its own type definitions, so you do not need this installed.",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"html2canvas": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/http-errors": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz",
|
||||
|
@ -9007,7 +9039,7 @@
|
|||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
|
||||
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
||||
"dev": true
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/cross-env": {
|
||||
"version": "7.0.3",
|
||||
|
@ -9884,7 +9916,7 @@
|
|||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
||||
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"engines": {
|
||||
"node": ">=0.3.1"
|
||||
}
|
||||
|
@ -15247,7 +15279,7 @@
|
|||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
||||
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
|
||||
"dev": true
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/makeerror": {
|
||||
"version": "1.0.12",
|
||||
|
@ -20715,7 +20747,7 @@
|
|||
"version": "10.9.2",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz",
|
||||
"integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"dependencies": {
|
||||
"@cspotcode/source-map-support": "^0.8.0",
|
||||
"@tsconfig/node10": "^1.0.7",
|
||||
|
@ -20758,7 +20790,7 @@
|
|||
"version": "8.3.4",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz",
|
||||
"integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"dependencies": {
|
||||
"acorn": "^8.11.0"
|
||||
},
|
||||
|
@ -20770,7 +20802,7 @@
|
|||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
|
||||
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
|
||||
"dev": true
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/tsconfig-paths": {
|
||||
"version": "3.15.0",
|
||||
|
@ -21266,7 +21298,7 @@
|
|||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
||||
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
|
||||
"dev": true
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/v8-to-istanbul": {
|
||||
"version": "8.1.1",
|
||||
|
@ -22325,7 +22357,7 @@
|
|||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
|
||||
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/html2canvas": "^1.0.0",
|
||||
"@types/node": "^22.9.1",
|
||||
"@types/three": "^0.169.0",
|
||||
"axios": "^1.8.4",
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
import { Canvas } from "@react-three/fiber";
|
||||
import Throughput from "./cards/Throughput";
|
||||
import ReturnOfInvestment from "./cards/ReturnOfInvestment";
|
||||
import ProductionCapacity from "./cards/ProductionCapacity";
|
||||
import { OrbitControls } from "@react-three/drei";
|
||||
import StateWorking from "./cards/StateWorking";
|
||||
|
||||
const CardsScene = () => {
|
||||
return (
|
||||
<div className="cards-scene" style={{ width: "100%", height: "100%" }}>
|
||||
{/* <Canvas> */}
|
||||
{/* 3d-cards */}
|
||||
|
||||
{/* <ProductionCapacity /> */}
|
||||
{/* <ReturnOfInvestment /> */}
|
||||
{/* <StateWorking /> */}
|
||||
{/* <Throughput /> */}
|
||||
|
||||
{/* <OrbitControls /> */}
|
||||
{/* </Canvas> */}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CardsScene;
|
|
@ -6,7 +6,7 @@ import useToggleStore from "../../../store/useUIToggleStore";
|
|||
import Assets from "./Assets";
|
||||
import useModuleStore from "../../../store/useModuleStore";
|
||||
import Widgets from "./visualization/widgets/Widgets";
|
||||
import Templates from "./visualization/Templates";
|
||||
import Templates from "../../../modules/visualization/template/Templates";
|
||||
import Search from "../../ui/inputs/Search";
|
||||
|
||||
const SideBarLeft: React.FC = () => {
|
||||
|
|
|
@ -45,7 +45,10 @@ const ChartWidget: React.FC<WidgetProps> = ({ type, index, title }) => {
|
|||
),
|
||||
title,
|
||||
panel: "top",
|
||||
data: sampleData,
|
||||
Data: {
|
||||
measurements:{},
|
||||
duration:'1h'
|
||||
},
|
||||
});
|
||||
}}
|
||||
onDragEnd={() => setDraggedAsset(null)}
|
||||
|
|
|
@ -5,11 +5,11 @@ import {
|
|||
GlobeIcon,
|
||||
WalletIcon,
|
||||
} from "../../../../icons/3dChartIcons";
|
||||
import SimpleCard from "../../../../ui/realTimeVis/floating/SimpleCard";
|
||||
import SimpleCard from "../../../../../modules/visualization/widgets/floating/cards/SimpleCard";
|
||||
|
||||
import WarehouseThroughput from "../../../../ui/realTimeVis/floating/WarehouseThroughput";
|
||||
import ProductivityDashboard from "../../../../ui/realTimeVis/floating/ProductivityDashboard";
|
||||
import FleetEfficiency from "../../../../ui/realTimeVis/floating/FleetEfficiency";
|
||||
import WarehouseThroughput from "../../../../../modules/visualization/widgets/floating/cards/WarehouseThroughput";
|
||||
import ProductivityDashboard from "../../../../../modules/visualization/widgets/floating/cards/ProductivityDashboard";
|
||||
import FleetEfficiency from "../../../../../modules/visualization/widgets/floating/cards/FleetEfficiency";
|
||||
|
||||
interface Widget {
|
||||
id: string;
|
||||
|
@ -33,7 +33,7 @@ const WidgetsFloating = () => {
|
|||
};
|
||||
|
||||
return (
|
||||
<div className="floatingWidgets-wrapper">
|
||||
<div className="floatingWidgets-wrapper widgets-wrapper">
|
||||
{/* {widgets.map((widget) => (
|
||||
<div
|
||||
key={widget.id}
|
||||
|
@ -48,24 +48,28 @@ const WidgetsFloating = () => {
|
|||
<SimpleCard
|
||||
header={"Today’s Earnings"}
|
||||
icon={WalletIcon}
|
||||
iconName={"WalletIcon"}
|
||||
value={"$53,000"}
|
||||
per={"+55%"}
|
||||
/>
|
||||
<SimpleCard
|
||||
header={"Today’s Users"}
|
||||
icon={GlobeIcon}
|
||||
iconName={"GlobeIcon"}
|
||||
value={"1,200"}
|
||||
per={"+30%"}
|
||||
/>
|
||||
<SimpleCard
|
||||
header={"New Clients"}
|
||||
icon={DocumentIcon}
|
||||
iconName={"DocumentIcon"}
|
||||
value={"250"}
|
||||
per={"+12%"}
|
||||
/>
|
||||
<SimpleCard
|
||||
header={"Total Sales"}
|
||||
icon={CartIcon}
|
||||
iconName={"CartIcon"}
|
||||
value={"$150,000"}
|
||||
per={"+20%"}
|
||||
/>{" "}
|
||||
|
|
|
@ -98,7 +98,7 @@ const GlobalProperties: React.FC = () => {
|
|||
// setPlaneValue({ height: value * 100, width: value * 100 });
|
||||
}
|
||||
function updatedGrid(value: number) {
|
||||
console.log(" (value * 100) / 4 : ", (value * 100) / 4);
|
||||
// console.log(" (value * 100) / 4 : ", (value * 100) / 4);
|
||||
setGridValue({ size: value * 100, divisions: (value * 100) / 4 });
|
||||
setPlaneValue({ height: value * 100, width: value * 100 });
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ const ZoneProperties: React.FC = () => {
|
|||
if (response.message === "updated successfully") {
|
||||
setEdit(false);
|
||||
} else {
|
||||
console.log(response);
|
||||
// console.log(response);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
|
@ -63,7 +63,7 @@ const ZoneProperties: React.FC = () => {
|
|||
)
|
||||
);
|
||||
}else{
|
||||
console.log(response?.message);
|
||||
// console.log(response?.message);
|
||||
}
|
||||
}
|
||||
function handleVectorChange(key: "zoneViewPortTarget" | "zoneViewPortPosition", newValue: [number, number, number]) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
|||
import ChartComponent from "../../../sidebarLeft/visualization/widgets/ChartComponent";
|
||||
import RegularDropDown from "../../../../ui/inputs/RegularDropDown";
|
||||
import { WalletIcon } from "../../../../icons/3dChartIcons";
|
||||
import SimpleCard from "../../../../ui/realTimeVis/floating/SimpleCard";
|
||||
import SimpleCard from "../../../../../modules/visualization/widgets/floating/cards/SimpleCard";
|
||||
|
||||
interface Widget {
|
||||
id: string;
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
} from "../icons/ExportToolsIcons";
|
||||
import { ArrowIcon, TickIcon } from "../icons/ExportCommonIcons";
|
||||
import useModuleStore, { useThreeDStore } from "../../store/useModuleStore";
|
||||
import { handleSaveTemplate } from "../../modules/visualization/handleSaveTemplate";
|
||||
import { handleSaveTemplate } from "../../modules/visualization/functions/handleSaveTemplate";
|
||||
import { usePlayButtonStore } from "../../store/usePlayButtonStore";
|
||||
import useTemplateStore from "../../store/useTemplateStore";
|
||||
import { useSelectedZoneStore } from "../../store/useZoneStore";
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
import { getActiveProperties } from "./getActiveProperties";
|
||||
|
||||
export const convertAutoToNumeric = (
|
||||
canvasRect: DOMRect,
|
||||
position: {
|
||||
top: number | "auto";
|
||||
left: number | "auto";
|
||||
right: number | "auto";
|
||||
bottom: number | "auto";
|
||||
}
|
||||
): { top: number; left: number; right: number; bottom: number } => {
|
||||
const { width, height } = canvasRect;
|
||||
|
||||
// Determine which properties are active
|
||||
const [activeProp1, activeProp2] = getActiveProperties(position);
|
||||
|
||||
let top = typeof position.top !== "string" ? position.top : 0;
|
||||
let left = typeof position.left !== "string" ? position.left : 0;
|
||||
let right = typeof position.right !== "string" ? position.right : 0;
|
||||
let bottom = typeof position.bottom !== "string" ? position.bottom : 0;
|
||||
|
||||
// Calculate missing properties based on active properties
|
||||
if (activeProp1 === "top") {
|
||||
bottom = height - top;
|
||||
} else if (activeProp1 === "bottom") {
|
||||
top = height - bottom;
|
||||
}
|
||||
|
||||
if (activeProp2 === "left") {
|
||||
right = width - left;
|
||||
} else if (activeProp2 === "right") {
|
||||
left = width - right;
|
||||
}
|
||||
|
||||
return {
|
||||
top,
|
||||
left,
|
||||
right,
|
||||
bottom,
|
||||
};
|
||||
};
|
|
@ -1,105 +0,0 @@
|
|||
import { StockIncreseIcon } from "../../../icons/RealTimeVisulationIcons";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { Line } from "react-chartjs-2";
|
||||
import io from "socket.io-client";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import axios from "axios";
|
||||
|
||||
const ProgressCard1 = ({ id,title,}: {
|
||||
id: string,
|
||||
title: string;
|
||||
}) => {
|
||||
const { measurements: chartMeasurements, duration: chartDuration, name: widgetName } = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h")
|
||||
const [name, setName] = useState(title)
|
||||
const [value, setValue] = useState<any>('')
|
||||
const { selectedChartId } = useWidgetStore();
|
||||
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0]
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const socket = io(`http://${iotApiUrl}`);
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0) return;
|
||||
|
||||
const inputData = {
|
||||
measurements,
|
||||
duration,
|
||||
interval: 1000,
|
||||
};
|
||||
|
||||
|
||||
const startStream = () => {
|
||||
socket.emit("lastInput", inputData);
|
||||
};
|
||||
|
||||
socket.on("connect", startStream);
|
||||
|
||||
socket.on("lastOutput", (response) => {
|
||||
const responseData = response.input1;
|
||||
setValue(responseData);
|
||||
|
||||
});
|
||||
|
||||
return () => {
|
||||
socket.off("lastOutput");
|
||||
socket.emit("stop_stream"); // Stop streaming when component unmounts
|
||||
socket.disconnect();
|
||||
};
|
||||
}, [measurements, duration]);
|
||||
|
||||
const fetchSavedInputes = async() => {
|
||||
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements)
|
||||
setDuration(response.data.Data.duration)
|
||||
setName(response.data.widgetName)
|
||||
} else {
|
||||
console.log("Unexpected response:", response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("There was an error!", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetchSavedInputes();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedChartId?.id === id) {
|
||||
fetchSavedInputes();
|
||||
}
|
||||
}
|
||||
,[chartMeasurements, chartDuration, widgetName])
|
||||
|
||||
return(
|
||||
<div className="chart progressBar">
|
||||
<div className="header">{name}</div>
|
||||
<div className="stock">
|
||||
<span className="stock-item">
|
||||
<span className="stockValues">
|
||||
<div className="value">{value}</div>
|
||||
<div className="key">Units</div>
|
||||
|
||||
</span>
|
||||
<div className="stock-description">{
|
||||
measurements ? `${measurements?.input1?.fields}` : 'description'}</div>
|
||||
</span>
|
||||
<div className="icon">
|
||||
<StockIncreseIcon />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
};
|
||||
|
||||
export default ProgressCard1;
|
|
@ -1,125 +0,0 @@
|
|||
import { StockIncreseIcon } from "../../../icons/RealTimeVisulationIcons";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { Line } from "react-chartjs-2";
|
||||
import io from "socket.io-client";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import axios from "axios";
|
||||
|
||||
const ProgressCard2 = ({ id,title,}: {
|
||||
id: string,
|
||||
title: string;
|
||||
}) => {
|
||||
const { measurements: chartMeasurements, duration: chartDuration, name: widgetName } = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h")
|
||||
const [name, setName] = useState(title)
|
||||
const [value1, setValue1] = useState<any>('')
|
||||
const [value2, setValue2] = useState<any>('')
|
||||
const { selectedChartId } = useWidgetStore();
|
||||
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0]
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0) return;
|
||||
|
||||
const socket = io(`http://${iotApiUrl}`);
|
||||
|
||||
const inputData = {
|
||||
measurements,
|
||||
duration,
|
||||
interval: 1000,
|
||||
};
|
||||
|
||||
|
||||
const startStream = () => {
|
||||
socket.emit("lastInput", inputData);
|
||||
};
|
||||
|
||||
socket.on("connect", startStream);
|
||||
|
||||
socket.on("lastOutput", (response) => {
|
||||
const responseData1 = response.input1;
|
||||
const responseData2 = response.input2;
|
||||
setValue1(responseData1);
|
||||
setValue2(responseData2);
|
||||
});
|
||||
|
||||
return () => {
|
||||
socket.off("lastOutput");
|
||||
socket.emit("stop_stream"); // Stop streaming when component unmounts
|
||||
socket.disconnect();
|
||||
};
|
||||
}, [measurements, duration]);
|
||||
|
||||
const fetchSavedInputes = async() => {
|
||||
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements)
|
||||
setDuration(response.data.Data.duration)
|
||||
setName(response.data.widgetName)
|
||||
} else {
|
||||
console.log("Unexpected response:", response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("There was an error!", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetchSavedInputes();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedChartId?.id === id) {
|
||||
fetchSavedInputes();
|
||||
}
|
||||
}
|
||||
,[chartMeasurements, chartDuration, widgetName])
|
||||
|
||||
return(
|
||||
<div className="chart progressBar">
|
||||
<div className="header">{name}</div>
|
||||
|
||||
<div className="stock">
|
||||
<span className="stock-item">
|
||||
<span className="stockValues">
|
||||
<div className="value">{value1}</div>
|
||||
<div className="key">Units</div>
|
||||
|
||||
</span>
|
||||
<div className="stock-description">{
|
||||
measurements ? `${measurements?.input1?.fields}` : 'description'}</div>
|
||||
</span>
|
||||
<div className="icon">
|
||||
<StockIncreseIcon />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="stock">
|
||||
<span className="stock-item">
|
||||
<span className="stockValues">
|
||||
<div className="value">{value2}</div>
|
||||
<div className="key">Units</div>
|
||||
|
||||
</span>
|
||||
<div className="stock-description">{
|
||||
measurements ? `${measurements?.input2?.fields}` : 'description'}</div>
|
||||
</span>
|
||||
<div className="icon">
|
||||
<StockIncreseIcon />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
)
|
||||
};
|
||||
|
||||
export default ProgressCard2;
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Line } from "@react-three/drei";
|
||||
import {
|
||||
useNavMesh,
|
||||
|
@ -6,7 +6,7 @@ import {
|
|||
useSimulationStates,
|
||||
} from "../../../store/store";
|
||||
import PathNavigator from "./pathNavigator";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import { useAnimationPlaySpeed, usePlayButtonStore, useResetButtonStore } from "../../../store/usePlayButtonStore";
|
||||
|
||||
type PathPoints = {
|
||||
modelUuid: string;
|
||||
|
@ -30,9 +30,17 @@ const Agv: React.FC<ProcessContainerProps> = ({
|
|||
const { simulationStates } = useSimulationStates();
|
||||
const { navMesh } = useNavMesh();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { PlayAgv, setPlayAgv } = usePlayAgv();
|
||||
const { isReset, setReset } = useResetButtonStore();
|
||||
const { speed } = useAnimationPlaySpeed();
|
||||
const globalSpeed = useRef(1);
|
||||
|
||||
useEffect(() => { globalSpeed.current = speed }, [speed])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPlaying || isReset) {
|
||||
agvRef.current = [];
|
||||
}
|
||||
}, [isPlaying, isReset])
|
||||
|
||||
useEffect(() => {
|
||||
if (simulationStates.length > 0) {
|
||||
|
@ -58,21 +66,9 @@ const Agv: React.FC<ProcessContainerProps> = ({
|
|||
bufferTime: model.points.actions.buffer,
|
||||
hitCount: model.points.actions.hitCount,
|
||||
points: [
|
||||
{
|
||||
x: model.position[0],
|
||||
y: model.position[1],
|
||||
z: model.position[2],
|
||||
},
|
||||
{
|
||||
x: model.points.actions.start.x,
|
||||
y: 0,
|
||||
z: model.points.actions.start.y,
|
||||
},
|
||||
{
|
||||
x: model.points.actions.end.x,
|
||||
y: 0,
|
||||
z: model.points.actions.end.y,
|
||||
},
|
||||
{ x: model.position[0], y: model.position[1], z: model.position[2], },
|
||||
{ x: model.points.actions.start.x, y: 0, z: model.points.actions.start.y, },
|
||||
{ x: model.points.actions.end.x, y: 0, z: model.points.actions.end.y, },
|
||||
],
|
||||
}));
|
||||
|
||||
|
@ -89,6 +85,7 @@ const Agv: React.FC<ProcessContainerProps> = ({
|
|||
pathPoints={pair.points}
|
||||
id={pair.modelUuid}
|
||||
speed={pair.modelSpeed}
|
||||
globalSpeed={globalSpeed.current}
|
||||
bufferTime={pair.bufferTime}
|
||||
hitCount={pair.hitCount}
|
||||
processes={processes}
|
||||
|
|
|
@ -3,15 +3,15 @@ import * as THREE from "three";
|
|||
import { useFrame, useThree } from "@react-three/fiber";
|
||||
import { NavMeshQuery } from "@recast-navigation/core";
|
||||
import { Line } from "@react-three/drei";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import { useAnimationPlaySpeed, usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import { usePlayAgv } from "../../../store/store";
|
||||
import crate from "../../../assets/gltf-glb/crate_box.glb";
|
||||
|
||||
interface PathNavigatorProps {
|
||||
navMesh: any;
|
||||
pathPoints: any;
|
||||
id: string;
|
||||
speed: number;
|
||||
globalSpeed: number,
|
||||
bufferTime: number;
|
||||
hitCount: number;
|
||||
processes: any[];
|
||||
|
@ -31,6 +31,7 @@ export default function PathNavigator({
|
|||
pathPoints,
|
||||
id,
|
||||
speed,
|
||||
globalSpeed,
|
||||
bufferTime,
|
||||
hitCount,
|
||||
processes,
|
||||
|
@ -38,30 +39,12 @@ export default function PathNavigator({
|
|||
MaterialRef,
|
||||
}: PathNavigatorProps) {
|
||||
const [currentPhase, setCurrentPhase] = useState<Phase>("initial");
|
||||
//
|
||||
|
||||
const [path, setPath] = useState<[number, number, number][]>([]);
|
||||
const PickUpDrop = useRef([]);
|
||||
|
||||
// const [currentPhase, setCurrentPhase] = useState<"initial" | "loop">(
|
||||
// "initial"
|
||||
// );
|
||||
const [toPickupPath, setToPickupPath] = useState<[number, number, number][]>(
|
||||
[]
|
||||
);
|
||||
|
||||
const [pickupDropPath, setPickupDropPath] = useState<
|
||||
[number, number, number][]
|
||||
>([]);
|
||||
const [dropPickupPath, setDropPickupPath] = useState<
|
||||
[number, number, number][]
|
||||
>([]);
|
||||
const [initialPosition, setInitialPosition] = useState<THREE.Vector3 | null>(
|
||||
null
|
||||
);
|
||||
const [initialRotation, setInitialRotation] = useState<THREE.Euler | null>(
|
||||
null
|
||||
);
|
||||
const [toPickupPath, setToPickupPath] = useState<[number, number, number][]>([]);
|
||||
const [pickupDropPath, setPickupDropPath] = useState<[number, number, number][]>([]);
|
||||
const [dropPickupPath, setDropPickupPath] = useState<[number, number, number][]>([]);
|
||||
const [initialPosition, setInitialPosition] = useState<THREE.Vector3 | null>(null);
|
||||
const [initialRotation, setInitialRotation] = useState<THREE.Euler | null>(null);
|
||||
const [boxVisible, setBoxVisible] = useState(false);
|
||||
|
||||
const distancesRef = useRef<number[]>([]);
|
||||
|
@ -70,11 +53,20 @@ export default function PathNavigator({
|
|||
const isWaiting = useRef(false);
|
||||
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
const hasStarted = useRef(false);
|
||||
const hasReachedPickup = useRef(false);
|
||||
|
||||
const { scene } = useThree();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { PlayAgv, setPlayAgv } = usePlayAgv();
|
||||
|
||||
const boxRef = useRef<THREE.Mesh | null>(null);
|
||||
|
||||
const baseMaterials = useMemo(() => ({
|
||||
Box: new THREE.MeshStandardMaterial({ color: 0x8b4513 }),
|
||||
Crate: new THREE.MeshStandardMaterial({ color: 0x00ff00 }),
|
||||
Default: new THREE.MeshStandardMaterial({ color: 0xcccccc })
|
||||
}), []);
|
||||
|
||||
useEffect(() => {
|
||||
const object = scene.getObjectByProperty("uuid", id);
|
||||
if (object) {
|
||||
|
@ -105,12 +97,16 @@ export default function PathNavigator({
|
|||
|
||||
setPath([]);
|
||||
setCurrentPhase("initial");
|
||||
setToPickupPath([]);
|
||||
setPickupDropPath([]);
|
||||
setDropPickupPath([]);
|
||||
setBoxVisible(false);
|
||||
distancesRef.current = [];
|
||||
totalDistanceRef.current = 0;
|
||||
progressRef.current = 0;
|
||||
isWaiting.current = false;
|
||||
hasStarted.current = false;
|
||||
hasReachedPickup.current = false;
|
||||
|
||||
if (initialPosition && initialRotation) {
|
||||
const object = scene.getObjectByProperty("uuid", id);
|
||||
|
@ -130,27 +126,16 @@ export default function PathNavigator({
|
|||
|
||||
const [pickup, drop] = pathPoints.slice(-2);
|
||||
|
||||
PickUpDrop.current = pathPoints.slice(-2);
|
||||
|
||||
const object = scene.getObjectByProperty("uuid", id);
|
||||
|
||||
if (!object) return;
|
||||
|
||||
const currentPosition = {
|
||||
x: object.position.x,
|
||||
y: object.position.y,
|
||||
z: object.position.z,
|
||||
};
|
||||
const currentPosition = object.position;
|
||||
|
||||
const toPickupPath = computePath(currentPosition, pickup);
|
||||
const pickupToDropPath = computePath(pickup, drop);
|
||||
const dropToPickupPath = computePath(drop, pickup);
|
||||
|
||||
if (
|
||||
toPickupPath.length &&
|
||||
pickupToDropPath.length &&
|
||||
dropToPickupPath.length
|
||||
) {
|
||||
if (toPickupPath.length && pickupToDropPath.length && dropToPickupPath.length) {
|
||||
setPickupDropPath(pickupToDropPath);
|
||||
setDropPickupPath(dropToPickupPath);
|
||||
setToPickupPath(toPickupPath);
|
||||
|
@ -177,25 +162,9 @@ export default function PathNavigator({
|
|||
isWaiting.current = false;
|
||||
}, [path]);
|
||||
|
||||
// Add these refs outside the useFrame if not already present:
|
||||
const startPointReached = useRef(false);
|
||||
|
||||
const baseMaterials = useMemo(
|
||||
() => ({
|
||||
Box: new THREE.MeshStandardMaterial({ color: 0x8b4513 }),
|
||||
Crate: new THREE.MeshStandardMaterial({ color: 0x00ff00 }),
|
||||
// Default: new THREE.MeshStandardMaterial({ color: 0x00ff00 }),
|
||||
Default: new THREE.MeshStandardMaterial(),
|
||||
}),
|
||||
[]
|
||||
);
|
||||
|
||||
// Example usage:
|
||||
const targetModelUUID = id; // Replace with your target ID
|
||||
const matchedProcess = findProcessByTargetModelUUID(
|
||||
processes,
|
||||
targetModelUUID
|
||||
);
|
||||
function logAgvStatus(id: string, status: string) {
|
||||
// console.log(`AGV ${id}: ${status}`);
|
||||
}
|
||||
|
||||
function findProcessByTargetModelUUID(processes: any, targetModelUUID: any) {
|
||||
for (const process of processes) {
|
||||
|
@ -206,75 +175,55 @@ export default function PathNavigator({
|
|||
(target: any) => target.modelUUID === targetModelUUID
|
||||
)
|
||||
) {
|
||||
//
|
||||
return process.id; // Return the process if a match is found
|
||||
return process.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null; // Return null if no match is found
|
||||
return null;
|
||||
}
|
||||
|
||||
useFrame((_, delta) => {});
|
||||
const boxRef = useRef<THREE.Mesh | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!scene || !boxRef || !processes) return;
|
||||
if (!scene || !boxRef || !processes || !MaterialRef.current) return;
|
||||
|
||||
// 1. Find the existing object by UUID
|
||||
const existingObject = scene.getObjectByProperty("uuid", id);
|
||||
if (!existingObject) return;
|
||||
|
||||
// 2. Find the process that targets this object's modelUUID
|
||||
if (boxRef.current?.parent) {
|
||||
boxRef.current.parent.remove(boxRef.current);
|
||||
boxRef.current = null;
|
||||
}
|
||||
|
||||
if (boxVisible) {
|
||||
const matchedProcess = findProcessByTargetModelUUID(processes, id);
|
||||
|
||||
// 3. Determine the material (from materialref) if a process is matched
|
||||
let materialType = "Default";
|
||||
let materialType: "Box" | "Crate" | "Default" = "Default";
|
||||
|
||||
if (matchedProcess) {
|
||||
const materialEntry = MaterialRef.current.find((item: any) =>
|
||||
item.objects.some((obj: any) => obj.processId === matchedProcess)
|
||||
);
|
||||
console.log("materialEntry: ", materialEntry);
|
||||
if (materialEntry) {
|
||||
materialType = materialEntry.material; // "Box" or "Crate"
|
||||
materialType = materialEntry.material;
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Create the box mesh with the assigned material
|
||||
const boxGeometry = new THREE.BoxGeometry(0.5, 0.5, 0.5);
|
||||
const boxMaterial = baseMaterials[materialType as MaterialType];
|
||||
const boxMesh = new THREE.Mesh(boxGeometry, boxMaterial);
|
||||
const boxMesh = new THREE.Mesh(boxGeometry, baseMaterials[materialType]);
|
||||
boxMesh.position.y = 1;
|
||||
boxMesh.name = `box-${id}`;
|
||||
|
||||
// 5. Add to scene and cleanup
|
||||
existingObject.add(boxMesh);
|
||||
boxRef.current = boxMesh;
|
||||
}
|
||||
|
||||
if (!startPointReached.current && boxVisible) {
|
||||
setBoxVisible(false);
|
||||
}
|
||||
return () => {
|
||||
if (boxRef.current?.parent) {
|
||||
boxRef.current.parent.remove(boxRef.current);
|
||||
}
|
||||
boxRef.current = null;
|
||||
};
|
||||
}, [
|
||||
processes,
|
||||
MaterialRef,
|
||||
boxVisible,
|
||||
findProcessByTargetModelUUID,
|
||||
startPointReached,
|
||||
]);
|
||||
}, [processes, MaterialRef, boxVisible, scene, id, baseMaterials]);
|
||||
|
||||
useFrame((_, delta) => {
|
||||
const currentAgv = (agvRef.current || []).find(
|
||||
(agv: AGVData) => agv.vehicleId === id
|
||||
);
|
||||
const currentAgv = (agvRef.current || []).find((agv: AGVData) => agv.vehicleId === id);
|
||||
|
||||
if (!scene || !id || !isPlaying) return;
|
||||
|
||||
|
@ -283,7 +232,6 @@ export default function PathNavigator({
|
|||
|
||||
if (isPlaying && !hasStarted.current) {
|
||||
hasStarted.current = false;
|
||||
startPointReached.current = false;
|
||||
progressRef.current = 0;
|
||||
isWaiting.current = false;
|
||||
if (timeoutRef.current) {
|
||||
|
@ -295,10 +243,9 @@ export default function PathNavigator({
|
|||
const isAgvReady = () => {
|
||||
if (!agvRef.current || agvRef.current.length === 0) return false;
|
||||
if (!currentAgv) return false;
|
||||
return hitCount === currentAgv.expectedHitCount;
|
||||
return currentAgv.isActive && hitCount >= currentAgv.maxHitCount;
|
||||
};
|
||||
|
||||
// Step 1: Snap to start point on first play
|
||||
if (isPlaying && !hasStarted.current && toPickupPath.length > 0) {
|
||||
setBoxVisible(false);
|
||||
const startPoint = new THREE.Vector3(...toPickupPath[0]);
|
||||
|
@ -311,146 +258,132 @@ export default function PathNavigator({
|
|||
}
|
||||
|
||||
hasStarted.current = true;
|
||||
startPointReached.current = true;
|
||||
progressRef.current = 0;
|
||||
|
||||
hasReachedPickup.current = false;
|
||||
setToPickupPath(toPickupPath.slice(-1));
|
||||
|
||||
logAgvStatus(id, "Started from station, heading to pickup");
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 2: Wait at start point for AGV readiness
|
||||
if (isPlaying && startPointReached.current && path.length === 0) {
|
||||
if (!isAgvReady()) {
|
||||
return; // Prevent transitioning to the next phase if AGV is not ready
|
||||
if (isPlaying && currentPhase === "initial" && !hasReachedPickup.current) {
|
||||
const reached = moveAlongPath(object, path, distancesRef.current, speed, delta, progressRef);
|
||||
|
||||
if (reached) {
|
||||
hasReachedPickup.current = true;
|
||||
if (currentAgv) {
|
||||
currentAgv.status = 'picking';
|
||||
}
|
||||
logAgvStatus(id, "Reached pickup point, Waiting for material");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPlaying && currentAgv?.isActive && currentPhase === "initial") {
|
||||
if (!isAgvReady()) return;
|
||||
setTimeout(() => {
|
||||
setBoxVisible(true);
|
||||
|
||||
setPath([...toPickupPath]); // Start path transition once the AGV is ready
|
||||
setPath([...pickupDropPath]);
|
||||
setCurrentPhase("toDrop");
|
||||
progressRef.current = 0;
|
||||
console.log("startPointReached: ", startPointReached.current);
|
||||
startPointReached.current = false;
|
||||
|
||||
logAgvStatus(id, "Started from pickup point, heading to drop point");
|
||||
if (currentAgv) {
|
||||
currentAgv.status = 'toDrop';
|
||||
}
|
||||
}, 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.length < 2) return;
|
||||
if (isPlaying && currentPhase === "toDrop") {
|
||||
const reached = moveAlongPath(object, path, distancesRef.current, speed, delta, progressRef);
|
||||
|
||||
progressRef.current += delta * speed;
|
||||
if (reached && !isWaiting.current) {
|
||||
isWaiting.current = true;
|
||||
logAgvStatus(id, "Reached drop point");
|
||||
if (currentAgv) {
|
||||
currentAgv.status = 'droping';
|
||||
}
|
||||
timeoutRef.current = setTimeout(() => {
|
||||
setPath([...dropPickupPath]);
|
||||
setCurrentPhase("toPickup");
|
||||
progressRef.current = 0;
|
||||
isWaiting.current = false;
|
||||
setBoxVisible(false);
|
||||
if (currentAgv) {
|
||||
currentAgv.status = 'toPickup';
|
||||
}
|
||||
logAgvStatus(id, "Started from droping point, heading to pickup point");
|
||||
}, bufferTime * 1000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPlaying && currentPhase === "toPickup") {
|
||||
const reached = moveAlongPath(object, path, distancesRef.current, speed, delta, progressRef);
|
||||
|
||||
if (reached) {
|
||||
if (currentAgv) {
|
||||
currentAgv.isActive = false;
|
||||
}
|
||||
setCurrentPhase("initial");
|
||||
if (currentAgv) {
|
||||
currentAgv.status = 'picking';
|
||||
}
|
||||
logAgvStatus(id, "Reached pickup point again, cycle complete");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
moveAlongPath(object, path, distancesRef.current, speed, delta, progressRef);
|
||||
});
|
||||
|
||||
function moveAlongPath(
|
||||
object: THREE.Object3D,
|
||||
path: [number, number, number][],
|
||||
distances: number[],
|
||||
speed: number,
|
||||
delta: number,
|
||||
progressRef: React.MutableRefObject<number>
|
||||
): boolean {
|
||||
if (path.length < 2) return false;
|
||||
|
||||
progressRef.current += delta * (speed * globalSpeed);
|
||||
let covered = progressRef.current;
|
||||
let accumulated = 0;
|
||||
let index = 0;
|
||||
|
||||
if (distancesRef.current.length !== path.length - 1) {
|
||||
distancesRef.current = [];
|
||||
totalDistanceRef.current = 0;
|
||||
|
||||
for (let i = 0; i < path.length - 1; i++) {
|
||||
const start = new THREE.Vector3(...path[i]);
|
||||
const end = new THREE.Vector3(...path[i + 1]);
|
||||
const distance = start.distanceTo(end);
|
||||
distancesRef.current.push(distance);
|
||||
totalDistanceRef.current += distance;
|
||||
}
|
||||
for (; index < distances.length; index++) {
|
||||
const dist = distances[index];
|
||||
if (accumulated + dist >= covered) break;
|
||||
accumulated += dist;
|
||||
}
|
||||
|
||||
while (
|
||||
index < distancesRef.current.length &&
|
||||
covered > accumulated + distancesRef.current[index]
|
||||
) {
|
||||
accumulated += distancesRef.current[index];
|
||||
index++;
|
||||
}
|
||||
|
||||
// AGV has completed its path
|
||||
if (index >= distancesRef.current.length) {
|
||||
progressRef.current = totalDistanceRef.current;
|
||||
|
||||
timeoutRef.current = setTimeout(() => {
|
||||
if (!isAgvReady()) {
|
||||
isWaiting.current = false;
|
||||
return;
|
||||
}
|
||||
|
||||
let nextPath = [];
|
||||
let nextPhase = currentPhase;
|
||||
|
||||
if (currentPhase === "toDrop") {
|
||||
nextPath = dropPickupPath;
|
||||
nextPhase = "toPickup";
|
||||
setBoxVisible(false);
|
||||
} else if (currentPhase === "toPickup") {
|
||||
// When returning to start point (toPickup phase completed)
|
||||
// Set position to toPickupPath[1] instead of [0]
|
||||
if (toPickupPath.length > 1) {
|
||||
object.position.copy(new THREE.Vector3(...toPickupPath[1]));
|
||||
// Also set rotation towards the next point if available
|
||||
if (toPickupPath.length > 2) {
|
||||
const nextPoint = new THREE.Vector3(...toPickupPath[2]);
|
||||
const direction = nextPoint
|
||||
.clone()
|
||||
.sub(object.position)
|
||||
if (index >= path.length - 1) {
|
||||
if (path.length > 1) {
|
||||
const lastDirection = new THREE.Vector3(...path[path.length - 1])
|
||||
.sub(new THREE.Vector3(...path[path.length - 2]))
|
||||
.normalize();
|
||||
object.rotation.y = Math.atan2(direction.x, direction.z);
|
||||
object.rotation.y = Math.atan2(lastDirection.x, lastDirection.z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Reset the path and mark start point as reached
|
||||
setPath([]);
|
||||
startPointReached.current = true;
|
||||
progressRef.current = 0;
|
||||
distancesRef.current = [];
|
||||
|
||||
// Stop the AGV by setting isplaying to false
|
||||
if (currentAgv) {
|
||||
currentAgv.isplaying = false;
|
||||
}
|
||||
|
||||
// Clear timeout and return to prevent further movement
|
||||
if (timeoutRef.current) {
|
||||
clearTimeout(timeoutRef.current);
|
||||
timeoutRef.current = null;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
nextPath = pickupDropPath;
|
||||
nextPhase = "toDrop";
|
||||
setBoxVisible(true);
|
||||
}
|
||||
|
||||
setPath([...nextPath]);
|
||||
setCurrentPhase(nextPhase);
|
||||
progressRef.current = 0;
|
||||
isWaiting.current = false;
|
||||
distancesRef.current = [];
|
||||
|
||||
// Reset hit count for the next cycle
|
||||
if (agvRef.current) {
|
||||
agvRef.current = agvRef.current.map((agv: AGVData) =>
|
||||
agv.vehicleId === id ? { ...agv, hitCount: 0 } : agv
|
||||
);
|
||||
}
|
||||
}, bufferTime * 1000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 4: Interpolate position and rotation
|
||||
const start = new THREE.Vector3(...path[index]);
|
||||
const end = new THREE.Vector3(...path[index + 1]);
|
||||
const dist = distancesRef.current[index];
|
||||
|
||||
if (!dist || dist === 0) return;
|
||||
const dist = distances[index];
|
||||
|
||||
const t = THREE.MathUtils.clamp((covered - accumulated) / dist, 0, 1);
|
||||
object.position.copy(start.clone().lerp(end, t));
|
||||
|
||||
const direction = new THREE.Vector3().subVectors(end, start).normalize();
|
||||
object.rotation.y = Math.atan2(direction.x, direction.z);
|
||||
});
|
||||
if (dist > 0.1) {
|
||||
const targetDirection = end.clone().sub(start).normalize();
|
||||
const targetRotationY = Math.atan2(targetDirection.x, targetDirection.z);
|
||||
|
||||
const rotationSpeed = Math.min(5 * delta, 1);
|
||||
object.rotation.y = THREE.MathUtils.lerp(object.rotation.y, targetRotationY, rotationSpeed);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
|
|
|
@ -10,13 +10,15 @@ import { useNavigate } from "react-router-dom";
|
|||
import { Html } from "@react-three/drei";
|
||||
import CollabUserIcon from "./collabUserIcon";
|
||||
import { getAvatarColor } from "./users/functions/getAvatarColor";
|
||||
import useModuleStore from "../../store/useModuleStore";
|
||||
|
||||
const CamModelsGroup = () => {
|
||||
const navigate = useNavigate();
|
||||
const groupRef = useRef<THREE.Group>(null);
|
||||
const email = localStorage.getItem("email");
|
||||
const { activeUsers, setActiveUsers } = useActiveUsers();
|
||||
const { setActiveUsers } = useActiveUsers();
|
||||
const { socket } = useSocketStore();
|
||||
const { activeModule } = useModuleStore();
|
||||
|
||||
const loader = new GLTFLoader();
|
||||
const dracoLoader = new DRACOLoader();
|
||||
|
@ -24,7 +26,12 @@ const CamModelsGroup = () => {
|
|||
loader.setDRACOLoader(dracoLoader);
|
||||
|
||||
const [cams, setCams] = useState<any[]>([]);
|
||||
const [models, setModels] = useState<Record<string, { targetPosition: THREE.Vector3; targetRotation: THREE.Euler }>>({});
|
||||
const [models, setModels] = useState<
|
||||
Record<
|
||||
string,
|
||||
{ targetPosition: THREE.Vector3; targetRotation: THREE.Euler }
|
||||
>
|
||||
>({});
|
||||
|
||||
const dedupeCams = (cams: any[]) => {
|
||||
const seen = new Set();
|
||||
|
@ -53,9 +60,13 @@ const CamModelsGroup = () => {
|
|||
socket.on("userConnectResponse", (data: any) => {
|
||||
if (!groupRef.current) return;
|
||||
if (data.data.userData.email === email) return;
|
||||
if (socket.id === data.socketId || organization !== data.organization) return;
|
||||
if (socket.id === data.socketId || organization !== data.organization)
|
||||
return;
|
||||
|
||||
const model = groupRef.current.getObjectByProperty("uuid", data.data.userData._id);
|
||||
const model = groupRef.current.getObjectByProperty(
|
||||
"uuid",
|
||||
data.data.userData._id
|
||||
);
|
||||
if (model) {
|
||||
groupRef.current.remove(model);
|
||||
}
|
||||
|
@ -84,7 +95,8 @@ const CamModelsGroup = () => {
|
|||
|
||||
socket.on("userDisConnectResponse", (data: any) => {
|
||||
if (!groupRef.current) return;
|
||||
if (socket.id === data.socketId || organization !== data.organization) return;
|
||||
if (socket.id === data.socketId || organization !== data.organization)
|
||||
return;
|
||||
|
||||
setCams((prev) =>
|
||||
prev.filter((cam) => cam.uuid !== data.data.userData._id)
|
||||
|
@ -134,9 +146,21 @@ const CamModelsGroup = () => {
|
|||
|
||||
const { targetPosition, targetRotation } = models[uuid];
|
||||
model.position.lerp(targetPosition, 0.1);
|
||||
model.rotation.x = THREE.MathUtils.lerp(model.rotation.x, targetRotation.x, 0.1);
|
||||
model.rotation.y = THREE.MathUtils.lerp(model.rotation.y, targetRotation.y, 0.1);
|
||||
model.rotation.z = THREE.MathUtils.lerp(model.rotation.z, targetRotation.z, 0.1);
|
||||
model.rotation.x = THREE.MathUtils.lerp(
|
||||
model.rotation.x,
|
||||
targetRotation.x,
|
||||
0.1
|
||||
);
|
||||
model.rotation.y = THREE.MathUtils.lerp(
|
||||
model.rotation.y,
|
||||
targetRotation.y,
|
||||
0.1
|
||||
);
|
||||
model.rotation.z = THREE.MathUtils.lerp(
|
||||
model.rotation.z,
|
||||
targetRotation.z,
|
||||
0.1
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -154,8 +178,16 @@ const CamModelsGroup = () => {
|
|||
const newCams = filteredData.map((cam: any) => {
|
||||
const newModel = gltf.scene.clone();
|
||||
newModel.uuid = cam.userData._id;
|
||||
newModel.position.set(cam.position.x, cam.position.y, cam.position.z);
|
||||
newModel.rotation.set(cam.rotation.x, cam.rotation.y, cam.rotation.z);
|
||||
newModel.position.set(
|
||||
cam.position.x,
|
||||
cam.position.y,
|
||||
cam.position.z
|
||||
);
|
||||
newModel.rotation.set(
|
||||
cam.rotation.x,
|
||||
cam.rotation.y,
|
||||
cam.rotation.z
|
||||
);
|
||||
newModel.userData = cam.userData;
|
||||
return newModel;
|
||||
});
|
||||
|
@ -169,7 +201,11 @@ const CamModelsGroup = () => {
|
|||
}, []);
|
||||
|
||||
return (
|
||||
<group ref={groupRef} name="Cam-Model-Group">
|
||||
<group
|
||||
ref={groupRef}
|
||||
name="Cam-Model-Group"
|
||||
visible={activeModule !== "visualization" ? true : false}
|
||||
>
|
||||
{cams.map((cam, index) => (
|
||||
<primitive key={cam.uuid} object={cam}>
|
||||
<Html
|
||||
|
@ -181,11 +217,12 @@ const CamModelsGroup = () => {
|
|||
color: "white",
|
||||
textAlign: "center",
|
||||
fontFamily: "Arial, sans-serif",
|
||||
display: `${activeModule !== "visualization" ? "" : "none"}`,
|
||||
}}
|
||||
position={[-0.015, 0, 0.7]}
|
||||
>
|
||||
<CollabUserIcon
|
||||
userImage={cam.userData.userImage ||""}
|
||||
userImage={cam.userData.userImage || ""}
|
||||
userName={cam.userData.userName}
|
||||
color={getAvatarColor(index, cam.userData.userName)}
|
||||
/>
|
||||
|
|
|
@ -20,7 +20,6 @@ async function loadInitialFloorItems(
|
|||
const organization = (email!.split("@")[1]).split(".")[0];
|
||||
|
||||
const items = await getFloorAssets(organization);
|
||||
console.log('items: ', items);
|
||||
localStorage.setItem("FloorItems", JSON.stringify(items));
|
||||
await initializeDB();
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import CopyPasteControls from "./copyPasteControls";
|
|||
import MoveControls from "./moveControls";
|
||||
import RotateControls from "./rotateControls";
|
||||
import useModuleStore from "../../../../store/useModuleStore";
|
||||
import { detectModifierKeys } from "../../../../utils/shortcutkeys/detectModifierKeys";
|
||||
|
||||
const SelectionControls: React.FC = () => {
|
||||
const { camera, controls, gl, scene, pointer } = useThree();
|
||||
|
@ -102,13 +101,12 @@ const SelectionControls: React.FC = () => {
|
|||
};
|
||||
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
const keyCombination = detectModifierKeys(event);
|
||||
if (movedObjects.length > 0 || rotatedObjects.length > 0) return;
|
||||
if (keyCombination === "ESCAPE") {
|
||||
if (event.key.toLowerCase() === "escape") {
|
||||
event.preventDefault();
|
||||
clearSelection();
|
||||
}
|
||||
if (keyCombination === "DELETE") {
|
||||
if (event.key.toLowerCase() === "delete") {
|
||||
event.preventDefault();
|
||||
deleteSelection();
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ import Simulation from "../simulation/simulation";
|
|||
|
||||
// import Simulation from "./simulationtemp/simulation";
|
||||
import ZoneCentreTarget from "../../components/ui/componets/zoneCameraTarget";
|
||||
import Dropped3dWidgets from "../../components/ui/componets/Dropped3dWidget";
|
||||
import ZoneAssets from "../../components/ui/componets/zoneAssets";
|
||||
import Dropped3dWidgets from "../../modules/visualization/widgets/3d/Dropped3dWidget";
|
||||
import ZoneAssets from "../visualization/zoneAssets";
|
||||
|
||||
export default function Scene() {
|
||||
const map = useMemo(
|
||||
|
|
|
@ -26,6 +26,7 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
|||
}) => {
|
||||
const gltf = useLoader(GLTFLoader, crate) as GLTF;
|
||||
const groupRef = useRef<THREE.Group>(null);
|
||||
const tempStackedObjectsRef = useRef<Record<string, boolean>>({});
|
||||
|
||||
const {
|
||||
animationStates,
|
||||
|
@ -43,27 +44,19 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
|||
checkAndCountTriggers,
|
||||
} = useProcessAnimation(processes, setProcesses, agvRef);
|
||||
|
||||
const baseMaterials = useMemo(
|
||||
() => ({
|
||||
const baseMaterials = useMemo(() => ({
|
||||
Box: new THREE.MeshStandardMaterial({ color: 0x8b4513 }),
|
||||
Crate: new THREE.MeshStandardMaterial({ color: 0x00ff00 }),
|
||||
// Default: new THREE.MeshStandardMaterial({ color: 0x00ff00 }),
|
||||
Default: new THREE.MeshStandardMaterial(),
|
||||
}),
|
||||
[]
|
||||
);
|
||||
}), []);
|
||||
|
||||
useEffect(() => {
|
||||
// Update material references for all spawned objects
|
||||
Object.entries(animationStates).forEach(([processId, processState]) => {
|
||||
Object.keys(processState.spawnedObjects).forEach((objectId) => {
|
||||
const entry = {
|
||||
processId,
|
||||
objectId,
|
||||
};
|
||||
const entry = { processId, objectId, };
|
||||
|
||||
const materialType =
|
||||
processState.spawnedObjects[objectId]?.currentMaterialType;
|
||||
const materialType = processState.spawnedObjects[objectId]?.currentMaterialType;
|
||||
|
||||
if (!materialType) {
|
||||
return;
|
||||
|
@ -72,17 +65,13 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
|||
const matRefArray = MaterialRef.current;
|
||||
|
||||
// Find existing material group
|
||||
const existing = matRefArray.find(
|
||||
(entryGroup: { material: string; objects: any[] }) =>
|
||||
const existing = matRefArray.find((entryGroup: { material: string; objects: any[] }) =>
|
||||
entryGroup.material === materialType
|
||||
);
|
||||
|
||||
if (existing) {
|
||||
// Check if this processId + objectId already exists
|
||||
const alreadyExists = existing.objects.some(
|
||||
(o: any) =>
|
||||
o.processId === entry.processId && o.objectId === entry.objectId
|
||||
);
|
||||
const alreadyExists = existing.objects.some((o: any) => o.processId === entry.processId && o.objectId === entry.objectId);
|
||||
|
||||
if (!alreadyExists) {
|
||||
existing.objects.push(entry);
|
||||
|
@ -102,8 +91,7 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
|||
|
||||
useFrame(() => {
|
||||
// Spawn logic frame
|
||||
const currentTime =
|
||||
clockRef.current.getElapsedTime() - elapsedBeforePauseRef.current;
|
||||
const currentTime = clockRef.current.getElapsedTime() - elapsedBeforePauseRef.current;
|
||||
|
||||
setAnimationStates((prev) => {
|
||||
const newStates = { ...prev };
|
||||
|
@ -131,10 +119,7 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
|||
: parseFloat(spawnAction.spawnInterval as string) || 0;
|
||||
|
||||
// Check if this is a zero interval spawn and we already spawned an object
|
||||
if (
|
||||
spawnInterval === 0 &&
|
||||
processState.hasSpawnedZeroIntervalObject === true
|
||||
) {
|
||||
if (spawnInterval === 0 && processState.hasSpawnedZeroIntervalObject === true) {
|
||||
return; // Don't spawn more objects for zero interval
|
||||
}
|
||||
|
||||
|
@ -312,35 +297,87 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
|||
// }
|
||||
// }
|
||||
|
||||
// if (isLastPoint) {
|
||||
// if (currentPointData?.actions) {
|
||||
// const hasNonInherit = hasNonInheritActions(
|
||||
// currentPointData.actions
|
||||
// );
|
||||
// if (!hasNonInherit) {
|
||||
// // Remove the object if all actions are inherit
|
||||
// updatedObjects[objectId] = {
|
||||
// ...obj,
|
||||
// visible: false,
|
||||
// state: { ...stateRef, isAnimating: false },
|
||||
// };
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
// // No actions at last point - remove the object
|
||||
// updatedObjects[objectId] = {
|
||||
// ...obj,
|
||||
// visible: false,
|
||||
// state: { ...stateRef, isAnimating: false },
|
||||
// };
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (isLastPoint) {
|
||||
if (currentPointData?.actions) {
|
||||
const hasNonInherit = hasNonInheritActions(
|
||||
currentPointData.actions
|
||||
const isAgvPicking = agvRef.current.some(
|
||||
(agv: any) => agv.processId === process.id && agv.status === "picking"
|
||||
);
|
||||
if (!hasNonInherit) {
|
||||
// Remove the object if all actions are inherit
|
||||
|
||||
const shouldHide = !currentPointData?.actions || !hasNonInheritActions(currentPointData.actions);
|
||||
|
||||
if (shouldHide) {
|
||||
if (isAgvPicking) {
|
||||
updatedObjects[objectId] = {
|
||||
...obj,
|
||||
visible: false,
|
||||
state: { ...stateRef, isAnimating: false },
|
||||
state: {
|
||||
...stateRef,
|
||||
isAnimating: false,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
tempStackedObjectsRef.current[objectId] = true;
|
||||
|
||||
updatedObjects[objectId] = {
|
||||
...obj,
|
||||
visible: true,
|
||||
state: {
|
||||
...stateRef,
|
||||
isAnimating: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// No actions at last point - remove the object
|
||||
}
|
||||
|
||||
if (tempStackedObjectsRef.current[objectId]) {
|
||||
const isAgvPicking = agvRef.current.some(
|
||||
(agv: any) => agv.processId === process.id && agv.status === "picking"
|
||||
);
|
||||
|
||||
if (isAgvPicking) {
|
||||
delete tempStackedObjectsRef.current[objectId];
|
||||
|
||||
updatedObjects[objectId] = {
|
||||
...obj,
|
||||
visible: false,
|
||||
state: { ...stateRef, isAnimating: false },
|
||||
state: {
|
||||
...stateRef,
|
||||
isAnimating: false,
|
||||
},
|
||||
};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isLastPoint) {
|
||||
const nextPoint = path[nextPointIdx];
|
||||
const distance =
|
||||
path[stateRef.currentIndex].distanceTo(nextPoint);
|
||||
const distance = path[stateRef.currentIndex].distanceTo(nextPoint);
|
||||
const effectiveSpeed = stateRef.speed * speedRef.current;
|
||||
const movement = effectiveSpeed * delta;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
// pointActions: PointAction[][];
|
||||
// pointTriggers: PointTrigger[][];
|
||||
// speed: number;
|
||||
// isplaying: boolean;
|
||||
// isActive: boolean;
|
||||
// }
|
||||
|
||||
// interface ProcessCreatorProps {
|
||||
|
@ -147,7 +147,7 @@
|
|||
// pointActions: [],
|
||||
// pointTriggers: [], // Added point triggers array
|
||||
// speed: 1,
|
||||
// isplaying: false,
|
||||
// isActive: false,
|
||||
// });
|
||||
|
||||
// // Enhanced connection checking function
|
||||
|
@ -283,7 +283,7 @@
|
|||
// pointActions,
|
||||
// pointTriggers,
|
||||
// speed: processSpeed,
|
||||
// isplaying: false,
|
||||
// isActive: false,
|
||||
// };
|
||||
// },
|
||||
// [scene]
|
||||
|
@ -410,7 +410,7 @@
|
|||
// p.connections.targets.map((t: { modelUUID: string }) => t.modelUUID)
|
||||
// )
|
||||
// .join(","),
|
||||
// isplaying: false,
|
||||
// isActive: false,
|
||||
// }));
|
||||
// }, [convertedPaths]);
|
||||
|
||||
|
@ -459,6 +459,7 @@ import {
|
|||
ConveyorEventsSchema,
|
||||
VehicleEventsSchema,
|
||||
} from "../../../types/world/worldTypes";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
|
||||
// Type definitions
|
||||
export interface PointAction {
|
||||
|
@ -495,7 +496,7 @@ export interface SimulationPath {
|
|||
points: PathPoint[];
|
||||
pathPosition: [number, number, number];
|
||||
speed?: number;
|
||||
isplaying: boolean;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
export interface Process {
|
||||
|
@ -505,7 +506,7 @@ export interface Process {
|
|||
pointActions: PointAction[][];
|
||||
pointTriggers: PointTrigger[][];
|
||||
speed: number;
|
||||
isplaying: boolean;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
interface ProcessCreatorProps {
|
||||
|
@ -556,7 +557,7 @@ function convertToSimulationPath(
|
|||
typeof path.speed === "string"
|
||||
? parseFloat(path.speed) || 1
|
||||
: path.speed || 1,
|
||||
isplaying: false, // Added missing property
|
||||
isActive: false, // Added missing property
|
||||
};
|
||||
} else {
|
||||
// For vehicle paths, handle the case where triggers might not exist
|
||||
|
@ -582,7 +583,7 @@ function convertToSimulationPath(
|
|||
],
|
||||
pathPosition: path.position,
|
||||
speed: path.points.speed || 1,
|
||||
isplaying: false,
|
||||
isActive: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -595,7 +596,7 @@ const createEmptyProcess = (): Process => ({
|
|||
pointActions: [],
|
||||
pointTriggers: [], // Added point triggers array
|
||||
speed: 1,
|
||||
isplaying: false,
|
||||
isActive: false,
|
||||
});
|
||||
|
||||
// Enhanced connection checking function
|
||||
|
@ -731,7 +732,7 @@ export function useProcessCreation() {
|
|||
pointActions,
|
||||
pointTriggers,
|
||||
speed: processSpeed,
|
||||
isplaying: false,
|
||||
isActive: false,
|
||||
};
|
||||
},
|
||||
[scene]
|
||||
|
@ -824,6 +825,7 @@ const ProcessCreator: React.FC<ProcessCreatorProps> = React.memo(
|
|||
const { createProcessesFromPaths } = useProcessCreation();
|
||||
const prevPathsRef = useRef<SimulationPath[]>([]);
|
||||
const prevProcessesRef = useRef<Process[]>([]);
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
|
||||
const convertedPaths = useMemo((): SimulationPath[] => {
|
||||
if (!simulationStates) return [];
|
||||
|
@ -858,7 +860,7 @@ const ProcessCreator: React.FC<ProcessCreatorProps> = React.memo(
|
|||
p.connections.targets.map((t: { modelUUID: string }) => t.modelUUID)
|
||||
)
|
||||
.join(","),
|
||||
isplaying: false,
|
||||
isActive: false,
|
||||
}));
|
||||
}, [convertedPaths]);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ export interface ProcessPath {
|
|||
pathRotation: number[];
|
||||
speed: number;
|
||||
type: "Conveyor" | "Vehicle";
|
||||
isplaying: boolean
|
||||
isActive: boolean
|
||||
}
|
||||
|
||||
export interface ProcessData {
|
||||
|
|
|
@ -52,15 +52,11 @@ export const useProcessAnimation = (
|
|||
const clockRef = useRef<THREE.Clock>(new THREE.Clock());
|
||||
const pauseTimeRef = useRef<number>(0);
|
||||
const elapsedBeforePauseRef = useRef<number>(0);
|
||||
const animationStatesRef = useRef<
|
||||
Record<string, EnhancedProcessAnimationState>
|
||||
>({});
|
||||
const animationStatesRef = useRef<Record<string, EnhancedProcessAnimationState>>({});
|
||||
const { speed } = useAnimationPlaySpeed();
|
||||
const prevIsPlaying = useRef<boolean | null>(null);
|
||||
const [internalResetFlag, setInternalResetFlag] = useState(false);
|
||||
const [animationStates, setAnimationStates] = useState<
|
||||
Record<string, EnhancedProcessAnimationState>
|
||||
>({});
|
||||
const [animationStates, setAnimationStates] = useState<Record<string, EnhancedProcessAnimationState>>({});
|
||||
const speedRef = useRef<number>(speed);
|
||||
const { PlayAgv, setPlayAgv } = usePlayAgv();
|
||||
|
||||
|
@ -70,7 +66,7 @@ export const useProcessAnimation = (
|
|||
}, [speed]);
|
||||
|
||||
useEffect(() => {
|
||||
if (prevIsPlaying.current !== null) {
|
||||
if (prevIsPlaying.current !== null || !isPlaying) {
|
||||
setAnimationStates({});
|
||||
}
|
||||
prevIsPlaying.current = isPlaying;
|
||||
|
@ -104,8 +100,7 @@ export const useProcessAnimation = (
|
|||
if (isPaused) {
|
||||
pauseTimeRef.current = clockRef.current.getElapsedTime();
|
||||
} else if (pauseTimeRef.current > 0) {
|
||||
const pausedDuration =
|
||||
clockRef.current.getElapsedTime() - pauseTimeRef.current;
|
||||
const pausedDuration = clockRef.current.getElapsedTime() - pauseTimeRef.current;
|
||||
elapsedBeforePauseRef.current += pausedDuration;
|
||||
}
|
||||
}, [isPaused]);
|
||||
|
@ -147,6 +142,77 @@ export const useProcessAnimation = (
|
|||
}
|
||||
}, [isPlaying, processes, internalResetFlag]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isPlaying && !internalResetFlag) {
|
||||
const newStates: Record<string, EnhancedProcessAnimationState> = {};
|
||||
|
||||
// Initialize AGVs for each process first
|
||||
processes.forEach((process) => {
|
||||
// Find all vehicle paths for this process
|
||||
const vehiclePaths = process.paths?.filter(
|
||||
(path) => path.type === "Vehicle"
|
||||
) || [];
|
||||
|
||||
// Initialize AGVs for each vehicle path
|
||||
vehiclePaths.forEach((vehiclePath) => {
|
||||
if (vehiclePath.points?.length > 0) {
|
||||
const vehiclePoint = vehiclePath.points[0];
|
||||
const action = vehiclePoint.actions?.[0];
|
||||
const maxHitCount = action?.hitCount;
|
||||
|
||||
const vehicleId = vehiclePath.modeluuid;
|
||||
const processId = process.id;
|
||||
|
||||
// Check if this AGV already exists
|
||||
const existingAgv = agvRef.current.find(
|
||||
(v: any) => v.vehicleId === vehicleId && v.processId === processId
|
||||
);
|
||||
|
||||
if (!existingAgv) {
|
||||
// Initialize the AGV in a stationed state
|
||||
agvRef.current.push({
|
||||
processId,
|
||||
vehicleId,
|
||||
maxHitCount: maxHitCount || 0,
|
||||
isActive: false,
|
||||
hitCount: 0,
|
||||
status: 'stationed',
|
||||
lastUpdated: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Then initialize trigger counts as before
|
||||
const triggerCounts: Record<string, number> = {};
|
||||
process.paths?.forEach((path) => {
|
||||
path.points?.forEach((point) => {
|
||||
point.triggers?.forEach((trigger: Trigger) => {
|
||||
if (trigger.type === "On-Hit" && trigger.isUsed) {
|
||||
triggerCounts[`${point.uuid}-${trigger.uuid}`] = 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
newStates[process.id] = {
|
||||
spawnedObjects: {},
|
||||
nextSpawnTime: 0,
|
||||
objectIdCounter: 0,
|
||||
isProcessDelaying: false,
|
||||
processDelayStartTime: 0,
|
||||
processDelayDuration: 0,
|
||||
triggerCounts,
|
||||
triggerLogs: [],
|
||||
};
|
||||
});
|
||||
|
||||
setAnimationStates(newStates);
|
||||
animationStatesRef.current = newStates;
|
||||
clockRef.current.start();
|
||||
}
|
||||
}, [isPlaying, processes, internalResetFlag]);
|
||||
|
||||
// Helper functions
|
||||
const findSpawnPoint = (process: ProcessData): ProcessPoint | null => {
|
||||
for (const path of process.paths || []) {
|
||||
|
@ -396,15 +462,29 @@ export const useProcessAnimation = (
|
|||
);
|
||||
if (onHitTriggers.length === 0) return prev;
|
||||
|
||||
const newTriggerCounts = { ...processState.triggerCounts };
|
||||
let newTriggerCounts = { ...processState.triggerCounts };
|
||||
const newTriggerLogs = [...processState.triggerLogs];
|
||||
let shouldLog = false;
|
||||
|
||||
// Update counts for all valid triggers
|
||||
// Find all vehicle paths for this process
|
||||
const vehiclePaths = process.paths.filter(
|
||||
(path) => path.type === "Vehicle"
|
||||
);
|
||||
|
||||
// Check if any vehicle is active for this process
|
||||
const activeVehicles = vehiclePaths.filter(path => {
|
||||
const vehicleId = path.modeluuid;
|
||||
const vehicleEntry = agvRef.current.find(
|
||||
(v: any) => v.vehicleId === vehicleId && v.processId === processId
|
||||
);
|
||||
return vehicleEntry?.isActive;
|
||||
});
|
||||
|
||||
// Only count triggers if no vehicles are active for this process
|
||||
if (activeVehicles.length === 0) {
|
||||
onHitTriggers.forEach((trigger: Trigger) => {
|
||||
const triggerKey = `${point.uuid}-${trigger.uuid}`;
|
||||
newTriggerCounts[triggerKey] =
|
||||
(newTriggerCounts[triggerKey] || 0) + 1;
|
||||
newTriggerCounts[triggerKey] = (newTriggerCounts[triggerKey] || 0) + 1;
|
||||
shouldLog = true;
|
||||
newTriggerLogs.push({
|
||||
timestamp: currentTime,
|
||||
|
@ -413,54 +493,43 @@ export const useProcessAnimation = (
|
|||
triggerId: trigger.uuid,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const processTotalHits = Object.values(newTriggerCounts).reduce(
|
||||
(a, b) => a + b,
|
||||
0
|
||||
);
|
||||
let processTotalHits = Object.values(newTriggerCounts).reduce((a, b) => a + b, 0);
|
||||
|
||||
if (shouldLog) {
|
||||
const vehiclePaths = process.paths.filter(
|
||||
(path) => path.type === "Vehicle"
|
||||
);
|
||||
|
||||
vehiclePaths.forEach((vehiclePath) => {
|
||||
if (vehiclePath.points?.length > 0) {
|
||||
const vehiclePoint = vehiclePath.points[0];
|
||||
const action = vehiclePoint.actions?.[0];
|
||||
let expectedHitCount = action?.hitCount;
|
||||
const maxHitCount = action?.hitCount;
|
||||
|
||||
if (expectedHitCount !== undefined) {
|
||||
if (maxHitCount !== undefined) {
|
||||
const vehicleId = vehiclePath.modeluuid;
|
||||
|
||||
let vehicleEntry = agvRef.current.find(
|
||||
(v: any) =>
|
||||
v.vehicleId === vehicleId && v.processId === processId
|
||||
);
|
||||
let vehicleEntry = agvRef.current.find((v: any) => v.vehicleId === vehicleId && v.processId === processId);
|
||||
|
||||
if (!vehicleEntry) {
|
||||
vehicleEntry = {
|
||||
processId,
|
||||
vehicleId,
|
||||
expectedHitCount,
|
||||
isplaying: false,
|
||||
hitCount: 0, // Initialize hitCount
|
||||
maxHitCount: maxHitCount,
|
||||
isActive: false,
|
||||
hitCount: 0,
|
||||
status: 'stationed'
|
||||
};
|
||||
agvRef.current.push(vehicleEntry);
|
||||
}
|
||||
|
||||
// Increment expectedHitCount if not playing
|
||||
if (!vehicleEntry.isplaying) {
|
||||
vehicleEntry.expectedHitCount = processTotalHits;
|
||||
}
|
||||
|
||||
// Set vehicle's hitCount to the processTotalHits
|
||||
// if (!vehicleEntry.isActive && vehicleEntry.status === 'picking') {
|
||||
if (!vehicleEntry.isActive) {
|
||||
vehicleEntry.hitCount = processTotalHits;
|
||||
vehicleEntry.lastUpdated = currentTime;
|
||||
|
||||
// If hitCount matches expectedHitCount, set isplaying to true
|
||||
if (vehicleEntry.hitCount >= vehicleEntry.expectedHitCount) {
|
||||
vehicleEntry.isplaying = true;
|
||||
if (vehicleEntry.hitCount >= vehicleEntry.maxHitCount) {
|
||||
vehicleEntry.isActive = true;
|
||||
newTriggerCounts = {};
|
||||
processTotalHits = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import Agv from "../builder/agv/agv";
|
|||
function Simulation() {
|
||||
const { activeModule } = useModuleStore();
|
||||
const pathsGroupRef = useRef() as React.MutableRefObject<THREE.Group>;
|
||||
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||
const [processes, setProcesses] = useState<any[]>([]);
|
||||
const agvRef = useRef([]);
|
||||
const MaterialRef = useRef([]);
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
import React, { useEffect, useRef, useState, useCallback } from "react";
|
||||
import { useWidgetStore, Widget } from "../../../store/useWidgetStore";
|
||||
import { MoveArrowLeft, MoveArrowRight } from "../../icons/SimulationIcons";
|
||||
import { InfoIcon } from "../../icons/ExportCommonIcons";
|
||||
import { useWidgetStore, Widget } from "../../store/useWidgetStore";
|
||||
|
||||
import {
|
||||
useDroppedObjectsStore,
|
||||
useFloatingWidget,
|
||||
} from "../../../store/useDroppedObjectsStore";
|
||||
import { getSelect2dZoneData } from "../../../services/realTimeVisulization/zoneData/getSelect2dZoneData";
|
||||
import { getFloatingZoneData } from "../../../services/realTimeVisulization/zoneData/getFloatingData";
|
||||
import { get3dWidgetZoneData } from "../../../services/realTimeVisulization/zoneData/get3dWidgetData";
|
||||
} from "../../store/useDroppedObjectsStore";
|
||||
import { getSelect2dZoneData } from "../../services/realTimeVisulization/zoneData/getSelect2dZoneData";
|
||||
import { getFloatingZoneData } from "../../services/realTimeVisulization/zoneData/getFloatingData";
|
||||
import { get3dWidgetZoneData } from "../../services/realTimeVisulization/zoneData/get3dWidgetData";
|
||||
import {
|
||||
MoveArrowLeft,
|
||||
MoveArrowRight,
|
||||
} from "../../components/icons/SimulationIcons";
|
||||
import { InfoIcon } from "../../components/icons/ExportCommonIcons";
|
||||
|
||||
// Define the type for `Side`
|
||||
type Side = "top" | "bottom" | "left" | "right";
|
||||
|
@ -83,9 +87,9 @@ const DisplayZone: React.FC<DisplayZoneProps> = ({
|
|||
// State to track overflow visibility
|
||||
const [showLeftArrow, setShowLeftArrow] = useState(false);
|
||||
const [showRightArrow, setShowRightArrow] = useState(false);
|
||||
const { floatingWidget, setFloatingWidget } = useFloatingWidget()
|
||||
const { floatingWidget, setFloatingWidget } = useFloatingWidget();
|
||||
|
||||
const { setSelectedChartId } = useWidgetStore()
|
||||
const { setSelectedChartId } = useWidgetStore();
|
||||
|
||||
// Function to calculate overflow state
|
||||
const updateOverflowState = useCallback(() => {
|
||||
|
@ -166,9 +170,9 @@ const DisplayZone: React.FC<DisplayZoneProps> = ({
|
|||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
let response = await getSelect2dZoneData(zoneId, organization);
|
||||
console.log('response: ', response);
|
||||
console.log("response: ", response);
|
||||
let res = await getFloatingZoneData(zoneId, organization);
|
||||
console.log('res: ', res);
|
||||
console.log("res: ", res);
|
||||
|
||||
setFloatingWidget(res);
|
||||
// Set the selected zone in the store
|
||||
|
@ -190,9 +194,7 @@ const DisplayZone: React.FC<DisplayZoneProps> = ({
|
|||
zoneViewPortTarget: response.viewPortCenter || {},
|
||||
zoneViewPortPosition: response.viewPortposition || {},
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
return (
|
|
@ -1,34 +1,39 @@
|
|||
import React, { useEffect, useState, useRef } from "react";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import Panel from "./Panel";
|
||||
import AddButtons from "./AddButtons";
|
||||
import { useSelectedZoneStore } from "../../../store/useZoneStore";
|
||||
import { usePlayButtonStore } from "../../store/usePlayButtonStore";
|
||||
import Panel from "./widgets/panel/Panel";
|
||||
import AddButtons from "./widgets/panel/AddButtons";
|
||||
import { useSelectedZoneStore } from "../../store/useZoneStore";
|
||||
import DisplayZone from "./DisplayZone";
|
||||
import Scene from "../../../modules/scene/scene";
|
||||
import useModuleStore from "../../../store/useModuleStore";
|
||||
import Scene from "../scene/scene";
|
||||
import useModuleStore from "../../store/useModuleStore";
|
||||
|
||||
import { useDroppedObjectsStore, useFloatingWidget } from "../../../store/useDroppedObjectsStore";
|
||||
import {
|
||||
useDroppedObjectsStore,
|
||||
useFloatingWidget,
|
||||
} from "../../store/useDroppedObjectsStore";
|
||||
import {
|
||||
useAsset3dWidget,
|
||||
useSocketStore,
|
||||
useWidgetSubOption,
|
||||
useZones,
|
||||
} from "../../../store/store";
|
||||
import { getZone2dData } from "../../../services/realTimeVisulization/zoneData/getZoneData";
|
||||
import { generateUniqueId } from "../../../functions/generateUniqueId";
|
||||
} from "../../store/store";
|
||||
import { getZone2dData } from "../../services/realTimeVisulization/zoneData/getZoneData";
|
||||
import { generateUniqueId } from "../../functions/generateUniqueId";
|
||||
import { determinePosition } from "./functions/determinePosition";
|
||||
import { addingFloatingWidgets } from "../../../services/realTimeVisulization/zoneData/addFloatingWidgets";
|
||||
import SocketRealTimeViz from "../../../modules/visualization/realTimeVizSocket.dev";
|
||||
import RenderOverlay from "../../templates/Overlay";
|
||||
import ConfirmationPopup from "../../layout/confirmationPopup/ConfirmationPopup";
|
||||
import DroppedObjects from "./DroppedFloatingWidgets";
|
||||
import EditWidgetOption from "../menu/EditWidgetOption";
|
||||
import { addingFloatingWidgets } from "../../services/realTimeVisulization/zoneData/addFloatingWidgets";
|
||||
import SocketRealTimeViz from "./socket/realTimeVizSocket.dev";
|
||||
import RenderOverlay from "../../components/templates/Overlay";
|
||||
import ConfirmationPopup from "../../components/layout/confirmationPopup/ConfirmationPopup";
|
||||
import DroppedObjects from "./widgets/floating/DroppedFloatingWidgets";
|
||||
import EditWidgetOption from "../../components/ui/menu/EditWidgetOption";
|
||||
import {
|
||||
useEditWidgetOptionsStore,
|
||||
useRightClickSelected,
|
||||
useRightSelected,
|
||||
} from "../../../store/useZone3DWidgetStore";
|
||||
import Dropped3dWidgets from "./Dropped3dWidget";
|
||||
} from "../../store/useZone3DWidgetStore";
|
||||
import Dropped3dWidgets from "./widgets/3d/Dropped3dWidget";
|
||||
import OuterClick from "../../utils/outerClick";
|
||||
import { useWidgetStore } from "../../store/useWidgetStore";
|
||||
|
||||
type Side = "top" | "bottom" | "left" | "right";
|
||||
|
||||
|
@ -74,10 +79,22 @@ const RealTimeVisulization: React.FC = () => {
|
|||
const [openConfirmationPopup, setOpenConfirmationPopup] = useState(false);
|
||||
|
||||
// const [floatingWidgets, setFloatingWidgets] = useState<Record<string, { zoneName: string; zoneId: string; objects: any[] }>>({});
|
||||
const { floatingWidget, setFloatingWidget } = useFloatingWidget()
|
||||
const { floatingWidget, setFloatingWidget } = useFloatingWidget();
|
||||
const { widgetSelect, setWidgetSelect } = useAsset3dWidget();
|
||||
const { widgetSubOption, setWidgetSubOption } = useWidgetSubOption();
|
||||
const { visualizationSocket } = useSocketStore();
|
||||
const { setSelectedChartId } = useWidgetStore();
|
||||
|
||||
OuterClick({
|
||||
contextClassName: [
|
||||
"chart-container",
|
||||
"floating",
|
||||
"sidebar-right-wrapper",
|
||||
"card",
|
||||
"dropdown-menu",
|
||||
],
|
||||
setMenuVisible: () => setSelectedChartId(null),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
async function GetZoneData() {
|
||||
|
@ -85,7 +102,7 @@ const RealTimeVisulization: React.FC = () => {
|
|||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
try {
|
||||
const response = await getZone2dData(organization);
|
||||
console.log('response: ', response);
|
||||
// console.log('response: ', response);
|
||||
|
||||
if (!Array.isArray(response)) {
|
||||
return;
|
||||
|
@ -107,7 +124,7 @@ const RealTimeVisulization: React.FC = () => {
|
|||
{}
|
||||
);
|
||||
setZonesData(formattedData);
|
||||
} catch (error) { }
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
GetZoneData();
|
||||
|
@ -123,7 +140,7 @@ const RealTimeVisulization: React.FC = () => {
|
|||
activeSides: selectedZone.activeSides || [],
|
||||
panelOrder: selectedZone.panelOrder || [],
|
||||
lockedPanels: selectedZone.lockedPanels || [],
|
||||
points:selectedZone.points||[],
|
||||
points: selectedZone.points || [],
|
||||
zoneId: selectedZone.zoneId || "",
|
||||
zoneViewPortTarget: selectedZone.zoneViewPortTarget || [],
|
||||
zoneViewPortPosition: selectedZone.zoneViewPortPosition || [],
|
||||
|
@ -138,12 +155,10 @@ const RealTimeVisulization: React.FC = () => {
|
|||
const handleDrop = async (event: React.DragEvent<HTMLDivElement>) => {
|
||||
event.preventDefault();
|
||||
try {
|
||||
event.preventDefault();
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
|
||||
const data = event.dataTransfer.getData("text/plain");
|
||||
// if (widgetSelect !== "") return;
|
||||
if (widgetSubOption === "3D") return;
|
||||
if (!data || selectedZone.zoneName === "") return;
|
||||
|
||||
|
@ -151,69 +166,88 @@ const RealTimeVisulization: React.FC = () => {
|
|||
const canvasElement = document.getElementById("real-time-vis-canvas");
|
||||
if (!canvasElement) throw new Error("Canvas element not found");
|
||||
|
||||
const canvasRect = canvasElement.getBoundingClientRect();
|
||||
const relativeX = event.clientX - canvasRect.left;
|
||||
const relativeY = event.clientY - canvasRect.top;
|
||||
// Get canvas dimensions and mouse position
|
||||
const rect = canvasElement.getBoundingClientRect();
|
||||
let relativeX = (event.clientX - rect.left) ;
|
||||
let relativeY = event.clientY - rect.top;
|
||||
|
||||
// Widget dimensions (with defaults)
|
||||
const widgetWidth = droppedData.width || 125; // 250/2 as default
|
||||
const widgetHeight = droppedData.height || 100; // 83/2 as default
|
||||
|
||||
// Clamp to ensure widget stays fully inside canvas
|
||||
const clampedX = Math.max(
|
||||
0, // Prevent going beyond left edge
|
||||
Math.min(
|
||||
relativeX,
|
||||
rect.width - widgetWidth // Prevent going beyond right edge
|
||||
)
|
||||
);
|
||||
|
||||
console.log('clampedX: ', clampedX);
|
||||
const clampedY = Math.max(
|
||||
0, // Prevent going beyond top edge
|
||||
Math.min(
|
||||
relativeY,
|
||||
rect.height - widgetHeight // Prevent going beyond bottom edge
|
||||
)
|
||||
);
|
||||
|
||||
// Debug logging (optional)
|
||||
console.log("Drop coordinates:", {
|
||||
rawX: relativeX,
|
||||
rawY: relativeY,
|
||||
clampedX,
|
||||
clampedY,
|
||||
canvasWidth: rect.width,
|
||||
canvasHeight: rect.height,
|
||||
widgetWidth,
|
||||
widgetHeight
|
||||
});
|
||||
|
||||
const finalPosition = determinePosition(rect, clampedX, clampedY);
|
||||
|
||||
const newPosition = determinePosition(canvasRect, relativeX, relativeY);
|
||||
console.log("newPosition: ", newPosition);
|
||||
const newObject = {
|
||||
...droppedData,
|
||||
id: generateUniqueId(),
|
||||
position: determinePosition(canvasRect, relativeX, relativeY),
|
||||
position: finalPosition,
|
||||
};
|
||||
|
||||
// Only set zone if it’s not already in the store (prevents overwriting objects)
|
||||
const existingZone =
|
||||
useDroppedObjectsStore.getState().zones[selectedZone.zoneName];
|
||||
// Zone management
|
||||
const existingZone = useDroppedObjectsStore.getState().zones[selectedZone.zoneName];
|
||||
if (!existingZone) {
|
||||
useDroppedObjectsStore
|
||||
.getState()
|
||||
.setZone(selectedZone.zoneName, selectedZone.zoneId);
|
||||
useDroppedObjectsStore.getState().setZone(selectedZone.zoneName, selectedZone.zoneId);
|
||||
}
|
||||
|
||||
let addFloatingWidget = {
|
||||
organization: organization,
|
||||
// Socket emission
|
||||
const addFloatingWidget = {
|
||||
organization,
|
||||
widget: newObject,
|
||||
zoneId: selectedZone.zoneId,
|
||||
};
|
||||
console.log("newObject: ", newObject);
|
||||
|
||||
if (visualizationSocket) {
|
||||
visualizationSocket.emit("v2:viz-float:add", addFloatingWidget);
|
||||
}
|
||||
useDroppedObjectsStore
|
||||
.getState()
|
||||
.addObject(selectedZone.zoneName, newObject);
|
||||
|
||||
//I need to console here objects based on selectedZone.zoneId
|
||||
// Console the objects after adding
|
||||
// Store update
|
||||
useDroppedObjectsStore.getState().addObject(selectedZone.zoneName, newObject);
|
||||
|
||||
// Post-drop verification
|
||||
const droppedObjectsStore = useDroppedObjectsStore.getState();
|
||||
const currentZone = droppedObjectsStore.zones[selectedZone.zoneName];
|
||||
|
||||
if (currentZone && currentZone.zoneId === selectedZone.zoneId) {
|
||||
console.log(
|
||||
`Objects for Zone ID: ${selectedZone.zoneId}`,
|
||||
currentZone.objects
|
||||
);
|
||||
setFloatingWidget(currentZone.objects)
|
||||
console.log(`Objects for Zone ${selectedZone.zoneId}:`, currentZone.objects);
|
||||
setFloatingWidget(currentZone.objects);
|
||||
} else {
|
||||
console.warn("Zone not found or mismatched zoneId");
|
||||
console.warn("Zone not found or zoneId mismatch");
|
||||
}
|
||||
|
||||
// let response = await addingFloatingWidgets(
|
||||
// selectedZone.zoneId,
|
||||
// organization,
|
||||
// newObject
|
||||
// );
|
||||
// Add the dropped object to the zone if the API call is successful
|
||||
// if (response.message === "FloatWidget created successfully") {
|
||||
// }
|
||||
|
||||
// Update floating widgets state
|
||||
|
||||
} catch (error) { }
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error in handleDrop:", error);
|
||||
// Consider adding user feedback here (e.g., toast notification)
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -253,7 +287,7 @@ const RealTimeVisulization: React.FC = () => {
|
|||
<RenderOverlay>
|
||||
<ConfirmationPopup
|
||||
message={"Are you sure want to delete?"}
|
||||
onConfirm={() => console.log("confirm")}
|
||||
onConfirm={() => console.log("Confirmed")}
|
||||
onCancel={() => setOpenConfirmationPopup(false)}
|
||||
/>
|
||||
</RenderOverlay>
|
||||
|
@ -286,7 +320,6 @@ const RealTimeVisulization: React.FC = () => {
|
|||
"Horizontal Move",
|
||||
"RotateX",
|
||||
"RotateY",
|
||||
"RotateZ",
|
||||
"Delete",
|
||||
]}
|
||||
/>
|
|
@ -1,4 +1,4 @@
|
|||
import { Template } from "../../store/useTemplateStore";
|
||||
import { Template } from "../../../store/useTemplateStore";
|
||||
import { captureVisualization } from "./captureVisualization";
|
||||
|
||||
type HandleSaveTemplateProps = {
|
||||
|
@ -26,7 +26,6 @@ export const handleSaveTemplate = async ({
|
|||
templates = [],
|
||||
visualizationSocket,
|
||||
}: HandleSaveTemplateProps): Promise<void> => {
|
||||
console.log("floatingWidget: ", floatingWidget);
|
||||
try {
|
||||
// Check if the selected zone has any widgets
|
||||
if (!selectedZone.panelOrder || selectedZone.panelOrder.length === 0) {
|
||||
|
@ -49,6 +48,7 @@ export const handleSaveTemplate = async ({
|
|||
// Capture visualization snapshot
|
||||
const snapshot = await captureVisualization();
|
||||
|
||||
|
||||
if (!snapshot) {
|
||||
return;
|
||||
}
|
|
@ -1,238 +0,0 @@
|
|||
import { useEffect } from "react";
|
||||
import { useSocketStore } from "../../store/store";
|
||||
import { useSelectedZoneStore } from "../../store/useZoneStore";
|
||||
import { useDroppedObjectsStore } from "../../store/useDroppedObjectsStore";
|
||||
import { useZoneWidgetStore } from "../../store/useZone3DWidgetStore";
|
||||
import useTemplateStore from "../../store/useTemplateStore";
|
||||
|
||||
type WidgetData = {
|
||||
id: string;
|
||||
type: string;
|
||||
position: [number, number, number];
|
||||
rotation?: [number, number, number];
|
||||
tempPosition?: [number, number, number];
|
||||
};
|
||||
|
||||
export default function SocketRealTimeViz() {
|
||||
const { visualizationSocket } = useSocketStore();
|
||||
const { setSelectedZone } = useSelectedZoneStore();
|
||||
const deleteObject = useDroppedObjectsStore((state) => state.deleteObject);
|
||||
const updateObjectPosition = useDroppedObjectsStore((state) => state.updateObjectPosition);
|
||||
const { addWidget } = useZoneWidgetStore()
|
||||
const { removeTemplate } = useTemplateStore();
|
||||
const { setTemplates } = useTemplateStore();
|
||||
const { zoneWidgetData, setZoneWidgetData, updateWidgetPosition, updateWidgetRotation } = useZoneWidgetStore();
|
||||
|
||||
useEffect(() => {
|
||||
if (visualizationSocket) {
|
||||
//add panel response
|
||||
visualizationSocket.on("viz-panel:response:updates", (addPanel: any) => {
|
||||
|
||||
if (addPanel.success) {
|
||||
let addPanelData = addPanel.data.data
|
||||
setSelectedZone(addPanelData)
|
||||
}
|
||||
})
|
||||
//delete panel response
|
||||
visualizationSocket.on("viz-panel:response:delete", (deletePanel: any) => {
|
||||
|
||||
if (deletePanel.success) {
|
||||
let deletePanelData = deletePanel.data.data
|
||||
setSelectedZone(deletePanelData)
|
||||
}
|
||||
})
|
||||
//clear Panel response
|
||||
visualizationSocket.on("viz-panel:response:clear", (clearPanel: any) => {
|
||||
|
||||
if (clearPanel.success && clearPanel.message === "PanelWidgets cleared successfully") {
|
||||
|
||||
let clearPanelData = clearPanel.data.data
|
||||
setSelectedZone(clearPanelData)
|
||||
}
|
||||
})
|
||||
//lock Panel response
|
||||
visualizationSocket.on("viz-panel:response:locked", (lockPanel: any) => {
|
||||
|
||||
if (lockPanel.success && lockPanel.message === "locked panel updated successfully") {
|
||||
|
||||
let lockPanelData = lockPanel.data.data
|
||||
setSelectedZone(lockPanelData)
|
||||
}
|
||||
})
|
||||
// add 2dWidget response
|
||||
visualizationSocket.on("viz-widget:response:updates", (add2dWidget: any) => {
|
||||
|
||||
|
||||
if (add2dWidget.success && add2dWidget.data) {
|
||||
setSelectedZone((prev) => {
|
||||
const isWidgetAlreadyAdded = prev.widgets.some(
|
||||
(widget) => widget.id === add2dWidget.data.widgetData.id
|
||||
);
|
||||
if (isWidgetAlreadyAdded) return prev; // Prevent duplicate addition
|
||||
return {
|
||||
...prev,
|
||||
zoneId: add2dWidget.data.zoneId,
|
||||
zoneName: add2dWidget.data.zoneName,
|
||||
widgets: [...prev.widgets, add2dWidget.data.widgetData], // Append new widget
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
//delete 2D Widget response
|
||||
visualizationSocket.on("viz-widget:response:delete", (deleteWidget: any) => {
|
||||
|
||||
|
||||
if (deleteWidget?.success && deleteWidget.data) {
|
||||
setSelectedZone((prevZone: any) => ({
|
||||
...prevZone,
|
||||
zoneId: deleteWidget.data.zoneId,
|
||||
zoneName: deleteWidget.data.zoneName,
|
||||
widgets: deleteWidget.data.widgetDeleteDatas, // Replace with new widget list
|
||||
}));
|
||||
}
|
||||
});
|
||||
//add Floating Widget response
|
||||
visualizationSocket.on("viz-float:response:updates", (addFloatingWidget: any) => {
|
||||
|
||||
|
||||
if (addFloatingWidget.success) {
|
||||
if (addFloatingWidget.success && addFloatingWidget.message === "FloatWidget created successfully") {
|
||||
const state = useDroppedObjectsStore.getState();
|
||||
const zone = state.zones[addFloatingWidget.data.zoneName];
|
||||
if (!zone) {
|
||||
state.setZone(addFloatingWidget.data.zoneName, addFloatingWidget.data.zoneId);
|
||||
}
|
||||
const existingObjects = zone ? zone.objects : [];
|
||||
const newWidget = addFloatingWidget.data.widget;
|
||||
// ✅ Check if the widget ID already exists before adding
|
||||
const isAlreadyAdded = existingObjects.some(obj => obj.id === newWidget.id);
|
||||
if (isAlreadyAdded) {
|
||||
|
||||
return; // Don't add the widget if it already exists
|
||||
}
|
||||
// Add widget only if it doesn't exist
|
||||
state.addObject(addFloatingWidget.data.zoneName, newWidget);
|
||||
}
|
||||
if (addFloatingWidget.message === "Widget updated successfully") {
|
||||
updateObjectPosition(addFloatingWidget.data.zoneName, addFloatingWidget.data.index, addFloatingWidget.data.position);
|
||||
}
|
||||
}
|
||||
});
|
||||
//duplicate Floating Widget response
|
||||
visualizationSocket.on("viz-float:response:addDuplicate", (duplicateFloatingWidget: any) => {
|
||||
|
||||
|
||||
if (duplicateFloatingWidget.success && duplicateFloatingWidget.message === "duplicate FloatWidget created successfully") {
|
||||
useDroppedObjectsStore.setState((state) => {
|
||||
const zone = state.zones[duplicateFloatingWidget.data.zoneName];
|
||||
if (!zone) return state; // Zone doesn't exist, return state as is
|
||||
const existingObjects = zone.objects;
|
||||
const newWidget = duplicateFloatingWidget.data.widget;
|
||||
// ✅ Check if the object with the same ID already exists
|
||||
const isAlreadyAdded = existingObjects.some(obj => obj.id === newWidget.id);
|
||||
if (isAlreadyAdded) {
|
||||
|
||||
return state; // Don't update state if it's already there
|
||||
}
|
||||
return {
|
||||
zones: {
|
||||
...state.zones,
|
||||
[duplicateFloatingWidget.data.zoneName]: {
|
||||
...zone,
|
||||
objects: [...existingObjects, newWidget], // Append only if it's not a duplicate
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
//delete Floating Widget response
|
||||
visualizationSocket.on("viz-float:response:delete", (deleteFloatingWidget: any) => {
|
||||
|
||||
|
||||
if (deleteFloatingWidget.success) {
|
||||
deleteObject(deleteFloatingWidget.data.zoneName, deleteFloatingWidget.data.floatWidgetID);
|
||||
}
|
||||
});
|
||||
//add 3D Widget response
|
||||
visualizationSocket.on("viz-widget3D:response:updates", (add3DWidget: any) => {
|
||||
|
||||
|
||||
if (add3DWidget.success) {
|
||||
|
||||
if (add3DWidget.message === "Widget created successfully") {
|
||||
addWidget(add3DWidget.data.zoneId, add3DWidget.data.widget);
|
||||
}
|
||||
}
|
||||
});
|
||||
//delete 3D Widget response
|
||||
visualizationSocket.on("viz-widget3D:response:delete", (delete3DWidget: any) => {
|
||||
|
||||
// "3DWidget delete unsuccessfull"
|
||||
if (delete3DWidget.success && delete3DWidget.message === "3DWidget delete successfull") {
|
||||
const activeZoneWidgets = zoneWidgetData[delete3DWidget.data.zoneId] || [];
|
||||
setZoneWidgetData(
|
||||
delete3DWidget.data.zoneId,
|
||||
activeZoneWidgets.filter((w: WidgetData) => w.id !== delete3DWidget.data.id)
|
||||
);
|
||||
}
|
||||
});
|
||||
//update3D widget response
|
||||
visualizationSocket.on("viz-widget3D:response:modifyPositionRotation", (update3DWidget: any) => {
|
||||
|
||||
|
||||
if (update3DWidget.success && update3DWidget.message === "widget update successfully") {
|
||||
updateWidgetPosition(update3DWidget.data.zoneId, update3DWidget.data.widget.id, update3DWidget.data.widget.position);
|
||||
updateWidgetRotation(update3DWidget.data.zoneId, update3DWidget.data.widget.id, update3DWidget.data.widget.rotation);
|
||||
}
|
||||
});
|
||||
// add Template response
|
||||
visualizationSocket.on("viz-template:response:add", (addingTemplate: any) => {
|
||||
|
||||
|
||||
if (addingTemplate.success) {
|
||||
if (addingTemplate.message === "Template saved successfully") {
|
||||
setTemplates(addingTemplate.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
//load Template response
|
||||
visualizationSocket.on("viz-template:response:addTemplateZone", (loadTemplate: any) => {
|
||||
|
||||
|
||||
if (loadTemplate.success) {
|
||||
if (loadTemplate.message === "Template placed in Zone") {
|
||||
let template = loadTemplate.data.template
|
||||
setSelectedZone({
|
||||
panelOrder: template.panelOrder,
|
||||
activeSides: Array.from(new Set(template.panelOrder)), // No merging with previous `activeSides`
|
||||
widgets: template.widgets,
|
||||
});
|
||||
useDroppedObjectsStore.getState().setZone(template.zoneName, template.zoneId);
|
||||
|
||||
if (Array.isArray(template.floatingWidget)) {
|
||||
template.floatingWidget.forEach((val: any) => {
|
||||
useDroppedObjectsStore.getState().addObject(template.zoneName, val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
//delete Template response
|
||||
visualizationSocket.on("viz-template:response:delete", (deleteTemplate: any) => {
|
||||
|
||||
|
||||
if (deleteTemplate.success) {
|
||||
if (deleteTemplate.message === 'Template deleted successfully') {
|
||||
removeTemplate(deleteTemplate.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [visualizationSocket])
|
||||
|
||||
return (
|
||||
<></>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,296 @@
|
|||
import { useEffect } from "react";
|
||||
import { useSocketStore } from "../../../store/store";
|
||||
import { useSelectedZoneStore } from "../../../store/useZoneStore";
|
||||
import { useDroppedObjectsStore } from "../../../store/useDroppedObjectsStore";
|
||||
import { useZoneWidgetStore } from "../../../store/useZone3DWidgetStore";
|
||||
import useTemplateStore from "../../../store/useTemplateStore";
|
||||
|
||||
type WidgetData = {
|
||||
id: string;
|
||||
type: string;
|
||||
position: [number, number, number];
|
||||
rotation?: [number, number, number];
|
||||
tempPosition?: [number, number, number];
|
||||
};
|
||||
|
||||
export default function SocketRealTimeViz() {
|
||||
const { visualizationSocket } = useSocketStore();
|
||||
const { setSelectedZone } = useSelectedZoneStore();
|
||||
const deleteObject = useDroppedObjectsStore((state) => state.deleteObject);
|
||||
const updateObjectPosition = useDroppedObjectsStore(
|
||||
(state) => state.updateObjectPosition
|
||||
);
|
||||
const { addWidget } = useZoneWidgetStore();
|
||||
const { removeTemplate } = useTemplateStore();
|
||||
const { setTemplates } = useTemplateStore();
|
||||
const {
|
||||
zoneWidgetData,
|
||||
setZoneWidgetData,
|
||||
updateWidgetPosition,
|
||||
updateWidgetRotation,
|
||||
} = useZoneWidgetStore();
|
||||
|
||||
useEffect(() => {
|
||||
if (visualizationSocket) {
|
||||
//add panel response
|
||||
visualizationSocket.on("viz-panel:response:updates", (addPanel: any) => {
|
||||
if (addPanel.success) {
|
||||
let addPanelData = addPanel.data.data;
|
||||
setSelectedZone(addPanelData);
|
||||
}
|
||||
});
|
||||
//delete panel response
|
||||
visualizationSocket.on(
|
||||
"viz-panel:response:delete",
|
||||
(deletePanel: any) => {
|
||||
if (deletePanel.success) {
|
||||
let deletePanelData = deletePanel.data.data;
|
||||
setSelectedZone(deletePanelData);
|
||||
}
|
||||
}
|
||||
);
|
||||
//clear Panel response
|
||||
visualizationSocket.on("viz-panel:response:clear", (clearPanel: any) => {
|
||||
if (
|
||||
clearPanel.success &&
|
||||
clearPanel.message === "PanelWidgets cleared successfully"
|
||||
) {
|
||||
let clearPanelData = clearPanel.data.data;
|
||||
setSelectedZone(clearPanelData);
|
||||
}
|
||||
});
|
||||
//lock Panel response
|
||||
visualizationSocket.on("viz-panel:response:locked", (lockPanel: any) => {
|
||||
if (
|
||||
lockPanel.success &&
|
||||
lockPanel.message === "locked panel updated successfully"
|
||||
) {
|
||||
let lockPanelData = lockPanel.data.data;
|
||||
setSelectedZone(lockPanelData);
|
||||
}
|
||||
});
|
||||
// add 2dWidget response
|
||||
visualizationSocket.on(
|
||||
"viz-widget:response:updates",
|
||||
(add2dWidget: any) => {
|
||||
if (add2dWidget.success && add2dWidget.data) {
|
||||
setSelectedZone((prev) => {
|
||||
const isWidgetAlreadyAdded = prev.widgets.some(
|
||||
(widget) => widget.id === add2dWidget.data.widgetData.id
|
||||
);
|
||||
if (isWidgetAlreadyAdded) return prev; // Prevent duplicate addition
|
||||
return {
|
||||
...prev,
|
||||
zoneId: add2dWidget.data.zoneId,
|
||||
zoneName: add2dWidget.data.zoneName,
|
||||
widgets: [...prev.widgets, add2dWidget.data.widgetData], // Append new widget
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
//delete 2D Widget response
|
||||
visualizationSocket.on(
|
||||
"viz-widget:response:delete",
|
||||
(deleteWidget: any) => {
|
||||
if (deleteWidget?.success && deleteWidget.data) {
|
||||
setSelectedZone((prevZone: any) => ({
|
||||
...prevZone,
|
||||
zoneId: deleteWidget.data.zoneId,
|
||||
zoneName: deleteWidget.data.zoneName,
|
||||
widgets: deleteWidget.data.widgetDeleteDatas, // Replace with new widget list
|
||||
}));
|
||||
}
|
||||
}
|
||||
);
|
||||
//add Floating Widget response
|
||||
visualizationSocket.on(
|
||||
"viz-float:response:updates",
|
||||
(addFloatingWidget: any) => {
|
||||
if (addFloatingWidget.success) {
|
||||
if (
|
||||
addFloatingWidget.success &&
|
||||
addFloatingWidget.message === "FloatWidget created successfully"
|
||||
) {
|
||||
const state = useDroppedObjectsStore.getState();
|
||||
const zone = state.zones[addFloatingWidget.data.zoneName];
|
||||
if (!zone) {
|
||||
state.setZone(
|
||||
addFloatingWidget.data.zoneName,
|
||||
addFloatingWidget.data.zoneId
|
||||
);
|
||||
}
|
||||
const existingObjects = zone ? zone.objects : [];
|
||||
const newWidget = addFloatingWidget.data.widget;
|
||||
// ✅ Check if the widget ID already exists before adding
|
||||
const isAlreadyAdded = existingObjects.some(
|
||||
(obj) => obj.id === newWidget.id
|
||||
);
|
||||
if (isAlreadyAdded) {
|
||||
return; // Don't add the widget if it already exists
|
||||
}
|
||||
// Add widget only if it doesn't exist
|
||||
state.addObject(addFloatingWidget.data.zoneName, newWidget);
|
||||
}
|
||||
if (addFloatingWidget.message === "Widget updated successfully") {
|
||||
updateObjectPosition(
|
||||
addFloatingWidget.data.zoneName,
|
||||
addFloatingWidget.data.index,
|
||||
addFloatingWidget.data.position
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//duplicate Floating Widget response
|
||||
visualizationSocket.on(
|
||||
"viz-float:response:addDuplicate",
|
||||
(duplicateFloatingWidget: any) => {
|
||||
if (
|
||||
duplicateFloatingWidget.success &&
|
||||
duplicateFloatingWidget.message ===
|
||||
"duplicate FloatWidget created successfully"
|
||||
) {
|
||||
useDroppedObjectsStore.setState((state) => {
|
||||
const zone = state.zones[duplicateFloatingWidget.data.zoneName];
|
||||
if (!zone) return state; // Zone doesn't exist, return state as is
|
||||
const existingObjects = zone.objects;
|
||||
const newWidget = duplicateFloatingWidget.data.widget;
|
||||
// ✅ Check if the object with the same ID already exists
|
||||
const isAlreadyAdded = existingObjects.some(
|
||||
(obj) => obj.id === newWidget.id
|
||||
);
|
||||
if (isAlreadyAdded) {
|
||||
return state; // Don't update state if it's already there
|
||||
}
|
||||
return {
|
||||
zones: {
|
||||
...state.zones,
|
||||
[duplicateFloatingWidget.data.zoneName]: {
|
||||
...zone,
|
||||
objects: [...existingObjects, newWidget], // Append only if it's not a duplicate
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
//delete Floating Widget response
|
||||
visualizationSocket.on(
|
||||
"viz-float:response:delete",
|
||||
(deleteFloatingWidget: any) => {
|
||||
if (deleteFloatingWidget.success) {
|
||||
deleteObject(
|
||||
deleteFloatingWidget.data.zoneName,
|
||||
deleteFloatingWidget.data.floatWidgetID
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
//add 3D Widget response
|
||||
visualizationSocket.on(
|
||||
"viz-widget3D:response:updates",
|
||||
(add3DWidget: any) => {
|
||||
if (add3DWidget.success) {
|
||||
if (add3DWidget.message === "Widget created successfully") {
|
||||
addWidget(add3DWidget.data.zoneId, add3DWidget.data.widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//delete 3D Widget response
|
||||
visualizationSocket.on(
|
||||
"viz-widget3D:response:delete",
|
||||
(delete3DWidget: any) => {
|
||||
// "3DWidget delete unsuccessfull"
|
||||
if (
|
||||
delete3DWidget.success &&
|
||||
delete3DWidget.message === "3DWidget delete successfull"
|
||||
) {
|
||||
const activeZoneWidgets =
|
||||
zoneWidgetData[delete3DWidget.data.zoneId] || [];
|
||||
setZoneWidgetData(
|
||||
delete3DWidget.data.zoneId,
|
||||
activeZoneWidgets.filter(
|
||||
(w: WidgetData) => w.id !== delete3DWidget.data.id
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
//update3D widget response
|
||||
visualizationSocket.on(
|
||||
"viz-widget3D:response:modifyPositionRotation",
|
||||
(update3DWidget: any) => {
|
||||
if (
|
||||
update3DWidget.success &&
|
||||
update3DWidget.message === "widget update successfully"
|
||||
) {
|
||||
updateWidgetPosition(
|
||||
update3DWidget.data.zoneId,
|
||||
update3DWidget.data.widget.id,
|
||||
update3DWidget.data.widget.position
|
||||
);
|
||||
updateWidgetRotation(
|
||||
update3DWidget.data.zoneId,
|
||||
update3DWidget.data.widget.id,
|
||||
update3DWidget.data.widget.rotation
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
// add Template response
|
||||
visualizationSocket.on(
|
||||
"viz-template:response:add",
|
||||
(addingTemplate: any) => {
|
||||
if (addingTemplate.success) {
|
||||
if (addingTemplate.message === "Template saved successfully") {
|
||||
setTemplates(addingTemplate.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//load Template response
|
||||
visualizationSocket.on(
|
||||
"viz-template:response:addTemplateZone",
|
||||
(loadTemplate: any) => {
|
||||
if (loadTemplate.success) {
|
||||
if (loadTemplate.message === "Template placed in Zone") {
|
||||
let template = loadTemplate.data.template;
|
||||
setSelectedZone({
|
||||
panelOrder: template.panelOrder,
|
||||
activeSides: Array.from(new Set(template.panelOrder)), // No merging with previous `activeSides`
|
||||
widgets: template.widgets,
|
||||
});
|
||||
useDroppedObjectsStore
|
||||
.getState()
|
||||
.setZone(template.zoneName, template.zoneId);
|
||||
|
||||
if (Array.isArray(template.floatingWidget)) {
|
||||
template.floatingWidget.forEach((val: any) => {
|
||||
useDroppedObjectsStore
|
||||
.getState()
|
||||
.addObject(template.zoneName, val);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//delete Template response
|
||||
visualizationSocket.on(
|
||||
"viz-template:response:delete",
|
||||
(deleteTemplate: any) => {
|
||||
if (deleteTemplate.success) {
|
||||
if (deleteTemplate.message === "Template deleted successfully") {
|
||||
removeTemplate(deleteTemplate.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}, [visualizationSocket]);
|
||||
|
||||
return <></>;
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
import { useEffect } from "react";
|
||||
import { useDroppedObjectsStore } from "../../../../store/useDroppedObjectsStore";
|
||||
import useTemplateStore from "../../../../store/useTemplateStore";
|
||||
import { useSelectedZoneStore } from "../../../../store/useZoneStore";
|
||||
import { getTemplateData } from "../../../../services/realTimeVisulization/zoneData/getTemplate";
|
||||
import { useSocketStore } from "../../../../store/store";
|
||||
import RenameInput from "../../../ui/inputs/RenameInput";
|
||||
import useTemplateStore from "../../../store/useTemplateStore";
|
||||
import { useSelectedZoneStore } from "../../../store/useZoneStore";
|
||||
import { useSocketStore } from "../../../store/store";
|
||||
import { getTemplateData } from "../../../services/realTimeVisulization/zoneData/getTemplate";
|
||||
import { useDroppedObjectsStore } from "../../../store/useDroppedObjectsStore";
|
||||
import RenameInput from "../../../components/ui/inputs/RenameInput";
|
||||
|
||||
|
||||
|
||||
const Templates = () => {
|
||||
const { templates, removeTemplate, setTemplates } = useTemplateStore();
|
||||
|
@ -26,9 +28,14 @@ const Templates = () => {
|
|||
templateData();
|
||||
}, []);
|
||||
|
||||
const handleDeleteTemplate = async (id: string) => {
|
||||
const handleDeleteTemplate = async (
|
||||
e: React.MouseEvent<HTMLButtonElement>,
|
||||
id: string
|
||||
) => {
|
||||
try {
|
||||
e.stopPropagation();
|
||||
const email = localStorage.getItem("email") || "";
|
||||
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
let deleteTemplate = {
|
||||
organization: organization,
|
||||
|
@ -49,7 +56,6 @@ const Templates = () => {
|
|||
const handleLoadTemplate = async (template: any) => {
|
||||
try {
|
||||
if (selectedZone.zoneName === "") return;
|
||||
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
|
||||
|
@ -91,10 +97,10 @@ const Templates = () => {
|
|||
<div
|
||||
key={template.id}
|
||||
className="template-item"
|
||||
onClick={() => handleLoadTemplate(template)}
|
||||
|
||||
>
|
||||
{template?.snapshot && (
|
||||
<div className="template-image-container">
|
||||
<div className="template-image-container" onClick={() => handleLoadTemplate(template)}>
|
||||
<img
|
||||
src={template.snapshot}
|
||||
alt={`${template.name} preview`}
|
||||
|
@ -108,7 +114,7 @@ const Templates = () => {
|
|||
<RenameInput value={`Template ${index + 1}`} />
|
||||
</div>
|
||||
<button
|
||||
onClick={() => handleDeleteTemplate(template.id)}
|
||||
onClick={(e) => handleDeleteTemplate(e, template.id)}
|
||||
className="delete-button"
|
||||
aria-label="Delete template"
|
||||
>
|
|
@ -1,24 +1,25 @@
|
|||
import { useWidgetStore } from "../../../store/useWidgetStore";
|
||||
import ProgressCard from "../realTimeVis/charts/ProgressCard";
|
||||
import PieGraphComponent from "../realTimeVis/charts/PieGraphComponent";
|
||||
import BarGraphComponent from "../realTimeVis/charts/BarGraphComponent";
|
||||
import LineGraphComponent from "../realTimeVis/charts/LineGraphComponent";
|
||||
import DoughnutGraphComponent from "../realTimeVis/charts/DoughnutGraphComponent";
|
||||
import PolarAreaGraphComponent from "../realTimeVis/charts/PolarAreaGraphComponent";
|
||||
import ProgressCard1 from "../realTimeVis/charts/ProgressCard1";
|
||||
import ProgressCard2 from "../realTimeVis/charts/ProgressCard2";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import ProgressCard from "../2d/charts/ProgressCard";
|
||||
import PieGraphComponent from "../2d/charts/PieGraphComponent";
|
||||
import BarGraphComponent from "../2d/charts/BarGraphComponent";
|
||||
import LineGraphComponent from "../2d/charts/LineGraphComponent";
|
||||
import DoughnutGraphComponent from "../2d/charts/DoughnutGraphComponent";
|
||||
import PolarAreaGraphComponent from "../2d/charts/PolarAreaGraphComponent";
|
||||
import ProgressCard1 from "../2d/charts/ProgressCard1";
|
||||
import ProgressCard2 from "../2d/charts/ProgressCard2";
|
||||
import {
|
||||
DeleteIcon,
|
||||
DublicateIcon,
|
||||
KebabIcon,
|
||||
} from "../../icons/ExportCommonIcons";
|
||||
} from "../../../../components/icons/ExportCommonIcons";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { duplicateWidgetApi } from "../../../services/realTimeVisulization/zoneData/duplicateWidget";
|
||||
import { deleteWidgetApi } from "../../../services/realTimeVisulization/zoneData/deleteWidgetApi";
|
||||
import { useClickOutside } from "./functions/handleWidgetsOuterClick";
|
||||
import { useSocketStore } from "../../../store/store";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import OuterClick from "../../../utils/outerClick";
|
||||
import { duplicateWidgetApi } from "../../../../services/realTimeVisulization/zoneData/duplicateWidget";
|
||||
import { deleteWidgetApi } from "../../../../services/realTimeVisulization/zoneData/deleteWidgetApi";
|
||||
import { useClickOutside } from "../../functions/handleWidgetsOuterClick";
|
||||
import { useSocketStore } from "../../../../store/store";
|
||||
import { usePlayButtonStore } from "../../../../store/usePlayButtonStore";
|
||||
import OuterClick from "../../../../utils/outerClick";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
|
||||
type Side = "top" | "bottom" | "left" | "right";
|
||||
|
||||
|
@ -44,7 +45,7 @@ export const DraggableWidget = ({
|
|||
zoneName: string;
|
||||
zoneId: string;
|
||||
activeSides: Side[];
|
||||
points:[];
|
||||
points: [];
|
||||
panelOrder: Side[];
|
||||
lockedPanels: Side[];
|
||||
widgets: Widget[];
|
||||
|
@ -54,7 +55,7 @@ export const DraggableWidget = ({
|
|||
zoneName: string;
|
||||
activeSides: Side[];
|
||||
panelOrder: Side[];
|
||||
points:[];
|
||||
points: [];
|
||||
lockedPanels: Side[];
|
||||
zoneId: string;
|
||||
zoneViewPortTarget: number[];
|
||||
|
@ -81,6 +82,16 @@ export const DraggableWidget = ({
|
|||
const [panelDimensions, setPanelDimensions] = useState<{
|
||||
[side in Side]?: { width: number; height: number };
|
||||
}>({});
|
||||
const { measurements, duration, name } = useChartStore();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
|
||||
const [canvasDimensions, setCanvasDimensions] = useState({
|
||||
width: 0,
|
||||
height: 0,
|
||||
});
|
||||
useEffect(() => {
|
||||
console.log("changes loggggg", measurements, duration, name);
|
||||
}, [measurements, duration, name])
|
||||
const handlePointerDown = () => {
|
||||
if (selectedChartId?.id !== widget.id) {
|
||||
setSelectedChartId(widget);
|
||||
|
@ -89,17 +100,6 @@ export const DraggableWidget = ({
|
|||
|
||||
const chartWidget = useRef<HTMLDivElement>(null);
|
||||
|
||||
OuterClick({
|
||||
contextClassName: [
|
||||
"chart-container",
|
||||
"floating",
|
||||
"sidebar-right-wrapper",
|
||||
"card",
|
||||
"dropdown-menu",
|
||||
],
|
||||
setMenuVisible: () => setSelectedChartId(null),
|
||||
});
|
||||
|
||||
const deleteSelectedChart = async () => {
|
||||
try {
|
||||
const email = localStorage.getItem("email") || "";
|
||||
|
@ -139,43 +139,53 @@ export const DraggableWidget = ({
|
|||
}
|
||||
};
|
||||
|
||||
// Calculate panel size
|
||||
const panelSize = Math.max(
|
||||
Math.min(canvasDimensions.width * 0.25, canvasDimensions.height * 0.25),
|
||||
170 // Min 170px
|
||||
);
|
||||
|
||||
const getCurrentWidgetCount = (panel: Side) =>
|
||||
selectedZone.widgets.filter((w) => w.panel === panel).length;
|
||||
// Calculate panel capacity
|
||||
|
||||
const calculatePanelCapacity = (panel: Side) => {
|
||||
const CHART_WIDTH = 150;
|
||||
const CHART_HEIGHT = 150;
|
||||
const FALLBACK_HORIZONTAL_CAPACITY = 5;
|
||||
const FALLBACK_VERTICAL_CAPACITY = 3;
|
||||
const CHART_WIDTH = panelSize;
|
||||
const CHART_HEIGHT = panelSize;
|
||||
|
||||
const dimensions = panelDimensions[panel];
|
||||
if (!dimensions) {
|
||||
return panel === "top" || panel === "bottom"
|
||||
? FALLBACK_HORIZONTAL_CAPACITY
|
||||
: FALLBACK_VERTICAL_CAPACITY;
|
||||
return panel === "top" || panel === "bottom" ? 5 : 3; // Fallback capacities
|
||||
}
|
||||
|
||||
return panel === "top" || panel === "bottom"
|
||||
? Math.floor(dimensions.width / CHART_WIDTH)
|
||||
: Math.floor(dimensions.height / CHART_HEIGHT);
|
||||
? Math.max(1, Math.floor(dimensions.width / CHART_WIDTH))
|
||||
: Math.max(1, Math.floor(dimensions.height / CHART_HEIGHT));
|
||||
};
|
||||
|
||||
const isPanelFull = (panel: Side) => {
|
||||
const currentWidgetCount = getCurrentWidgetCount(panel);
|
||||
const panelCapacity = calculatePanelCapacity(panel);
|
||||
return currentWidgetCount >= panelCapacity;
|
||||
|
||||
return currentWidgetCount > panelCapacity;
|
||||
};
|
||||
|
||||
const duplicateWidget = async () => {
|
||||
try {
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
console.log("widget data sent", widget);
|
||||
|
||||
|
||||
const duplicatedWidget: Widget = {
|
||||
...widget,
|
||||
Data: {
|
||||
duration: duration,
|
||||
measurements: { ...measurements }
|
||||
},
|
||||
id: `${widget.id}-copy-${Date.now()}`,
|
||||
};
|
||||
console.log('duplicatedWidget: ', duplicatedWidget);
|
||||
console.log("duplicatedWidget: ", duplicatedWidget);
|
||||
|
||||
let duplicateWidget = {
|
||||
organization: organization,
|
||||
|
@ -183,6 +193,8 @@ export const DraggableWidget = ({
|
|||
widget: duplicatedWidget,
|
||||
};
|
||||
if (visualizationSocket) {
|
||||
console.log("duplecate widget", duplicateWidget);
|
||||
|
||||
visualizationSocket.emit("v2:viz-widget:add", duplicateWidget);
|
||||
}
|
||||
setSelectedZone((prevZone: any) => ({
|
||||
|
@ -255,12 +267,7 @@ export const DraggableWidget = ({
|
|||
// useClickOutside(chartWidget, () => {
|
||||
// setSelectedChartId(null);
|
||||
// });
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
|
||||
const [canvasDimensions, setCanvasDimensions] = useState({
|
||||
width: 0,
|
||||
height: 0,
|
||||
});
|
||||
// Track canvas dimensions
|
||||
|
||||
// Current: Two identical useEffect hooks for canvas dimensions
|
||||
|
@ -298,8 +305,7 @@ export const DraggableWidget = ({
|
|||
<div
|
||||
draggable
|
||||
key={widget.id}
|
||||
className={`chart-container ${
|
||||
selectedChartId?.id === widget.id && !isPlaying && "activeChart"
|
||||
className={`chart-container ${selectedChartId?.id === widget.id && !isPlaying && "activeChart"
|
||||
}`}
|
||||
onPointerDown={handlePointerDown}
|
||||
onDragStart={handleDragStart}
|
||||
|
@ -326,10 +332,9 @@ export const DraggableWidget = ({
|
|||
{openKebabId === widget.id && (
|
||||
<div className="kebab-options" ref={widgetRef}>
|
||||
<div
|
||||
className={`edit btn ${
|
||||
isPanelFull(widget.panel) ? "btn-blur" : ""
|
||||
className={`edit btn ${isPanelFull(widget.panel) ? "btn-blur" : ""
|
||||
}`}
|
||||
onClick={isPanelFull(widget.panel) ? undefined : duplicateWidget}
|
||||
onClick={duplicateWidget}
|
||||
>
|
||||
<div className="icon">
|
||||
<DublicateIcon />
|
||||
|
@ -402,5 +407,3 @@ export const DraggableWidget = ({
|
|||
</>
|
||||
);
|
||||
};
|
||||
|
||||
// by using canvasDimensions.height canvasDimensions.width dynamically div value insted of static 6 and 4 calculate according to canvasDimensions.width canvasDimensions.height
|
|
@ -188,10 +188,11 @@
|
|||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { Bar } from "react-chartjs-2";
|
||||
import io from "socket.io-client";
|
||||
import { useThemeStore } from "../../../../store/useThemeStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
|
||||
import axios from "axios";
|
||||
import { useThemeStore } from "../../../../../store/useThemeStore";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
|
@ -1,10 +1,11 @@
|
|||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { Doughnut } from "react-chartjs-2";
|
||||
import { Line } from "react-chartjs-2";
|
||||
import io from "socket.io-client";
|
||||
import { useThemeStore } from "../../../../store/useThemeStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
|
||||
import axios from "axios";
|
||||
import { useThemeStore } from "../../../../../store/useThemeStore";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
||||
|
@ -15,7 +16,7 @@ interface ChartComponentProps {
|
|||
fontWeight?: "Light" | "Regular" | "Bold";
|
||||
}
|
||||
|
||||
const DoughnutGraphComponent = ({
|
||||
const LineGraphComponent = ({
|
||||
id,
|
||||
type,
|
||||
title,
|
||||
|
@ -96,11 +97,11 @@ const DoughnutGraphComponent = ({
|
|||
},
|
||||
},
|
||||
scales: {
|
||||
// x: {
|
||||
// ticks: {
|
||||
// display: true, // This hides the x-axis labels
|
||||
// },
|
||||
// },
|
||||
x: {
|
||||
ticks: {
|
||||
display: true, // This hides the x-axis labels
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
[title, chartFontStyle, name]
|
||||
|
@ -160,6 +161,8 @@ const DoughnutGraphComponent = ({
|
|||
try {
|
||||
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`);
|
||||
if (response.status === 200) {
|
||||
console.log('line chart res',response);
|
||||
|
||||
setmeasurements(response.data.Data.measurements)
|
||||
setDuration(response.data.Data.duration)
|
||||
setName(response.data.widgetName)
|
||||
|
@ -183,7 +186,7 @@ const DoughnutGraphComponent = ({
|
|||
}
|
||||
,[chartMeasurements, chartDuration, widgetName])
|
||||
|
||||
return <Doughnut data={Object.keys(measurements).length > 0 ? chartData : defaultData} options={options} />;
|
||||
return <Line data={Object.keys(measurements).length > 0 ? chartData : defaultData} options={options} />;
|
||||
};
|
||||
|
||||
export default DoughnutGraphComponent;
|
||||
export default LineGraphComponent;
|
|
@ -1,10 +1,11 @@
|
|||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { Line } from "react-chartjs-2";
|
||||
import io from "socket.io-client";
|
||||
import { useThemeStore } from "../../../../store/useThemeStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
|
||||
import axios from "axios";
|
||||
import { useThemeStore } from "../../../../../store/useThemeStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
||||
|
@ -24,11 +25,18 @@ const LineGraphComponent = ({
|
|||
fontWeight = "Regular",
|
||||
}: ChartComponentProps) => {
|
||||
const { themeColor } = useThemeStore();
|
||||
const { measurements: chartMeasurements, duration: chartDuration, name: widgetName } = useChartStore();
|
||||
const {
|
||||
measurements: chartMeasurements,
|
||||
duration: chartDuration,
|
||||
name: widgetName,
|
||||
} = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h")
|
||||
const [name, setName] = useState("Widget")
|
||||
const [chartData, setChartData] = useState<{ labels: string[]; datasets: any[] }>({
|
||||
const [duration, setDuration] = useState("1h");
|
||||
const [name, setName] = useState("Widget");
|
||||
const [chartData, setChartData] = useState<{
|
||||
labels: string[];
|
||||
datasets: any[];
|
||||
}>({
|
||||
labels: [],
|
||||
datasets: [],
|
||||
});
|
||||
|
@ -36,7 +44,7 @@ const LineGraphComponent = ({
|
|||
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0]
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
const defaultData = {
|
||||
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
|
||||
datasets: [
|
||||
|
@ -50,13 +58,17 @@ const LineGraphComponent = ({
|
|||
],
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
},[])
|
||||
useEffect(() => {}, []);
|
||||
|
||||
// Memoize Theme Colors
|
||||
const buttonActionColor = useMemo(() => themeColor[0] || "#5c87df", [themeColor]);
|
||||
const buttonAbortColor = useMemo(() => themeColor[1] || "#ffffff", [themeColor]);
|
||||
const buttonActionColor = useMemo(
|
||||
() => themeColor[0] || "#5c87df",
|
||||
[themeColor]
|
||||
);
|
||||
const buttonAbortColor = useMemo(
|
||||
() => themeColor[1] || "#ffffff",
|
||||
[themeColor]
|
||||
);
|
||||
|
||||
// Memoize Font Styling
|
||||
const chartFontWeightMap = useMemo(
|
||||
|
@ -68,8 +80,14 @@ const LineGraphComponent = ({
|
|||
[]
|
||||
);
|
||||
|
||||
const fontSizeValue = useMemo(() => (fontSize ? parseInt(fontSize) : 12), [fontSize]);
|
||||
const fontWeightValue = useMemo(() => chartFontWeightMap[fontWeight], [fontWeight, chartFontWeightMap]);
|
||||
const fontSizeValue = useMemo(
|
||||
() => (fontSize ? parseInt(fontSize) : 12),
|
||||
[fontSize]
|
||||
);
|
||||
const fontWeightValue = useMemo(
|
||||
() => chartFontWeightMap[fontWeight],
|
||||
[fontWeight, chartFontWeightMap]
|
||||
);
|
||||
|
||||
const chartFontStyle = useMemo(
|
||||
() => ({
|
||||
|
@ -110,7 +128,8 @@ const LineGraphComponent = ({
|
|||
// },[measurements])
|
||||
|
||||
useEffect(() => {
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0) return;
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0)
|
||||
return;
|
||||
|
||||
const socket = io(`http://${iotApiUrl}`);
|
||||
|
||||
|
@ -120,7 +139,6 @@ const LineGraphComponent = ({
|
|||
interval: 1000,
|
||||
};
|
||||
|
||||
|
||||
const startStream = () => {
|
||||
socket.emit("lineInput", inputData);
|
||||
};
|
||||
|
@ -154,15 +172,16 @@ const LineGraphComponent = ({
|
|||
};
|
||||
}, [measurements, duration, iotApiUrl]);
|
||||
|
||||
const fetchSavedInputes = async() => {
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`);
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`
|
||||
);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements)
|
||||
setDuration(response.data.Data.duration)
|
||||
setName(response.data.widgetName)
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
console.log("Unexpected response:", response);
|
||||
}
|
||||
|
@ -170,7 +189,7 @@ const LineGraphComponent = ({
|
|||
console.error("There was an error!", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchSavedInputes();
|
||||
|
@ -180,10 +199,14 @@ const LineGraphComponent = ({
|
|||
if (selectedChartId?.id === id) {
|
||||
fetchSavedInputes();
|
||||
}
|
||||
}
|
||||
,[chartMeasurements, chartDuration, widgetName])
|
||||
}, [chartMeasurements, chartDuration, widgetName]);
|
||||
|
||||
return <Line data={Object.keys(measurements).length > 0 ? chartData : defaultData} options={options} />;
|
||||
return (
|
||||
<Line
|
||||
data={Object.keys(measurements).length > 0 ? chartData : defaultData}
|
||||
options={options}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default LineGraphComponent;
|
|
@ -183,14 +183,14 @@
|
|||
|
||||
// export default PieChartComponent;
|
||||
|
||||
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { Pie } from "react-chartjs-2";
|
||||
import io from "socket.io-client";
|
||||
import { useThemeStore } from "../../../../store/useThemeStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
|
||||
import axios from "axios";
|
||||
import { useThemeStore } from "../../../../../store/useThemeStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
||||
|
@ -210,11 +210,18 @@ const PieChartComponent = ({
|
|||
fontWeight = "Regular",
|
||||
}: ChartComponentProps) => {
|
||||
const { themeColor } = useThemeStore();
|
||||
const { measurements: chartMeasurements, duration: chartDuration, name: widgetName } = useChartStore();
|
||||
const {
|
||||
measurements: chartMeasurements,
|
||||
duration: chartDuration,
|
||||
name: widgetName,
|
||||
} = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h")
|
||||
const [name, setName] = useState("Widget")
|
||||
const [chartData, setChartData] = useState<{ labels: string[]; datasets: any[] }>({
|
||||
const [duration, setDuration] = useState("1h");
|
||||
const [name, setName] = useState("Widget");
|
||||
const [chartData, setChartData] = useState<{
|
||||
labels: string[];
|
||||
datasets: any[];
|
||||
}>({
|
||||
labels: [],
|
||||
datasets: [],
|
||||
});
|
||||
|
@ -222,7 +229,7 @@ const PieChartComponent = ({
|
|||
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0]
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
const defaultData = {
|
||||
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
|
||||
datasets: [
|
||||
|
@ -236,13 +243,17 @@ const PieChartComponent = ({
|
|||
],
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
},[])
|
||||
useEffect(() => {}, []);
|
||||
|
||||
// Memoize Theme Colors
|
||||
const buttonActionColor = useMemo(() => themeColor[0] || "#5c87df", [themeColor]);
|
||||
const buttonAbortColor = useMemo(() => themeColor[1] || "#ffffff", [themeColor]);
|
||||
const buttonActionColor = useMemo(
|
||||
() => themeColor[0] || "#5c87df",
|
||||
[themeColor]
|
||||
);
|
||||
const buttonAbortColor = useMemo(
|
||||
() => themeColor[1] || "#ffffff",
|
||||
[themeColor]
|
||||
);
|
||||
|
||||
// Memoize Font Styling
|
||||
const chartFontWeightMap = useMemo(
|
||||
|
@ -254,8 +265,14 @@ const PieChartComponent = ({
|
|||
[]
|
||||
);
|
||||
|
||||
const fontSizeValue = useMemo(() => (fontSize ? parseInt(fontSize) : 12), [fontSize]);
|
||||
const fontWeightValue = useMemo(() => chartFontWeightMap[fontWeight], [fontWeight, chartFontWeightMap]);
|
||||
const fontSizeValue = useMemo(
|
||||
() => (fontSize ? parseInt(fontSize) : 12),
|
||||
[fontSize]
|
||||
);
|
||||
const fontWeightValue = useMemo(
|
||||
() => chartFontWeightMap[fontWeight],
|
||||
[fontWeight, chartFontWeightMap]
|
||||
);
|
||||
|
||||
const chartFontStyle = useMemo(
|
||||
() => ({
|
||||
|
@ -296,7 +313,8 @@ const PieChartComponent = ({
|
|||
// },[measurements])
|
||||
|
||||
useEffect(() => {
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0) return;
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0)
|
||||
return;
|
||||
|
||||
const socket = io(`http://${iotApiUrl}`);
|
||||
|
||||
|
@ -306,7 +324,6 @@ const PieChartComponent = ({
|
|||
interval: 1000,
|
||||
};
|
||||
|
||||
|
||||
const startStream = () => {
|
||||
socket.emit("lineInput", inputData);
|
||||
};
|
||||
|
@ -340,15 +357,16 @@ const PieChartComponent = ({
|
|||
};
|
||||
}, [measurements, duration, iotApiUrl]);
|
||||
|
||||
const fetchSavedInputes = async() => {
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`);
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`
|
||||
);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements)
|
||||
setDuration(response.data.Data.duration)
|
||||
setName(response.data.widgetName)
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
console.log("Unexpected response:", response);
|
||||
}
|
||||
|
@ -356,7 +374,7 @@ const PieChartComponent = ({
|
|||
console.error("There was an error!", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchSavedInputes();
|
||||
|
@ -366,10 +384,14 @@ const PieChartComponent = ({
|
|||
if (selectedChartId?.id === id) {
|
||||
fetchSavedInputes();
|
||||
}
|
||||
}
|
||||
,[chartMeasurements, chartDuration, widgetName])
|
||||
}, [chartMeasurements, chartDuration, widgetName]);
|
||||
|
||||
return <Pie data={Object.keys(measurements).length > 0 ? chartData : defaultData} options={options} />;
|
||||
return (
|
||||
<Pie
|
||||
data={Object.keys(measurements).length > 0 ? chartData : defaultData}
|
||||
options={options}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default PieChartComponent;
|
|
@ -1,10 +1,11 @@
|
|||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { PolarArea } from "react-chartjs-2";
|
||||
import io from "socket.io-client";
|
||||
import { useThemeStore } from "../../../../store/useThemeStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
|
||||
import axios from "axios";
|
||||
import { useThemeStore } from "../../../../../store/useThemeStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
||||
|
@ -24,11 +25,18 @@ const PolarAreaGraphComponent = ({
|
|||
fontWeight = "Regular",
|
||||
}: ChartComponentProps) => {
|
||||
const { themeColor } = useThemeStore();
|
||||
const { measurements: chartMeasurements, duration: chartDuration, name: widgetName } = useChartStore();
|
||||
const {
|
||||
measurements: chartMeasurements,
|
||||
duration: chartDuration,
|
||||
name: widgetName,
|
||||
} = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h")
|
||||
const [name, setName] = useState("Widget")
|
||||
const [chartData, setChartData] = useState<{ labels: string[]; datasets: any[] }>({
|
||||
const [duration, setDuration] = useState("1h");
|
||||
const [name, setName] = useState("Widget");
|
||||
const [chartData, setChartData] = useState<{
|
||||
labels: string[];
|
||||
datasets: any[];
|
||||
}>({
|
||||
labels: [],
|
||||
datasets: [],
|
||||
});
|
||||
|
@ -36,7 +44,7 @@ const PolarAreaGraphComponent = ({
|
|||
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0]
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
const defaultData = {
|
||||
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
|
||||
datasets: [
|
||||
|
@ -50,13 +58,17 @@ const PolarAreaGraphComponent = ({
|
|||
],
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
},[])
|
||||
useEffect(() => {}, []);
|
||||
|
||||
// Memoize Theme Colors
|
||||
const buttonActionColor = useMemo(() => themeColor[0] || "#5c87df", [themeColor]);
|
||||
const buttonAbortColor = useMemo(() => themeColor[1] || "#ffffff", [themeColor]);
|
||||
const buttonActionColor = useMemo(
|
||||
() => themeColor[0] || "#5c87df",
|
||||
[themeColor]
|
||||
);
|
||||
const buttonAbortColor = useMemo(
|
||||
() => themeColor[1] || "#ffffff",
|
||||
[themeColor]
|
||||
);
|
||||
|
||||
// Memoize Font Styling
|
||||
const chartFontWeightMap = useMemo(
|
||||
|
@ -68,8 +80,14 @@ const PolarAreaGraphComponent = ({
|
|||
[]
|
||||
);
|
||||
|
||||
const fontSizeValue = useMemo(() => (fontSize ? parseInt(fontSize) : 12), [fontSize]);
|
||||
const fontWeightValue = useMemo(() => chartFontWeightMap[fontWeight], [fontWeight, chartFontWeightMap]);
|
||||
const fontSizeValue = useMemo(
|
||||
() => (fontSize ? parseInt(fontSize) : 12),
|
||||
[fontSize]
|
||||
);
|
||||
const fontWeightValue = useMemo(
|
||||
() => chartFontWeightMap[fontWeight],
|
||||
[fontWeight, chartFontWeightMap]
|
||||
);
|
||||
|
||||
const chartFontStyle = useMemo(
|
||||
() => ({
|
||||
|
@ -110,7 +128,8 @@ const PolarAreaGraphComponent = ({
|
|||
// },[measurements])
|
||||
|
||||
useEffect(() => {
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0) return;
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0)
|
||||
return;
|
||||
|
||||
const socket = io(`http://${iotApiUrl}`);
|
||||
|
||||
|
@ -120,7 +139,6 @@ const PolarAreaGraphComponent = ({
|
|||
interval: 1000,
|
||||
};
|
||||
|
||||
|
||||
const startStream = () => {
|
||||
socket.emit("lineInput", inputData);
|
||||
};
|
||||
|
@ -154,15 +172,16 @@ const PolarAreaGraphComponent = ({
|
|||
};
|
||||
}, [measurements, duration, iotApiUrl]);
|
||||
|
||||
const fetchSavedInputes = async() => {
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`);
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`
|
||||
);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements)
|
||||
setDuration(response.data.Data.duration)
|
||||
setName(response.data.widgetName)
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
console.log("Unexpected response:", response);
|
||||
}
|
||||
|
@ -170,7 +189,7 @@ const PolarAreaGraphComponent = ({
|
|||
console.error("There was an error!", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchSavedInputes();
|
||||
|
@ -180,10 +199,14 @@ const PolarAreaGraphComponent = ({
|
|||
if (selectedChartId?.id === id) {
|
||||
fetchSavedInputes();
|
||||
}
|
||||
}
|
||||
,[chartMeasurements, chartDuration, widgetName])
|
||||
}, [chartMeasurements, chartDuration, widgetName]);
|
||||
|
||||
return <PolarArea data={Object.keys(measurements).length > 0 ? chartData : defaultData} options={options} />;
|
||||
return (
|
||||
<PolarArea
|
||||
data={Object.keys(measurements).length > 0 ? chartData : defaultData}
|
||||
options={options}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default PolarAreaGraphComponent;
|
|
@ -1,4 +1,4 @@
|
|||
import { StockIncreseIcon } from "../../../icons/RealTimeVisulationIcons";
|
||||
import { StockIncreseIcon } from "../../../../../components/icons/RealTimeVisulationIcons";
|
||||
|
||||
const ProgressCard = ({
|
||||
title,
|
|
@ -0,0 +1,105 @@
|
|||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { Line } from "react-chartjs-2";
|
||||
import io from "socket.io-client";
|
||||
|
||||
import axios from "axios";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import { StockIncreseIcon } from "../../../../../components/icons/RealTimeVisulationIcons";
|
||||
|
||||
const ProgressCard1 = ({ id, title }: { id: string; title: string }) => {
|
||||
const {
|
||||
measurements: chartMeasurements,
|
||||
duration: chartDuration,
|
||||
name: widgetName,
|
||||
} = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h");
|
||||
const [name, setName] = useState(title);
|
||||
const [value, setValue] = useState<any>("");
|
||||
const { selectedChartId } = useWidgetStore();
|
||||
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
|
||||
useEffect(() => {
|
||||
const socket = io(`http://${iotApiUrl}`);
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0)
|
||||
return;
|
||||
|
||||
const inputData = {
|
||||
measurements,
|
||||
duration,
|
||||
interval: 1000,
|
||||
};
|
||||
|
||||
const startStream = () => {
|
||||
socket.emit("lastInput", inputData);
|
||||
};
|
||||
|
||||
socket.on("connect", startStream);
|
||||
|
||||
socket.on("lastOutput", (response) => {
|
||||
const responseData = response.input1;
|
||||
setValue(responseData);
|
||||
});
|
||||
|
||||
return () => {
|
||||
socket.off("lastOutput");
|
||||
socket.emit("stop_stream"); // Stop streaming when component unmounts
|
||||
socket.disconnect();
|
||||
};
|
||||
}, [measurements, duration]);
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`
|
||||
);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
console.log("Unexpected response:", response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("There was an error!", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchSavedInputes();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedChartId?.id === id) {
|
||||
fetchSavedInputes();
|
||||
}
|
||||
}, [chartMeasurements, chartDuration, widgetName]);
|
||||
|
||||
return (
|
||||
<div className="chart progressBar">
|
||||
<div className="header">{name}</div>
|
||||
<div className="stock">
|
||||
<span className="stock-item">
|
||||
<span className="stockValues">
|
||||
<div className="value">{value}</div>
|
||||
<div className="key">Units</div>
|
||||
</span>
|
||||
<div className="stock-description">
|
||||
{measurements ? `${measurements?.input1?.fields}` : "description"}
|
||||
</div>
|
||||
</span>
|
||||
<div className="icon">
|
||||
<StockIncreseIcon />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProgressCard1;
|
|
@ -0,0 +1,125 @@
|
|||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { Line } from "react-chartjs-2";
|
||||
import io from "socket.io-client";
|
||||
|
||||
import axios from "axios";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import { StockIncreseIcon } from "../../../../../components/icons/RealTimeVisulationIcons";
|
||||
|
||||
const ProgressCard2 = ({ id, title }: { id: string; title: string }) => {
|
||||
const {
|
||||
measurements: chartMeasurements,
|
||||
duration: chartDuration,
|
||||
name: widgetName,
|
||||
} = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h");
|
||||
const [name, setName] = useState(title);
|
||||
const [value1, setValue1] = useState<any>("");
|
||||
const [value2, setValue2] = useState<any>("");
|
||||
const { selectedChartId } = useWidgetStore();
|
||||
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
const email = localStorage.getItem("email") || "";
|
||||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
|
||||
useEffect(() => {
|
||||
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0)
|
||||
return;
|
||||
|
||||
const socket = io(`http://${iotApiUrl}`);
|
||||
|
||||
const inputData = {
|
||||
measurements,
|
||||
duration,
|
||||
interval: 1000,
|
||||
};
|
||||
|
||||
const startStream = () => {
|
||||
socket.emit("lastInput", inputData);
|
||||
};
|
||||
|
||||
socket.on("connect", startStream);
|
||||
|
||||
socket.on("lastOutput", (response) => {
|
||||
const responseData1 = response.input1;
|
||||
const responseData2 = response.input2;
|
||||
setValue1(responseData1);
|
||||
setValue2(responseData2);
|
||||
});
|
||||
|
||||
return () => {
|
||||
socket.off("lastOutput");
|
||||
socket.emit("stop_stream"); // Stop streaming when component unmounts
|
||||
socket.disconnect();
|
||||
};
|
||||
}, [measurements, duration]);
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`
|
||||
);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
console.log("Unexpected response:", response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("There was an error!", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchSavedInputes();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedChartId?.id === id) {
|
||||
fetchSavedInputes();
|
||||
}
|
||||
}, [chartMeasurements, chartDuration, widgetName]);
|
||||
|
||||
return (
|
||||
<div className="chart progressBar">
|
||||
<div className="header">{name}</div>
|
||||
|
||||
<div className="stock">
|
||||
<span className="stock-item">
|
||||
<span className="stockValues">
|
||||
<div className="value">{value1}</div>
|
||||
<div className="key">Units</div>
|
||||
</span>
|
||||
<div className="stock-description">
|
||||
{measurements ? `${measurements?.input1?.fields}` : "description"}
|
||||
</div>
|
||||
</span>
|
||||
<div className="icon">
|
||||
<StockIncreseIcon />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="stock">
|
||||
<span className="stock-item">
|
||||
<span className="stockValues">
|
||||
<div className="value">{value2}</div>
|
||||
<div className="key">Units</div>
|
||||
</span>
|
||||
<div className="stock-description">
|
||||
{measurements ? `${measurements?.input2?.fields}` : "description"}
|
||||
</div>
|
||||
</span>
|
||||
<div className="icon">
|
||||
<StockIncreseIcon />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProgressCard2;
|
|
@ -1,35 +1,25 @@
|
|||
import * as THREE from "three";
|
||||
import { useThree } from "@react-three/fiber";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
useAsset3dWidget,
|
||||
useSocketStore,
|
||||
useWidgetSubOption,
|
||||
} from "../../../store/store";
|
||||
import useModuleStore from "../../../store/useModuleStore";
|
||||
import { ThreeState } from "../../../types/world/worldTypes";
|
||||
import * as THREE from "three";
|
||||
import Throughput from "../../layout/3D-cards/cards/Throughput";
|
||||
import ProductionCapacity from "../../layout/3D-cards/cards/ProductionCapacity";
|
||||
import ReturnOfInvestment from "../../layout/3D-cards/cards/ReturnOfInvestment";
|
||||
import StateWorking from "../../layout/3D-cards/cards/StateWorking";
|
||||
import { useSelectedZoneStore } from "../../../store/useZoneStore";
|
||||
import { generateUniqueId } from "../../../functions/generateUniqueId";
|
||||
import { adding3dWidgets } from "../../../services/realTimeVisulization/zoneData/add3dWidget";
|
||||
import { get3dWidgetZoneData } from "../../../services/realTimeVisulization/zoneData/get3dWidgetData";
|
||||
import { use3DWidget } from "../../../store/useDroppedObjectsStore";
|
||||
import {
|
||||
useEditWidgetOptionsStore,
|
||||
useLeftData,
|
||||
useRightClickSelected,
|
||||
useRightSelected,
|
||||
useTopData,
|
||||
useZoneWidgetStore,
|
||||
} from "../../../store/useZone3DWidgetStore";
|
||||
import { delete3dWidgetApi } from "../../../services/realTimeVisulization/zoneData/delete3dWidget";
|
||||
import {
|
||||
update3dWidget,
|
||||
update3dWidgetRotation,
|
||||
} from "../../../services/realTimeVisulization/zoneData/update3dWidget";
|
||||
import { useAsset3dWidget, useSocketStore, useWidgetSubOption } from "../../../../store/store";
|
||||
import useModuleStore from "../../../../store/useModuleStore";
|
||||
import { ThreeState } from "../../../../types/world/worldTypes";
|
||||
import { useSelectedZoneStore } from "../../../../store/useZoneStore";
|
||||
import { useEditWidgetOptionsStore, useLeftData, useRightClickSelected, useRightSelected, useTopData, useZoneWidgetStore } from "../../../../store/useZone3DWidgetStore";
|
||||
import { use3DWidget } from "../../../../store/useDroppedObjectsStore";
|
||||
import { get3dWidgetZoneData } from "../../../../services/realTimeVisulization/zoneData/get3dWidgetData";
|
||||
import { generateUniqueId } from "../../../../functions/generateUniqueId";
|
||||
import ProductionCapacity from "./cards/ProductionCapacity";
|
||||
import ReturnOfInvestment from "./cards/ReturnOfInvestment";
|
||||
import StateWorking from "./cards/StateWorking";
|
||||
import Throughput from "./cards/Throughput";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
type WidgetData = {
|
||||
id: string;
|
||||
type: string;
|
||||
|
@ -57,10 +47,14 @@ export default function Dropped3dWidgets() {
|
|||
const planeIntersect = useRef(new THREE.Vector3());
|
||||
const rotationStartRef = useRef<[number, number, number]>([0, 0, 0]);
|
||||
const mouseStartRef = useRef<{ x: number; y: number }>({ x: 0, y: 0 });
|
||||
const { setSelectedChartId } = useWidgetStore();
|
||||
const { measurements, duration} = useChartStore();
|
||||
let [floorPlanesVertical, setFloorPlanesVertical] = useState(
|
||||
new THREE.Plane(new THREE.Vector3(0, 1, 0))
|
||||
);
|
||||
|
||||
const [intersectcontextmenu, setintersectcontextmenu] = useState<number | undefined>();
|
||||
const [horizontalX, setHorizontalX] = useState<number | undefined>();
|
||||
const [horizontalZ, setHorizontalZ] = useState<number | undefined>();
|
||||
|
||||
const activeZoneWidgets = zoneWidgetData[selectedZone.zoneId] || [];
|
||||
useEffect(() => {
|
||||
|
@ -177,7 +171,6 @@ export default function Dropped3dWidgets() {
|
|||
};
|
||||
|
||||
const onDrop = (event: any) => {
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
|
@ -190,13 +183,18 @@ export default function Dropped3dWidgets() {
|
|||
if (!newWidget || !widgetSelect.startsWith("ui")) return;
|
||||
|
||||
// ✅ Extract 2D drop position
|
||||
const [x, , z] = newWidget.position;
|
||||
let [x, y, z] = newWidget.position;
|
||||
|
||||
// ✅ Clamp Y to at least 0
|
||||
y = Math.max(y, 0);
|
||||
newWidget.position = [x, y, z];
|
||||
|
||||
// ✅ Prepare polygon from selectedZone.points
|
||||
const points3D = selectedZone.points as Array<[number, number, number]>;
|
||||
const zonePolygonXZ = points3D.map(([x, , z]) => [x, z] as [number, number]);
|
||||
|
||||
const isInside = isPointInPolygon([x, z], zonePolygonXZ);
|
||||
|
||||
// ✅ Remove temp widget
|
||||
const prevWidgets = useZoneWidgetStore.getState().zoneWidgetData[selectedZone.zoneId] || [];
|
||||
const cleanedWidgets = prevWidgets.filter(w => w.id !== newWidget.id);
|
||||
|
@ -206,12 +204,14 @@ export default function Dropped3dWidgets() {
|
|||
[selectedZone.zoneId]: cleanedWidgets,
|
||||
},
|
||||
}));
|
||||
// if (!isInside) {
|
||||
|
||||
// (Optional) Prevent adding if dropped outside zone
|
||||
// if (!isInside) {
|
||||
// createdWidgetRef.current = null;
|
||||
// return; // Stop here
|
||||
// return;
|
||||
// }
|
||||
// ✅ Add widget if inside polygon
|
||||
|
||||
// ✅ Add widget
|
||||
addWidget(selectedZone.zoneId, newWidget);
|
||||
|
||||
const add3dWidget = {
|
||||
|
@ -228,6 +228,7 @@ export default function Dropped3dWidgets() {
|
|||
};
|
||||
|
||||
|
||||
|
||||
canvasElement.addEventListener("dragenter", handleDragEnter);
|
||||
canvasElement.addEventListener("dragover", handleDragOver);
|
||||
canvasElement.addEventListener("drop", onDrop);
|
||||
|
@ -249,8 +250,10 @@ export default function Dropped3dWidgets() {
|
|||
const widgetToDuplicate = activeZoneWidgets.find(
|
||||
(w: WidgetData) => w.id === rightClickSelected
|
||||
);
|
||||
console.log("3d widget to duplecate", widgetToDuplicate);
|
||||
|
||||
if (!widgetToDuplicate) return;
|
||||
const newWidget: WidgetData = {
|
||||
const newWidget: any = {
|
||||
id: generateUniqueId(),
|
||||
type: widgetToDuplicate.type,
|
||||
position: [
|
||||
|
@ -259,6 +262,10 @@ export default function Dropped3dWidgets() {
|
|||
widgetToDuplicate.position[2] + 0.5,
|
||||
],
|
||||
rotation: widgetToDuplicate.rotation || [0, 0, 0],
|
||||
Data:{
|
||||
measurements: measurements,
|
||||
duration: duration
|
||||
},
|
||||
};
|
||||
const adding3dWidget = {
|
||||
organization: organization,
|
||||
|
@ -337,22 +344,34 @@ export default function Dropped3dWidgets() {
|
|||
const organization = email?.split("@")[1]?.split(".")[0];
|
||||
const handleMouseDown = (event: MouseEvent) => {
|
||||
if (!rightClickSelected || !rightSelect) return;
|
||||
const selectedZoneId = Object.keys(zoneWidgetData).find(
|
||||
(zoneId: string) =>
|
||||
zoneWidgetData[zoneId].some(
|
||||
(widget: WidgetData) => widget.id === rightClickSelected
|
||||
)
|
||||
);
|
||||
if (!selectedZoneId) return;
|
||||
const selectedWidget = zoneWidgetData[selectedZoneId].find(
|
||||
(widget: WidgetData) => widget.id === rightClickSelected
|
||||
);
|
||||
if (!selectedWidget) return
|
||||
// let points = [];
|
||||
// points.push(new THREE.Vector3(0, 0, 0));
|
||||
// points.push(new THREE.Vector3(0, selectedWidget.position[1], 0));
|
||||
// const newgeometry = new THREE.BufferGeometry().setFromPoints(points);
|
||||
// let vector = new THREE.Vector3();
|
||||
// camera.getWorldDirection(vector);
|
||||
// let cameraDirection = vector;
|
||||
// let newPlane = new THREE.Plane(cameraDirection);
|
||||
// floorPlanesVertical = newPlane;
|
||||
// setFloorPlanesVertical(newPlane);
|
||||
// const intersect1 = raycaster?.ray?.intersectPlane(
|
||||
// floorPlanesVertical,
|
||||
// planeIntersect.current
|
||||
// );
|
||||
|
||||
const cameraDirection = new THREE.Vector3();
|
||||
camera.getWorldDirection(cameraDirection);
|
||||
// setintersectcontextmenu(intersect1.y);
|
||||
|
||||
// Plane normal should be perpendicular to screen (XZ move), so use screen right direction
|
||||
const right = new THREE.Vector3();
|
||||
camera.getWorldDirection(cameraDirection);
|
||||
cameraDirection.y = 0;
|
||||
cameraDirection.normalize();
|
||||
|
||||
right.crossVectors(new THREE.Vector3(0, 1, 0), cameraDirection).normalize();
|
||||
|
||||
// Create a plane that allows vertical movement
|
||||
const verticalPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(right, new THREE.Vector3(0, 0, 0));
|
||||
|
||||
setFloorPlanesVertical(verticalPlane);
|
||||
if (rightSelect === "RotateX" || rightSelect === "RotateY") {
|
||||
mouseStartRef.current = { x: event.clientX, y: event.clientY };
|
||||
|
||||
|
@ -370,6 +389,7 @@ export default function Dropped3dWidgets() {
|
|||
rotationStartRef.current = selectedWidget.rotation || [0, 0, 0];
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const handleMouseMove = (event: MouseEvent) => {
|
||||
|
@ -392,90 +412,110 @@ export default function Dropped3dWidgets() {
|
|||
|
||||
raycaster.setFromCamera(mouse, camera);
|
||||
|
||||
if (rightSelect === "Horizontal Move" &&raycaster.ray.intersectPlane(plane.current, planeIntersect.current)) {
|
||||
const points3D = selectedZone.points as Array<[number, number, number]>;
|
||||
const zonePolygonXZ = points3D.map(([x, , z]) => [x, z] as [number, number]);
|
||||
const newPosition: [number, number, number] = [
|
||||
planeIntersect.current.x,
|
||||
selectedWidget.position[1],
|
||||
planeIntersect.current.z,
|
||||
];
|
||||
const isInside = isPointInPolygon(
|
||||
[newPosition[0], newPosition[2]],
|
||||
zonePolygonXZ
|
||||
if (rightSelect === "Horizontal Move") {
|
||||
const intersect = raycaster.ray.intersectPlane(plane.current, planeIntersect.current);
|
||||
if (
|
||||
intersect &&
|
||||
typeof horizontalX === "number" &&
|
||||
typeof horizontalZ === "number"
|
||||
) {
|
||||
const selectedZoneId = Object.keys(zoneWidgetData).find(zoneId =>
|
||||
zoneWidgetData[zoneId].some(widget => widget.id === rightClickSelected)
|
||||
);
|
||||
// if (isInside) {
|
||||
if (!selectedZoneId) return;
|
||||
|
||||
const selectedWidget = zoneWidgetData[selectedZoneId].find(widget => widget.id === rightClickSelected);
|
||||
if (!selectedWidget) return;
|
||||
|
||||
const newPosition: [number, number, number] = [
|
||||
intersect.x + horizontalX,
|
||||
selectedWidget.position[1],
|
||||
intersect.z + horizontalZ,
|
||||
];
|
||||
|
||||
|
||||
updateWidgetPosition(selectedZoneId, rightClickSelected, newPosition);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rightSelect === "Vertical Move") {
|
||||
if (raycaster.ray.intersectPlane(floorPlanesVertical, planeIntersect.current)) {
|
||||
const currentY = selectedWidget.position[1];
|
||||
const newY = planeIntersect.current.y;
|
||||
console.log('planeIntersect.current: ', planeIntersect.current);
|
||||
const intersect = raycaster.ray.intersectPlane(floorPlanesVertical, planeIntersect.current);
|
||||
|
||||
const deltaY = newY - currentY;
|
||||
if (intersect && typeof intersectcontextmenu === "number") {
|
||||
const diff = intersect.y - intersectcontextmenu;
|
||||
const unclampedY = selectedWidget.position[1] + diff;
|
||||
const newY = Math.max(0, unclampedY); // Prevent going below floor (y=0)
|
||||
|
||||
// Reject if jump is too large (safety check)
|
||||
if (Math.abs(deltaY) > 200) return;
|
||||
setintersectcontextmenu(intersect.y);
|
||||
|
||||
// Clamp jump or apply smoothing
|
||||
const clampedY = currentY + THREE.MathUtils.clamp(deltaY, -10, 10);
|
||||
|
||||
if (clampedY > 0) {
|
||||
updateWidgetPosition(selectedZoneId, rightClickSelected, [
|
||||
const newPosition: [number, number, number] = [
|
||||
selectedWidget.position[0],
|
||||
clampedY,
|
||||
newY,
|
||||
selectedWidget.position[2],
|
||||
]);
|
||||
}
|
||||
];
|
||||
|
||||
updateWidgetPosition(selectedZoneId, rightClickSelected, newPosition);
|
||||
}
|
||||
}
|
||||
|
||||
if (rightSelect === "RotateX") {
|
||||
if (rightSelect?.startsWith("Rotate")) {
|
||||
const axis = rightSelect.slice(-1).toLowerCase(); // "x", "y", or "z"
|
||||
const currentX = event.pageX;
|
||||
const sign = currentX > prevX ? 1 : currentX < prevX ? -1 : 0;
|
||||
setPrevX(currentX);
|
||||
if (selectedWidget?.rotation && selectedWidget.rotation.length >= 3) {
|
||||
const newRotation: [number, number, number] = [
|
||||
selectedWidget.rotation[0] + 0.05 * sign,
|
||||
selectedWidget.rotation[1],
|
||||
selectedWidget.rotation[2],
|
||||
];
|
||||
|
||||
const index = axis === "x" ? 0 : axis === "y" ? 1 : 2;
|
||||
const currentRotation = selectedWidget.rotation as [number, number, number]; // assert type
|
||||
const newRotation: [number, number, number] = [...currentRotation];
|
||||
newRotation[index] += 0.05 * sign;
|
||||
updateWidgetRotation(selectedZoneId, rightClickSelected, newRotation);
|
||||
}
|
||||
}
|
||||
// if (rightSelect === "RotateX") {
|
||||
//
|
||||
// const currentX = event.pageX;
|
||||
// const sign = currentX > prevX ? 1 : currentX < prevX ? -1 : 0;
|
||||
//
|
||||
// setPrevX(currentX);
|
||||
// if (selectedWidget?.rotation && selectedWidget.rotation.length >= 3) {
|
||||
//
|
||||
// const newRotation: [number, number, number] = [
|
||||
// selectedWidget.rotation[0] + 0.05 * sign,
|
||||
// selectedWidget.rotation[1],
|
||||
// selectedWidget.rotation[2],
|
||||
// ];
|
||||
// updateWidgetRotation(selectedZoneId, rightClickSelected, newRotation);
|
||||
// }
|
||||
// }
|
||||
// if (rightSelect === "RotateY") {
|
||||
// const currentX = event.pageX;
|
||||
// const sign = currentX > prevX ? 1 : currentX < prevX ? -1 : 0;
|
||||
// setPrevX(currentX);
|
||||
// if (selectedWidget?.rotation && selectedWidget.rotation.length >= 3) {
|
||||
// const newRotation: [number, number, number] = [
|
||||
// selectedWidget.rotation[0],
|
||||
// selectedWidget.rotation[1] + 0.05 * sign,
|
||||
// selectedWidget.rotation[2],
|
||||
// ];
|
||||
|
||||
if (rightSelect === "RotateY") {
|
||||
const currentX = event.pageX;
|
||||
const sign = currentX > prevX ? 1 : currentX < prevX ? -1 : 0;
|
||||
setPrevX(currentX);
|
||||
if (selectedWidget?.rotation && selectedWidget.rotation.length >= 3) {
|
||||
const newRotation: [number, number, number] = [
|
||||
selectedWidget.rotation[0] ,
|
||||
selectedWidget.rotation[1]+ 0.05 * sign,
|
||||
selectedWidget.rotation[2],
|
||||
];
|
||||
// updateWidgetRotation(selectedZoneId, rightClickSelected, newRotation);
|
||||
// }
|
||||
// }
|
||||
// if (rightSelect === "RotateZ") {
|
||||
// const currentX = event.pageX;
|
||||
// const sign = currentX > prevX ? 1 : currentX < prevX ? -1 : 0;
|
||||
// setPrevX(currentX);
|
||||
// if (selectedWidget?.rotation && selectedWidget.rotation.length >= 3) {
|
||||
// const newRotation: [number, number, number] = [
|
||||
// selectedWidget.rotation[0],
|
||||
// selectedWidget.rotation[1],
|
||||
// selectedWidget.rotation[2] + 0.05 * sign,
|
||||
// ];
|
||||
|
||||
updateWidgetRotation(selectedZoneId, rightClickSelected, newRotation);
|
||||
}
|
||||
}
|
||||
if (rightSelect === "RotateZ") {
|
||||
const currentX = event.pageX;
|
||||
const sign = currentX > prevX ? 1 : currentX < prevX ? -1 : 0;
|
||||
setPrevX(currentX);
|
||||
if (selectedWidget?.rotation && selectedWidget.rotation.length >= 3) {
|
||||
const newRotation: [number, number, number] = [
|
||||
selectedWidget.rotation[0] ,
|
||||
selectedWidget.rotation[1],
|
||||
selectedWidget.rotation[2]+ 0.05 * sign,
|
||||
];
|
||||
|
||||
updateWidgetRotation(selectedZoneId, rightClickSelected, newRotation);
|
||||
}
|
||||
}
|
||||
// updateWidgetRotation(selectedZoneId, rightClickSelected, newRotation);
|
||||
// }
|
||||
// }
|
||||
};
|
||||
const handleMouseUp = () => {
|
||||
if (!rightClickSelected || !rightSelect) return;
|
||||
|
@ -564,11 +604,60 @@ export default function Dropped3dWidgets() {
|
|||
};
|
||||
}, [rightClickSelected, rightSelect, zoneWidgetData, gl]);
|
||||
|
||||
const handleRightClick3d = (event: React.MouseEvent, id: string) => {
|
||||
event.preventDefault();
|
||||
|
||||
const canvasElement = document.getElementById("real-time-vis-canvas");
|
||||
if (!canvasElement) throw new Error("Canvas element not found");
|
||||
|
||||
const canvasRect = canvasElement.getBoundingClientRect();
|
||||
const relativeX = event.clientX - canvasRect.left;
|
||||
const relativeY = event.clientY - canvasRect.top;
|
||||
|
||||
setEditWidgetOptions(true);
|
||||
setRightClickSelected(id);
|
||||
setTop(relativeY);
|
||||
setLeft(relativeX);
|
||||
|
||||
const selectedZoneId = Object.keys(zoneWidgetData).find(zoneId =>
|
||||
zoneWidgetData[zoneId].some(widget => widget.id === id)
|
||||
);
|
||||
if (!selectedZoneId) return;
|
||||
|
||||
const selectedWidget = zoneWidgetData[selectedZoneId].find(widget => widget.id === id);
|
||||
if (!selectedWidget) return;
|
||||
|
||||
const { top, left, width, height } = canvasElement.getBoundingClientRect();
|
||||
mouse.x = ((event.clientX - left) / width) * 2 - 1;
|
||||
mouse.y = -((event.clientY - top) / height) * 2 + 1;
|
||||
|
||||
raycaster.setFromCamera(mouse, camera);
|
||||
|
||||
const cameraDirection = new THREE.Vector3();
|
||||
camera.getWorldDirection(cameraDirection);
|
||||
const verticalPlane = new THREE.Plane(cameraDirection);
|
||||
setFloorPlanesVertical(verticalPlane);
|
||||
|
||||
const intersectPoint = raycaster.ray.intersectPlane(verticalPlane, planeIntersect.current);
|
||||
if (intersectPoint) {
|
||||
setintersectcontextmenu(intersectPoint.y);
|
||||
}
|
||||
const intersect2 = raycaster.ray.intersectPlane(plane.current, planeIntersect.current);
|
||||
if (intersect2) {
|
||||
const xDiff = -intersect2.x + selectedWidget.position[0];
|
||||
const zDiff = -intersect2.z + selectedWidget.position[2];
|
||||
setHorizontalX(xDiff);
|
||||
setHorizontalZ(zDiff);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{activeZoneWidgets.map(
|
||||
({ id, type, position, rotation = [0, 0, 0] }: WidgetData) => {
|
||||
({ id, type, position, Data, rotation = [0, 0, 0] }: any) => {
|
||||
const handleRightClick = (event: React.MouseEvent, id: string) => {
|
||||
setSelectedChartId({ id: id, type: type })
|
||||
event.preventDefault();
|
||||
const canvasElement = document.getElementById(
|
||||
"real-time-vis-canvas"
|
||||
|
@ -581,6 +670,7 @@ export default function Dropped3dWidgets() {
|
|||
setRightClickSelected(id);
|
||||
setTop(relativeY);
|
||||
setLeft(relativeX);
|
||||
handleRightClick3d(event, id)
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
|
@ -592,6 +682,7 @@ export default function Dropped3dWidgets() {
|
|||
type={type}
|
||||
position={position}
|
||||
rotation={rotation}
|
||||
Data={Data}
|
||||
onContextMenu={(e) => handleRightClick(e, id)}
|
||||
/>
|
||||
);
|
||||
|
@ -603,6 +694,7 @@ export default function Dropped3dWidgets() {
|
|||
type={type}
|
||||
position={position}
|
||||
rotation={rotation}
|
||||
Data={Data}
|
||||
onContextMenu={(e) => handleRightClick(e, id)}
|
||||
/>
|
||||
);
|
||||
|
@ -614,6 +706,7 @@ export default function Dropped3dWidgets() {
|
|||
type={type}
|
||||
position={position}
|
||||
rotation={rotation}
|
||||
Data={Data}
|
||||
onContextMenu={(e) => handleRightClick(e, id)}
|
||||
/>
|
||||
);
|
||||
|
@ -625,6 +718,7 @@ export default function Dropped3dWidgets() {
|
|||
type={type}
|
||||
position={position}
|
||||
rotation={rotation}
|
||||
Data={Data}
|
||||
onContextMenu={(e) => handleRightClick(e, id)}
|
||||
/>
|
||||
);
|
|
@ -11,11 +11,11 @@ import {
|
|||
Legend,
|
||||
TooltipItem, // Import TooltipItem for typing
|
||||
} from "chart.js";
|
||||
import { ThroughputIcon } from "../../../icons/3dChartIcons";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
|
||||
import axios from "axios";
|
||||
import io from "socket.io-client";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
|
||||
// Register ChartJS components
|
||||
ChartJS.register(
|
||||
|
@ -31,6 +31,7 @@ interface ProductionCapacityProps {
|
|||
type: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
Data?: any,
|
||||
onContextMenu?: (event: React.MouseEvent) => void;
|
||||
// onPointerDown:any
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ interface ProductionCapacityProps {
|
|||
const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
|
||||
id,
|
||||
type,
|
||||
Data,
|
||||
position,
|
||||
rotation,
|
||||
onContextMenu,
|
||||
|
@ -48,8 +50,8 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
|
|||
duration: chartDuration,
|
||||
name: widgetName,
|
||||
} = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h");
|
||||
const [measurements, setmeasurements] = useState<any>(Data?.measurements ? Data.measurements : {});
|
||||
const [duration, setDuration] = useState(Data?.duration ? Data.duration : "1h");
|
||||
const [name, setName] = useState("Widget");
|
||||
const [chartData, setChartData] = useState<{
|
||||
labels: string[];
|
||||
|
@ -227,6 +229,7 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
|
|||
// transform: transformStyle.transform,
|
||||
transformStyle: "preserve-3d",
|
||||
position: "absolute",
|
||||
transform:'translate(-50%, -50%)',
|
||||
}}
|
||||
>
|
||||
<div className="headeproductionCapacityr-wrapper">
|
|
@ -11,11 +11,13 @@ import {
|
|||
ChartData,
|
||||
ChartOptions,
|
||||
} from "chart.js";
|
||||
import { WavyIcon } from "../../../icons/3dChartIcons";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
|
||||
|
||||
import axios from "axios";
|
||||
import io from "socket.io-client";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
import { WavyIcon } from "../../../../../components/icons/3dChartIcons";
|
||||
|
||||
// Register Chart.js components
|
||||
ChartJS.register(
|
||||
|
@ -44,11 +46,13 @@ interface ReturnOfInvestmentProps {
|
|||
type: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
Data?: any;
|
||||
onContextMenu?: (event: React.MouseEvent) => void;
|
||||
}
|
||||
const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
|
||||
id,
|
||||
type,
|
||||
Data,
|
||||
position,
|
||||
rotation,
|
||||
onContextMenu,
|
||||
|
@ -59,8 +63,8 @@ const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
|
|||
duration: chartDuration,
|
||||
name: widgetName,
|
||||
} = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h");
|
||||
const [measurements, setmeasurements] = useState<any>(Data?.measurements ? Data.measurements : {});
|
||||
const [duration, setDuration] = useState(Data?.duration ? Data.duration : "1h");
|
||||
const [name, setName] = useState("Widget");
|
||||
const [chartData, setChartData] = useState<{
|
||||
labels: string[];
|
|
@ -1,9 +1,10 @@
|
|||
import { Html } from "@react-three/drei";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
|
||||
import axios from "axios";
|
||||
import io from "socket.io-client";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
|
||||
// import image from "../../../../assets/image/temp/image.png";
|
||||
interface StateWorkingProps {
|
||||
|
@ -11,11 +12,13 @@ interface StateWorkingProps {
|
|||
type: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
Data?:any;
|
||||
onContextMenu?: (event: React.MouseEvent) => void;
|
||||
}
|
||||
const StateWorking: React.FC<StateWorkingProps> = ({
|
||||
id,
|
||||
type,
|
||||
Data,
|
||||
position,
|
||||
rotation,
|
||||
onContextMenu,
|
||||
|
@ -26,8 +29,8 @@ const StateWorking: React.FC<StateWorkingProps> = ({
|
|||
duration: chartDuration,
|
||||
name: widgetName,
|
||||
} = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h");
|
||||
const [measurements, setmeasurements] = useState<any>(Data?.measurements ? Data.measurements : {});
|
||||
const [duration, setDuration] = useState(Data?.duration ? Data.duration : "1h");
|
||||
const [name, setName] = useState("Widget");
|
||||
const [datas, setDatas] = useState<any>({});
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
|
@ -13,11 +13,13 @@ import {
|
|||
ChartData,
|
||||
ChartOptions,
|
||||
} from "chart.js";
|
||||
import { ThroughputIcon } from "../../../icons/3dChartIcons";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
|
||||
|
||||
import axios from "axios";
|
||||
import io from "socket.io-client";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
import { ThroughputIcon } from "../../../../../components/icons/3dChartIcons";
|
||||
|
||||
// Register Chart.js components
|
||||
ChartJS.register(
|
||||
|
@ -46,12 +48,14 @@ interface ThroughputProps {
|
|||
type: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
Data?:any;
|
||||
onContextMenu?: (event: React.MouseEvent) => void;
|
||||
}
|
||||
|
||||
const Throughput: React.FC<ThroughputProps> = ({
|
||||
id,
|
||||
type,
|
||||
Data,
|
||||
position,
|
||||
rotation,
|
||||
onContextMenu,
|
||||
|
@ -62,8 +66,8 @@ const Throughput: React.FC<ThroughputProps> = ({
|
|||
duration: chartDuration,
|
||||
name: widgetName,
|
||||
} = useChartStore();
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
const [duration, setDuration] = useState("1h");
|
||||
const [measurements, setmeasurements] = useState<any>(Data?.measurements ? Data.measurements : {});
|
||||
const [duration, setDuration] = useState(Data?.duration ? Data.duration : "1h");
|
||||
const [name, setName] = useState("Widget");
|
||||
const [chartData, setChartData] = useState<{
|
||||
labels: string[];
|
|
@ -1,29 +1,29 @@
|
|||
import { WalletIcon } from "../../icons/3dChartIcons";
|
||||
import { WalletIcon } from "../../../../components/icons/3dChartIcons";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
useDroppedObjectsStore,
|
||||
Zones,
|
||||
} from "../../../store/useDroppedObjectsStore";
|
||||
import useModuleStore from "../../../store/useModuleStore";
|
||||
import { determinePosition } from "./functions/determinePosition";
|
||||
import { getActiveProperties } from "./functions/getActiveProperties";
|
||||
import { addingFloatingWidgets } from "../../../services/realTimeVisulization/zoneData/addFloatingWidgets";
|
||||
} from "../../../../store/useDroppedObjectsStore";
|
||||
import useModuleStore from "../../../../store/useModuleStore";
|
||||
import { determinePosition } from "../../functions/determinePosition";
|
||||
import { getActiveProperties } from "../../functions/getActiveProperties";
|
||||
import { addingFloatingWidgets } from "../../../../services/realTimeVisulization/zoneData/addFloatingWidgets";
|
||||
import {
|
||||
DublicateIcon,
|
||||
KebabIcon,
|
||||
DeleteIcon,
|
||||
} from "../../icons/ExportCommonIcons";
|
||||
} from "../../../../components/icons/ExportCommonIcons";
|
||||
import DistanceLines from "./DistanceLines"; // Import the DistanceLines component
|
||||
import { deleteFloatingWidgetApi } from "../../../services/realTimeVisulization/zoneData/deleteFloatingWidget";
|
||||
import { deleteFloatingWidgetApi } from "../../../../services/realTimeVisulization/zoneData/deleteFloatingWidget";
|
||||
|
||||
import TotalCardComponent from "../realTimeVis/floating/TotalCardComponent";
|
||||
import WarehouseThroughputComponent from "../realTimeVis/floating/WarehouseThroughputComponent";
|
||||
import FleetEfficiencyComponent from "../realTimeVis/floating/FleetEfficiencyComponent";
|
||||
import { useWidgetStore } from "../../../store/useWidgetStore";
|
||||
import { useSocketStore } from "../../../store/store";
|
||||
import { useClickOutside } from "./functions/handleWidgetsOuterClick";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import { useSelectedZoneStore } from "../../../store/useZoneStore";
|
||||
import TotalCardComponent from "./cards/TotalCardComponent";
|
||||
import WarehouseThroughputComponent from "./cards/WarehouseThroughputComponent";
|
||||
import FleetEfficiencyComponent from "./cards/FleetEfficiencyComponent";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import { useSocketStore } from "../../../../store/store";
|
||||
import { useClickOutside } from "../../functions/handleWidgetsOuterClick";
|
||||
import { usePlayButtonStore } from "../../../../store/usePlayButtonStore";
|
||||
import { useSelectedZoneStore } from "../../../../store/useZoneStore";
|
||||
interface DraggingState {
|
||||
zone: string;
|
||||
index: number;
|
||||
|
@ -560,7 +560,7 @@ const DroppedObjects: React.FC = () => {
|
|||
key={`${zoneName}-${index}`}
|
||||
className={`${obj.className} ${
|
||||
selectedChartId?.id === obj.id && "activeChart"
|
||||
}`}
|
||||
} `}
|
||||
ref={chartWidget}
|
||||
style={{
|
||||
position: "absolute",
|
||||
|
@ -569,7 +569,9 @@ const DroppedObjects: React.FC = () => {
|
|||
right: rightPosition,
|
||||
bottom: bottomPosition,
|
||||
pointerEvents: isPlaying ? "none" : "auto",
|
||||
minHeight: `${obj.className === "warehouseThroughput" && "150px !important"} `
|
||||
minHeight: `${
|
||||
obj.className === "warehouseThroughput" && "150px !important"
|
||||
} `,
|
||||
}}
|
||||
onPointerDown={(event) => {
|
||||
setSelectedChartId(obj);
|
||||
|
@ -661,3 +663,4 @@ const DroppedObjects: React.FC = () => {
|
|||
};
|
||||
|
||||
export default DroppedObjects;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import React, { useState, useEffect } from 'react'
|
||||
import { Line } from 'react-chartjs-2'
|
||||
import useChartStore from '../../../../store/useChartStore';
|
||||
import { useWidgetStore } from '../../../../store/useWidgetStore';
|
||||
import useChartStore from '../../../../../store/useChartStore';
|
||||
import { useWidgetStore } from '../../../../../store/useWidgetStore';
|
||||
import axios from 'axios';
|
||||
import io from "socket.io-client";
|
||||
|
||||
|
@ -41,7 +41,7 @@ const FleetEfficiencyComponent = ({object}: any) => {
|
|||
|
||||
socket.on("lastOutput", (response) => {
|
||||
const responseData = response.input1;
|
||||
console.log(responseData);
|
||||
// console.log(responseData);
|
||||
|
||||
if (typeof responseData === "number") {
|
||||
console.log("It's a number!");
|
|
@ -2,7 +2,8 @@ import React from "react";
|
|||
|
||||
interface SimpleCardProps {
|
||||
header: string;
|
||||
icon: React.ComponentType<React.SVGProps<SVGSVGElement>>; // React component for SVG icon
|
||||
icon: React.ElementType; // React component for SVG icon
|
||||
iconName?: string;
|
||||
value: string;
|
||||
per: string; // Percentage change
|
||||
position?: [number, number];
|
||||
|
@ -11,23 +12,25 @@ interface SimpleCardProps {
|
|||
const SimpleCard: React.FC<SimpleCardProps> = ({
|
||||
header,
|
||||
icon: Icon,
|
||||
iconName,
|
||||
value,
|
||||
per,
|
||||
position = [0, 0],
|
||||
}) => {
|
||||
const handleDragStart = (event: React.DragEvent<HTMLDivElement>) => {
|
||||
const rect = event.currentTarget.getBoundingClientRect(); // Get position
|
||||
|
||||
const cardData = JSON.stringify({
|
||||
header,
|
||||
value,
|
||||
per,
|
||||
icon: Icon,
|
||||
|
||||
iconName: iconName || "UnknownIcon", // Use the custom iconName
|
||||
className: event.currentTarget.className,
|
||||
position: [rect.top, rect.left], // ✅ Store position
|
||||
});
|
||||
|
||||
event.dataTransfer.setData("text/plain", cardData);
|
||||
console.log("cardData: ", cardData);
|
||||
};
|
||||
|
||||
return (
|
|
@ -1,10 +1,15 @@
|
|||
import React, { useState, useEffect } from "react";
|
||||
import { Line } from "react-chartjs-2";
|
||||
import useChartStore from "../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/useChartStore";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import axios from "axios";
|
||||
import io from "socket.io-client";
|
||||
import { WalletIcon } from "../../../icons/3dChartIcons";
|
||||
import {
|
||||
CartIcon,
|
||||
DocumentIcon,
|
||||
GlobeIcon,
|
||||
WalletIcon,
|
||||
} from "../../../../../components/icons/3dChartIcons";
|
||||
|
||||
const TotalCardComponent = ({ object }: any) => {
|
||||
const [progress, setProgress] = useState<any>(0);
|
||||
|
@ -77,6 +82,20 @@ const TotalCardComponent = ({ object }: any) => {
|
|||
}
|
||||
}, [header, flotingDuration, flotingMeasurements]);
|
||||
|
||||
const mapIcon = (iconName: string) => {
|
||||
switch (iconName) {
|
||||
case "WalletIcon":
|
||||
return <WalletIcon />;
|
||||
case "GlobeIcon":
|
||||
return <GlobeIcon />;
|
||||
case "DocumentIcon":
|
||||
return <DocumentIcon />;
|
||||
case "CartIcon":
|
||||
return <CartIcon />;
|
||||
default:
|
||||
return <WalletIcon />;
|
||||
}
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<div className="header-wrapper">
|
||||
|
@ -86,9 +105,7 @@ const TotalCardComponent = ({ object }: any) => {
|
|||
<div className="per">{object.per}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="icon">
|
||||
<WalletIcon />
|
||||
</div>
|
||||
<div className="icon">{mapIcon(object.iconName)}</div>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
import React, { useState, useEffect } from 'react'
|
||||
import { Line } from 'react-chartjs-2'
|
||||
import useChartStore from '../../../../store/useChartStore';
|
||||
import { useWidgetStore } from '../../../../store/useWidgetStore';
|
||||
import useChartStore from '../../../../../store/useChartStore';
|
||||
import { useWidgetStore } from '../../../../../store/useWidgetStore';
|
||||
import axios from 'axios';
|
||||
import io from "socket.io-client";
|
||||
|
|
@ -3,11 +3,11 @@ import {
|
|||
CleanPannel,
|
||||
EyeIcon,
|
||||
LockIcon,
|
||||
} from "../../icons/RealTimeVisulationIcons";
|
||||
import { AddIcon } from "../../icons/ExportCommonIcons";
|
||||
import { useSocketStore } from "../../../store/store";
|
||||
import { clearPanel } from "../../../services/realTimeVisulization/zoneData/clearPanel";
|
||||
import { lockPanel } from "../../../services/realTimeVisulization/zoneData/lockPanel";
|
||||
} from "../../../../components/icons/RealTimeVisulationIcons";
|
||||
import { AddIcon } from "../../../../components/icons/ExportCommonIcons";
|
||||
import { useSocketStore } from "../../../../store/store";
|
||||
import { clearPanel } from "../../../../services/realTimeVisulization/zoneData/clearPanel";
|
||||
import { lockPanel } from "../../../../services/realTimeVisulization/zoneData/lockPanel";
|
||||
|
||||
// Define the type for `Side`
|
||||
type Side = "top" | "bottom" | "left" | "right";
|
|
@ -1,10 +1,10 @@
|
|||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useWidgetStore } from "../../../store/useWidgetStore";
|
||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||
import { DraggableWidget } from "./DraggableWidget";
|
||||
|
||||
import { arrayMove } from "@dnd-kit/sortable";
|
||||
import { addingWidgets } from "../../../services/realTimeVisulization/zoneData/addWidgets";
|
||||
import { useAsset3dWidget, useSocketStore } from "../../../store/store";
|
||||
import { useAsset3dWidget, useSocketStore } from "../../../../store/store";
|
||||
import { usePlayButtonStore } from "../../../../store/usePlayButtonStore";
|
||||
import { useWidgetStore } from "../../../../store/useWidgetStore";
|
||||
import { DraggableWidget } from "../2d/DraggableWidget";
|
||||
|
||||
type Side = "top" | "bottom" | "left" | "right";
|
||||
|
||||
|
@ -22,7 +22,7 @@ interface PanelProps {
|
|||
activeSides: Side[];
|
||||
panelOrder: Side[];
|
||||
lockedPanels: Side[];
|
||||
points:[];
|
||||
points: [];
|
||||
zoneId: string;
|
||||
zoneViewPortTarget: number[];
|
||||
zoneViewPortPosition: number[];
|
||||
|
@ -34,7 +34,7 @@ interface PanelProps {
|
|||
activeSides: Side[];
|
||||
panelOrder: Side[];
|
||||
lockedPanels: Side[];
|
||||
points:[];
|
||||
points: [];
|
||||
zoneId: string;
|
||||
zoneViewPortTarget: number[];
|
||||
zoneViewPortPosition: number[];
|
||||
|
@ -108,8 +108,7 @@ const Panel: React.FC<PanelProps> = ({
|
|||
case "bottom":
|
||||
return {
|
||||
minWidth: "170px",
|
||||
width: `calc(100% - ${
|
||||
(leftActive ? panelSize : 0) + (rightActive ? panelSize : 0)
|
||||
width: `calc(100% - ${(leftActive ? panelSize : 0) + (rightActive ? panelSize : 0)
|
||||
}px)`,
|
||||
minHeight: "170px",
|
||||
height: `${panelSize}px`,
|
||||
|
@ -123,8 +122,7 @@ const Panel: React.FC<PanelProps> = ({
|
|||
minWidth: "170px",
|
||||
width: `${panelSize}px`,
|
||||
minHeight: "170px",
|
||||
height: `calc(100% - ${
|
||||
(topActive ? panelSize : 0) + (bottomActive ? panelSize : 0)
|
||||
height: `calc(100% - ${(topActive ? panelSize : 0) + (bottomActive ? panelSize : 0)
|
||||
}px)`,
|
||||
top: topActive ? `${panelSize}px` : "0",
|
||||
bottom: bottomActive ? `${panelSize}px` : "0",
|
||||
|
@ -151,6 +149,7 @@ const Panel: React.FC<PanelProps> = ({
|
|||
const currentWidgetsCount = getCurrentWidgetCount(panel);
|
||||
const maxCapacity = calculatePanelCapacity(panel);
|
||||
|
||||
|
||||
if (currentWidgetsCount < maxCapacity) {
|
||||
addWidgetToPanel(draggedAsset, panel);
|
||||
}
|
||||
|
@ -284,8 +283,7 @@ const Panel: React.FC<PanelProps> = ({
|
|||
<div
|
||||
key={side}
|
||||
id="panel-wrapper"
|
||||
className={`panel ${side}-panel absolute ${
|
||||
hiddenPanels[selectedZone.zoneId]?.includes(side) ? "hidePanel" : ""
|
||||
className={`panel ${side}-panel absolute ${hiddenPanels[selectedZone.zoneId]?.includes(side) ? "hidePanel" : ""
|
||||
}`}
|
||||
style={getPanelStyle(side)}
|
||||
onDrop={(e) => handleDrop(e, side)}
|
|
@ -1,8 +1,8 @@
|
|||
import React, { useEffect, useRef } from 'react'
|
||||
import { useSelectedFloorItem, useZoneAssetId } from '../../../store/store';
|
||||
import { useSelectedFloorItem, useZoneAssetId } from '../../store/store';
|
||||
import * as THREE from "three";
|
||||
import { useThree } from '@react-three/fiber';
|
||||
import * as Types from "../../../types/world/worldTypes";
|
||||
import * as Types from "../../types/world/worldTypes";
|
||||
export default function ZoneAssets() {
|
||||
const { zoneAssetId, setZoneAssetId } = useZoneAssetId();
|
||||
const { setSelectedFloorItem } = useSelectedFloorItem();
|
|
@ -3,7 +3,7 @@ import ModuleToggle from "../components/ui/ModuleToggle";
|
|||
import SideBarLeft from "../components/layout/sidebarLeft/SideBarLeft";
|
||||
import SideBarRight from "../components/layout/sidebarRight/SideBarRight";
|
||||
import useModuleStore, { useThreeDStore } from "../store/useModuleStore";
|
||||
import RealTimeVisulization from "../components/ui/componets/RealTimeVisulization";
|
||||
import RealTimeVisulization from "../modules/visualization/RealTimeVisulization";
|
||||
import Tools from "../components/ui/Tools";
|
||||
// import Scene from "../modules/scene/scene";
|
||||
import {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { create } from "zustand";
|
||||
import { addingFloatingWidgets } from "../services/realTimeVisulization/zoneData/addFloatingWidgets";
|
||||
import { useSocketStore } from "./store";
|
||||
import useChartStore from "./useChartStore";
|
||||
|
||||
type DroppedObject = {
|
||||
className: string;
|
||||
|
@ -96,7 +97,10 @@ export const useDroppedObjectsStore = create<DroppedObjectsState>((set) => ({
|
|||
const state = useDroppedObjectsStore.getState(); // Get the current state
|
||||
const zone = state.zones[zoneName];
|
||||
let socketState = useSocketStore.getState();
|
||||
let iotData = useChartStore.getState();
|
||||
let visualizationSocket = socketState.visualizationSocket;
|
||||
let iotMeasurements = iotData.flotingMeasurements;
|
||||
let iotDuration = iotData.flotingDuration;
|
||||
|
||||
if (!zone) return;
|
||||
|
||||
|
@ -109,6 +113,10 @@ export const useDroppedObjectsStore = create<DroppedObjectsState>((set) => ({
|
|||
// Create a shallow copy of the object with a unique ID and slightly adjusted position
|
||||
const duplicatedObject: DroppedObject = {
|
||||
...originalObject,
|
||||
Data:{
|
||||
measurements: iotMeasurements,
|
||||
duration: iotDuration,
|
||||
},
|
||||
id: `${originalObject.id}-copy-${Date.now()}`, // Unique ID
|
||||
position: {
|
||||
...originalObject.position,
|
||||
|
@ -122,6 +130,7 @@ export const useDroppedObjectsStore = create<DroppedObjectsState>((set) => ({
|
|||
: originalObject.position.left,
|
||||
},
|
||||
};
|
||||
console.log("duplicated object",duplicatedObject);
|
||||
|
||||
let duplicateFloatingWidget = {
|
||||
organization: organization,
|
||||
|
|
|
@ -8,22 +8,8 @@ export interface Widget {
|
|||
fontFamily?: string;
|
||||
fontSize?: string;
|
||||
fontWeight?: string;
|
||||
data: {
|
||||
// Chart data
|
||||
labels?: string[];
|
||||
datasets?: Array<{
|
||||
data: number[];
|
||||
backgroundColor: string;
|
||||
borderColor: string;
|
||||
borderWidth: number;
|
||||
}>;
|
||||
// Progress card data
|
||||
stocks?: Array<{
|
||||
key: string;
|
||||
value: number;
|
||||
description: string;
|
||||
}>;
|
||||
};
|
||||
data?: any;
|
||||
Data?:any;
|
||||
}
|
||||
|
||||
interface WidgetStore {
|
||||
|
|
|
@ -130,7 +130,6 @@
|
|||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.widget-left-sideBar {
|
||||
.widgets-wrapper {
|
||||
|
||||
min-height: 50vh;
|
||||
|
@ -138,6 +137,9 @@
|
|||
overflow: auto;
|
||||
}
|
||||
|
||||
.widget-left-sideBar {
|
||||
|
||||
|
||||
.widget2D {
|
||||
overflow: auto;
|
||||
|
||||
|
@ -1088,43 +1090,51 @@
|
|||
right: -10px;
|
||||
transform: translate(0, -50%);
|
||||
}
|
||||
&:nth-child(1), &:nth-child(9) {
|
||||
|
||||
&:nth-child(1),
|
||||
&:nth-child(9) {
|
||||
&::after {
|
||||
@include gradient-by-child(1); // First child uses the first color
|
||||
}
|
||||
}
|
||||
|
||||
&:nth-child(2), &:nth-child(10) {
|
||||
&:nth-child(2),
|
||||
&:nth-child(10) {
|
||||
&::after {
|
||||
@include gradient-by-child(2); // Second child uses the second color
|
||||
}
|
||||
}
|
||||
|
||||
&:nth-child(3), &:nth-child(11) {
|
||||
&:nth-child(3),
|
||||
&:nth-child(11) {
|
||||
&::after {
|
||||
@include gradient-by-child(3); // Third child uses the third color
|
||||
}
|
||||
}
|
||||
|
||||
&:nth-child(4), &:nth-child(12) {
|
||||
&:nth-child(4),
|
||||
&:nth-child(12) {
|
||||
&::after {
|
||||
@include gradient-by-child(4); // Fourth child uses the fourth color
|
||||
}
|
||||
}
|
||||
|
||||
&:nth-child(5), &:nth-child(13) {
|
||||
&:nth-child(5),
|
||||
&:nth-child(13) {
|
||||
&::after {
|
||||
@include gradient-by-child(5); // Fifth child uses the fifth color
|
||||
}
|
||||
}
|
||||
|
||||
&:nth-child(6), &:nth-child(14) {
|
||||
&:nth-child(6),
|
||||
&:nth-child(14) {
|
||||
&::after {
|
||||
@include gradient-by-child(6); // Fifth child uses the fifth color
|
||||
}
|
||||
}
|
||||
|
||||
&:nth-child(7), &:nth-child(15) {
|
||||
&:nth-child(7),
|
||||
&:nth-child(15) {
|
||||
&::after {
|
||||
@include gradient-by-child(7); // Fifth child uses the fifth color
|
||||
}
|
||||
|
@ -1160,6 +1170,7 @@
|
|||
position: relative;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
|
||||
&:hover {
|
||||
.asset-name {
|
||||
opacity: 1;
|
||||
|
@ -1173,21 +1184,24 @@
|
|||
padding: 8px;
|
||||
width: 100%;
|
||||
font-size: var(--font-size-regular);
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
background: color-mix(in srgb,
|
||||
var(--background-color) 40%,
|
||||
transparent
|
||||
);
|
||||
transparent);
|
||||
backdrop-filter: blur(5px);
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
|
||||
/* Added properties for ellipsis */
|
||||
display: -webkit-box; /* Necessary for multiline truncation */
|
||||
-webkit-line-clamp: 2; /* Number of lines to show */
|
||||
-webkit-box-orient: vertical; /* Box orientation for the ellipsis */
|
||||
overflow: hidden; /* Hide overflowing content */
|
||||
text-overflow: ellipsis; /* Add ellipsis for truncated content */
|
||||
display: -webkit-box;
|
||||
/* Necessary for multiline truncation */
|
||||
-webkit-line-clamp: 2;
|
||||
/* Number of lines to show */
|
||||
-webkit-box-orient: vertical;
|
||||
/* Box orientation for the ellipsis */
|
||||
overflow: hidden;
|
||||
/* Hide overflowing content */
|
||||
text-overflow: ellipsis;
|
||||
/* Add ellipsis for truncated content */
|
||||
}
|
||||
|
||||
.asset-image {
|
||||
|
|
|
@ -285,9 +285,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.chart-container.notLinked {
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
position: absolute;
|
||||
|
@ -755,6 +752,13 @@
|
|||
z-index: 2 !important;
|
||||
}
|
||||
|
||||
.chart-container.notLinked {
|
||||
|
||||
outline: 1px solid red;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.connectionSuccess {
|
||||
outline-color: #43c06d;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue