Made automatic builds of apps happen when an app is selected onprem
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
|
|
||||||
import { securityFramework} from "./LandingpageUsecases.jsx";
|
|
||||||
import CytoscapeComponent from 'react-cytoscapejs';
|
import CytoscapeComponent from 'react-cytoscapejs';
|
||||||
import frameworkStyle from '../frameworkStyle.jsx';
|
import frameworkStyle from '../frameworkStyle.jsx';
|
||||||
import AppSearch from './Appsearch.jsx';
|
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import theme from '../theme';
|
import theme from '../theme';
|
||||||
import { useAlert } from "react-alert";
|
import { useAlert } from "react-alert";
|
||||||
import { usecaseTypes } from "../components/UsecaseSearch.jsx"
|
|
||||||
|
import AppSearch from '../components/Appsearch.jsx';
|
||||||
import PaperComponent from "../components/PaperComponent.jsx"
|
import PaperComponent from "../components/PaperComponent.jsx"
|
||||||
|
import { usecaseTypes } from "../components/UsecaseSearch.jsx"
|
||||||
import SuggestedWorkflows from "../components/SuggestedWorkflows.jsx"
|
import SuggestedWorkflows from "../components/SuggestedWorkflows.jsx"
|
||||||
|
import { securityFramework} from "../components/LandingpageUsecases.jsx";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Paper,
|
Paper,
|
||||||
@@ -751,7 +752,41 @@ const AppFramework = (props) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const activateApp = (appid) => {
|
||||||
|
fetch(globalUrl+"/api/v1/apps/"+appid+"/activate", {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
credentials: "include",
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response.status !== 200) {
|
||||||
|
console.log("Failed to activate")
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json()
|
||||||
|
})
|
||||||
|
.then((responseJson) => {
|
||||||
|
if (responseJson.success === false) {
|
||||||
|
alert.error("Failed to activate the app")
|
||||||
|
} else {
|
||||||
|
//alert.success("App activated for your organization! Refresh the page to use the app.")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
//alert.error(error.toString())
|
||||||
|
console.log("Activate app error: ", error.toString())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const setFrameworkItem = (data) => {
|
const setFrameworkItem = (data) => {
|
||||||
|
console.log("Setting framework item: ", data, isCloud)
|
||||||
|
if (!isCloud) {
|
||||||
|
activateApp(data.id)
|
||||||
|
}
|
||||||
|
|
||||||
fetch(globalUrl + "/api/v1/apps/frameworkConfiguration", {
|
fetch(globalUrl + "/api/v1/apps/frameworkConfiguration", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
CheckCircleRounded as CheckCircleRoundedIcon,
|
CheckCircleRounded as CheckCircleRoundedIcon,
|
||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
import { FixName } from "../views/Apps.jsx";
|
import { FixName } from "../views/Apps.jsx";
|
||||||
|
import aa from 'search-insights'
|
||||||
|
|
||||||
// Handles workflow updates on first open to highlight the issues of the workflow
|
// Handles workflow updates on first open to highlight the issues of the workflow
|
||||||
// Variables
|
// Variables
|
||||||
@@ -32,6 +33,7 @@ import { FixName } from "../views/Apps.jsx";
|
|||||||
// Specifically used for UNSAVED workflows only?
|
// Specifically used for UNSAVED workflows only?
|
||||||
const ConfigureWorkflow = (props) => {
|
const ConfigureWorkflow = (props) => {
|
||||||
const {
|
const {
|
||||||
|
userdata,
|
||||||
globalUrl,
|
globalUrl,
|
||||||
theme,
|
theme,
|
||||||
workflow,
|
workflow,
|
||||||
@@ -526,6 +528,26 @@ const ConfigureWorkflow = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const activateApp = (app_id, app_name, app_version) => {
|
const activateApp = (app_id, app_name, app_version) => {
|
||||||
|
|
||||||
|
if (aa !== undefined) {
|
||||||
|
aa('init', {
|
||||||
|
appId: "JNSS5CFDZZ",
|
||||||
|
apiKey: "db08e40265e2941b9a7d8f644b6e5240",
|
||||||
|
})
|
||||||
|
|
||||||
|
const timestamp = new Date().getTime()
|
||||||
|
aa('sendEvents', [
|
||||||
|
{
|
||||||
|
eventType: 'conversion',
|
||||||
|
eventName: 'Public App Activated',
|
||||||
|
index: 'appsearch',
|
||||||
|
objectIDs: [app_id],
|
||||||
|
timestamp: timestamp,
|
||||||
|
userToken: userdata === undefined || userdata === null || userdata.id === undefined ? "unauthenticated" : userdata.id,
|
||||||
|
}
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
fetch(
|
fetch(
|
||||||
`${globalUrl}/api/v1/apps/${app_id}/activate?app_name=${app_name}&app_version=${app_version}`,
|
`${globalUrl}/api/v1/apps/${app_id}/activate?app_name=${app_name}&app_version=${app_version}`,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import theme from '../theme';
|
import theme from '../theme';
|
||||||
|
import { useNavigate, Link } from "react-router-dom";
|
||||||
import { useAlert } from "react-alert";
|
import { useAlert } from "react-alert";
|
||||||
import ConfigureWorkflow from "../components/ConfigureWorkflow.jsx";
|
import ConfigureWorkflow from "../components/ConfigureWorkflow.jsx";
|
||||||
import PaperComponent from "../components/PaperComponent.jsx"
|
import PaperComponent from "../components/PaperComponent.jsx"
|
||||||
@@ -785,9 +786,90 @@ const UsecaseSearch = (props) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stolen from /views/Workflows
|
||||||
|
// Due to states, not easy to just import as component~
|
||||||
|
const setNewWorkflow = (
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
tags,
|
||||||
|
defaultReturnValue,
|
||||||
|
editingWorkflow,
|
||||||
|
redirect,
|
||||||
|
currentUsecases,
|
||||||
|
inputblogpost,
|
||||||
|
inputstatus,
|
||||||
|
) => {
|
||||||
|
var method = "POST";
|
||||||
|
var extraData = "";
|
||||||
|
var workflowdata = {};
|
||||||
|
|
||||||
|
if (editingWorkflow.id !== undefined) {
|
||||||
|
console.log("Building original workflow");
|
||||||
|
method = "PUT";
|
||||||
|
extraData = "/" + editingWorkflow.id + "?skip_save=true";
|
||||||
|
workflowdata = editingWorkflow;
|
||||||
|
|
||||||
|
console.log("REMOVING OWNER");
|
||||||
|
workflowdata["owner"] = "";
|
||||||
|
// FIXME: Loop triggers and turn them off?
|
||||||
|
}
|
||||||
|
|
||||||
|
workflowdata["name"] = name;
|
||||||
|
workflowdata["description"] = description;
|
||||||
|
if (tags !== undefined) {
|
||||||
|
workflowdata["tags"] = tags;
|
||||||
|
}
|
||||||
|
workflowdata["blogpost"] = inputblogpost
|
||||||
|
workflowdata["status"] = inputstatus
|
||||||
|
|
||||||
|
if (defaultReturnValue !== undefined) {
|
||||||
|
workflowdata["default_return_value"] = defaultReturnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentUsecases !== undefined && currentUsecases !== null) {
|
||||||
|
workflowdata["usecase_ids"] = currentUsecases
|
||||||
|
//workflows[0].category = ["detect"]
|
||||||
|
//workflows[0].usecase_ids = ["Correlate tickets"]
|
||||||
|
}
|
||||||
|
|
||||||
|
const new_url = `${globalUrl}/api/v1/workflows${extraData}`
|
||||||
|
return fetch(new_url, {
|
||||||
|
method: method,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(workflowdata),
|
||||||
|
credentials: "include",
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response.status !== 200) {
|
||||||
|
console.log("Status not 200 for workflows :O!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then((responseJson) => {
|
||||||
|
if (responseJson.success === false) {
|
||||||
|
if (responseJson.reason !== undefined) {
|
||||||
|
alert.error("Error setting workflow: ", responseJson.reason)
|
||||||
|
} else {
|
||||||
|
alert.error("Error setting workflow.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseJson;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
alert.error(error.toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const mergeWorkflowUsecases = (usecasedata) => {
|
const mergeWorkflowUsecases = (usecasedata) => {
|
||||||
//const url = `${globalUrl}/api/v1/workflows/merge`;
|
//const url = `${globalUrl}/api/v1/workflows/merge`;
|
||||||
//const url = `https://0360-178-232-150-183.ngrok.io/api/v1/workflows/merge`;
|
|
||||||
const url = `https://shuffler.io/api/v1/workflows/merge`;
|
const url = `https://shuffler.io/api/v1/workflows/merge`;
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
mode: "cors",
|
mode: "cors",
|
||||||
@@ -845,10 +927,57 @@ const UsecaseSearch = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Gets a full workflow that has to be handled from cloud directly
|
||||||
|
//
|
||||||
if (!isCloud) {
|
if (!isCloud) {
|
||||||
console.log("Not cloud!")
|
console.log("Not cloud!")
|
||||||
|
if (setFoundWorkflowId !== undefined) {
|
||||||
setFoundWorkflowId(responseJson.id)
|
setFoundWorkflowId(responseJson.id)
|
||||||
|
}
|
||||||
setWorkflow(responseJson)
|
setWorkflow(responseJson)
|
||||||
|
|
||||||
|
setNewWorkflow(
|
||||||
|
responseJson.name,
|
||||||
|
responseJson.description,
|
||||||
|
responseJson.tags,
|
||||||
|
responseJson.default_return_value,
|
||||||
|
{},
|
||||||
|
false,
|
||||||
|
[],
|
||||||
|
"",
|
||||||
|
responseJson.status,
|
||||||
|
)
|
||||||
|
.then((response) => {
|
||||||
|
if (response !== undefined) {
|
||||||
|
// SET THE FULL THING
|
||||||
|
responseJson.id = response.id;
|
||||||
|
responseJson.first_save = false;
|
||||||
|
responseJson.previously_saved = false;
|
||||||
|
responseJson.is_valid = false;
|
||||||
|
|
||||||
|
// Actually create it
|
||||||
|
setNewWorkflow(
|
||||||
|
responseJson.name,
|
||||||
|
responseJson.description,
|
||||||
|
responseJson.tags,
|
||||||
|
responseJson.default_return_value,
|
||||||
|
responseJson,
|
||||||
|
false,
|
||||||
|
[],
|
||||||
|
"",
|
||||||
|
responseJson.status,
|
||||||
|
).then((response) => {
|
||||||
|
if (response !== undefined) {
|
||||||
|
alert.success("Successfully generated " + responseJson.name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
alert.error("Generate error: " + error.toString());
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
} else if (isCloud) {
|
} else if (isCloud) {
|
||||||
if (responseJson.workflow_id !== null && responseJson.workflow_id !== undefined) {
|
if (responseJson.workflow_id !== null && responseJson.workflow_id !== undefined) {
|
||||||
if (responseJson.added_auth !== undefined && responseJson.added_auth !== null && responseJson.added_auth.length > 0) {
|
if (responseJson.added_auth !== undefined && responseJson.added_auth !== null && responseJson.added_auth.length > 0) {
|
||||||
@@ -1077,8 +1206,41 @@ const UsecaseSearch = (props) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
//console.log("Data: ", data)
|
//console.log("Data: ", data)
|
||||||
|
const activateApp = (appid) => {
|
||||||
|
fetch(globalUrl+"/api/v1/apps/"+appid+"/activate", {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
credentials: "include",
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response.status !== 200) {
|
||||||
|
console.log("Failed to activate")
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json()
|
||||||
|
})
|
||||||
|
.then((responseJson) => {
|
||||||
|
if (responseJson.success === false) {
|
||||||
|
alert.error("Failed to activate the app")
|
||||||
|
} else {
|
||||||
|
//alert.success("App activated for your organization! Refresh the page to use the app.")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
//alert.error(error.toString())
|
||||||
|
console.log("Activate app error: ", error.toString())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const setFrameworkItem = (data) => {
|
const setFrameworkItem = (data) => {
|
||||||
|
// Making sure the app is being auto-built and added
|
||||||
|
if (!isCloud) {
|
||||||
|
activateApp(data.id)
|
||||||
|
}
|
||||||
|
|
||||||
fetch(globalUrl + "/api/v1/apps/frameworkConfiguration", {
|
fetch(globalUrl + "/api/v1/apps/frameworkConfiguration", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ const WelcomeForm = (props) => {
|
|||||||
const foundTab = params["tab"];
|
const foundTab = params["tab"];
|
||||||
if (foundTab !== null && foundTab !== undefined && !isNaN(foundTab)) {
|
if (foundTab !== null && foundTab !== undefined && !isNaN(foundTab)) {
|
||||||
if (foundTab === 3 || foundTab === "3") {
|
if (foundTab === 3 || foundTab === "3") {
|
||||||
console.log("SET SEARCH!!")
|
//console.log("Set search!")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//navigate(`/welcome?tab=1`)
|
//navigate(`/welcome?tab=1`)
|
||||||
@@ -380,8 +380,6 @@ const WelcomeForm = (props) => {
|
|||||||
console.log("Selected app changed (effect)")
|
console.log("Selected app changed (effect)")
|
||||||
}, [newSelectedApp])
|
}, [newSelectedApp])
|
||||||
|
|
||||||
console.log("Clickdiff: ", clickdiff)
|
|
||||||
|
|
||||||
//const buttonWidth = 145
|
//const buttonWidth = 145
|
||||||
const buttonWidth = 450
|
const buttonWidth = 450
|
||||||
const buttonMargin = 10
|
const buttonMargin = 10
|
||||||
|
|||||||
Reference in New Issue
Block a user