diff --git a/frontend/src/views/AppCreator.jsx b/frontend/src/views/AppCreator.jsx index 6619f95f..3b0a90ad 100644 --- a/frontend/src/views/AppCreator.jsx +++ b/frontend/src/views/AppCreator.jsx @@ -66,6 +66,7 @@ const appIconStyle = { marginLeft: "5px", } + const useStyles = makeStyles({ notchedOutline: { borderColor: "#f85a3e !important" @@ -222,6 +223,8 @@ const AppCreator = (props) => { const [parameterLocation, setParameterLocation] = useState(apikeySelection.length > 0 ? apikeySelection[0] : ""); const [refreshUrl, setRefreshUrl] = useState(""); const [oauth2Scopes, setOauth2Scopes] = useState(["google.com"]); + const [projectCategories, setProjectCategories] = useState([]); + const [selectedCategory, setSelectedCategory] = useState(""); const [urlPath, setUrlPath] = useState(""); //const [urlPathQueries, setUrlPathQueries] = useState([{"name": "test", "required": false}]); @@ -231,6 +234,7 @@ const AppCreator = (props) => { const [firstrequest, setFirstrequest] = React.useState(true) const [basedata, setBasedata] = React.useState({}) const [actions, setActions] = useState([]) + const [filteredActions, setFilteredActions] = useState([]) const [errorCode, setErrorCode] = useState("") const [appBuilding, setAppBuilding] = useState(false) const [extraBodyFields, setExtraBodyFields] = useState([]) @@ -288,6 +292,7 @@ const AppCreator = (props) => { "method": actionNonBodyRequest[0], }); + const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io" useEffect(() => { @@ -391,7 +396,7 @@ const AppCreator = (props) => { const handleGetRef = (parameter, data) => { try { if (parameter === null || parameter["$ref"] === undefined) { - console.log("$ref not found in getref: ") + //console.log("$ref not found in getref: ") return parameter } } catch (e) { @@ -527,6 +532,7 @@ const AppCreator = (props) => { var newActions = [] var wordlist = {} + var all_categories = [] if (data.paths !== null && data.paths !== undefined) { for (let [path, pathvalue] of Object.entries(data.paths)) { for (let [method, methodvalue] of Object.entries(pathvalue)) { @@ -560,6 +566,24 @@ const AppCreator = (props) => { "example_response": "", } + // Finding category + if (path.includes("/")) { + const pathsplit = path.split("/") + var categoryindex = -1 + // Stupid way of finding a category/grouping + for (var key in pathsplit) { + if (pathsplit[key].length > 0 && pathsplit[key] !== "v1" && pathsplit[key] !== "v2" && pathsplit[key] !== "api" && pathsplit[key] !== "1.0" && pathsplit[key] !== "apis") { + newaction["category"] = pathsplit[key] + if (!all_categories.includes(pathsplit[key])) { + all_categories.push(pathsplit[key]) + } + break + } + } + } + + //console.log("Category: + //console.log("Schema is application/json: ", methodvalue) //console.log("DATA", data) if (methodvalue["requestBody"] !== undefined) { @@ -964,12 +988,15 @@ const AppCreator = (props) => { setActionAmount(newActions.length) } - if (newActions.length > 1000) { + //const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io" + if (newActions.length > 1000 && isCloud) { alert.error("Cut down actions from "+newActions.length+" to 999 because of limit") newActions = newActions.slice(0,999) } + setProjectCategories(all_categories) setActions(newActions) + setFilteredActions(newActions) setIsAppLoaded(true) } @@ -1515,6 +1542,7 @@ const AppCreator = (props) => { } setActions(actions) + setFilteredActions(actions) setUpdate(Math.random()) } @@ -1534,6 +1562,7 @@ const AppCreator = (props) => { }) setActions(actions) + setFilteredActions(actions) setActionAmount(actionAmount-1) setUpdate(Math.random()) } @@ -1827,7 +1856,7 @@ const AppCreator = (props) => { null :