diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index a57927d3..8c0e8870 100755
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -476,8 +476,8 @@ const App = (message, props) => {
/>
}
/>
- {/* } />
- } /> */}
+ } />
+ } />
{
{hits.map((data, index) => {
const appUrl =
isCloud === true ?
- `/apps/${data.id}`
- : `https://shuffler.io/apps/${data.objectID}`;
+ `/apps/${data.objectID}`
+ : `apps/${data.objectID}`;
if (data.name === "" && data.id === "") {
return null
diff --git a/frontend/src/components/AppModal.jsx b/frontend/src/components/AppModal.jsx
index 5f33898c..c3deb1ae 100644
--- a/frontend/src/components/AppModal.jsx
+++ b/frontend/src/components/AppModal.jsx
@@ -590,7 +590,7 @@ const AppModal = ({ open, onClose, app, globalUrl, getApps }) => {
{
})
}
- var parsedUrl = isCloud ? `/apps/${hit.objectID}` : `https://shuffler.io/apps/${hit.objectID}`
+ var parsedUrl = isCloud ? `/apps/${hit.objectID}` : `/apps/${hit.objectID}`
parsedUrl += `?queryID=${hit.__queryID}`
return (
diff --git a/frontend/src/views/AppExplorer.jsx b/frontend/src/views/AppExplorer.jsx
index e746f75e..3fec4d41 100644
--- a/frontend/src/views/AppExplorer.jsx
+++ b/frontend/src/views/AppExplorer.jsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect, useContext } from "react";
+import React, { useState, useEffect, useContext, useRef } from "react";
import theme from "../theme.jsx";
import ReactGA from "react-ga4";
@@ -223,6 +223,7 @@ const AppExplorer = (props) => {
result: baseResult,
});
const [executing, setExecuting] = useState(false);
+ const [activatedApps, setActivatedApps] = useState([]);
const [anchorEl, setAnchorEl] = React.useState(null);
const [creatorProfile, setCreatorProfile] = React.useState({});
const [selectedTab, setSelectedTab] = React.useState(0);
@@ -247,6 +248,7 @@ const AppExplorer = (props) => {
})
const isCloud = (window.location.host === "localhost:3002" || window.location.host === "shuffler.io") ? true : (process.env.IS_SSR === "true");
+ const isFirstRequestSentRef = useRef(false);
// FIXME: This is used, as useEffect() creates an issue with apps not loading at all
@@ -299,13 +301,15 @@ const AppExplorer = (props) => {
if (serverside) {
console.log("Not getting app because serverside.");
} else {
- if (params.appid.length === 32 || params.appid.length === 36) {
- handleEditApp(params.appid);
- runAlgoliaAppSearch(params.appid, false, true);
- } else {
- runAlgoliaAppSearch(params.appid);
-
- //handleEditApp()
+ if (isCloud) {
+ if (params.appid.length === 32 || params.appid.length === 36) {
+ handleEditApp(params.appid);
+ runAlgoliaAppSearch(params.appid, false, true);
+ } else {
+ runAlgoliaAppSearch(params.appid);
+
+ //handleEditApp()
+ }
}
}
//parseIncomingOpenapiData(YAML.parse(data))
@@ -344,6 +348,86 @@ const AppExplorer = (props) => {
loadOrganization(userdata.active_org.id)
}
+ const getApps = () => {
+ // Get apps from localstorage
+ var storageApps = []
+ try {
+ const appstorage = localStorage.getItem("apps")
+ storageApps = JSON.parse(appstorage)
+ if (storageApps === null || storageApps === undefined || storageApps.length === 0) {
+ storageApps = []
+ } else {
+ setActivatedApps(storageApps)
+ }
+ } catch (e) {
+ //console.log("Failed to get apps from localstorage: ", e)
+ }
+
+
+ fetch(globalUrl + "/api/v1/apps", {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ },
+ credentials: "include",
+ })
+ .then((response) => {
+ if (response.status !== 200) {
+ console.log("Status not 200 for apps :O!");
+
+ //if (isCloud) {
+ // window.location.pathname = "/search";
+ //}
+ }
+
+ return response.json();
+ })
+ .then((responseJson) => {
+ var privateapps = [];
+ var valid = [];
+ var invalid = [];
+ for (var key in responseJson) {
+ const app = responseJson[key];
+
+ if (app.categories !== undefined && app.categories !== null && app?.categories.includes("Eradication")) {
+ app.categories = ["EDR"]
+ }
+
+ if (app.is_valid && !(!app.activated && app.generated)) {
+ privateapps.push(app);
+ } else if (
+ app.private_id !== undefined &&
+ app.private_id.length > 0
+ ) {
+ valid.push(app);
+ } else {
+ invalid.push(app);
+ }
+ }
+
+ privateapps.push(...valid);
+ privateapps.push(...invalid);
+ setActivatedApps(privateapps);
+
+ if (params.appid.length === 32 || params.appid.length === 36) {
+ handleEditApp(params.appid, privateapps);
+ runAlgoliaAppSearch(params.appid, false, true, privateapps);
+ } else {
+ runAlgoliaAppSearch(params.appid,true, false, privateapps);
+ }
+ })
+ .catch((error) => {
+ toast(error.toString());
+ });
+ };
+
+ useEffect(() => {
+ if (activatedApps?.length === 0 && !isCloud) {
+ getApps();
+ }
+ }, [activatedApps]);
+
var activateButton = (