updated
This commit is contained in:
@@ -4,7 +4,8 @@ export const createAisleApi = async (
|
||||
aisleUuid: string,
|
||||
points: any,
|
||||
type: Object,
|
||||
projectId: string
|
||||
projectId: string,
|
||||
versionId: string,
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/UpsertAisle`, {
|
||||
@@ -15,7 +16,7 @@ export const createAisleApi = async (
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify({ aisleUuid, points, type, projectId }),
|
||||
body: JSON.stringify({ aisleUuid, points, type, projectId, versionId }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -27,9 +28,9 @@ export const createAisleApi = async (
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const deleteAisleApi = async (aisleUuid: string, projectId: string) => {
|
||||
export const deleteAisleApi = async (aisleUuid: string, projectId: string, versionId: string) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/DeleteAisle`, {
|
||||
method: "PATCH",
|
||||
@@ -21,9 +21,9 @@ export const deleteAisleApi = async (aisleUuid: string, projectId: string) => {
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getAisleApi = async (projectId: string) => {
|
||||
export const getAisleApi = async (projectId: string, versionId: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/Aisles/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/Aisles/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
@@ -23,6 +23,6 @@ export const getAisleApi = async (projectId: string) => {
|
||||
return await response.json();
|
||||
} catch (error: any) {
|
||||
console.error("Failed to get asset image:", error);
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +19,6 @@ 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);
|
||||
console.log(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,9 +21,9 @@ export const getAssetModel = async (modelId: string) => {
|
||||
} catch (error) {
|
||||
echo.error("Failed to get asset model");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,6 +15,6 @@ export const getCategoryAsset = async (categoryName: any) => {
|
||||
return result;
|
||||
} catch (error: any) {
|
||||
echo.error("Failed to get category asset");
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,9 +26,9 @@ export const deleteFloorItem = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to delete floor item");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getFloorAssets = async (organization: string, projectId?: string) => {
|
||||
export const getFloorAssets = async (organization: string, projectId?: string, versionId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/floorAssets/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/floorAssets/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
@@ -21,15 +21,14 @@ export const getFloorAssets = async (organization: string, projectId?: string) =
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
// console.log('result: ', result);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to get floor asset");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,50 +1,29 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
export const setFloorItemApi = async (
|
||||
organization: string,
|
||||
modelUuid?: string,
|
||||
modelName?: string,
|
||||
projectId?: string,
|
||||
assetId?: string,
|
||||
position?: Object,
|
||||
rotation?: Object,
|
||||
isLocked?: boolean,
|
||||
isVisible?: boolean,
|
||||
) => {
|
||||
try {
|
||||
const body: any = {
|
||||
organization,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
rotation,
|
||||
assetId,
|
||||
isLocked,
|
||||
isVisible,
|
||||
projectId,
|
||||
};
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/setAsset`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set or update Floor Item");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to set floor items");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
export const setAssetsApi = async (data: any) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/setAsset`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set or update Floor Item");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to set floor items");
|
||||
if (error instanceof Error) {
|
||||
console.log(error.message);
|
||||
} else {
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -26,9 +26,9 @@ export const deleteWallItem = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to delete wall items");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getWallItems = async (organization: string,projectId?:string) => {
|
||||
export const getWallItems = async (organization: string, projectId?: string, versionId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/walls/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/walls/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
@@ -25,9 +25,9 @@ export const getWallItems = async (organization: string,projectId?:string) => {
|
||||
} catch (error) {
|
||||
echo.error("Failed to get wall items");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,9 +39,9 @@ export const setWallItem = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to set wall items");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,9 +28,9 @@ export const getCamera = async (organization: string, userId: string, projectId?
|
||||
} catch (error) {
|
||||
echo.error("Failed to get camera");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -31,9 +31,9 @@ export const setCamera = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to set camera");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,9 +24,9 @@ export default async function getActiveUsersData(organization: string) {
|
||||
} catch (error) {
|
||||
echo.error("Failed to get active users");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ export default async function fetchShareUsers(organization: string) {
|
||||
} catch (error) {
|
||||
echo.error("Failed to get user API");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ export default async function giveCollabAccess(
|
||||
} catch (error) {
|
||||
echo.error("Failed to give collab access");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
46
app/src/services/factoryBuilder/comments/addCommentsApi.ts
Normal file
46
app/src/services/factoryBuilder/comments/addCommentsApi.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const addCommentsApi = async (
|
||||
projectId: any,
|
||||
comment: string,
|
||||
threadId?: string,
|
||||
commentId?: string
|
||||
) => {
|
||||
console.log(
|
||||
" projectId, comments, threadId: ",
|
||||
projectId,
|
||||
comment,
|
||||
threadId,
|
||||
commentId
|
||||
);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v1/Thread/addComment`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify({ projectId, comment, threadId, commentId }),
|
||||
}
|
||||
);
|
||||
console.log('response: ', response);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add project");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log("result: ", result);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
34
app/src/services/factoryBuilder/comments/createThreadApi.ts
Normal file
34
app/src/services/factoryBuilder/comments/createThreadApi.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const createThreadApi = async (
|
||||
projectId: any,
|
||||
state: string,
|
||||
position: any,
|
||||
rotation: any,
|
||||
threadTitle: any
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/v1/upsetThread`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify({ projectId, state, position, rotation, threadTitle }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add project");
|
||||
}
|
||||
const result = await response.json();
|
||||
console.log('result: ', result);
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
43
app/src/services/factoryBuilder/comments/deleteCommentApi.ts
Normal file
43
app/src/services/factoryBuilder/comments/deleteCommentApi.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
|
||||
|
||||
export const deleteCommentApi = async (
|
||||
projectId: string,
|
||||
threadId: string,
|
||||
commentId: string
|
||||
) => {
|
||||
const body: any = {
|
||||
projectId,
|
||||
threadId,
|
||||
commentId,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v1/Thread/deleteComment`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to clearPanel in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
35
app/src/services/factoryBuilder/comments/deleteThreadApi.ts
Normal file
35
app/src/services/factoryBuilder/comments/deleteThreadApi.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
|
||||
|
||||
export const deleteThreadApi = async (projectId: string, threadId: string) => {
|
||||
const body: any = {
|
||||
projectId,
|
||||
threadId,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/v1/Thread/delete`, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to clearPanel in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
|
||||
|
||||
export const editThreadTitleApi = async (
|
||||
projectId: string,
|
||||
threadId: string,
|
||||
threadTitle: string
|
||||
) => {
|
||||
const body: any = {
|
||||
projectId,
|
||||
threadId,
|
||||
threadTitle,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v1/Thread/updateTitle`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to clearPanel in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
34
app/src/services/factoryBuilder/comments/getAllThreads.ts
Normal file
34
app/src/services/factoryBuilder/comments/getAllThreads.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getAllThreads = async (projectId: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/v1/Threads/${projectId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get assets");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
// console.log('result: ', result);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to get floor asset");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -26,9 +26,9 @@ export const findEnvironment = async (organization: string, userId: string, proj
|
||||
} catch (error) {
|
||||
echo.error("Failed to find env");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,9 +46,9 @@ export const setEnvironment = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to set env");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,9 +19,9 @@ export const deleteLayer = async (organization: string, layer: number) => {
|
||||
} catch (error) {
|
||||
echo.error("Failed to delete line");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,9 +19,9 @@ export const deleteLineApi = async (organization: string, line: Object) => {
|
||||
} catch (error) {
|
||||
echo.error("Failed to delete line");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,9 +19,9 @@ export const deletePointApi = async (organization: string, uuid: string) => {
|
||||
} catch (error) {
|
||||
echo.error("Failed to delete point");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getLines = async (organization: string,projectId?:string) => {
|
||||
export const getLines = async (organization: string, projectId?: string, versionId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/lines/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/lines/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
@@ -25,9 +25,9 @@ export const getLines = async (organization: string,projectId?:string) => {
|
||||
} catch (error) {
|
||||
echo.error("Failed to get Lines");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,9 +24,9 @@ export const setLine = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to set line");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,9 +23,9 @@ export const updatePoint = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to update point");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,9 +22,9 @@ export const signUpApi = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to sign-up");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const createVersionApi = async (projectId: string, createdBy: string, hierarchyVersion: string, versionName: string, description: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/generateVersion`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
projectId,
|
||||
createdBy,
|
||||
hierarchyVersion,
|
||||
versionName,
|
||||
description
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to create Version History");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to create Version History");
|
||||
if (error instanceof Error) {
|
||||
console.log(error.message);
|
||||
} else {
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getVersionDataApi = async (projectId: string, versionId: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/version/${versionId}/${projectId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Version Data");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to get Version Data");
|
||||
if (error instanceof Error) {
|
||||
console.log(error.message);
|
||||
} else {
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const getVersionHistoryApi = async (projectId: string, page?: number, limit?: number) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/${projectId}/versions`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "",
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Version History");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to get Version History");
|
||||
if (error instanceof Error) {
|
||||
console.log(error.message);
|
||||
} else {
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -24,9 +24,9 @@ export const deleteZonesApi = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to delete zone");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
|
||||
|
||||
export const getZonesApi = async (organization: string, projectId?: string) => {
|
||||
export const getZonesApi = async (organization: string, projectId?: string, versionId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/zones/${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/V1/zones/${projectId}/${versionId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
@@ -17,19 +17,19 @@ export const getZonesApi = async (organization: string, projectId?: string) => {
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Zones");
|
||||
throw new Error("Failed to get Zones");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
// console.log('result:zone ', result);
|
||||
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to get zone data");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,9 +23,9 @@ export const setZonesApi = async (
|
||||
} catch (error) {
|
||||
echo.error("Failed to zone data");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.log(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.log("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user