Refactor API service functions for improved error handling and code consistency

- Updated signUpApi, deleteZonesApi, getZonesApi, setZonesApi, and other API functions to enhance error logging with echo.error statements.
- Reformatted function parameters for better readability.
- Removed unnecessary comments and console logs.
- Ensured consistent error messages across all API functions.
- Improved code structure for better maintainability.
This commit is contained in:
Nalvazhuthi
2025-05-08 15:19:21 +05:30
parent 1ce08821ff
commit 307d2eabee
105 changed files with 3758 additions and 3032 deletions

View File

@@ -81,7 +81,9 @@ const Assets: React.FC = () => {
try {
const filt = await fetchAssets();
setFiltereredAssets(filt);
} catch {}
} catch {
echo.error("Filter asset not found");
}
};
filteredAssets();
}, [categoryAssets]);
@@ -154,6 +156,7 @@ const Assets: React.FC = () => {
setisLoading(false); // End loading
} catch (error) {
setisLoading(false);
echo.error("failed to fetch assets");
}
}
};

View File

@@ -39,7 +39,9 @@ const ZoneProperties: React.FC = () => {
} else {
// console.log(response);
}
} catch (error) {}
} catch (error) {
echo.error("Failed to set zone view");
}
}
function handleEditView() {

View File

@@ -11,22 +11,24 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const BarChartInput = (props: Props) => {
const [widgetName, setWidgetName] = useState('Widget');
const [widgetName, setWidgetName] = useState("Widget");
const { setMeasurements, updateDuration, updateName } = useChartStore();
const [duration, setDuration] = useState('1h')
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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]
const organization = email?.split("@")[1]?.split(".")[0];
const [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
@@ -36,6 +38,7 @@ const BarChartInput = (props: Props) => {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.log("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -46,22 +49,24 @@ const BarChartInput = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.widgetName)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId]);
// Sync Zustand state when component mounts
@@ -71,36 +76,45 @@ const BarChartInput = (props: Props) => {
updateName(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -125,20 +139,23 @@ const BarChartInput = (props: Props) => {
// setDuration(option);
};
const handleNameChange = async (name:any) => {
console.log('name change requested',name);
const handleNameChange = async (name: any) => {
console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName || selectedChartId?.title} onRename={handleNameChange}/>
<RenameInput
value={widgetName || selectedChartId?.title}
onRename={handleNameChange}
/>
</div>
{[...Array(3)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -148,7 +165,9 @@ const BarChartInput = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}
@@ -179,4 +198,4 @@ const BarChartInput = (props: Props) => {
);
};
export default BarChartInput;
export default BarChartInput;

View File

@@ -11,35 +11,37 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const FleetEfficiencyInputComponent = (props: Props) => {
const [widgetName, setWidgetName] = useState('Widget');
const { setFlotingMeasurements, updateFlotingDuration, updateHeader } = useChartStore();
const [duration, setDuration] = useState('1h')
const [widgetName, setWidgetName] = useState("Widget");
const { setFlotingMeasurements, updateFlotingDuration, updateHeader } =
useChartStore();
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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]
const organization = email?.split("@")[1]?.split(".")[0];
const [isLoading, setLoading] = useState<boolean>(true);
const isSelected = () => {
}
const isSelected = () => {};
useEffect(() => {
const fetchZoneData = async () => {
try {
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
setLoading(true)
setLoading(true);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
setDropDownData(response.data);
setLoading(false)
setLoading(false);
} else {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -50,24 +52,25 @@ const FleetEfficiencyInputComponent = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.header)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
// Sync Zustand state when component mounts
@@ -77,35 +80,45 @@ const FleetEfficiencyInputComponent = (props: Props) => {
updateHeader(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
header: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
header: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -130,20 +143,23 @@ const FleetEfficiencyInputComponent = (props: Props) => {
// setDuration(option);
};
const handleNameChange = async (name:any) => {
console.log('name change requested',name);
const handleNameChange = async (name: any) => {
console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName || selectedChartId?.header} onRename={handleNameChange}/>
<RenameInput
value={widgetName || selectedChartId?.header}
onRename={handleNameChange}
/>
</div>
{[...Array(1)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -153,7 +169,9 @@ const FleetEfficiencyInputComponent = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}
@@ -184,4 +202,4 @@ const FleetEfficiencyInputComponent = (props: Props) => {
);
};
export default FleetEfficiencyInputComponent;
export default FleetEfficiencyInputComponent;

View File

@@ -11,22 +11,25 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const FlotingWidgetInput = (props: Props) => {
const [widgetName, setWidgetName] = useState('Widget');
const { setFlotingMeasurements, updateFlotingDuration, updateHeader } = useChartStore();
const [duration, setDuration] = useState('1h')
const [widgetName, setWidgetName] = useState("Widget");
const { setFlotingMeasurements, updateFlotingDuration, updateHeader } =
useChartStore();
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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]
const organization = email?.split("@")[1]?.split(".")[0];
const [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
@@ -36,6 +39,8 @@ const FlotingWidgetInput = (props: Props) => {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -46,24 +51,25 @@ const FlotingWidgetInput = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.header)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
// Sync Zustand state when component mounts
@@ -73,35 +79,45 @@ const FlotingWidgetInput = (props: Props) => {
updateHeader(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
header: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
header: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -126,20 +142,23 @@ const FlotingWidgetInput = (props: Props) => {
// setDuration(option);
};
const handleNameChange = async (name:any) => {
console.log('name change requested',name);
const handleNameChange = async (name: any) => {
console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName || selectedChartId?.header} onRename={handleNameChange}/>
<RenameInput
value={widgetName || selectedChartId?.header}
onRename={handleNameChange}
/>
</div>
{[...Array(6)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -149,7 +168,9 @@ const FlotingWidgetInput = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}

View File

@@ -72,7 +72,6 @@
// setMeasurements(measurementsData);
// }, [selections]);
// return (
// <>
// <div className="inputs-wrapper">
@@ -115,8 +114,6 @@
// export default LineGrapInput
import React, { useEffect, useState } from "react";
import MultiLevelDropdown from "../../../../ui/inputs/MultiLevelDropDown";
import { AddIcon } from "../../../../icons/ExportCommonIcons";
@@ -130,31 +127,34 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const LineGrapInput = (props: Props) => {
const [widgetName, setWidgetName] = useState('Widget');
const [widgetName, setWidgetName] = useState("Widget");
const { setMeasurements, updateDuration, updateName } = useChartStore();
const [duration, setDuration] = useState('1h')
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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]
const organization = email?.split("@")[1]?.split(".")[0];
const [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
setDropDownData(response.data);
setLoading(false)
setLoading(false);
} else {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -165,22 +165,24 @@ const LineGrapInput = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.widgetName)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
// Sync Zustand state when component mounts
@@ -190,36 +192,45 @@ const LineGrapInput = (props: Props) => {
updateName(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -244,20 +255,23 @@ const LineGrapInput = (props: Props) => {
// setDuration(option);
};
const handleNameChange = async (name:any) => {
console.log('name change requested',name);
const handleNameChange = async (name: any) => {
console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName || selectedChartId?.title} onRename={handleNameChange}/>
<RenameInput
value={widgetName || selectedChartId?.title}
onRename={handleNameChange}
/>
</div>
{[...Array(4)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -267,7 +281,9 @@ const LineGrapInput = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}

View File

@@ -11,31 +11,34 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const PieChartInput = (props: Props) => {
const [widgetName, setWidgetName] = useState('Widget');
const [widgetName, setWidgetName] = useState("Widget");
const { setMeasurements, updateDuration, updateName } = useChartStore();
const [duration, setDuration] = useState('1h')
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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]
const organization = email?.split("@")[1]?.split(".")[0];
const [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
setDropDownData(response.data);
setLoading(false)
setLoading(false);
} else {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -46,22 +49,24 @@ const PieChartInput = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.widgetName)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
// Sync Zustand state when component mounts
@@ -71,36 +76,45 @@ const PieChartInput = (props: Props) => {
updateName(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -125,20 +139,23 @@ const PieChartInput = (props: Props) => {
// setDuration(option);
};
const handleNameChange = async (name:any) => {
console.log('name change requested',name);
const handleNameChange = async (name: any) => {
console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName || selectedChartId?.title} onRename={handleNameChange}/>
<RenameInput
value={widgetName || selectedChartId?.title}
onRename={handleNameChange}
/>
</div>
{[...Array(2)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -148,7 +165,9 @@ const PieChartInput = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}
@@ -179,4 +198,4 @@ const PieChartInput = (props: Props) => {
);
};
export default PieChartInput;
export default PieChartInput;

View File

@@ -11,31 +11,34 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const Progress1Input = (props: Props) => {
const [widgetName, setWidgetName] = useState('Widget');
const [widgetName, setWidgetName] = useState("Widget");
const { setMeasurements, updateDuration, updateName } = useChartStore();
const [duration, setDuration] = useState('1h')
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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]
const organization = email?.split("@")[1]?.split(".")[0];
const [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
setDropDownData(response.data);
setLoading(false)
setLoading(false);
} else {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -46,22 +49,24 @@ const Progress1Input = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.widgetName)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
// Sync Zustand state when component mounts
@@ -71,36 +76,45 @@ const Progress1Input = (props: Props) => {
updateName(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -121,18 +135,21 @@ const Progress1Input = (props: Props) => {
}
};
const handleNameChange = async (name:any) => {
const handleNameChange = async (name: any) => {
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName || selectedChartId?.title} onRename={handleNameChange}/>
<RenameInput
value={widgetName || selectedChartId?.title}
onRename={handleNameChange}
/>
</div>
{[...Array(1)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -142,7 +159,9 @@ const Progress1Input = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}
@@ -173,4 +192,4 @@ const Progress1Input = (props: Props) => {
);
};
export default Progress1Input;
export default Progress1Input;

View File

@@ -11,31 +11,34 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const Progress2Input = (props: Props) => {
const [widgetName, setWidgetName] = useState('Widget');
const [widgetName, setWidgetName] = useState("Widget");
const { setMeasurements, updateDuration, updateName } = useChartStore();
const [duration, setDuration] = useState('1h')
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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]
const organization = email?.split("@")[1]?.split(".")[0];
const [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
setDropDownData(response.data);
setLoading(false)
setLoading(false);
} else {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -46,22 +49,24 @@ const Progress2Input = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.widgetName)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
// Sync Zustand state when component mounts
@@ -71,36 +76,45 @@ const Progress2Input = (props: Props) => {
updateName(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
panel: selectedChartId.panel,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -121,18 +135,21 @@ const Progress2Input = (props: Props) => {
}
};
const handleNameChange = async (name:any) => {
const handleNameChange = async (name: any) => {
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName || selectedChartId?.title} onRename={handleNameChange}/>
<RenameInput
value={widgetName || selectedChartId?.title}
onRename={handleNameChange}
/>
</div>
{[...Array(2)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -142,7 +159,9 @@ const Progress2Input = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}
@@ -173,4 +192,4 @@ const Progress2Input = (props: Props) => {
);
};
export default Progress2Input;
export default Progress2Input;

View File

@@ -11,31 +11,35 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const WarehouseThroughputInputComponent = (props: Props) => {
const [widgetName, setWidgetName] = useState('Widget');
const { setFlotingMeasurements, updateFlotingDuration, updateHeader } = useChartStore();
const [duration, setDuration] = useState('1h')
const [widgetName, setWidgetName] = useState("Widget");
const { setFlotingMeasurements, updateFlotingDuration, updateHeader } =
useChartStore();
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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]
const organization = email?.split("@")[1]?.split(".")[0];
const [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
setDropDownData(response.data);
setLoading(false)
setLoading(false);
} else {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -46,24 +50,24 @@ const WarehouseThroughputInputComponent = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/A_floatWidget/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.header)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
// Sync Zustand state when component mounts
@@ -73,35 +77,44 @@ const WarehouseThroughputInputComponent = (props: Props) => {
updateHeader(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
header: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
header: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -126,20 +139,23 @@ const WarehouseThroughputInputComponent = (props: Props) => {
// setDuration(option);
};
const handleNameChange = async (name:any) => {
console.log('name change requested',name);
const handleNameChange = async (name: any) => {
console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName || selectedChartId?.header} onRename={handleNameChange}/>
<RenameInput
value={widgetName || selectedChartId?.header}
onRename={handleNameChange}
/>
</div>
{[...Array(1)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -149,7 +165,9 @@ const WarehouseThroughputInputComponent = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}

View File

@@ -11,31 +11,34 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const Widget2InputCard3D = (props: Props) => {
const { selectedChartId } = useWidgetStore();
const { selectedChartId } = useWidgetStore();
const [widgetName, setWidgetName] = useState("untited");
const { setMeasurements, updateDuration, updateName } = useChartStore();
const [duration, setDuration] = useState('1h')
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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 [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
setDropDownData(response.data);
setLoading(false)
setLoading(false);
} else {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -46,22 +49,24 @@ const Widget2InputCard3D = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.widgetName)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
// Sync Zustand state when component mounts
@@ -71,35 +76,44 @@ const Widget2InputCard3D = (props: Props) => {
updateName(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -124,20 +138,20 @@ const Widget2InputCard3D = (props: Props) => {
// setDuration(option);
};
const handleNameChange = async (name:any) => {
console.log('name change requested',name);
const handleNameChange = async (name: any) => {
console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName} onRename={handleNameChange}/>
<RenameInput value={widgetName} onRename={handleNameChange} />
</div>
{[...Array(2)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -147,7 +161,9 @@ const Widget2InputCard3D = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}
@@ -165,4 +181,4 @@ const Widget2InputCard3D = (props: Props) => {
);
};
export default Widget2InputCard3D;
export default Widget2InputCard3D;

View File

@@ -9,31 +9,34 @@ import axios from "axios";
import RenameInput from "../../../../ui/inputs/RenameInput";
const Widget3InputCard3D = () => {
const { selectedChartId } = useWidgetStore();
const { selectedChartId } = useWidgetStore();
const [widgetName, setWidgetName] = useState("untited");
const { setMeasurements, updateDuration, updateName } = useChartStore();
const [duration, setDuration] = useState('1h')
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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 [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/getinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
setDropDownData(response.data);
setLoading(false)
setLoading(false);
} else {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -44,22 +47,24 @@ const Widget3InputCard3D = () => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.widgetName)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
useEffect(() => {
@@ -68,35 +73,44 @@ const Widget3InputCard3D = () => {
updateName(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -117,20 +131,20 @@ const Widget3InputCard3D = () => {
}
};
const handleNameChange = async (name:any) => {
console.log('name change requested',name);
const handleNameChange = async (name: any) => {
console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName} onRename={handleNameChange}/>
<RenameInput value={widgetName} onRename={handleNameChange} />
</div>
{[...Array(7)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -140,7 +154,9 @@ const Widget3InputCard3D = () => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}

View File

@@ -11,31 +11,34 @@ import RenameInput from "../../../../ui/inputs/RenameInput";
type Props = {};
const Widget4InputCard3D = (props: Props) => {
const { selectedChartId } = useWidgetStore();
const { selectedChartId } = useWidgetStore();
const [widgetName, setWidgetName] = useState("untited");
const { setMeasurements, updateDuration, updateName } = useChartStore();
const [duration, setDuration] = useState('1h')
const [duration, setDuration] = useState("1h");
const [dropDowndata, setDropDownData] = useState({});
const [selections, setSelections] = useState<Record<string, { name: string; fields: string }>>({});
const [selections, setSelections] = useState<
Record<string, { name: string; fields: string }>
>({});
const { selectedZone } = useSelectedZoneStore();
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 [isLoading, setLoading] = useState<boolean>(true);
useEffect(() => {
const fetchZoneData = async () => {
try {
setLoading(true)
setLoading(true);
const response = await axios.get(`http://${iotApiUrl}/floatinput`);
if (response.status === 200) {
// console.log("dropdown data:", response.data);
setDropDownData(response.data);
setLoading(false)
setLoading(false);
} else {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch zone data");
console.error("There was an error!", error);
}
};
@@ -46,22 +49,24 @@ const Widget4InputCard3D = (props: Props) => {
const fetchSavedInputes = async () => {
if (selectedChartId.id !== "") {
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${selectedChartId.id}/${organization}`);
const response = await axios.get(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget3D/${selectedChartId.id}/${organization}`
);
if (response.status === 200) {
setSelections(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setWidgetName(response.data.widgetName)
setSelections(response.data.Data.measurements);
setDuration(response.data.Data.duration);
setWidgetName(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);
}
}
}
};
fetchSavedInputes();
}, [selectedChartId.id]);
// Sync Zustand state when component mounts
@@ -71,35 +76,44 @@ const Widget4InputCard3D = (props: Props) => {
updateName(widgetName);
}, [selections, duration, widgetName]);
const sendInputes = async (inputMeasurement: any, inputDuration: any, inputName: any) => {
const sendInputes = async (
inputMeasurement: any,
inputDuration: any,
inputName: any
) => {
try {
const response = await axios.post(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`, {
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
const response = await axios.post(
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`,
{
organization: organization,
zoneId: selectedZone.zoneId,
widget: {
id: selectedChartId.id,
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration,
},
},
} as any
);
if (response.status === 200) {
return true
return true;
} else {
console.log("Unexpected response:", response);
return false
return false;
}
} catch (error) {
echo.error("Failed to send input");
console.error("There was an error!", error);
return false
return false;
}
}
const handleSelect = async (inputKey: string, selectedData: { name: string; fields: string } | null) => {
};
const handleSelect = async (
inputKey: string,
selectedData: { name: string; fields: string } | null
) => {
// async() => {
const newSelections = { ...selections };
if (selectedData === null) {
@@ -124,20 +138,20 @@ const Widget4InputCard3D = (props: Props) => {
// setDuration(option);
};
const handleNameChange = async (name:any) => {
console.log('name change requested',name);
const handleNameChange = async (name: any) => {
console.log("name change requested", name);
if (await sendInputes(selections, duration, name)) {
setWidgetName(name);
}
}
};
return (
<>
<div className="inputs-wrapper">
<div className="datas">
<div className="datas__label">Title</div>
<RenameInput value={widgetName} onRename={handleNameChange}/>
<RenameInput value={widgetName} onRename={handleNameChange} />
</div>
{[...Array(1)].map((_, index) => {
const inputKey = `input${index + 1}`;
@@ -147,7 +161,9 @@ const Widget4InputCard3D = (props: Props) => {
<div className="datas__class">
<MultiLevelDropdown
data={dropDowndata}
onSelect={(selectedData) => handleSelect(inputKey, selectedData)}
onSelect={(selectedData) =>
handleSelect(inputKey, selectedData)
}
onUnselect={() => handleSelect(inputKey, null)}
selectedValue={selections[inputKey]} // Load from Zustand
isLoading={isLoading}

View File

@@ -90,6 +90,7 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
zoneViewPortPosition: response?.viewPortposition ?? [],
});
} catch (error) {
echo.error("Failed to select zone");
console.log(error);
}
}

View File

@@ -99,6 +99,7 @@ async function addAssetModel(
}
}
} catch (error) {
echo.error("Failed to add asset");
console.error('Error fetching asset model:', error);
} finally {
setSelectedItem({});

File diff suppressed because it is too large Load Diff

View File

@@ -36,6 +36,7 @@ const MarketPlace = () => {
setFilteredModels(filt.items);
setisLoading(false);
} catch {
echo.error("Failed to filter asset");
setisLoading(false);
}
};

View File

@@ -52,6 +52,7 @@ export default function SwitchView() {
}
});
} catch (error) {
echo.error("Failed to retrieve camera position or target");
console.error("Failed to retrieve camera position or target:", error);
state.controls?.setPosition(...CONSTANTS.threeDimension.defaultPosition);
state.controls?.setTarget(...CONSTANTS.threeDimension.defaultTarget);

View File

@@ -1,4 +1,7 @@
import { usePlayButtonStore, useResetButtonStore } from "../../../store/usePlayButtonStore";
import {
usePlayButtonStore,
useResetButtonStore,
} from "../../../store/usePlayButtonStore";
import { useConveyorActions } from "./conveyor/useConveyorActions";
import { useMachineActions } from "./machine/useMachineActions";
import { useRoboticArmActions } from "./roboticArm/useRoboticArmActions";
@@ -7,58 +10,85 @@ import { useVehicleActions } from "./vehicle/useVehicleActions";
import { useCallback, useEffect } from "react";
export function useActionHandler() {
const { isReset } = useResetButtonStore();
const { isPlaying } = usePlayButtonStore();
const { handleConveyorAction, cleanup: cleanupConveyor } = useConveyorActions();
const { handleVehicleAction, cleanup: cleanupVehicle } = useVehicleActions();
const { handleRoboticArmAction, cleanup: cleanupRoboticArm } = useRoboticArmActions();
const { handleMachineAction, cleanup: cleanupMachine } = useMachineActions();
const { handleStorageAction, cleanup: cleanupStorage } = useStorageActions();
const { isReset } = useResetButtonStore();
const { isPlaying } = usePlayButtonStore();
const { handleConveyorAction, cleanup: cleanupConveyor } =
useConveyorActions();
const { handleVehicleAction, cleanup: cleanupVehicle } = useVehicleActions();
const { handleRoboticArmAction, cleanup: cleanupRoboticArm } =
useRoboticArmActions();
const { handleMachineAction, cleanup: cleanupMachine } = useMachineActions();
const { handleStorageAction, cleanup: cleanupStorage } = useStorageActions();
const handleAction = useCallback((action: Action, materialId?: string) => {
if (!action) return;
const handleAction = useCallback(
(action: Action, materialId?: string) => {
if (!action) return;
try {
switch (action.actionType) {
case 'default': case 'spawn': case 'swap': case 'delay': case 'despawn':
handleConveyorAction(action as ConveyorAction, materialId as string);
break;
case 'travel':
handleVehicleAction(action as VehicleAction);
break;
case 'pickAndPlace':
handleRoboticArmAction(action as RoboticArmAction);
break;
case 'process':
handleMachineAction(action as MachineAction);
break;
case 'store':
handleStorageAction(action as StorageAction);
break;
default:
console.warn(`Unknown action type: ${(action as Action).actionType}`);
}
} catch (error) {
console.error('Error handling action:', error);
try {
switch (action.actionType) {
case "default":
case "spawn":
case "swap":
case "delay":
case "despawn":
handleConveyorAction(
action as ConveyorAction,
materialId as string
);
break;
case "travel":
handleVehicleAction(action as VehicleAction);
break;
case "pickAndPlace":
handleRoboticArmAction(action as RoboticArmAction);
break;
case "process":
handleMachineAction(action as MachineAction);
break;
case "store":
handleStorageAction(action as StorageAction);
break;
default:
console.warn(
`Unknown action type: ${(action as Action).actionType}`
);
}
}, [handleConveyorAction, handleVehicleAction, handleRoboticArmAction, handleMachineAction, handleStorageAction]);
} catch (error) {
echo.error("Failed to handle action");
console.error("Error handling action:", error);
}
},
[
handleConveyorAction,
handleVehicleAction,
handleRoboticArmAction,
handleMachineAction,
handleStorageAction,
]
);
const cleanup = useCallback(() => {
cleanupConveyor();
cleanupVehicle();
cleanupRoboticArm();
cleanupMachine();
cleanupStorage();
}, [cleanupConveyor, cleanupVehicle, cleanupRoboticArm, cleanupMachine, cleanupStorage]);
const cleanup = useCallback(() => {
cleanupConveyor();
cleanupVehicle();
cleanupRoboticArm();
cleanupMachine();
cleanupStorage();
}, [
cleanupConveyor,
cleanupVehicle,
cleanupRoboticArm,
cleanupMachine,
cleanupStorage,
]);
useEffect(() => {
return () => {
cleanup();
};
}, [cleanup, isReset, isPlaying]);
return {
handleAction,
cleanup
useEffect(() => {
return () => {
cleanup();
};
}
}, [cleanup, isReset, isPlaying]);
return {
handleAction,
cleanup,
};
}

View File

@@ -25,6 +25,7 @@ function VehicleInstance({ agvDetail }: { agvDetail: VehicleStatus }) {
segmentPath?.map(({ x, y, z }) => [x, 0, z] as [number, number, number]) || []
);
} catch {
echo.error("Failed to compute path");
return [];
}
},

View File

@@ -54,7 +54,9 @@ export default function NavMeshDetails({
const debugDrawer = new DebugDrawer();
debugDrawer.drawNavMesh(navMesh);
// scene.add(debugDrawer);
} catch (error) { }
} catch (error) {
echo.error("Failed to initialize navigation")
}
};
initializeNavigation();

View File

@@ -103,6 +103,7 @@ const RealTimeVisulization: React.FC = () => {
);
setZonesData(formattedData);
} catch (error) {
echo.error("Failed to fetch zone data");
console.log(error);
}
}

View File

@@ -27,6 +27,7 @@ export const captureVisualization = async (): Promise<string | null> => {
// Convert to PNG with highest quality
return canvas.toDataURL('image/png', 1.0);
} catch (error) {
echo.error("Failed to capturing visualization");
console.error("Error capturing visualization:", error);
return null;
}

View File

@@ -48,7 +48,6 @@ export const handleSaveTemplate = async ({
// Capture visualization snapshot
const snapshot = await captureVisualization();
if (!snapshot) {
return;
}
@@ -92,6 +91,6 @@ export const handleSaveTemplate = async ({
//
}
} catch (error) {
//
echo.error("Failed to save template");
}
};

View File

@@ -4,119 +4,120 @@ import { determinePosition } from "./determinePosition";
import { getActiveProperties } from "./getActiveProperties";
interface HandleDropProps {
widgetSubOption: any;
visualizationSocket: any;
selectedZone: any;
setFloatingWidget: (value: any) => void;
event: React.DragEvent<HTMLDivElement>
widgetSubOption: any;
visualizationSocket: any;
selectedZone: any;
setFloatingWidget: (value: any) => void;
event: React.DragEvent<HTMLDivElement>;
}
export const createHandleDrop = ({
widgetSubOption,
visualizationSocket,
selectedZone,
setFloatingWidget,
event,
widgetSubOption,
visualizationSocket,
selectedZone,
setFloatingWidget,
event,
}: HandleDropProps) => {
event.preventDefault();
try {
const email = localStorage.getItem("email") ?? "";
const organization = email?.split("@")[1]?.split(".")[0];
event.preventDefault();
try {
const email = localStorage.getItem("email") ?? "";
const organization = email?.split("@")[1]?.split(".")[0];
const data = event.dataTransfer.getData("text/plain");
if (widgetSubOption === "3D") return;
if (!data || selectedZone.zoneName === "") return;
const data = event.dataTransfer.getData("text/plain");
if (widgetSubOption === "3D") return;
if (!data || selectedZone.zoneName === "") return;
const droppedData = JSON.parse(data);
const canvasElement = document.getElementById("work-space-three-d-canvas");
if (!canvasElement) throw new Error("Canvas element not found");
const droppedData = JSON.parse(data);
const canvasElement = document.getElementById("work-space-three-d-canvas");
if (!canvasElement) throw new Error("Canvas element not found");
const rect = canvasElement.getBoundingClientRect();
const relativeX = event.clientX - rect.left;
const relativeY = event.clientY - rect.top;
const rect = canvasElement.getBoundingClientRect();
const relativeX = event.clientX - rect.left;
const relativeY = event.clientY - rect.top;
// Widget dimensions
const widgetWidth = droppedData.width ?? 125;
const widgetHeight = droppedData.height ?? 100;
// Widget dimensions
const widgetWidth = droppedData.width ?? 125;
const widgetHeight = droppedData.height ?? 100;
// Center the widget at cursor
const centerOffsetX = widgetWidth / 2;
const centerOffsetY = widgetHeight / 2;
// Center the widget at cursor
const centerOffsetX = widgetWidth / 2;
const centerOffsetY = widgetHeight / 2;
const adjustedX = relativeX - centerOffsetX;
const adjustedY = relativeY - centerOffsetY;
const adjustedX = relativeX - centerOffsetX;
const adjustedY = relativeY - centerOffsetY;
const finalPosition = determinePosition(rect, adjustedX, adjustedY);
const [activeProp1, activeProp2] = getActiveProperties(finalPosition);
const finalPosition = determinePosition(rect, adjustedX, adjustedY);
const [activeProp1, activeProp2] = getActiveProperties(finalPosition);
let finalY = 0;
let finalX = 0;
let finalY = 0;
let finalX = 0;
if (activeProp1 === "top") {
finalY = adjustedY;
} else {
finalY = rect.height - (adjustedY + widgetHeight);
}
if (activeProp2 === "left") {
finalX = adjustedX;
} else {
finalX = rect.width - (adjustedX + widgetWidth);
}
// Clamp to boundaries
finalX = Math.max(0, Math.min(rect.width - widgetWidth, finalX));
finalY = Math.max(0, Math.min(rect.height - widgetHeight, finalY));
const boundedPosition = {
...finalPosition,
[activeProp1]: finalY,
[activeProp2]: finalX,
[activeProp1 === "top" ? "bottom" : "top"]: "auto",
[activeProp2 === "left" ? "right" : "left"]: "auto",
};
const newObject = {
...droppedData,
id: generateUniqueId(),
position: boundedPosition,
};
const existingZone =
useDroppedObjectsStore.getState().zones[selectedZone.zoneName];
if (!existingZone) {
useDroppedObjectsStore
.getState()
.setZone(selectedZone.zoneName, selectedZone.zoneId);
}
const addFloatingWidget = {
organization,
widget: newObject,
zoneId: selectedZone.zoneId,
};
if (visualizationSocket) {
visualizationSocket.emit("v2:viz-float:add", addFloatingWidget);
}
useDroppedObjectsStore
.getState()
.addObject(selectedZone.zoneName, newObject);
const droppedObjectsStore = useDroppedObjectsStore.getState();
const currentZone = droppedObjectsStore.zones[selectedZone.zoneName];
if (currentZone && currentZone.zoneId === selectedZone.zoneId) {
console.log(
`Objects for Zone ${selectedZone.zoneId}:`,
currentZone.objects
);
setFloatingWidget(currentZone.objects);
} else {
console.warn("Zone not found or zoneId mismatch");
}
} catch (error) {
console.error("Error in handleDrop:", error);
if (activeProp1 === "top") {
finalY = adjustedY;
} else {
finalY = rect.height - (adjustedY + widgetHeight);
}
if (activeProp2 === "left") {
finalX = adjustedX;
} else {
finalX = rect.width - (adjustedX + widgetWidth);
}
// Clamp to boundaries
finalX = Math.max(0, Math.min(rect.width - widgetWidth, finalX));
finalY = Math.max(0, Math.min(rect.height - widgetHeight, finalY));
const boundedPosition = {
...finalPosition,
[activeProp1]: finalY,
[activeProp2]: finalX,
[activeProp1 === "top" ? "bottom" : "top"]: "auto",
[activeProp2 === "left" ? "right" : "left"]: "auto",
};
const newObject = {
...droppedData,
id: generateUniqueId(),
position: boundedPosition,
};
const existingZone =
useDroppedObjectsStore.getState().zones[selectedZone.zoneName];
if (!existingZone) {
useDroppedObjectsStore
.getState()
.setZone(selectedZone.zoneName, selectedZone.zoneId);
}
const addFloatingWidget = {
organization,
widget: newObject,
zoneId: selectedZone.zoneId,
};
if (visualizationSocket) {
visualizationSocket.emit("v2:viz-float:add", addFloatingWidget);
}
useDroppedObjectsStore
.getState()
.addObject(selectedZone.zoneName, newObject);
const droppedObjectsStore = useDroppedObjectsStore.getState();
const currentZone = droppedObjectsStore.zones[selectedZone.zoneName];
if (currentZone && currentZone.zoneId === selectedZone.zoneId) {
console.log(
`Objects for Zone ${selectedZone.zoneId}:`,
currentZone.objects
);
setFloatingWidget(currentZone.objects);
} else {
console.warn("Zone not found or zoneId mismatch");
}
} catch (error) {
echo.error("Failed to drop widget");
console.error("Error in handleDrop:", error);
}
};

View File

@@ -19,6 +19,7 @@ const Templates = () => {
let response = await getTemplateData(organization);
setTemplates(response);
} catch (error) {
echo.error("Failed to fetching template data");
console.error("Error fetching template data:", error);
}
}
@@ -47,6 +48,7 @@ const Templates = () => {
}
removeTemplate(id);
} catch (error) {
echo.error("Failed to delete template");
console.error("Error deleting template:", error);
}
};
@@ -85,6 +87,7 @@ const Templates = () => {
});
}
} catch (error) {
echo.error("Failed to load template");
console.error("Error loading template:", error);
}
};

View File

@@ -141,6 +141,7 @@ export const DraggableWidget = ({
// }));
// }
} catch (error) {
echo.error("Failed to delete selected chart");
} finally {
setOpenKebabId(null);
}
@@ -206,7 +207,7 @@ export const DraggableWidget = ({
widgets: [...prevZone.widgets, duplicatedWidget],
}));
} catch (error) {
echo.error("Failed to dublicate widget");
} finally {
setOpenKebabId(null);
}

View File

@@ -56,7 +56,7 @@
// () => themeColor[1] || "#ffffff",
// [themeColor]
// );
// // Memoize Font Weight Mapping
// const chartFontWeightMap = useMemo(
// () => ({
@@ -66,19 +66,19 @@
// }),
// []
// );
// // Parse and Memoize Font Size
// const fontSizeValue = useMemo(
// () => (fontSize ? parseInt(fontSize) : 12),
// [fontSize]
// );
// // Determine and Memoize Font Weight
// const fontWeightValue = useMemo(
// () => chartFontWeightMap[fontWeight],
// [fontWeight, chartFontWeightMap]
// );
// // Memoize Chart Font Style
// const chartFontStyle = useMemo(
// () => ({
@@ -88,10 +88,10 @@
// }),
// [fontFamily, fontSizeValue, fontWeightValue]
// );
// // Memoize Chart Data
// // const data = useMemo(() => propsData, [propsData]);
// // Memoize Chart Options
// const options = useMemo(
// () => ({
@@ -183,8 +183,6 @@
// export default LineGraphComponent;
import React, { useEffect, useMemo, useState } from "react";
import { Bar } from "react-chartjs-2";
import io from "socket.io-client";
@@ -212,19 +210,26 @@ const BarGraphComponent = ({
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: [],
});
const { selectedChartId } = useWidgetStore();
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]
const organization = email?.split("@")[1]?.split(".")[0];
const defaultData = {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [
@@ -238,13 +243,17 @@ const BarGraphComponent = ({
],
};
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(
@@ -256,8 +265,14 @@ const BarGraphComponent = ({
[]
);
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(
() => ({
@@ -268,37 +283,38 @@ const BarGraphComponent = ({
[fontFamily, fontSizeValue, fontWeightValue]
);
// Memoize Chart Options
const options = useMemo(
() => ({
responsive: true,
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: name,
font: chartFontStyle,
},
legend: {
display: false,
// Memoize Chart Options
const options = useMemo(
() => ({
responsive: true,
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: name,
font: chartFontStyle,
},
legend: {
display: false,
},
},
scales: {
x: {
ticks: {
display: true, // This hides the x-axis labels
},
},
scales: {
x: {
ticks: {
display: true, // This hides the x-axis labels
},
},
},
}),
[title, chartFontStyle, name]
);
},
}),
[title, chartFontStyle, name]
);
// useEffect(() => {console.log(measurements);
// },[measurements])
// useEffect(() => {console.log(measurements);
// },[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}`);
@@ -308,8 +324,7 @@ const BarGraphComponent = ({
interval: 1000,
};
const startStream = () => {
const startStream = () => {
socket.emit("lineInput", inputData);
};
@@ -342,23 +357,25 @@ const BarGraphComponent = ({
};
}, [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 {
echo.error("Failed to fetch saved inputs");
console.log("Unexpected response:", response);
}
} catch (error) {
console.error("There was an error!", error);
}
}
}
};
useEffect(() => {
fetchSavedInputes();
@@ -368,10 +385,14 @@ const BarGraphComponent = ({
if (selectedChartId?.id === id) {
fetchSavedInputes();
}
}
,[chartMeasurements, chartDuration, widgetName])
}, [chartMeasurements, chartDuration, widgetName]);
return <Bar data={Object.keys(measurements).length > 0 ? chartData : defaultData} options={options} />;
return (
<Bar
data={Object.keys(measurements).length > 0 ? chartData : defaultData}
options={options}
/>
);
};
export default BarGraphComponent;

View File

@@ -168,6 +168,7 @@ const DoughnutGraphComponent = ({
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch saved inputs");
console.error("There was an error!", error);
}
}

View File

@@ -183,6 +183,7 @@ const LineGraphComponent = ({
setDuration(response.data.Data.duration);
setName(response.data.widgetName);
} else {
echo.error("Failed to fetch saved inputs");
console.log("Unexpected response:", response);
}
} catch (error) {

View File

@@ -368,6 +368,7 @@ const PieChartComponent = ({
setDuration(response.data.Data.duration);
setName(response.data.widgetName);
} else {
echo.error("Failed to fetch saved inputs");
console.log("Unexpected response:", response);
}
} catch (error) {

View File

@@ -183,6 +183,7 @@ const PolarAreaGraphComponent = ({
setDuration(response.data.Data.duration);
setName(response.data.widgetName);
} else {
echo.error("Failed to fetch saved inputs");
console.log("Unexpected response:", response);
}
} catch (error) {

View File

@@ -63,9 +63,11 @@ const ProgressCard1 = ({ id, title }: { id: string; title: string }) => {
setDuration(response.data.Data.duration);
setName(response.data.widgetName);
} else {
echo.error("Failed to fetch saved inputs");
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch saved inputs");
console.error("There was an error!", error);
}
}

View File

@@ -70,6 +70,7 @@ const ProgressCard2 = ({ id, title }: { id: string; title: string }) => {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch saved inputs");
console.error("There was an error!", error);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -31,7 +31,7 @@ interface ProductionCapacityProps {
type: string;
position: [number, number, number];
rotation: [number, number, number];
Data?: any,
Data?: any;
onContextMenu?: (event: React.MouseEvent) => void;
// onPointerDown:any
}
@@ -50,8 +50,12 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
duration: chartDuration,
name: widgetName,
} = useChartStore();
const [measurements, setmeasurements] = useState<any>(Data?.measurements ? Data.measurements : {});
const [duration, setDuration] = useState(Data?.duration ? Data.duration : "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[];
@@ -175,7 +179,9 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
setName(response.data.widgetName);
} else {
}
} catch (error) { }
} catch (error) {
echo.error("Failed to fetch saved inputs");
}
}
};
@@ -189,12 +195,9 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
}
}, [chartMeasurements, chartDuration, widgetName]);
useEffect(() => { }, [rotation]);
useEffect(() => {}, [rotation]);
return (
<Html
position={position}
scale={[0.5, 0.5, 0.5]}
@@ -216,20 +219,20 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
// e.stopPropagation();
}}
wrapperClass="pointer-none"
>
<div
className={`productionCapacity-wrapper card ${selectedChartId?.id === id ? "activeChart" : ""}`}
className={`productionCapacity-wrapper card ${
selectedChartId?.id === id ? "activeChart" : ""
}`}
onClick={() => setSelectedChartId({ id: id, type: type })}
onContextMenu={onContextMenu}
style={{
width: "300px", // Original width
height: "300px", // Original height
// transform: transformStyle.transform,
transformStyle: "preserve-3d",
position: "absolute",
transform:'translate(-50%, -50%)',
transform: "translate(-50%, -50%)",
}}
>
<div className="headeproductionCapacityr-wrapper">
@@ -263,7 +266,6 @@ const ProductionCapacity: React.FC<ProductionCapacityProps> = ({
</div>
</div>
</Html>
);
};

View File

@@ -12,7 +12,6 @@ import {
ChartOptions,
} from "chart.js";
import axios from "axios";
import io from "socket.io-client";
import { useWidgetStore } from "../../../../../store/useWidgetStore";
@@ -63,8 +62,12 @@ const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
duration: chartDuration,
name: widgetName,
} = useChartStore();
const [measurements, setmeasurements] = useState<any>(Data?.measurements ? Data.measurements : {});
const [duration, setDuration] = useState(Data?.duration ? Data.duration : "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[];
@@ -208,6 +211,7 @@ const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch saved inputs");
console.error("There was an error!", error);
}
}
@@ -238,8 +242,7 @@ const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
rotation={rotation}
scale={[0.5, 0.5, 0.5]}
transform
sprite={false}
sprite={false}
// style={{
// transform: transformStyle.transform,
// transformStyle: "preserve-3d",

View File

@@ -12,7 +12,7 @@ interface StateWorkingProps {
type: string;
position: [number, number, number];
rotation: [number, number, number];
Data?:any;
Data?: any;
onContextMenu?: (event: React.MouseEvent) => void;
}
const StateWorking: React.FC<StateWorkingProps> = ({
@@ -29,8 +29,12 @@ const StateWorking: React.FC<StateWorkingProps> = ({
duration: chartDuration,
name: widgetName,
} = useChartStore();
const [measurements, setmeasurements] = useState<any>(Data?.measurements ? Data.measurements : {});
const [duration, setDuration] = useState(Data?.duration ? Data.duration : "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;
@@ -85,6 +89,7 @@ const StateWorking: React.FC<StateWorkingProps> = ({
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch saved inputs");
console.error("There was an error!", error);
}
}
@@ -116,7 +121,7 @@ const StateWorking: React.FC<StateWorkingProps> = ({
scale={[0.5, 0.5, 0.5]}
transform
zIndexRange={[1, 0]}
sprite={false}
sprite={false}
// style={{
// transform: transformStyle.transform,
// transformStyle: "preserve-3d",

View File

@@ -14,7 +14,6 @@ import {
ChartOptions,
} from "chart.js";
import axios from "axios";
import io from "socket.io-client";
import { useWidgetStore } from "../../../../../store/useWidgetStore";
@@ -48,7 +47,7 @@ interface ThroughputProps {
type: string;
position: [number, number, number];
rotation: [number, number, number];
Data?:any;
Data?: any;
onContextMenu?: (event: React.MouseEvent) => void;
}
@@ -66,8 +65,12 @@ const Throughput: React.FC<ThroughputProps> = ({
duration: chartDuration,
name: widgetName,
} = useChartStore();
const [measurements, setmeasurements] = useState<any>(Data?.measurements ? Data.measurements : {});
const [duration, setDuration] = useState(Data?.duration ? Data.duration : "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[];
@@ -186,6 +189,7 @@ const Throughput: React.FC<ThroughputProps> = ({
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch saved inputs");
console.error("There was an error!", error);
}
}
@@ -217,7 +221,7 @@ const Throughput: React.FC<ThroughputProps> = ({
scale={[0.5, 0.5, 0.5]}
transform
zIndexRange={[1, 0]}
sprite={false}
sprite={false}
// style={{
// transform: transformStyle.transform,
// transformStyle: "preserve-3d",

View File

@@ -1,7 +1,5 @@
import { useEffect, useRef, useState } from "react";
import {
useDroppedObjectsStore,
} from "../../../../store/visualization/useDroppedObjectsStore";
import { useDroppedObjectsStore } from "../../../../store/visualization/useDroppedObjectsStore";
import useModuleStore from "../../../../store/useModuleStore";
import { determinePosition } from "../../functions/determinePosition";
import { getActiveProperties } from "../../functions/getActiveProperties";
@@ -132,8 +130,9 @@ const DroppedObjects: React.FC = () => {
visualizationSocket.emit("v2:viz-float:delete", deleteFloatingWidget);
}
deleteObject(zoneName, id);
} catch (error) {}
} catch (error) {
echo.error("Failed to delete widget");
}
}
const handlePointerDown = (event: React.PointerEvent, index: number) => {
@@ -308,6 +307,7 @@ const DroppedObjects: React.FC = () => {
updateObjectPosition(zoneName, draggingIndex.index, boundedPosition);
}
} catch (error) {
echo.error("Failed to add widget");
console.log(error);
} finally {
setDraggingIndex(null);
@@ -380,7 +380,6 @@ const DroppedObjects: React.FC = () => {
setCurrentPosition(newPosition);
// Update position immediately without animation frame
updateObjectPosition(zoneName, draggingIndex.index, newPosition);
};
const handlePointerUp = async (event: React.PointerEvent<HTMLDivElement>) => {
@@ -446,6 +445,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

View File

@@ -71,6 +71,7 @@ const FleetEfficiencyComponent = ({ object }: any) => {
console.log("Unexpected response:", response);
}
} catch (error) {
echo.error("Failed to fetch saved inputs");
console.error("There was an error!", error);
}
}

View File

@@ -67,6 +67,7 @@ const TotalCardComponent = ({ object }: any) => {
setDuration(response.data.Data.duration);
setName(response.data.header);
} else {
echo.error("Failed to fetch saved inputs");
}
} catch (error) {}
}

View File

@@ -1,205 +1,209 @@
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 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";
const WarehouseThroughputComponent = ({
object
}: any) => {
const WarehouseThroughputComponent = ({ object }: any) => {
const [measurements, setmeasurements] = useState<any>({});
const [duration, setDuration] = useState("1h");
const [name, setName] = useState(object.header ? object.header : "");
const [chartData, setChartData] = useState<{
labels: string[];
datasets: any[];
}>({
labels: [],
datasets: [],
});
const email = localStorage.getItem("email") || "";
const organization = email?.split("@")[1]?.split(".")[0];
const { header, flotingDuration, flotingMeasurements } = useChartStore();
const { selectedChartId } = useWidgetStore();
const [measurements, setmeasurements] = useState<any>({});
const [duration, setDuration] = useState("1h")
const [name, setName] = useState(object.header ? object.header : '')
const [chartData, setChartData] = useState<{ labels: string[]; datasets: any[] }>({
labels: [],
datasets: [],
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",
], // Months of the year
datasets: [
{
label: "Throughput (units/month)",
data: [500, 400, 300, 450, 350, 250, 200, 300, 250, 150, 100, 150], // Example monthly data
borderColor: "#6f42c1", // Use the desired color for the line (purple)
backgroundColor: "rgba(111, 66, 193, 0.2)", // Use a semi-transparent purple for the fill
borderWidth: 2, // Line thickness
fill: true, // Enable fill for this dataset
pointRadius: 0, // Remove dots at each data point
tension: 0.5, // Smooth interpolation for the line
},
],
};
// Line graph options
const lineGraphOptions = {
responsive: true,
maintainAspectRatio: false, // Allow custom height/width adjustments
plugins: {
legend: {
display: false, // Hide legend
},
title: {
display: false, // No chart title needed
},
tooltip: {
callbacks: {
label: (context: any) => {
const value = context.parsed.y;
return `${value} units`; // Customize tooltip to display "units"
},
},
},
},
scales: {
x: {
grid: {
display: false, // Hide x-axis grid lines
},
ticks: {
maxRotation: 0, // Prevent label rotation
autoSkip: false, // Display all months
font: {
size: 8, // Adjust font size for readability
color: "#ffffff", // Light text color for labels
},
},
},
y: {
display: true, // Show y-axis
grid: {
drawBorder: false, // Remove border line
color: "rgba(255, 255, 255, 0.2)", // Light gray color for grid lines
borderDash: [5, 5], // Dotted line style (array defines dash and gap lengths)
},
ticks: {
font: {
size: 8, // Adjust font size for readability
color: "#ffffff", // Light text color for ticks
},
},
},
},
elements: {
line: {
tension: 0.5, // Smooth interpolation for the line
},
},
};
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("lineInput", inputData);
};
socket.on("connect", startStream);
socket.on("lineOutput", (response) => {
const responseData = response.data;
// Extract timestamps and values
const labels = responseData.time;
const datasets = Object.keys(measurements).map((key) => {
const measurement = measurements[key];
const datasetKey = `${measurement.name}.${measurement.fields}`;
return {
label: datasetKey,
data: responseData[datasetKey]?.values ?? [],
borderColor: "#6f42c1", // Use the desired color for the line (purple)
backgroundColor: "rgba(111, 66, 193, 0.2)", // Use a semi-transparent purple for the fill
borderWidth: 2, // Line thickness
fill: true, // Enable fill for this dataset
pointRadius: 0, // Remove dots at each data point
tension: 0.5, // Smooth interpolation for the line
};
});
setChartData({ labels, datasets });
});
const email = localStorage.getItem("email") || "";
const organization = email?.split("@")[1]?.split(".")[0]
const { header, flotingDuration, flotingMeasurements } = useChartStore();
const { selectedChartId } = useWidgetStore();
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
return () => {
socket.off("lineOutput");
socket.emit("stop_stream"); // Stop streaming when component unmounts
socket.disconnect();
};
}, [measurements, duration, iotApiUrl]);
const lineGraphData = {
labels: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
], // Months of the year
datasets: [
{
label: "Throughput (units/month)",
data: [500, 400, 300, 450, 350, 250, 200, 300, 250, 150, 100, 150], // Example monthly data
borderColor: "#6f42c1", // Use the desired color for the line (purple)
backgroundColor: "rgba(111, 66, 193, 0.2)", // Use a semi-transparent purple for the fill
borderWidth: 2, // Line thickness
fill: true, // Enable fill for this dataset
pointRadius: 0, // Remove dots at each data point
tension: 0.5, // Smooth interpolation for the line
},
],
};
// Line graph options
const lineGraphOptions = {
responsive: true,
maintainAspectRatio: false, // Allow custom height/width adjustments
plugins: {
legend: {
display: false, // Hide legend
},
title: {
display: false, // No chart title needed
},
tooltip: {
callbacks: {
label: (context: any) => {
const value = context.parsed.y;
return `${value} units`; // Customize tooltip to display "units"
},
},
},
},
scales: {
x: {
grid: {
display: false, // Hide x-axis grid lines
},
ticks: {
maxRotation: 0, // Prevent label rotation
autoSkip: false, // Display all months
font: {
size: 8, // Adjust font size for readability
color: "#ffffff", // Light text color for labels
},
},
},
y: {
display: true, // Show y-axis
grid: {
drawBorder: false, // Remove border line
color: "rgba(255, 255, 255, 0.2)", // Light gray color for grid lines
borderDash: [5, 5], // Dotted line style (array defines dash and gap lengths)
},
ticks: {
font: {
size: 8, // Adjust font size for readability
color: "#ffffff", // Light text color for ticks
},
},
},
},
elements: {
line: {
tension: 0.5, // Smooth interpolation for the line
},
},
};
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("lineInput", inputData);
};
socket.on("connect", startStream);
socket.on("lineOutput", (response) => {
const responseData = response.data;
// Extract timestamps and values
const labels = responseData.time;
const datasets = Object.keys(measurements).map((key) => {
const measurement = measurements[key];
const datasetKey = `${measurement.name}.${measurement.fields}`;
return {
label: datasetKey,
data: responseData[datasetKey]?.values ?? [],
borderColor: "#6f42c1", // Use the desired color for the line (purple)
backgroundColor: "rgba(111, 66, 193, 0.2)", // Use a semi-transparent purple for the fill
borderWidth: 2, // Line thickness
fill: true, // Enable fill for this dataset
pointRadius: 0, // Remove dots at each data point
tension: 0.5, // Smooth interpolation for the line
};
});
setChartData({ labels, datasets });
});
return () => {
socket.off("lineOutput");
socket.emit("stop_stream"); // Stop streaming when component unmounts
socket.disconnect();
};
}, [measurements, duration, iotApiUrl]);
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}`);
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) {
console.error("There was an error!", error);
}
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}`
);
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);
}
useEffect(() => {
fetchSavedInputes();
}, []);
useEffect(() => {
if (selectedChartId?.id === object?.id) {
fetchSavedInputes();
}
}
,[header, flotingDuration, flotingMeasurements])
return (
<>
<div className="header">
<h2>{name}</h2>
{/* <p>
}
};
useEffect(() => {
fetchSavedInputes();
}, []);
useEffect(() => {
if (selectedChartId?.id === object?.id) {
fetchSavedInputes();
}
}, [header, flotingDuration, flotingMeasurements]);
return (
<>
<div className="header">
<h2>{name}</h2>
{/* <p>
<span>(+5) more</span> in 2025
</p> */}
</div>
<div className="lineGraph" style={{ height: "100%" }}>
<Line data={ Object.keys(measurements).length > 0 ? chartData : lineGraphData} options={lineGraphOptions} />
</div>
</>
)
}
</div>
<div className="lineGraph" style={{ height: "100%" }}>
<Line
data={
Object.keys(measurements).length > 0 ? chartData : lineGraphData
}
options={lineGraphOptions}
/>
</div>
</>
);
};
export default WarehouseThroughputComponent
export default WarehouseThroughputComponent;

View File

@@ -254,6 +254,7 @@ const AddButtons: React.FC<ButtonsProps> = ({
setSelectedZone(updatedZone);
} catch (error) {
echo.error("Failed to adding panel");
console.error("Error adding panel:", error);
}
}

View File

@@ -106,7 +106,6 @@ const DisplayZone: React.FC<DisplayZoneProps> = ({
// console.log('canScrollRight: ', canScrollRight);
// console.log('isOverflowing: ', isOverflowing);
}
}, []);
@@ -199,7 +198,9 @@ const DisplayZone: React.FC<DisplayZoneProps> = ({
zoneViewPortTarget: response.viewPortCenter || {},
zoneViewPortPosition: response.viewPortposition || {},
});
} catch (error) {}
} catch (error) {
echo.error("Failed to select zone");
}
}
return (

View File

@@ -34,7 +34,7 @@ import Footer from "../components/footer/Footer";
const Project: React.FC = () => {
let navigate = useNavigate();
// const echo = useLogger();
const echo = useLogger();
const { activeModule, setActiveModule } = useModuleStore();
const { loadingProgress } = useLoadingProgress();

View File

@@ -43,7 +43,9 @@ const UserAuth: React.FC = () => {
} else if (res.message === "User Not Found!!! Kindly signup...") {
setError("Account not found");
}
} catch (error) {}
} catch (error) {
echo.error("Login failed");
}
};
const handleRegister = async (e: FormEvent) => {
@@ -60,7 +62,9 @@ const UserAuth: React.FC = () => {
if (res.message === "User already exists") {
setError("User already exists");
}
} catch (error) {}
} catch (error) {
echo.error("Register user failed");
}
} else {
setError("Please fill all the fields!");
}

View File

@@ -1,23 +1,26 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getAssetImages = async (cursor?: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v3/AssetDatas?limit=10${cursor ? `&cursor=${cursor}` : ""}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v3/AssetDatas?limit=10${
cursor ? `&cursor=${cursor}` : ""
}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch assets");
}
return await response.json();
} catch (error: any) {
throw new Error(error.message);
if (!response.ok) {
throw new Error("Failed to fetch assets");
}
return await response.json();
} catch (error: any) {
echo.error("Failed to get asset image");
throw new Error(error.message);
}
};

View File

@@ -1,25 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getAssetModel = async (modelId: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/AssetFile/${modelId}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/AssetFile/${modelId}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch model");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to fetch model");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get asset model");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,7 +1,8 @@
let BackEnd_url = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getCategoryAsset = async (categoryName: any) => {
try {
const response = await fetch(`${BackEnd_url}/api/v2/getCategoryAssets/${categoryName}`,
const response = await fetch(
`${BackEnd_url}/api/v2/getCategoryAssets/${categoryName}`,
{
method: "GET",
headers: {
@@ -13,6 +14,7 @@ export const getCategoryAsset = async (categoryName: any) => {
const result = await response.json();
return result;
} catch (error: any) {
echo.error("Failed to get category asset");
throw new Error(error.message);
}
};

View File

@@ -1,26 +1,34 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteFloorItem = async (organization: string, modelUuid: string, modelName: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletefloorItem`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
});
export const deleteFloorItem = async (
organization: string,
modelUuid: string,
modelName: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/deletefloorItem`,
{
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
}
);
if (!response.ok) {
throw new Error("Failed to delete Floor Item");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to delete Floor Item");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete floor item");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,27 +1,30 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getFloorAssets = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/floorAssets/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/floorAssets/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to get assets");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to get assets");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get floor asset");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,36 +1,46 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setFloorItemApi = async (
organization: string,
modelUuid?: string,
modelName?: string,
modelfileID?: string,
position?: Object,
rotation?: Object,
isLocked?: boolean,
isVisible?: boolean,
organization: string,
modelUuid?: string,
modelName?: string,
modelfileID?: string,
position?: Object,
rotation?: Object,
isLocked?: boolean,
isVisible?: boolean
) => {
try {
const body: any = { organization, modelUuid, modelName, position, rotation, modelfileID, isLocked, isVisible };
try {
const body: any = {
organization,
modelUuid,
modelName,
position,
rotation,
modelfileID,
isLocked,
isVisible,
};
const response = await fetch(`${url_Backend_dwinzo}/api/v2/setasset`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
const response = await fetch(`${url_Backend_dwinzo}/api/v2/setasset`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error("Failed to set or update Floor Item");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to set or update Floor Item");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set floor items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,34 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteWallItem = async (organization: string, modelUuid: string, modelName: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteWallItem`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
});
export const deleteWallItem = async (
organization: string,
modelUuid: string,
modelName: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/deleteWallItem`,
{
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
}
);
if (!response.ok) {
throw new Error("Failed to delete Wall Item");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to delete Wall Item");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete wall items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getWallItems = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/findWallItems/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/findWallItems/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to get Wall Items");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to get Wall Items");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get wall items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,36 +1,47 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setWallItem = async (
organization: string,
modelUuid: string,
modelName: string,
type: string,
csgposition: Object,
csgscale: Object,
position: Object,
quaternion: Object,
scale: Object
organization: string,
modelUuid: string,
modelName: string,
type: string,
csgposition: Object,
csgscale: Object,
position: Object,
quaternion: Object,
scale: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setWallItems`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName, position, type, csgposition, csgscale, quaternion, scale }),
});
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setWallItems`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
organization,
modelUuid,
modelName,
position,
type,
csgposition,
csgscale,
quaternion,
scale,
}),
});
if (!response.ok) {
throw new Error("Failed to set or update Wall Item");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to set or update Wall Item");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set wall items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,16 +1,19 @@
import { setCamera } from './setCameraApi';
import * as THREE from 'three';
import { setCamera } from "./setCameraApi";
import * as THREE from "three";
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getCamera = async (organization: string, userId: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/getCamera/${organization}/${userId}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/getCamera/${organization}/${userId}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to get Camera position and target");
@@ -23,10 +26,11 @@ export const getCamera = async (organization: string, userId: string) => {
return result;
}
} catch (error) {
echo.error("Failed to get camera");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};
};

View File

@@ -1,26 +1,39 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setCamera = async (organization: string, userId: string, position: Object, target: Object, rotation: Object) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setCamera`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, userId, position, target, rotation }),
});
export const setCamera = async (
organization: string,
userId: string,
position: Object,
target: Object,
rotation: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setCamera`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
organization,
userId,
position,
target,
rotation,
}),
});
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set camera");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,32 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export default async function getActiveUsersData(organization: string) {
const apiUrl = `${url_Backend_dwinzo}/api/v1/activeCameras/${organization}`;
const apiUrl = `${url_Backend_dwinzo}/api/v1/activeCameras/${organization}`;
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
});
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
if (!response.ok) {
throw new Error("Failed to get active cameras ");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
};
if (!response.ok) {
throw new Error("Failed to get active cameras ");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get active users");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}

View File

@@ -1,32 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export default async function fetchShareUsers(organization: string) {
const apiUrl = `${url_Backend_dwinzo}/api/v1/findshareUsers?organization=${organization}`;
const apiUrl = `${url_Backend_dwinzo}/api/v1/findshareUsers?organization=${organization}`;
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
});
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
if (!response.ok) {
throw new Error("Failed to get users ");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
};
if (!response.ok) {
throw new Error("Failed to get users ");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get user API");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}

View File

@@ -1,26 +1,31 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export default async function giveCollabAccess(email: string, isShare: boolean, organization: string) {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/shareUser`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, isShare, organization }),
});
export default async function giveCollabAccess(
email: string,
isShare: boolean,
organization: string
) {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/shareUser`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, isShare, organization }),
});
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to give collab access");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}

View File

@@ -34,6 +34,7 @@ export const findEnvironment = async (organization: string, userId: string) => {
return result;
}
} catch (error) {
echo.error("Failed to find env");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -36,6 +36,7 @@ export const setEnvironment = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set env");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -1,26 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteLayer = async (organization: string, layer: number) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLayer`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer }),
});
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLayer`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer }),
});
if (!response.ok) {
throw new Error("Failed to delete line");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to delete line");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete line");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteLineApi = async (organization: string, line: Object) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLine`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, line }),
});
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLine`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, line }),
});
if (!response.ok) {
throw new Error("Failed to delete line");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to delete line");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete line");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deletePointApi = async (organization: string, uuid: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletePoint`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, uuid }),
});
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletePoint`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, uuid }),
});
if (!response.ok) {
throw new Error("Failed to delete point");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to delete point");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete point");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getLines = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/findLines/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/findLines/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to get Lines");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to get Lines");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get Lines");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setLine = async (organization: string, layer: number, line: Object, type: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer, line, type }),
});
export const setLine = async (
organization: string,
layer: number,
line: Object,
type: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer, line, type }),
});
if (!response.ok) {
throw new Error("Failed to set line");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to set line");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set line");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,31 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const updatePoint = async (organization: string, position: Object, uuid: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/updatePoint`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, position, uuid }),
});
export const updatePoint = async (
organization: string,
position: Object,
uuid: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/updatePoint`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, position, uuid }),
});
if (!response.ok) {
throw new Error("Failed to update point");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to update point");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to update point");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,22 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const signInApi = async (email: string, password: Object, organization: Object) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, password, organization }),
});
export const signInApi = async (
email: string,
password: Object,
organization: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, password, organization }),
});
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
return { error: error.message };
} else {
return { error: "An unknown error occurred" };
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to sign-in");
if (error instanceof Error) {
return { error: error.message };
} else {
return { error: "An unknown error occurred" };
}
};
}
};

View File

@@ -1,26 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const signUpApi = async (userName: string, email: string, password: Object, organization: Object) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/signup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userName, email, password, organization }),
});
export const signUpApi = async (
userName: string,
email: string,
password: Object,
organization: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/signup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userName, email, password, organization }),
});
if (!response.ok) {
throw new Error("Failed to signUpApi");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to signUpApi");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to sign-up");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,27 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteZonesApi = async (userId: string, organization: string, zoneId: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneId }),
});
export const deleteZonesApi = async (
userId: string,
organization: string,
zoneId: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneId }),
});
if (!response.ok) {
throw new Error("Failed to delete zone");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to delete zone");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete zone");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -2,25 +2,29 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const getZonesApi = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/findZones/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/findZones/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
// if (!response.ok) {
// throw new Error("Failed to get Zones");
// }
// if (!response.ok) {
// throw new Error("Failed to get Zones");
// }
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get zone data");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
};
}
};

View File

@@ -1,26 +1,31 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setZonesApi = async (userId: string, organization: string, zoneData: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneData }),
});
export const setZonesApi = async (
userId: string,
organization: string,
zoneData: any
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneData }),
});
if (!response.ok) {
throw new Error("Failed to set zone");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to set zone");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to zone data");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -16,6 +16,7 @@ export const getAssetDetails = async (filename: string) => {
const result = await response.json();
return result;
} catch (error: any) {
echo.error("Failed to fetch assetg details");
// console.error("Error fetching category:", error.message);
throw new Error(error.message);
}

View File

@@ -10,6 +10,7 @@ export const fetchAssets = async () => {
// console.log('last10Assets: ', last10Assets);
return result;
} catch (error) {
echo.error("Failed to fetch assets");
console.log("error: ", error);
// throw new Error(error.message);
}

View File

@@ -19,6 +19,7 @@ export const getSortedAssets = async (category: any, orders: any) => {
return result; // Return the result to be used later
} catch (error: any) {
echo.error("Failed to fetching category");
console.error("Error fetching category:", error.message);
throw new Error(error.message);
}

View File

@@ -1,26 +1,30 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const upsertProductOrEventApi = async (body: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/UpsertProductOrEvent`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/UpsertProductOrEvent`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
if (!response.ok) {
throw new Error("Failed to add product or event");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to add product or event");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to upsert product Or eventApi");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,30 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteEventDataApi = async (body: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/EventDataDelete`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/EventDataDelete`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
if (!response.ok) {
throw new Error("Failed to delete event data");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to delete event data");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete event data API");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteProductApi = async (productId: string, organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productDataDelete?productId=${productId}&organization=${organization}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
});
export const deleteProductApi = async (
productId: string,
organization: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/productDataDelete?productId=${productId}&organization=${organization}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to delete product data");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to delete product data");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete product API");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getProductApi = async (productId: string, organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productDatas?productId=${productId}&organization=${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
export const getProductApi = async (
productId: string,
organization: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/productDatas?productId=${productId}&organization=${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch product data");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to fetch product data");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get product asset");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,25 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getAllProductsApi = async ( organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/AllProducts/${organization}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
export const getAllProductsApi = async (organization: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/AllProducts/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch all products data");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to fetch all products data");
}
};
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get all product API");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -1,26 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const renameProductApi = async (body: { productName: string, productId: string, organization: string }) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productRename`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
export const renameProductApi = async (body: {
productName: string;
productId: string;
organization: string;
}) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productRename`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error("Failed to rename product");
}
const result = await response.json();
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
if (!response.ok) {
throw new Error("Failed to rename product");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to rename product Api");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -6,16 +6,13 @@ export const adding3dWidgets = async (
widget: {}
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/3dwidget/save`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, zoneId, widget }),
}
);
const response = await fetch(`${url_Backend_dwinzo}/api/v2/3dwidget/save`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, zoneId, widget }),
});
if (!response.ok) {
throw new Error("Failed to add 3dwidget in the zone");
@@ -24,6 +21,7 @@ export const adding3dWidgets = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to add 3d widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -6,9 +6,6 @@ export const addingFloatingWidgets = async (
organization: string,
widget: {}
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/floatwidget/save`,
@@ -28,6 +25,7 @@ export const addingFloatingWidgets = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to add floating");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -21,6 +21,7 @@ export const addingWidgets = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to add widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -21,6 +21,7 @@ export const clearPanel = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to clean pannel");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -6,10 +6,6 @@ export const delete3dWidgetApi = async (
organization: string,
id: string
) => {
console.log("zoneId: ", zoneId);
console.log("organization: ", organization);
console.log("id: ", id);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/widget3D/delete`,
@@ -29,6 +25,7 @@ export const delete3dWidgetApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete 3d widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -5,8 +5,6 @@ export const deleteFloatingWidgetApi = async (
floatWidgetID: string,
organization: string
) => {
console.log('organization: ', organization);
console.log('floatWidgetID: ', floatWidgetID);
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/floatwidget/delete`,
@@ -26,6 +24,7 @@ export const deleteFloatingWidgetApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete floating widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -6,9 +6,6 @@ export const deletePanelApi = async (
panelName: string,
organization: string
) => {
console.log('panelName: ', panelName);
console.log('organization: ', organization);
console.log('zoneId: ', zoneId);
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/panel/delete`, {
method: "PATCH",
@@ -25,6 +22,7 @@ export const deletePanelApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete pannel");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -23,6 +23,7 @@ export const deleteTemplateApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -4,18 +4,15 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const deleteWidgetApi = async (
widgetID: string,
organization: string,
zoneId:string
zoneId: string
) => {
console.log('zoneId: ', zoneId);
console.log('organization: ', organization);
console.log('widgetID: ', widgetID);
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/delete/widget`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, widgetID,zoneId }),
body: JSON.stringify({ organization, widgetID, zoneId }),
});
if (!response.ok) {
@@ -24,6 +21,7 @@ export const deleteWidgetApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -21,6 +21,7 @@ export const duplicateWidgetApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to dublicate widget");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -6,13 +6,13 @@ export const get3dWidgetZoneData = async (
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/3dwidgetData/${ZoneId}/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
`${url_Backend_dwinzo}/api/v2/3dwidgetData/${ZoneId}/${organization}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch Zone3dWidgetData");
@@ -20,6 +20,7 @@ export const get3dWidgetZoneData = async (
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch 3d data");
throw new Error(error.message);
}
};

View File

@@ -21,6 +21,7 @@ export const getFloatingZoneData = async (
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch floating data");
throw new Error(error.message);
}
};

View File

@@ -22,6 +22,7 @@ export const getSelect2dZoneData = async (
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch 2d widget data");
throw new Error(error.message);
}
};

View File

@@ -18,6 +18,7 @@ export const getTemplateData = async (organization?: string) => {
return await response.json();
} catch (error: any) {
echo.error("Failed to template data");
throw new Error(error.message);
}
};

View File

@@ -18,6 +18,7 @@ export const getZone2dData = async (organization?: string) => {
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch 2d zone data");
throw new Error(error.message);
}
};

View File

@@ -2,7 +2,6 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const getZoneData = async (zoneId: string, organization: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/A_zone/${zoneId}/${organization}`,
@@ -20,6 +19,7 @@ export const getZoneData = async (zoneId: string, organization: string) => {
return await response.json();
} catch (error: any) {
echo.error("Failed to fetch zone data");
throw new Error(error.message);
}
};

View File

@@ -24,6 +24,7 @@ export const loadTempleteApi = async (
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to load template");
if (error instanceof Error) {
throw new Error(error.message);
} else {

Some files were not shown because too many files have changed in this diff Show More