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,10 +76,15 @@ 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`, {
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: {
@@ -83,24 +93,28 @@ const BarChartInput = (props: Props) => {
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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}

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,10 +80,15 @@ 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`, {
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: {
@@ -88,24 +96,29 @@ const FleetEfficiencyInputComponent = (props: Props) => {
header: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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}

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,10 +79,15 @@ 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`, {
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: {
@@ -84,24 +95,29 @@ const FlotingWidgetInput = (props: Props) => {
header: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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,10 +192,15 @@ 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`, {
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: {
@@ -202,24 +209,28 @@ const LineGrapInput = (props: Props) => {
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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,10 +76,15 @@ 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`, {
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: {
@@ -83,24 +93,28 @@ const PieChartInput = (props: Props) => {
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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}

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,10 +76,15 @@ 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`, {
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: {
@@ -83,24 +93,28 @@ const Progress1Input = (props: Props) => {
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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}

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,10 +76,15 @@ 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`, {
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: {
@@ -83,24 +93,28 @@ const Progress2Input = (props: Props) => {
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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}

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,10 +77,15 @@ 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`, {
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: {
@@ -84,24 +93,28 @@ const WarehouseThroughputInputComponent = (props: Props) => {
header: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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

@@ -14,28 +14,31 @@ const Widget2InputCard3D = (props: Props) => {
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,10 +76,15 @@ 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`, {
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: {
@@ -82,24 +92,28 @@ const Widget2InputCard3D = (props: Props) => {
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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}

View File

@@ -12,28 +12,31 @@ const Widget3InputCard3D = () => {
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,10 +73,15 @@ 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`, {
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: {
@@ -79,24 +89,28 @@ const Widget3InputCard3D = () => {
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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

@@ -14,28 +14,31 @@ const Widget4InputCard3D = (props: Props) => {
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,10 +76,15 @@ 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`, {
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: {
@@ -82,24 +92,28 @@ const Widget4InputCard3D = (props: Props) => {
widgetName: inputName,
Data: {
measurements: inputMeasurement,
duration: inputDuration
}
}
} as any);
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";
@@ -9,39 +12,60 @@ import { useCallback, useEffect } from "react";
export function useActionHandler() {
const { isReset } = useResetButtonStore();
const { isPlaying } = usePlayButtonStore();
const { handleConveyorAction, cleanup: cleanupConveyor } = useConveyorActions();
const { handleConveyorAction, cleanup: cleanupConveyor } =
useConveyorActions();
const { handleVehicleAction, cleanup: cleanupVehicle } = useVehicleActions();
const { handleRoboticArmAction, cleanup: cleanupRoboticArm } = useRoboticArmActions();
const { handleRoboticArmAction, cleanup: cleanupRoboticArm } =
useRoboticArmActions();
const { handleMachineAction, cleanup: cleanupMachine } = useMachineActions();
const { handleStorageAction, cleanup: cleanupStorage } = useStorageActions();
const handleAction = useCallback((action: Action, materialId?: string) => {
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);
case "default":
case "spawn":
case "swap":
case "delay":
case "despawn":
handleConveyorAction(
action as ConveyorAction,
materialId as string
);
break;
case 'travel':
case "travel":
handleVehicleAction(action as VehicleAction);
break;
case 'pickAndPlace':
case "pickAndPlace":
handleRoboticArmAction(action as RoboticArmAction);
break;
case 'process':
case "process":
handleMachineAction(action as MachineAction);
break;
case 'store':
case "store":
handleStorageAction(action as StorageAction);
break;
default:
console.warn(`Unknown action type: ${(action as Action).actionType}`);
console.warn(
`Unknown action type: ${(action as Action).actionType}`
);
}
} catch (error) {
console.error('Error handling action:', error);
echo.error("Failed to handle action");
console.error("Error handling action:", error);
}
}, [handleConveyorAction, handleVehicleAction, handleRoboticArmAction, handleMachineAction, handleStorageAction]);
},
[
handleConveyorAction,
handleVehicleAction,
handleRoboticArmAction,
handleMachineAction,
handleStorageAction,
]
);
const cleanup = useCallback(() => {
cleanupConveyor();
@@ -49,7 +73,13 @@ export function useActionHandler() {
cleanupRoboticArm();
cleanupMachine();
cleanupStorage();
}, [cleanupConveyor, cleanupVehicle, cleanupRoboticArm, cleanupMachine, cleanupStorage]);
}, [
cleanupConveyor,
cleanupVehicle,
cleanupRoboticArm,
cleanupMachine,
cleanupStorage,
]);
useEffect(() => {
return () => {
@@ -59,6 +89,6 @@ export function useActionHandler() {
return {
handleAction,
cleanup
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

@@ -8,7 +8,7 @@ interface HandleDropProps {
visualizationSocket: any;
selectedZone: any;
setFloatingWidget: (value: any) => void;
event: React.DragEvent<HTMLDivElement>
event: React.DragEvent<HTMLDivElement>;
}
export const createHandleDrop = ({
@@ -117,6 +117,7 @@ export const createHandleDrop = ({
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

@@ -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,11 +210,18 @@ 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: [],
});
@@ -224,7 +229,7 @@ const BarGraphComponent = ({
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(
() => ({
@@ -298,7 +313,8 @@ const BarGraphComponent = ({
// },[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,7 +324,6 @@ const BarGraphComponent = ({
interval: 1000,
};
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);
}
}

View File

@@ -1,11 +1,22 @@
import * as THREE from "three";
import { useThree } from "@react-three/fiber";
import React, { useEffect, useRef, useState } from "react";
import { useAsset3dWidget, useSocketStore, useWidgetSubOption } from "../../../../store/store";
import {
useAsset3dWidget,
useSocketStore,
useWidgetSubOption,
} from "../../../../store/store";
import useModuleStore from "../../../../store/useModuleStore";
import { ThreeState } from "../../../../types/world/worldTypes";
import { useSelectedZoneStore } from "../../../../store/visualization/useZoneStore";
import { useEditWidgetOptionsStore, useLeftData, useRightClickSelected, useRightSelected, useTopData, useZoneWidgetStore } from "../../../../store/visualization/useZone3DWidgetStore";
import {
useEditWidgetOptionsStore,
useLeftData,
useRightClickSelected,
useRightSelected,
useTopData,
useZoneWidgetStore,
} from "../../../../store/visualization/useZone3DWidgetStore";
import { use3DWidget } from "../../../../store/visualization/useDroppedObjectsStore";
import { get3dWidgetZoneData } from "../../../../services/visulization/zone/get3dWidgetData";
import { generateUniqueId } from "../../../../functions/generateUniqueId";
@@ -33,8 +44,17 @@ export default function Dropped3dWidgets() {
const { top, setTop } = useTopData();
const { left, setLeft } = useLeftData();
const { rightSelect, setRightSelect } = useRightSelected();
const { editWidgetOptions, setEditWidgetOptions } = useEditWidgetOptionsStore();
const { zoneWidgetData, setZoneWidgetData, addWidget, updateWidgetPosition, updateWidgetRotation, tempWidget, tempWidgetPosition } = useZoneWidgetStore();
const { editWidgetOptions, setEditWidgetOptions } =
useEditWidgetOptionsStore();
const {
zoneWidgetData,
setZoneWidgetData,
addWidget,
updateWidgetPosition,
updateWidgetRotation,
tempWidget,
tempWidgetPosition,
} = useZoneWidgetStore();
const { setWidgets3D } = use3DWidget();
const { visualizationSocket } = useSocketStore();
const { rightClickSelected, setRightClickSelected } = useRightClickSelected();
@@ -48,7 +68,9 @@ export default function Dropped3dWidgets() {
let [floorPlanesVertical, setFloorPlanesVertical] = useState(
new THREE.Plane(new THREE.Vector3(0, 1, 0))
);
const [intersectcontextmenu, setintersectcontextmenu] = useState<number | undefined>();
const [intersectcontextmenu, setintersectcontextmenu] = useState<
number | undefined
>();
const [horizontalX, setHorizontalX] = useState<number | undefined>();
const [horizontalZ, setHorizontalZ] = useState<number | undefined>();
@@ -67,7 +89,7 @@ export default function Dropped3dWidgets() {
);
setWidgets3D(result);
if (result.length < 0) return
if (result.length < 0) return;
const formattedWidgets = result?.map((widget: WidgetData) => ({
id: widget.id,
@@ -161,7 +183,6 @@ export default function Dropped3dWidgets() {
tempWidgetPosition(selectedZone.zoneId, widget.id, [x, y, z]);
widget.position = [x, y, z];
}
};
const onDrop = (event: any) => {
@@ -185,13 +206,16 @@ export default function Dropped3dWidgets() {
// ✅ Prepare polygon from selectedZone.points
const points3D = selectedZone.points as Array<[number, number, number]>;
const zonePolygonXZ = points3D.map(([x, , z]) => [x, z] as [number, number]);
const zonePolygonXZ = points3D.map(
([x, , z]) => [x, z] as [number, number]
);
const isInside = isPointInPolygon([x, z], zonePolygonXZ);
// ✅ Remove temp widget
const prevWidgets = useZoneWidgetStore.getState().zoneWidgetData[selectedZone.zoneId] || [];
const cleanedWidgets = prevWidgets.filter(w => w.id !== newWidget.id);
const prevWidgets =
useZoneWidgetStore.getState().zoneWidgetData[selectedZone.zoneId] || [];
const cleanedWidgets = prevWidgets.filter((w) => w.id !== newWidget.id);
useZoneWidgetStore.setState((state) => ({
zoneWidgetData: {
...state.zoneWidgetData,
@@ -221,8 +245,6 @@ export default function Dropped3dWidgets() {
createdWidgetRef.current = null;
};
canvasElement.addEventListener("dragenter", handleDragEnter);
canvasElement.addEventListener("dragover", handleDragOver);
canvasElement.addEventListener("drop", onDrop);
@@ -232,7 +254,13 @@ export default function Dropped3dWidgets() {
canvasElement.removeEventListener("dragover", handleDragOver);
canvasElement.removeEventListener("drop", onDrop);
};
}, [widgetSelect, activeModule, selectedZone.zoneId, widgetSubOption, camera,]);
}, [
widgetSelect,
activeModule,
selectedZone.zoneId,
widgetSubOption,
camera,
]);
useEffect(() => {
if (!rightClickSelected) return;
@@ -258,7 +286,7 @@ export default function Dropped3dWidgets() {
rotation: widgetToDuplicate.rotation || [0, 0, 0],
Data: {
measurements: measurements,
duration: duration
duration: duration,
},
};
const adding3dWidget = {
@@ -300,6 +328,7 @@ export default function Dropped3dWidgets() {
)
);
} catch (error) {
echo.error("Failed to delete widget");
} finally {
setRightClickSelected(null);
setRightSelect(null);
@@ -310,7 +339,6 @@ export default function Dropped3dWidgets() {
}
}, [rightSelect, rightClickSelected]);
function isPointInPolygon(
point: [number, number],
polygon: Array<[number, number]>
@@ -323,8 +351,7 @@ export default function Dropped3dWidgets() {
const [xj, zj] = polygon[j];
const intersect =
zi > z !== zj > z &&
x < ((xj - xi) * (z - zi)) / (zj - zi) + xi;
zi > z !== zj > z && x < ((xj - xi) * (z - zi)) / (zj - zi) + xi;
if (intersect) inside = !inside;
}
@@ -348,7 +375,7 @@ export default function Dropped3dWidgets() {
const selectedWidget = zoneWidgetData[selectedZoneId].find(
(widget: WidgetData) => widget.id === rightClickSelected
);
if (!selectedWidget) return
if (!selectedWidget) return;
// let points = [];
// points.push(new THREE.Vector3(0, 0, 0));
// points.push(new THREE.Vector3(0, selectedWidget.position[1], 0));
@@ -383,12 +410,12 @@ export default function Dropped3dWidgets() {
rotationStartRef.current = selectedWidget.rotation || [0, 0, 0];
}
}
};
const handleMouseMove = (event: MouseEvent) => {
if (!rightClickSelected || !rightSelect) return;
const selectedZoneId = Object.keys(zoneWidgetData).find((zoneId: string) =>
const selectedZoneId = Object.keys(zoneWidgetData).find(
(zoneId: string) =>
zoneWidgetData[zoneId].some(
(widget: WidgetData) => widget.id === rightClickSelected
)
@@ -407,18 +434,25 @@ export default function Dropped3dWidgets() {
raycaster.setFromCamera(mouse, camera);
if (rightSelect === "Horizontal Move") {
const intersect = raycaster.ray.intersectPlane(plane.current, planeIntersect.current);
const intersect = raycaster.ray.intersectPlane(
plane.current,
planeIntersect.current
);
if (
intersect &&
typeof horizontalX === "number" &&
typeof horizontalZ === "number"
) {
const selectedZoneId = Object.keys(zoneWidgetData).find(zoneId =>
zoneWidgetData[zoneId].some(widget => widget.id === rightClickSelected)
const selectedZoneId = Object.keys(zoneWidgetData).find((zoneId) =>
zoneWidgetData[zoneId].some(
(widget) => widget.id === rightClickSelected
)
);
if (!selectedZoneId) return;
const selectedWidget = zoneWidgetData[selectedZoneId].find(widget => widget.id === rightClickSelected);
const selectedWidget = zoneWidgetData[selectedZoneId].find(
(widget) => widget.id === rightClickSelected
);
if (!selectedWidget) return;
const newPosition: [number, number, number] = [
@@ -427,14 +461,15 @@ export default function Dropped3dWidgets() {
intersect.z + horizontalZ,
];
updateWidgetPosition(selectedZoneId, rightClickSelected, newPosition);
}
}
if (rightSelect === "Vertical Move") {
const intersect = raycaster.ray.intersectPlane(floorPlanesVertical, planeIntersect.current);
const intersect = raycaster.ray.intersectPlane(
floorPlanesVertical,
planeIntersect.current
);
if (intersect && typeof intersectcontextmenu === "number") {
const diff = intersect.y - intersectcontextmenu;
@@ -460,7 +495,11 @@ export default function Dropped3dWidgets() {
setPrevX(currentX);
if (selectedWidget?.rotation && selectedWidget.rotation.length >= 3) {
const index = axis === "x" ? 0 : axis === "y" ? 1 : 2;
const currentRotation = selectedWidget.rotation as [number, number, number]; // assert type
const currentRotation = selectedWidget.rotation as [
number,
number,
number
]; // assert type
const newRotation: [number, number, number] = [...currentRotation];
newRotation[index] += 0.05 * sign;
updateWidgetRotation(selectedZoneId, rightClickSelected, newRotation);
@@ -613,12 +652,14 @@ export default function Dropped3dWidgets() {
setTop(relativeY);
setLeft(relativeX);
const selectedZoneId = Object.keys(zoneWidgetData).find(zoneId =>
zoneWidgetData[zoneId].some(widget => widget.id === id)
const selectedZoneId = Object.keys(zoneWidgetData).find((zoneId) =>
zoneWidgetData[zoneId].some((widget) => widget.id === id)
);
if (!selectedZoneId) return;
const selectedWidget = zoneWidgetData[selectedZoneId].find(widget => widget.id === id);
const selectedWidget = zoneWidgetData[selectedZoneId].find(
(widget) => widget.id === id
);
if (!selectedWidget) return;
const { top, left, width, height } = canvasElement.getBoundingClientRect();
@@ -632,11 +673,17 @@ export default function Dropped3dWidgets() {
const verticalPlane = new THREE.Plane(cameraDirection);
setFloorPlanesVertical(verticalPlane);
const intersectPoint = raycaster.ray.intersectPlane(verticalPlane, planeIntersect.current);
const intersectPoint = raycaster.ray.intersectPlane(
verticalPlane,
planeIntersect.current
);
if (intersectPoint) {
setintersectcontextmenu(intersectPoint.y);
}
const intersect2 = raycaster.ray.intersectPlane(plane.current, planeIntersect.current);
const intersect2 = raycaster.ray.intersectPlane(
plane.current,
planeIntersect.current
);
if (intersect2) {
const xDiff = -intersect2.x + selectedWidget.position[0];
const zDiff = -intersect2.z + selectedWidget.position[2];
@@ -645,13 +692,12 @@ export default function Dropped3dWidgets() {
}
};
return (
<>
{activeZoneWidgets.map(
({ id, type, position, Data, rotation = [0, 0, 0] }: any) => {
const handleRightClick = (event: React.MouseEvent, id: string) => {
setSelectedChartId({ id: id, type: type })
setSelectedChartId({ id: id, type: type });
event.preventDefault();
const canvasElement = document.getElementById(
"work-space-three-d-canvas"
@@ -664,7 +710,7 @@ export default function Dropped3dWidgets() {
setRightClickSelected(id);
setTop(relativeY);
setLeft(relativeX);
handleRightClick3d(event, id)
handleRightClick3d(event, id);
};
switch (type) {

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,7 +242,6 @@ const ReturnOfInvestment: React.FC<ReturnOfInvestmentProps> = ({
rotation={rotation}
scale={[0.5, 0.5, 0.5]}
transform
sprite={false}
// style={{
// transform: transformStyle.transform,

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);
}
}

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);
}
}

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,23 +1,23 @@
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[] }>({
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 organization = email?.split("@")[1]?.split(".")[0];
const { header, flotingDuration, flotingMeasurements } = useChartStore();
const { selectedChartId } = useWidgetStore();
@@ -108,9 +108,9 @@ const WarehouseThroughputComponent = ({
},
};
useEffect(() => {
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0) return;
if (!iotApiUrl || !measurements || Object.keys(measurements).length === 0)
return;
const socket = io(`http://${iotApiUrl}`);
@@ -120,7 +120,6 @@ const WarehouseThroughputComponent = ({
interval: 1000,
};
const startStream = () => {
socket.emit("lineInput", inputData);
};
@@ -157,23 +156,25 @@ const WarehouseThroughputComponent = ({
};
}, [measurements, duration, iotApiUrl]);
const fetchSavedInputes = async() => {
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}`);
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)
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();
@@ -183,9 +184,7 @@ const WarehouseThroughputComponent = ({
if (selectedChartId?.id === object?.id) {
fetchSavedInputes();
}
}
,[header, flotingDuration, flotingMeasurements])
}, [header, flotingDuration, flotingMeasurements]);
return (
<>
@@ -196,10 +195,15 @@ const WarehouseThroughputComponent = ({
</p> */}
</div>
<div className="lineGraph" style={{ height: "100%" }}>
<Line data={ Object.keys(measurements).length > 0 ? chartData : lineGraphData} options={lineGraphOptions} />
<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

@@ -3,7 +3,9 @@ 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}` : ""}`,
`${url_Backend_dwinzo}/api/v3/AssetDatas?limit=10${
cursor ? `&cursor=${cursor}` : ""
}`,
{
method: "GET",
headers: {
@@ -18,6 +20,7 @@ export const getAssetImages = async (cursor?: string) => {
return await response.json();
} catch (error: any) {
echo.error("Failed to get asset image");
throw new Error(error.message);
}
};

View File

@@ -2,12 +2,15 @@ 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}`, {
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");
@@ -16,6 +19,7 @@ export const getAssetModel = async (modelId: string) => {
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 {

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,14 +1,21 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteFloorItem = async (organization: string, modelUuid: string, modelName: string) => {
export const deleteFloorItem = async (
organization: string,
modelUuid: string,
modelName: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletefloorItem`, {
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");
@@ -17,6 +24,7 @@ export const deleteFloorItem = async (organization: string, modelUuid: string, m
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 {

View File

@@ -1,14 +1,16 @@
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}`, {
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");
@@ -18,6 +20,7 @@ export const getFloorAssets = async (organization: string) => {
return result;
} catch (error) {
echo.error("Failed to get floor asset");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -7,10 +7,19 @@ export const setFloorItemApi = async (
position?: Object,
rotation?: Object,
isLocked?: boolean,
isVisible?: boolean,
isVisible?: boolean
) => {
try {
const body: any = { organization, modelUuid, modelName, position, rotation, modelfileID, isLocked, isVisible };
const body: any = {
organization,
modelUuid,
modelName,
position,
rotation,
modelfileID,
isLocked,
isVisible,
};
const response = await fetch(`${url_Backend_dwinzo}/api/v2/setasset`, {
method: "POST",
@@ -27,6 +36,7 @@ export const setFloorItemApi = async (
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 {

View File

@@ -1,14 +1,21 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteWallItem = async (organization: string, modelUuid: string, modelName: string) => {
export const deleteWallItem = async (
organization: string,
modelUuid: string,
modelName: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteWallItem`, {
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");
@@ -17,6 +24,7 @@ export const deleteWallItem = async (organization: string, modelUuid: string, mo
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 {

View File

@@ -2,12 +2,15 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const getWallItems = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/findWallItems/${organization}`, {
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");
@@ -16,6 +19,7 @@ export const getWallItems = async (organization: string) => {
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 {

View File

@@ -17,7 +17,17 @@ export const setWallItem = async (
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName, position, type, csgposition, csgscale, quaternion, scale }),
body: JSON.stringify({
organization,
modelUuid,
modelName,
position,
type,
csgposition,
csgscale,
quaternion,
scale,
}),
});
if (!response.ok) {
@@ -27,6 +37,7 @@ export const setWallItem = async (
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 {

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}`, {
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,6 +26,7 @@ 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 {

View File

@@ -1,13 +1,25 @@
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) => {
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 }),
body: JSON.stringify({
organization,
userId,
position,
target,
rotation,
}),
});
if (!response.ok) {
@@ -17,6 +29,7 @@ export const setCamera = async (organization: string, userId: string, position:
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 {

View File

@@ -7,15 +7,14 @@ export default async function getActiveUsersData(organization: string) {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
"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 ");
}
@@ -23,10 +22,11 @@ export default async function getActiveUsersData(organization: string) {
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

@@ -7,15 +7,14 @@ export default async function fetchShareUsers(organization: string) {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
"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 ");
}
@@ -23,10 +22,11 @@ export default async function fetchShareUsers(organization: string) {
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,6 +1,10 @@
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) {
export default async function giveCollabAccess(
email: string,
isShare: boolean,
organization: string
) {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/shareUser`, {
method: "POST",
@@ -17,10 +21,11 @@ export default async function giveCollabAccess(email: string, isShare: boolean,
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

@@ -17,6 +17,7 @@ export const deleteLayer = async (organization: string, layer: number) => {
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 {

View File

@@ -17,6 +17,7 @@ export const deleteLineApi = async (organization: string, line: Object) => {
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 {

View File

@@ -17,6 +17,7 @@ export const deletePointApi = async (organization: string, uuid: string) => {
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 {

View File

@@ -2,12 +2,15 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const getLines = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/findLines/${organization}`, {
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");
@@ -16,6 +19,7 @@ export const getLines = async (organization: string) => {
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 {

View File

@@ -1,6 +1,11 @@
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) => {
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",
@@ -17,6 +22,7 @@ export const setLine = async (organization: string, layer: number, line: Object,
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 {

View File

@@ -1,6 +1,10 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const updatePoint = async (organization: string, position: Object, uuid: string) => {
export const updatePoint = async (
organization: string,
position: Object,
uuid: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/updatePoint`, {
method: "POST",
@@ -17,6 +21,7 @@ export const updatePoint = async (organization: string, position: Object, uuid:
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 {

View File

@@ -1,6 +1,10 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const signInApi = async (email: string, password: Object, organization: Object) => {
export const signInApi = async (
email: string,
password: Object,
organization: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/login`, {
method: "POST",
@@ -13,6 +17,7 @@ export const signInApi = async (email: string, password: Object, organization: O
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to sign-in");
if (error instanceof Error) {
return { error: error.message };
} else {

View File

@@ -1,6 +1,11 @@
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) => {
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",
@@ -17,6 +22,7 @@ export const signUpApi = async (userName: string, email: string, password: Objec
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 {

View File

@@ -1,6 +1,10 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteZonesApi = async (userId: string, organization: string, zoneId: string) => {
export const deleteZonesApi = async (
userId: string,
organization: string,
zoneId: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
@@ -18,6 +22,7 @@ export const deleteZonesApi = async (userId: string, organization: string, zoneI
return result;
} catch (error) {
echo.error("Failed to delete zone");
if (error instanceof Error) {
throw new Error(error.message);
} else {

View File

@@ -3,12 +3,15 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const getZonesApi = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/findZones/${organization}`, {
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");
@@ -17,6 +20,7 @@ export const getZonesApi = async (organization: string) => {
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 {

View File

@@ -1,6 +1,10 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setZonesApi = async (userId: string, organization: string, zoneData: any) => {
export const setZonesApi = async (
userId: string,
organization: string,
zoneData: any
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
@@ -17,6 +21,7 @@ export const setZonesApi = async (userId: string, organization: string, zoneData
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 {

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

@@ -2,13 +2,16 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const upsertProductOrEventApi = async (body: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/UpsertProductOrEvent`, {
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");
@@ -17,6 +20,7 @@ export const upsertProductOrEventApi = async (body: any) => {
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 {

View File

@@ -2,13 +2,16 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
export const deleteEventDataApi = async (body: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/EventDataDelete`, {
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");
@@ -17,6 +20,7 @@ export const deleteEventDataApi = async (body: any) => {
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 {

View File

@@ -1,13 +1,19 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteProductApi = async (productId: string, organization: string) => {
export const deleteProductApi = async (
productId: string,
organization: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productDataDelete?productId=${productId}&organization=${organization}`, {
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");
@@ -16,6 +22,7 @@ export const deleteProductApi = async (productId: string, organization: string)
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 {

View File

@@ -1,13 +1,19 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getProductApi = async (productId: string, organization: string) => {
export const getProductApi = async (
productId: string,
organization: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productDatas?productId=${productId}&organization=${organization}`, {
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");
@@ -16,6 +22,7 @@ export const getProductApi = async (productId: string, organization: string) =>
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 {

View File

@@ -1,13 +1,16 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getAllProductsApi = async ( organization: string) => {
export const getAllProductsApi = async (organization: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/AllProducts/${organization}`, {
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");
@@ -16,6 +19,7 @@ export const getAllProductsApi = async ( organization: string) => {
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 {

View File

@@ -1,6 +1,10 @@
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 }) => {
export const renameProductApi = async (body: {
productName: string;
productId: string;
organization: string;
}) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v2/productRename`, {
method: "PATCH",
@@ -17,6 +21,8 @@ export const renameProductApi = async (body: { productName: string, productId: s
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 {

View File

@@ -6,16 +6,13 @@ export const adding3dWidgets = async (
widget: {}
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/3dwidget/save`,
{
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

@@ -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