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:
@@ -8,6 +8,10 @@ import { useWidgetStore } from "../../../../../store/useWidgetStore";
|
||||
import axios from "axios";
|
||||
import RenameInput from "../../../../ui/inputs/RenameInput";
|
||||
import { getUserData } from "../../../../../functions/getUserData";
|
||||
import { get3dWidgetInput } from "../../../../../services/visulization/zone/get3dWidgetInput";
|
||||
import { useVersionContext } from "../../../../../modules/builder/version/versionContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { adding3dWidgets } from "../../../../../services/visulization/zone/add3dWidget";
|
||||
|
||||
type Props = {};
|
||||
|
||||
@@ -24,6 +28,9 @@ const Widget4InputCard3D = (props: Props) => {
|
||||
const iotApiUrl = process.env.REACT_APP_IOT_SOCKET_SERVER_URL;
|
||||
const { userName, userId, organization, email } = getUserData();
|
||||
const [isLoading, setLoading] = useState<boolean>(true);
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { projectId } = useParams()
|
||||
|
||||
useEffect(() => {
|
||||
const fetchZoneData = async () => {
|
||||
@@ -48,21 +55,14 @@ const Widget4InputCard3D = (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/v2/widget3D/${selectedChartId.id}/${organization}`
|
||||
);
|
||||
if (response.status === 200) {
|
||||
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);
|
||||
let response = await get3dWidgetInput(selectedChartId.id, organization)
|
||||
console.log('response: ', response);
|
||||
if (response) {
|
||||
setSelections(response.data.Data.measurements);
|
||||
setDuration(response.data.Data.duration);
|
||||
setWidgetName(response.data.widgetName);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -81,6 +81,17 @@ const Widget4InputCard3D = (props: Props) => {
|
||||
inputDuration: any,
|
||||
inputName: any
|
||||
) => {
|
||||
// let newWidget = {
|
||||
// id: selectedChartId.id,
|
||||
// widgetName: inputName,
|
||||
// Data: {
|
||||
// measurements: inputMeasurement,
|
||||
// duration: inputDuration,
|
||||
// },
|
||||
// }
|
||||
|
||||
// let response = await adding3dWidgets(selectedZone.zoneUuid, organization, newWidget, projectId, selectedVersion?.versionId || "")
|
||||
// console.log('response: ', response);
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`,
|
||||
|
||||
Reference in New Issue
Block a user