Implement API enhancements for token management and new endpoints
- Added token management for various API calls in the factoryBuilder and visualization services. - Updated deleteLayerApi, deleteLineApi, deletePointApi, getLinesApi, setLineApi, updatePointApi, and version control APIs to handle new access tokens from response headers. - Introduced new API endpoints for 3D widget and floating widget data retrieval. - Enhanced error handling and logging for API responses. - Created new sessionValidity and input retrieval components for better session management and data handling.
This commit is contained in:
@@ -12,6 +12,7 @@ import { useSocketStore } from "../../../../../store/builder/store";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { addingWidgets } from "../../../../../services/visulization/zone/addWidgets";
|
||||
import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
|
||||
import { getWidgetInputData } from "../../../../../services/visulization/zone/getWidgetInputData";
|
||||
|
||||
type Props = {};
|
||||
|
||||
@@ -43,11 +44,11 @@ const BarChartInput = (props: Props) => {
|
||||
setDropDownData(response.data);
|
||||
setLoading(false);
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
echo.log("Failed to fetch zone data");
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
fetchZoneData();
|
||||
@@ -56,33 +57,15 @@ const BarChartInput = (props: Props) => {
|
||||
useEffect(() => {
|
||||
const fetchSavedInputes = async () => {
|
||||
if (selectedChartId.id !== "") {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}&versionId=${selectedVersion?.versionId || ""}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200) {
|
||||
|
||||
setSelections(response.data.Datastructure.measurements);
|
||||
setDuration(response.data.Datastructure.duration);
|
||||
setWidgetName(response.data.widgetName);
|
||||
} else {
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
echo.error("Failed to fetch saved inputs");
|
||||
|
||||
let response = await getWidgetInputData(selectedChartId.id, selectedZone.zoneUuid, projectId, selectedVersion?.versionId || "")
|
||||
|
||||
if (response) {
|
||||
setSelections(response.Datastructure.measurements);
|
||||
setDuration(response.Datastructure.duration);
|
||||
setWidgetName(response.widgetName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fetchSavedInputes();
|
||||
}, [selectedChartId]);
|
||||
|
||||
@@ -118,47 +101,16 @@ const BarChartInput = (props: Props) => {
|
||||
// visualizationSocket.emit("v1:viz-3D-widget:add", adding3dWidget);
|
||||
|
||||
// }
|
||||
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget,projectId, selectedVersion?.versionId || "");
|
||||
|
||||
let response = await addingWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "");
|
||||
|
||||
if(response.message==="Widget updated successfully"){
|
||||
|
||||
if (response.message === "Widget updated successfully") {
|
||||
return true;
|
||||
}else{
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
};
|
||||
// try {
|
||||
// const response = await axios.post(
|
||||
// `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`,
|
||||
// {
|
||||
// headers: {
|
||||
// Authorization: "Bearer <access_token>",
|
||||
// "Content-Type": "application/json",
|
||||
// token: localStorage.getItem("token") || "",
|
||||
// refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// zoneUuid: selectedZone.zoneUuid,
|
||||
// organization: organization,
|
||||
// widget: {
|
||||
// id: selectedChartId.id,
|
||||
// panel: selectedChartId.panel,
|
||||
// widgetName: inputName,
|
||||
// Data: {
|
||||
// measurements: inputMeasurement,
|
||||
// duration: inputDuration,
|
||||
// },
|
||||
// },
|
||||
// } as any
|
||||
// );
|
||||
|
||||
|
||||
// } catch (error) {
|
||||
// echo.error("Failed to send input");
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
};
|
||||
|
||||
const handleSelect = async (
|
||||
@@ -190,7 +142,7 @@ const BarChartInput = (props: Props) => {
|
||||
};
|
||||
|
||||
const handleNameChange = async (name: any) => {
|
||||
|
||||
|
||||
|
||||
if (await sendInputes(selections, duration, name)) {
|
||||
setWidgetName(name);
|
||||
|
||||
Reference in New Issue
Block a user