refactor: update various components to improve readability and maintainability
This commit is contained in:
parent
d706a6a8a2
commit
6884ffd562
|
@ -14,9 +14,9 @@ const Analysis: React.FC = () => {
|
||||||
|
|
||||||
const AnalysisPresets: AnalysisPresetsType = {
|
const AnalysisPresets: AnalysisPresetsType = {
|
||||||
"Throughput time": [
|
"Throughput time": [
|
||||||
{ type: "default", inputs: { label: "Cycle time", activeOption: "s" } },
|
// { type: "default", inputs: { label: "Cycle time", activeOption: "s" } },
|
||||||
{ type: "default", inputs: { label: "machines / lines", activeOption: "item" } },
|
// { type: "default", inputs: { label: "machines / lines", activeOption: "item" } },
|
||||||
{ type: "default", inputs: { label: "Machine uptime", activeOption: "%" } },
|
// { type: "default", inputs: { label: "Machine uptime", activeOption: "%" } },
|
||||||
],
|
],
|
||||||
"Production capacity": [
|
"Production capacity": [
|
||||||
{ type: "default", inputs: { label: "Shift length", activeOption: "hr" } },
|
{ type: "default", inputs: { label: "Shift length", activeOption: "hr" } },
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import RenameInput from "../../../../ui/inputs/RenameInput";
|
import RenameInput from "../../../../ui/inputs/RenameInput";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useSocketStore } from "../../../../../store/builder/store";
|
||||||
|
|
||||||
type Props = {};
|
type Props = {};
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ const BarChartInput = (props: Props) => {
|
||||||
const organization = email?.split("@")[1]?.split(".")[0];
|
const organization = email?.split("@")[1]?.split(".")[0];
|
||||||
const [isLoading, setLoading] = useState<boolean>(true);
|
const [isLoading, setLoading] = useState<boolean>(true);
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
|
const { visualizationSocket } = useSocketStore();
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -92,6 +94,25 @@ const BarChartInput = (props: Props) => {
|
||||||
inputDuration: any,
|
inputDuration: any,
|
||||||
inputName: any
|
inputName: any
|
||||||
) => {
|
) => {
|
||||||
|
// const userId = localStorage.getItem("userId");
|
||||||
|
// let newWidget = {
|
||||||
|
// id: selectedChartId.id,
|
||||||
|
// panel: selectedChartId.panel,
|
||||||
|
// widgetName: inputName,
|
||||||
|
// Data: {
|
||||||
|
// measurements: inputMeasurement,
|
||||||
|
// duration: inputDuration,
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// const adding3dWidget = {
|
||||||
|
// organization: organization,
|
||||||
|
// widget: newWidget,
|
||||||
|
// zoneUuid: selectedZone.zoneUuid,
|
||||||
|
// projectId, userId
|
||||||
|
// };
|
||||||
|
// if (visualizationSocket) {
|
||||||
|
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
||||||
|
// }
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
||||||
|
|
|
@ -124,6 +124,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import RenameInput from "../../../../ui/inputs/RenameInput";
|
import RenameInput from "../../../../ui/inputs/RenameInput";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useSocketStore } from "../../../../../store/builder/store";
|
||||||
|
|
||||||
type Props = {};
|
type Props = {};
|
||||||
|
|
||||||
|
@ -142,6 +143,7 @@ const LineGrapInput = (props: Props) => {
|
||||||
const organization = email?.split("@")[1]?.split(".")[0];
|
const organization = email?.split("@")[1]?.split(".")[0];
|
||||||
const [isLoading, setLoading] = useState<boolean>(true);
|
const [isLoading, setLoading] = useState<boolean>(true);
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
|
const { visualizationSocket } = useSocketStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchZoneData = async () => {
|
const fetchZoneData = async () => {
|
||||||
|
@ -207,6 +209,25 @@ const LineGrapInput = (props: Props) => {
|
||||||
inputDuration: any,
|
inputDuration: any,
|
||||||
inputName: any
|
inputName: any
|
||||||
) => {
|
) => {
|
||||||
|
// const userId = localStorage.getItem("userId");
|
||||||
|
// let newWidget = {
|
||||||
|
// id: selectedChartId.id,
|
||||||
|
// panel: selectedChartId.panel,
|
||||||
|
// widgetName: inputName,
|
||||||
|
// Data: {
|
||||||
|
// measurements: inputMeasurement,
|
||||||
|
// duration: inputDuration,
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// const adding3dWidget = {
|
||||||
|
// organization: organization,
|
||||||
|
// widget: newWidget,
|
||||||
|
// zoneUuid: selectedZone.zoneUuid,
|
||||||
|
// projectId, userId
|
||||||
|
// };
|
||||||
|
// if (visualizationSocket) {
|
||||||
|
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
||||||
|
// }
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import RenameInput from "../../../../ui/inputs/RenameInput";
|
import RenameInput from "../../../../ui/inputs/RenameInput";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useSocketStore } from "../../../../../store/builder/store";
|
||||||
|
|
||||||
type Props = {};
|
type Props = {};
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ const PieChartInput = (props: Props) => {
|
||||||
const organization = email?.split("@")[1]?.split(".")[0];
|
const organization = email?.split("@")[1]?.split(".")[0];
|
||||||
const [isLoading, setLoading] = useState<boolean>(true);
|
const [isLoading, setLoading] = useState<boolean>(true);
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
|
const { visualizationSocket } = useSocketStore();
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -92,6 +94,26 @@ const PieChartInput = (props: Props) => {
|
||||||
inputDuration: any,
|
inputDuration: any,
|
||||||
inputName: any
|
inputName: any
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
|
// const userId = localStorage.getItem("userId");
|
||||||
|
// let newWidget = {
|
||||||
|
// id: selectedChartId.id,
|
||||||
|
// panel: selectedChartId.panel,
|
||||||
|
// widgetName: inputName,
|
||||||
|
// Data: {
|
||||||
|
// measurements: inputMeasurement,
|
||||||
|
// duration: inputDuration,
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
// const adding3dWidget = {
|
||||||
|
// organization: organization,
|
||||||
|
// widget: newWidget,
|
||||||
|
// zoneUuid: selectedZone.zoneUuid,
|
||||||
|
// projectId, userId
|
||||||
|
// };
|
||||||
|
// if (visualizationSocket) {
|
||||||
|
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
||||||
|
// }
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import RenameInput from "../../../../ui/inputs/RenameInput";
|
import RenameInput from "../../../../ui/inputs/RenameInput";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useSocketStore } from "../../../../../store/builder/store";
|
||||||
|
|
||||||
type Props = {};
|
type Props = {};
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ const Progress1Input = (props: Props) => {
|
||||||
const organization = email?.split("@")[1]?.split(".")[0];
|
const organization = email?.split("@")[1]?.split(".")[0];
|
||||||
const [isLoading, setLoading] = useState<boolean>(true);
|
const [isLoading, setLoading] = useState<boolean>(true);
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
|
const { visualizationSocket } = useSocketStore();
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -92,6 +94,25 @@ const Progress1Input = (props: Props) => {
|
||||||
inputDuration: any,
|
inputDuration: any,
|
||||||
inputName: any
|
inputName: any
|
||||||
) => {
|
) => {
|
||||||
|
// const userId = localStorage.getItem("userId");
|
||||||
|
// let newWidget = {
|
||||||
|
// id: selectedChartId.id,
|
||||||
|
// panel: selectedChartId.panel,
|
||||||
|
// widgetName: inputName,
|
||||||
|
// Data: {
|
||||||
|
// measurements: inputMeasurement,
|
||||||
|
// duration: inputDuration,
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
// const adding3dWidget = {
|
||||||
|
// organization: organization,
|
||||||
|
// widget: newWidget,
|
||||||
|
// zoneUuid: selectedZone.zoneUuid,
|
||||||
|
// projectId, userId
|
||||||
|
// };
|
||||||
|
// if (visualizationSocket) {
|
||||||
|
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
||||||
|
// }
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import RenameInput from "../../../../ui/inputs/RenameInput";
|
import RenameInput from "../../../../ui/inputs/RenameInput";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useSocketStore } from "../../../../../store/builder/store";
|
||||||
|
|
||||||
type Props = {};
|
type Props = {};
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ const Progress2Input = (props: Props) => {
|
||||||
const organization = email?.split("@")[1]?.split(".")[0];
|
const organization = email?.split("@")[1]?.split(".")[0];
|
||||||
const [isLoading, setLoading] = useState<boolean>(true);
|
const [isLoading, setLoading] = useState<boolean>(true);
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
|
const { visualizationSocket } = useSocketStore();
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -92,6 +94,25 @@ const Progress2Input = (props: Props) => {
|
||||||
inputDuration: any,
|
inputDuration: any,
|
||||||
inputName: any
|
inputName: any
|
||||||
) => {
|
) => {
|
||||||
|
// const userId = localStorage.getItem("userId");
|
||||||
|
// let newWidget = {
|
||||||
|
// id: selectedChartId.id,
|
||||||
|
// panel: selectedChartId.panel,
|
||||||
|
// widgetName: inputName,
|
||||||
|
// Data: {
|
||||||
|
// measurements: inputMeasurement,
|
||||||
|
// duration: inputDuration,
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// const adding3dWidget = {
|
||||||
|
// organization: organization,
|
||||||
|
// widget: newWidget,
|
||||||
|
// zoneUuid: selectedZone.zoneUuid,
|
||||||
|
// projectId, userId
|
||||||
|
// };
|
||||||
|
// if (visualizationSocket) {
|
||||||
|
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
||||||
|
// }
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
||||||
|
|
|
@ -91,7 +91,8 @@ const ThroughputSummary: React.FC = () => {
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (productionCapacityData >= 0) {
|
// console.log('productionCapacityData > 0: ', productionCapacityData > 0);
|
||||||
|
if (productionCapacityData > 0) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
console.log("productionCapacityData: ", productionCapacityData);
|
console.log("productionCapacityData: ", productionCapacityData);
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,7 +101,8 @@ const ThroughputSummary: React.FC = () => {
|
||||||
}, [productionCapacityData]);
|
}, [productionCapacityData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="production analysis-card">
|
<>
|
||||||
|
{!isLoading && <div className="production analysis-card">
|
||||||
<div className="production-wrapper analysis-card-wrapper">
|
<div className="production-wrapper analysis-card-wrapper">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<div className="header">
|
<div className="header">
|
||||||
|
@ -184,7 +186,8 @@ const ThroughputSummary: React.FC = () => {
|
||||||
<SkeletonUI type={"default"} />
|
<SkeletonUI type={"default"} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -83,16 +83,22 @@ const ROISummary = ({
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { roiSummary } = useROISummaryData();
|
const { roiSummary } = useROISummaryData();
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (roiSummary && typeof roiSummary === "object") {
|
if (roiSummary.productName) {
|
||||||
setIsLoading(false); // Data loaded
|
// If productName is set, assume data is loaded
|
||||||
|
setIsLoading(false);
|
||||||
} else {
|
} else {
|
||||||
setIsLoading(true); // Show skeleton while loading
|
// If productName is empty, assume still loading
|
||||||
|
setIsLoading(true);
|
||||||
}
|
}
|
||||||
}, [roiSummary]);
|
}, [roiSummary]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="roiSummary-container analysis-card">
|
<>
|
||||||
|
|
||||||
|
{
|
||||||
|
!isLoading && <div className="roiSummary-container analysis-card">
|
||||||
<div className="roiSummary-wrapper analysis-card-wrapper">
|
<div className="roiSummary-wrapper analysis-card-wrapper">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<div className="header">
|
<div className="header">
|
||||||
|
@ -238,7 +244,8 @@ const ROISummary = ({
|
||||||
// <div> No Data</div>
|
// <div> No Data</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,18 +30,24 @@ const ProductionCapacity = ({
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (throughputData >= 0) {
|
console.log('typeof throughputData:', typeof throughputData);
|
||||||
|
console.log('throughputData > 0: ', throughputData > 0);
|
||||||
|
if (throughputData > 0) {
|
||||||
// console.log('machineActiveTime: ', machineActiveTime);
|
// console.log('machineActiveTime: ', machineActiveTime);
|
||||||
// console.log('materialCycleTime: ', materialCycleTime);
|
// console.log('materialCycleTime: ', materialCycleTime);
|
||||||
// console.log('throughputData: ', throughputData);
|
// console.log('throughputData: ', throughputData);
|
||||||
// console.log('productionCapacityData: ', productionCapacityData);
|
// console.log('productionCapacityData: ', productionCapacityData);
|
||||||
|
setIsLoading(false);
|
||||||
|
} else {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [throughputData])
|
}, [throughputData])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="throughtputSummary-container analysis-card">
|
<>
|
||||||
|
|
||||||
|
{!isLoading && <div className="throughtputSummary-container analysis-card">
|
||||||
<div className="throughtputSummary-wrapper analysis-card-wrapper">
|
<div className="throughtputSummary-wrapper analysis-card-wrapper">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<div className="header">
|
<div className="header">
|
||||||
|
@ -95,7 +101,8 @@ const ProductionCapacity = ({
|
||||||
<SkeletonUI type={"default"} />
|
<SkeletonUI type={"default"} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ const SimulationPlayer: React.FC = () => {
|
||||||
<div className="icon">
|
<div className="icon">
|
||||||
<HourlySimulationIcon />
|
<HourlySimulationIcon />
|
||||||
</div>
|
</div>
|
||||||
<div className="label">Hourly Simulation</div>
|
<div className="label">ThroughPut Data</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="progress-wrapper">
|
<div className="progress-wrapper">
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -361,10 +361,7 @@ export default function Dropped3dWidgets() {
|
||||||
}
|
}
|
||||||
}, [rightSelect, rightClickSelected]);
|
}, [rightSelect, rightClickSelected]);
|
||||||
|
|
||||||
function isPointInPolygon(
|
function isPointInPolygon(point: [number, number], polygon: Array<[number, number]>): boolean {
|
||||||
point: [number, number],
|
|
||||||
polygon: Array<[number, number]>
|
|
||||||
): boolean {
|
|
||||||
const [x, z] = point;
|
const [x, z] = point;
|
||||||
let inside = false;
|
let inside = false;
|
||||||
|
|
||||||
|
@ -434,8 +431,6 @@ export default function Dropped3dWidgets() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleMouseMove = (event: MouseEvent) => {
|
const handleMouseMove = (event: MouseEvent) => {
|
||||||
if (!rightClickSelected || !rightSelect) return;
|
if (!rightClickSelected || !rightSelect) return;
|
||||||
const selectedzoneUuid = Object.keys(zoneWidgetData).find(
|
const selectedzoneUuid = Object.keys(zoneWidgetData).find(
|
||||||
|
|
Loading…
Reference in New Issue