Added more error message handlers to SDK

This commit is contained in:
frikky
2022-10-22 22:56:05 +02:00
parent 558b47b7dd
commit cbaf4ace92
4 changed files with 75 additions and 59 deletions
+40 -35
View File
@@ -34,8 +34,17 @@ import {
AttachFile as AttachFileIcon,
Apps as AppsIcon,
ErrorOutline as ErrorOutlineIcon,
AddAPhoto as AddAPhotoIcon,
AddAPhotoOutlined as AddAPhotoOutlinedIcon,
ZoomInOutlined as ZoomInOutlinedIcon,
ZoomOutOutlined as ZoomOutOutlinedIcon,
Loop as LoopIcon,
} from "@material-ui/icons";
import {
AddPhotoAlternate as AddPhotoAlternateIcon,
} from '@mui/icons-material';
import { v4 as uuidv4 } from "uuid";
import { Link, useParams } from "react-router-dom";
import YAML from "yaml";
@@ -44,12 +53,6 @@ import { useAlert } from "react-alert";
import words from "shellwords";
import AvatarEditor from "react-avatar-editor";
import AddAPhotoIcon from "@material-ui/icons/AddAPhoto";
import AddAPhotoOutlinedIcon from "@material-ui/icons/AddAPhotoOutlined";
import ZoomInOutlinedIcon from "@material-ui/icons/ZoomInOutlined";
import ZoomOutOutlinedIcon from "@material-ui/icons/ZoomOutOutlined";
import LoopIcon from "@material-ui/icons/Loop";
import AddPhotoAlternateIcon from "@material-ui/icons/AddPhotoAlternate";
const surfaceColor = "#27292D";
const inputColor = "#383B40";
@@ -344,14 +347,14 @@ const AppCreator = (defaultprops) => {
useEffect(() => {
if (window.location.pathname.includes("apps/edit")) {
setIsEditing(true);
handleEditApp();
handleEditApp(props.match.params.appid);
} else {
checkQuery();
}
}, []);
const handleEditApp = () => {
fetch(globalUrl + "/api/v1/apps/" + props.match.params.appid + "/config", {
const handleEditApp = (appid) => {
fetch(globalUrl + "/api/v1/apps/" + appid + "/config", {
method: "GET",
headers: {
"Content-Type": "application/json",
@@ -389,34 +392,36 @@ const AppCreator = (defaultprops) => {
setIsAppLoaded(true);
return;
}
handleEditApp(urlParams.get("id"))
fetch(globalUrl + "/api/v1/get_openapi/" + urlParams.get("id"), {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
credentials: "include",
})
.then((response) => {
if (response.status !== 200) {
throw new Error("NOT 200 :O");
}
//fetch(globalUrl + "/api/v1/get_openapi/" + urlParams.get("id"), {
// method: "GET",
// headers: {
// "Content-Type": "application/json",
// Accept: "application/json",
// },
// credentials: "include",
//})
// .then((response) => {
// if (response.status !== 200) {
// throw new Error("NOT 200 :O");
// }
return response.json();
})
.then((responseJson) => {
setIsAppLoaded(true);
if (!responseJson.success) {
alert.error("Failed to verify");
} else {
parseIncomingOpenapiData(responseJson);
}
})
.catch((error) => {
console.log("Error: ", error.toString());
alert.error(error.toString());
});
// return response.json();
// })
// .then((responseJson) => {
// setIsAppLoaded(true);
// if (!responseJson.success) {
// alert.error("Failed to verify");
// } else {
// parseIncomingOpenapiData(responseJson);
// }
// })
// .catch((error) => {
// console.log("Error: ", error.toString());
// alert.error(error.toString());
// });
};
const setFileFromb64 = () => {