Implement API enhancements for token management and new endpoints
- Added token management for various API calls in the factoryBuilder and visualization services. - Updated deleteLayerApi, deleteLineApi, deletePointApi, getLinesApi, setLineApi, updatePointApi, and version control APIs to handle new access tokens from response headers. - Introduced new API endpoints for 3D widget and floating widget data retrieval. - Enhanced error handling and logging for API responses. - Created new sessionValidity and input retrieval components for better session management and data handling.
This commit is contained in:
@@ -14,7 +14,7 @@ import EditWidgetOption from "../../components/ui/menu/EditWidgetOption";
|
||||
import { useEditWidgetOptionsStore, useRightClickSelected, useRightSelected, } from "../../store/visualization/useZone3DWidgetStore";
|
||||
import OuterClick from "../../utils/outerClick";
|
||||
import { useWidgetStore } from "../../store/useWidgetStore";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../functions/getUserData";
|
||||
import { useVersionContext } from "../builder/version/versionContext";
|
||||
|
||||
@@ -63,6 +63,7 @@ const RealTimeVisulization: React.FC = () => {
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
const navigate = useNavigate();
|
||||
|
||||
OuterClick({
|
||||
contextClassName: [
|
||||
@@ -81,6 +82,12 @@ const RealTimeVisulization: React.FC = () => {
|
||||
useEffect(() => {
|
||||
if (!projectId || !selectedVersion) return;
|
||||
getZone2dData(organization, projectId, selectedVersion?.versionId || '').then((response) => {
|
||||
if (!response) return;
|
||||
// if (response.status === 401) {
|
||||
// console.log("force logout");
|
||||
// navigate("/");
|
||||
// return;
|
||||
// }
|
||||
if (!Array.isArray(response)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import useChartStore from "../../../../../store/visualization/useChartStore";
|
||||
import { useSelectedZoneStore } from "../../../../../store/visualization/useZoneStore";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
||||
@@ -181,30 +182,14 @@ const BarGraphComponent = ({
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ''}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
|
||||
setmeasurements(response.data.Datastructure.measurements);
|
||||
setDuration(response.data.Datastructure.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
|
||||
|
||||
if (response) {
|
||||
setmeasurements(response.Datastructure.measurements);
|
||||
setDuration(response.Datastructure.duration);
|
||||
setName(response.widgetName);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useParams } from "react-router-dom";
|
||||
import { useSelectedZoneStore } from "../../../../../store/visualization/useZoneStore";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
||||
@@ -164,30 +165,14 @@ const DoughnutGraphComponent = ({
|
||||
const fetchSavedInputes = async () => {
|
||||
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
|
||||
setmeasurements(response.data.Datastructure.measurements)
|
||||
setDuration(response.data.Datastructure.duration)
|
||||
setName(response.data.widgetName)
|
||||
} else {
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
|
||||
let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
|
||||
|
||||
if (response) {
|
||||
setmeasurements(response.Datastructure.measurements)
|
||||
setDuration(response.Datastructure.duration)
|
||||
setName(response.widgetName)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useParams } from "react-router-dom";
|
||||
import { useSelectedZoneStore } from "../../../../../store/visualization/useZoneStore";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
||||
@@ -181,29 +182,12 @@ const LineGraphComponent = ({
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
|
||||
setmeasurements(response.data.Datastructure.measurements);
|
||||
setDuration(response.data.Datastructure.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
|
||||
|
||||
if (response) {
|
||||
setmeasurements(response.Datastructure.measurements)
|
||||
setDuration(response.Datastructure.duration)
|
||||
setName(response.widgetName)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
||||
@@ -181,30 +182,13 @@ const PieChartComponent = ({
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
|
||||
setmeasurements(response.data.Datastructure.measurements);
|
||||
setDuration(response.data.Datastructure.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
|
||||
|
||||
if (response) {
|
||||
setmeasurements(response.Datastructure.measurements)
|
||||
setDuration(response.Datastructure.duration)
|
||||
setName(response.widgetName)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
|
||||
|
||||
interface ChartComponentProps {
|
||||
id: string;
|
||||
@@ -181,30 +182,13 @@ const PolarAreaGraphComponent = ({
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
|
||||
setmeasurements(response.data.Datastructure.measurements);
|
||||
setDuration(response.data.Datastructure.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
|
||||
|
||||
if (response) {
|
||||
setmeasurements(response.Datastructure.measurements)
|
||||
setDuration(response.Datastructure.duration)
|
||||
setName(response.widgetName)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
|
||||
|
||||
const ProgressCard1 = ({ id, title }: { id: string; title: string }) => {
|
||||
const {
|
||||
@@ -61,31 +62,13 @@ const ProgressCard1 = ({ id, title }: { id: string; title: string }) => {
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
|
||||
|
||||
if (response) {
|
||||
setmeasurements(response.Datastructure.measurements)
|
||||
setDuration(response.Datastructure.duration)
|
||||
setName(response.widgetName)
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
|
||||
setmeasurements(response.data.Datastructure.measurements);
|
||||
setDuration(response.data.Datastructure.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
|
||||
|
||||
const ProgressCard2 = ({ id, title }: { id: string; title: string }) => {
|
||||
const {
|
||||
@@ -65,30 +66,12 @@ const ProgressCard2 = ({ id, title }: { id: string; title: string }) => {
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
|
||||
|
||||
setmeasurements(response.data.Datastructure.measurements);
|
||||
setDuration(response.data.Datastructure.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
|
||||
let response = await getWidgetInputData(id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
|
||||
|
||||
if (response) {
|
||||
setmeasurements(response.Datastructure.measurements)
|
||||
setDuration(response.Datastructure.duration)
|
||||
setName(response.widgetName)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -66,7 +66,6 @@ export default function Dropped3dWidgets() {
|
||||
const [horizontalZ, setHorizontalZ] = useState<number | undefined>();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
|
||||
const activeZoneWidgets = zoneWidgetData[selectedZone.zoneUuid] || [];
|
||||
const { projectId } = useParams();
|
||||
const { userId, organization, email } = getUserData();
|
||||
@@ -107,13 +106,16 @@ export default function Dropped3dWidgets() {
|
||||
const hasEntered = { current: false };
|
||||
|
||||
const handleDragEnter = (event: DragEvent) => {
|
||||
console.log("dragEnter");
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (hasEntered.current || !widgetSelect.startsWith("ui")) return;
|
||||
console.log('hasEntered.current : ', hasEntered.current );
|
||||
hasEntered.current = true;
|
||||
|
||||
const group1 = scene.getObjectByName("itemsGroup");
|
||||
console.log('group1: ', group1);
|
||||
if (!group1) return;
|
||||
|
||||
const rect = canvasElement.getBoundingClientRect();
|
||||
@@ -137,6 +139,7 @@ export default function Dropped3dWidgets() {
|
||||
intersect.object.type !== "GridHelper"
|
||||
);
|
||||
|
||||
console.log('intersects: ', intersects);
|
||||
if (intersects.length > 0) {
|
||||
const { x, y, z } = intersects[0].point;
|
||||
const newWidget: WidgetData = {
|
||||
|
||||
@@ -17,6 +17,7 @@ import io from "socket.io-client";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/visualization/useChartStore";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
||||
|
||||
// Register ChartJS components
|
||||
ChartJS.register(
|
||||
@@ -170,20 +171,27 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
|
||||
);
|
||||
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
} else {
|
||||
}
|
||||
} catch (error) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
let response = await get3dWidgetInput(id, organization)
|
||||
console.log('response: ', response);
|
||||
if (response) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
}
|
||||
// try {
|
||||
// const response = await axios.get(
|
||||
// `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${id}/${organization}`
|
||||
// );
|
||||
|
||||
// if (response.status === 200) {
|
||||
// setmeasurements(response.data.Data.measurements);
|
||||
// setDuration(response.data.Data.duration);
|
||||
// setName(response.data.widgetName);
|
||||
// } else {
|
||||
// }
|
||||
// } catch (error) {
|
||||
// echo.error("Failed to fetch saved inputs");
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/visualization/useChartStore";
|
||||
import { WavyIcon } from "../../../../../components/icons/3dChartIcons";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
||||
|
||||
// Register Chart.js components
|
||||
ChartJS.register(
|
||||
@@ -199,21 +200,28 @@ const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${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) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
console.error("There was an error!", error);
|
||||
let response = await get3dWidgetInput(id, organization)
|
||||
console.log('response: ', response);
|
||||
if (response) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
}
|
||||
// try {
|
||||
// const response = await axios.get(
|
||||
// `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${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) {
|
||||
// echo.error("Failed to fetch saved inputs");
|
||||
// console.error("There was an error!", error);
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import io from "socket.io-client";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/visualization/useChartStore";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
||||
|
||||
// import image from "../../../../assets/image/temp/image.png";
|
||||
interface StateWorkingProps {
|
||||
@@ -77,21 +78,28 @@ const StateWorking: React.FC<StateWorkingProps> = ({
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${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) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
console.error("There was an error!", error);
|
||||
let response = await get3dWidgetInput(id, organization)
|
||||
console.log('response: ', response);
|
||||
if (response) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
}
|
||||
// try {
|
||||
// const response = await axios.get(
|
||||
// `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${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) {
|
||||
// echo.error("Failed to fetch saved inputs");
|
||||
// console.error("There was an error!", error);
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import useChartStore from "../../../../../store/visualization/useChartStore";
|
||||
import { ThroughputIcon } from "../../../../../components/icons/3dChartIcons";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
||||
|
||||
// Register Chart.js components
|
||||
ChartJS.register(
|
||||
@@ -179,21 +180,28 @@ const Throughput: React.FC<ThroughputProps> = ({
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${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) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
console.error("There was an error!", error);
|
||||
let response = await get3dWidgetInput(id, organization)
|
||||
console.log('response: ', response);
|
||||
if (response) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.widgetName);
|
||||
}
|
||||
// try {
|
||||
// const response = await axios.get(
|
||||
// `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${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) {
|
||||
// echo.error("Failed to fetch saved inputs");
|
||||
// console.error("There was an error!", error);
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ const DroppedObjects: React.FC = () => {
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams();
|
||||
|
||||
|
||||
const [openKebabId, setOpenKebabId] = useState<string | null>(null);
|
||||
const updateObjectPosition = useDroppedObjectsStore(
|
||||
(state) => state.updateObjectPosition
|
||||
@@ -116,7 +117,7 @@ const DroppedObjects: React.FC = () => {
|
||||
|
||||
function handleDuplicate(zoneName: string, index: number) {
|
||||
setOpenKebabId(null);
|
||||
duplicateObject(zoneName, index, projectId, selectedVersion?.versionId ||''); // Call the duplicateObject method from the store
|
||||
duplicateObject(zoneName, index, projectId, selectedVersion?.versionId || ''); // Call the duplicateObject method from the store
|
||||
setSelectedChartId(null);
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ const DroppedObjects: React.FC = () => {
|
||||
organization,
|
||||
zoneUuid: zone.zoneUuid,
|
||||
versionId: selectedVersion?.versionId || '',
|
||||
userId,
|
||||
userId,
|
||||
projectId
|
||||
};
|
||||
|
||||
@@ -168,6 +169,7 @@ const DroppedObjects: React.FC = () => {
|
||||
setActiveEdges({ vertical, horizontal });
|
||||
|
||||
// Store the initial position strategy and active edges
|
||||
|
||||
setDraggingIndex({
|
||||
zone: zoneName,
|
||||
index,
|
||||
@@ -190,6 +192,8 @@ const DroppedObjects: React.FC = () => {
|
||||
offsetX = rect.width - relativeX - (obj.position.right as number);
|
||||
}
|
||||
|
||||
|
||||
|
||||
setOffset([offsetY, offsetX]);
|
||||
|
||||
// Add native event listeners for smoother tracking
|
||||
@@ -254,11 +258,14 @@ const DroppedObjects: React.FC = () => {
|
||||
};
|
||||
|
||||
const handlePointerUpNative = async (e: PointerEvent) => {
|
||||
|
||||
// Clean up native event listeners
|
||||
element.removeEventListener("pointermove", handlePointerMoveNative);
|
||||
element.removeEventListener("pointerup", handlePointerUpNative);
|
||||
element.releasePointerCapture(e.pointerId);
|
||||
|
||||
|
||||
|
||||
if (!draggingIndex || !offset) return;
|
||||
|
||||
const rect = container.getBoundingClientRect();
|
||||
@@ -305,15 +312,18 @@ const DroppedObjects: React.FC = () => {
|
||||
{
|
||||
...zone.objects[draggingIndex.index],
|
||||
position: boundedPosition,
|
||||
}
|
||||
},
|
||||
projectId,
|
||||
selectedVersion?.versionId || ""
|
||||
);
|
||||
|
||||
|
||||
if (response.message === "Widget updated successfully") {
|
||||
updateObjectPosition(zoneName, draggingIndex.index, boundedPosition);
|
||||
}
|
||||
} catch (error) {
|
||||
echo.error("Failed to add widget");
|
||||
console.log(error);
|
||||
|
||||
} finally {
|
||||
setDraggingIndex(null);
|
||||
setOffset(null);
|
||||
@@ -449,7 +459,7 @@ const DroppedObjects: React.FC = () => {
|
||||
updateObjectPosition(zoneName, draggingIndex.index, boundedPosition);
|
||||
} catch (error) {
|
||||
echo.error("Failed to add widget");
|
||||
console.log(error);
|
||||
|
||||
} finally {
|
||||
// Clean up regardless of success or failure
|
||||
setDraggingIndex(null);
|
||||
|
||||
@@ -7,6 +7,8 @@ import io from "socket.io-client";
|
||||
import { usePlayButtonStore } from "../../../../../store/usePlayButtonStore";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getFloatingWidgetInput } from "../../../../../services/visulization/zone/getFloatingWidgetInput";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
|
||||
const FleetEfficiencyComponent = ({ object }: any) => {
|
||||
const [progress, setProgress] = useState<any>(0);
|
||||
@@ -18,6 +20,8 @@ const FleetEfficiencyComponent = ({ object }: any) => {
|
||||
const { selectedChartId } = useWidgetStore();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { projectId } = useParams()
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
|
||||
@@ -44,10 +48,10 @@ const FleetEfficiencyComponent = ({ object }: any) => {
|
||||
|
||||
socket.on("lastOutput", (response) => {
|
||||
const responseData = response.input1;
|
||||
// console.log(responseData);
|
||||
//
|
||||
|
||||
if (typeof responseData === "number") {
|
||||
// console.log("It's a number!");
|
||||
//
|
||||
setProgress(responseData);
|
||||
}
|
||||
});
|
||||
@@ -61,28 +65,11 @@ const FleetEfficiencyComponent = ({ object }: any) => {
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (object?.id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${object?.id}/${organization}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.header);
|
||||
} else {
|
||||
// console.log("Unexpected response:", response);
|
||||
}
|
||||
} catch (error) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
console.error("There was an error!", error);
|
||||
let response = await getFloatingWidgetInput(object?.id, organization,projectId,selectedVersion?.versionId||"")
|
||||
if (response) {
|
||||
setmeasurements(response.Data.Datastructure.measurements);
|
||||
setDuration(response.Data.Datastructure.duration);
|
||||
setName(response.Data.header);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Line } from "react-chartjs-2";
|
||||
|
||||
import useChartStore from "../../../../../store/visualization/useChartStore";
|
||||
import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import axios from "axios";
|
||||
import io from "socket.io-client";
|
||||
import {
|
||||
CartIcon,
|
||||
DocumentIcon,
|
||||
GlobeIcon,
|
||||
WalletIcon,
|
||||
} from "../../../../../components/icons/3dChartIcons";
|
||||
import {CartIcon,DocumentIcon,GlobeIcon,WalletIcon,} from "../../../../../components/icons/3dChartIcons";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getFloatingWidgetInput } from "../../../../../services/visulization/zone/getFloatingWidgetInput";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
|
||||
const TotalCardComponent = ({ object }: any) => {
|
||||
const [progress, setProgress] = useState<any>(0);
|
||||
@@ -22,6 +19,8 @@ const TotalCardComponent = ({ object }: any) => {
|
||||
const { header, flotingDuration, flotingMeasurements } = useChartStore();
|
||||
const { selectedChartId } = useWidgetStore();
|
||||
const { projectId } = useParams()
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
|
||||
@@ -60,25 +59,12 @@ const TotalCardComponent = ({ object }: any) => {
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (object?.id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${object?.id}/${organization}`, {
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.header);
|
||||
} else {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
}
|
||||
} catch (error) { }
|
||||
let response = await getFloatingWidgetInput(object?.id, organization,projectId,selectedVersion?.versionId||"")
|
||||
if (response) {
|
||||
setmeasurements(response.Data.Datastructure.measurements);
|
||||
setDuration(response.Data.Datastructure.duration);
|
||||
setName(response.Data.header);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import axios from "axios";
|
||||
import io from "socket.io-client";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { getFloatingWidgetInput } from "../../../../../services/visulization/zone/getFloatingWidgetInput";
|
||||
import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
|
||||
const WarehouseThroughputComponent = ({ object }: any) => {
|
||||
const [measurements, setmeasurements] = useState<any>({});
|
||||
@@ -22,22 +24,12 @@ const WarehouseThroughputComponent = ({ object }: any) => {
|
||||
const { header, flotingDuration, flotingMeasurements } = useChartStore();
|
||||
const { selectedChartId } = useWidgetStore();
|
||||
const { projectId } = useParams()
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
|
||||
const lineGraphData = {
|
||||
labels: [
|
||||
"Jan",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec",
|
||||
labels: ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",
|
||||
], // Months of the year
|
||||
datasets: [
|
||||
{
|
||||
@@ -159,29 +151,14 @@ const WarehouseThroughputComponent = ({ object }: any) => {
|
||||
|
||||
const fetchSavedInputes = async () => {
|
||||
if (object?.id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${object?.id}/${organization}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
setmeasurements(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setName(response.data.header);
|
||||
} else {
|
||||
console.log("Unexpected response:", response);
|
||||
}
|
||||
} catch (error) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
console.error("There was an error!", error);
|
||||
let response = await getFloatingWidgetInput(object?.id, organization, projectId, selectedVersion?.versionId || "")
|
||||
|
||||
if (response) {
|
||||
setmeasurements(response.Data.measurements);
|
||||
setDuration(response.Data.duration);
|
||||
setName(response?.header);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user