diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 88b9a217..47d6e1ec 100755 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -660,7 +660,7 @@ class AppBase: break else: # FIXME: Add a checker for 403, and Proxy logs failing - self.logger.info(f"[ERROR] Bad resp {ret.status_code} for url {url}") + self.logger.info(f"[ERROR] Bad resp ({ret.status_code}) in send_result for url '{url}'") time.sleep(sleeptime) diff --git a/frontend/src/components/NewHeader.jsx b/frontend/src/components/NewHeader.jsx index da13952d..f1ca7520 100644 --- a/frontend/src/components/NewHeader.jsx +++ b/frontend/src/components/NewHeader.jsx @@ -203,6 +203,11 @@ const Header = (props) => { window.location.pathname = "/"; localStorage.setItem("globalUrl", "") + + // Delete userinfo from localstorage + localStorage.removeItem("apps") + localStorage.removeItem("workflows") + localStorage.removeItem("userinfo") }) .catch((error) => { console.log(error); @@ -476,7 +481,9 @@ const Header = (props) => { if (response.status !== 200) { console.log("Error in response"); } else { - localStorage.setItem("apps", []) + localStorage.removeItem("apps") + localStorage.removeItem("workflows") + localStorage.removeItem("userinfo") } return response.json(); diff --git a/frontend/src/components/Oauth2Auth.jsx b/frontend/src/components/Oauth2Auth.jsx index fe8562f5..c14e167d 100755 --- a/frontend/src/components/Oauth2Auth.jsx +++ b/frontend/src/components/Oauth2Auth.jsx @@ -70,8 +70,6 @@ const registeredApps = [ "microsoft_teams", "microsoft_teams_user_access", "todoist", - "microsoft_sentinel", - "microsoft_365_defender", "google_chat", "google_sheets", "google_drive", @@ -711,7 +709,7 @@ const AuthenticationOauth2 = (props) => { - Oauth2 requires a client ID and secret to authenticate, defined in the remote system. Your redirect URL is {window.location.origin}/set_authentication -  + Oauth2 requires a client ID and secret to authenticate, defined in the remote system. {authenticationType.type === "oauth2-app" ? null : Your redirect URL is {window.location.origin}/set_authentication - } { const fieldname = data.name === "url" && authenticationType.grant_type !== undefined && authenticationType.grant_type !== null && authenticationType.grant_type.length > 0 && authenticationType.type === "oauth2-app" ? "Token URL" : data.name return ( -
+
{fieldname} diff --git a/frontend/src/components/ParsedAction.jsx b/frontend/src/components/ParsedAction.jsx index 1bbe88f5..5b8737cf 100755 --- a/frontend/src/components/ParsedAction.jsx +++ b/frontend/src/components/ParsedAction.jsx @@ -3552,7 +3552,6 @@ const ParsedAction = (props) => { fullWidth variant="contained" onClick={() => { - console.log(authenticationType); //if (authenticationType.type === "oauth2" && authenticationType.redirect_uri !== undefined && authenticationType.redirect_uri !== null) { // return null //} diff --git a/frontend/src/theme.jsx b/frontend/src/theme.jsx index b183a1e4..5c240f4b 100644 --- a/frontend/src/theme.jsx +++ b/frontend/src/theme.jsx @@ -26,7 +26,16 @@ const theme = createTheme(adaptV4Theme({ green: "#5cc879", borderRadius: 10, defaultBorder: "1px solid rgba(255,255,255,0.3)", - jsonTheme: "brewer", + + //jsonTheme: "brewer", + //jsonTheme: "chalk", + //jsonTheme: "monokai", + //jsonTheme: "google", + //jsonTheme: "tomorrow", + jsonIconStyle: "round", + jsonTheme: "summerfruit", + jsonCollapseStringsAfterLength: 75, + reactJsonStyle: { padding: 5, width: "98%", diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index c24b6ca7..0d47a9de 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -1609,7 +1609,9 @@ If you're interested, please let me know a time that works for you, or set up a if (response.status !== 200) { console.log("Error in response"); } else { - localStorage.setItem("apps", []) + localStorage.removeItem("apps") + localStorage.removeItem("workflows") + localStorage.removeItem("userinfo") } return response.json(); diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index e06bf9bc..a9c2f825 100755 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -655,6 +655,48 @@ const AngularWorkflow = (defaultprops) => { // Handle the activation case, as they are NOT in the event management system yet if (selectedApp.actions === undefined || selectedApp.actions === null || selectedApp.actions.length > 1) { return + } else { + if (selectedApp.id !== undefined && selectedApp.id !== null && selectedApp.id.length > 0) { + const appUrl = `${globalUrl}/api/v1/apps/${selectedApp.id}/config?openapi=false` + fetch(appUrl, { + headers: { + Accept: "application/json", + }, + credentials: "include", + }) + .then((response) => { + return response.json() + }) + .then((responseJson) => { + if (responseJson.success === true && responseJson.app !== undefined && responseJson.app !== null && responseJson.app.length > 0) { + // Base64 decode into json + const foundapp = JSON.parse(atob(responseJson.app)) + if (foundapp.actions !== undefined && foundapp.actions !== null && foundapp.actions.length > selectedApp.actions.length) { + setSelectedApp(foundapp) + + for (var i = 0; i < apps.length; i++) { + if (apps[i].id !== foundapp.id) { + continue + } + + apps[i] = foundapp + setApps(apps) + setFilteredApps(apps) + + // Update the local storage + localStorage.setItem("apps", JSON.stringify(apps)) + break + } + } + + // FIXME: Add it to the existing list AND update the selected app + } + }) + .catch((error) => { + console.log(`Failed side-loading app ${selectedApp.name}`) + }) + + } } for (let appkey in apps) { @@ -2198,7 +2240,9 @@ const AngularWorkflow = (defaultprops) => { return } - return response.json(); + console.log("Apps loaded. JSON decoding next") + + return response.json() }) .then((responseJson) => { if (responseJson === null) { @@ -4178,14 +4222,18 @@ const AngularWorkflow = (defaultprops) => { // Check local storage has it const foundapps = localStorage.getItem("apps") if (foundapps !== null && foundapps !== undefined) { - const parsedapps = JSON.parse(foundapps) - if (parsedapps !== null && parsedapps !== undefined && parsedapps.length > 0) { - for (let appkey in parsedapps) { - if (parsedapps[appkey].name === curaction.app_name) { - curapp = parsedapps[appkey] - break + try { + const parsedapps = JSON.parse(foundapps) + if (parsedapps !== null && parsedapps !== undefined && parsedapps.length > 0) { + for (let appkey in parsedapps) { + if (parsedapps[appkey].name === curaction.app_name) { + curapp = parsedapps[appkey] + break + } } } + } catch (e) { + console.log("Problem with parsing apps from local storage", e) } } else { @@ -4193,6 +4241,12 @@ const AngularWorkflow = (defaultprops) => { } } + /* + if (curapp && curapp.app_id !== undefined && curapp.app_id !== null && curapp.app_id.length > 0 &&curapp.actions.length <= 1) { + toast(`Side-loading app ${curapp.name} to get actions.`) + } + */ + if (!curapp || curapp === undefined) { const tmpapp = { name: curaction.app_name, @@ -4205,6 +4259,7 @@ const AngularWorkflow = (defaultprops) => { setSelectedApp(tmpapp) setSelectedAction(curaction) } else { + curaction.app_id = curapp.id setAuthenticationType( @@ -6810,7 +6865,7 @@ const AngularWorkflow = (defaultprops) => { } console.log("Setupgraph done 2!") - }; + } const removeNode = (nodeId) => { const selectedNode = cy.getElementById(nodeId); @@ -8082,10 +8137,17 @@ const AngularWorkflow = (defaultprops) => { return; } + if (app.actions === undefined || app.actions === null) { + app.actions = [] + } + + /* if (app.actions === undefined || app.actions === null || app.actions.length === 0) { toast("App " + app.name + " currently has no actions to perform. Please go to https://shuffler.io/apps to edit it.") + return } + */ newNodeId = uuidv4(); const actionType = "ACTION"; @@ -8610,8 +8672,6 @@ const AngularWorkflow = (defaultprops) => { : hits.map((hit, index) => { - console.log("HIT: ", hit) - const innerlistitemStyle = { width: positionInfo.width + 35, overflowX: "hidden", @@ -15728,6 +15788,9 @@ const AngularWorkflow = (defaultprops) => { theme={theme.palette.jsonTheme} style={theme.palette.reactJsonStyle} collapsed={true} + iconStyle={theme.palette.jsonIconStyle} + collapseStringsAfterLength={theme.palette.jsonCollapseStringsAfterLength} + displayArrayKey={false} enableClipboard={(copy) => { handleReactJsonClipboard(copy); }} @@ -15735,7 +15798,7 @@ const AngularWorkflow = (defaultprops) => { onSelect={(select) => { HandleJsonCopy(validate.result, select, "exec"); }} - name={"Execution Argument"} + name={false} />
) @@ -16034,6 +16097,9 @@ const AngularWorkflow = (defaultprops) => { theme={theme.palette.jsonTheme} style={theme.palette.reactJsonStyle} collapsed={parsedCollapse} + iconStyle={theme.palette.jsonIconStyle} + collapseStringsAfterLength={theme.palette.jsonCollapseStringsAfterLength} + displayArrayKey={false} shouldCollapse={(field) => { console.log("FIELD: ", field) }} @@ -17134,6 +17200,9 @@ const AngularWorkflow = (defaultprops) => { theme={theme.palette.jsonTheme} style={theme.palette.reactJsonStyle} collapsed={true} + iconStyle={theme.palette.jsonIconStyle} + collapseStringsAfterLength={theme.palette.jsonCollapseStringsAfterLength} + displayArrayKey={false} enableClipboard={(copy) => { handleReactJsonClipboard(copy); }} @@ -17263,6 +17332,9 @@ const AngularWorkflow = (defaultprops) => { theme={theme.palette.jsonTheme} style={theme.palette.reactJsonStyle} collapsed={data.value.length < 10000 ? false : true} + iconStyle={theme.palette.jsonIconStyle} + collapseStringsAfterLength={theme.palette.jsonCollapseStringsAfterLength} + displayArrayKey={false} displayDataTypes={false} name={"Parsed data for variable " + data.name} /> @@ -17371,7 +17443,7 @@ const AngularWorkflow = (defaultprops) => { return "The app's Docker Image is not available in the environment yet. Re-run the app to force a re-download of the app. If the problem persists, contact support" } - if (result.status !== 200 && (result.url.includes("192.168") || result.url.includes("172.16") || result.url.includes("10.0"))) { + if (result.status !== 200 && result.url !== undefined && result.url !== null && (result.url.includes("192.168") || result.url.includes("172.16") || result.url.includes("10.0"))) { return "Consider whether your Orborus environment can connect to a local IP or not." } @@ -17648,6 +17720,9 @@ const AngularWorkflow = (defaultprops) => { theme={theme.palette.jsonTheme} style={theme.palette.reactJsonStyle} collapsed={selectedResult.result.length < 10000 ? false : true} + iconStyle={theme.palette.jsonIconStyle} + collapseStringsAfterLength={theme.palette.jsonCollapseStringsAfterLength} + displayArrayKey={false} enableClipboard={(copy) => { handleReactJsonClipboard(copy); }} diff --git a/frontend/src/views/AppCreator.jsx b/frontend/src/views/AppCreator.jsx index 04e0d6be..e9db7736 100755 --- a/frontend/src/views/AppCreator.jsx +++ b/frontend/src/views/AppCreator.jsx @@ -2994,15 +2994,15 @@ const AppCreator = (defaultprops) => { toast("Auth URL must start with http(s)://"); } - if (tmpstring.includes("?")) { - var newtmp = tmpstring.split("?") - if (tmpstring.length > 1) { - tmpstring = newtmp[0] - } - } + if (tmpstring.includes("?")) { + var newtmp = tmpstring.split("?") + if (tmpstring.length > 1) { + tmpstring = newtmp[0] + } + } - setParameterName(tmpstring) - }} + setParameterName(tmpstring) + }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, @@ -6054,10 +6054,11 @@ const AppCreator = (defaultprops) => {