FIXES: Added wazuh integration and loads more

This commit is contained in:
frikky
2020-12-22 11:41:11 +01:00
parent 2248e407f7
commit 8a99fb6048
17 changed files with 333 additions and 93 deletions
+28
View File
@@ -470,6 +470,33 @@ const Admin = (props) => {
})
}
const flushQueue = (name) => {
// Just use this one?
const url = globalUrl + '/api/v1/flush_queue';
fetch(url, {
method: 'DELETE',
credentials: "include",
headers: {
'Content-Type': 'application/json',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
alert.error(responseJson.reason)
getEnvironments()
} else {
setLoginInfo("")
setModalOpen(false)
getEnvironments()
}
}),
)
.catch(error => {
console.log("Error when deleting: ", error)
})
}
const deleteEnvironment = (name) => {
// FIXME - add some check here ROFL
alert.info("Deleting environment " + name)
@@ -2094,6 +2121,7 @@ const Admin = (props) => {
style={{minWidth: 150, maxWidth: 150, overflow: "hidden"}}
>
<Button disabled={environment.archived} variant="outlined" style={{borderRadius: "0px"}} onClick={() => deleteEnvironment(environment.Name)} color="primary">Archive</Button>
{/*<Button disabled={environment.archived} variant="outlined" style={{borderRadius: "0px"}} onClick={() => flushQueue(environment.Name)} color="primary">Flush Queue</Button>*/}
</ListItemText>
<ListItemText
style={{minWidth: 150, maxWidth: 150, overflow: "hidden"}}
+31 -9
View File
@@ -192,7 +192,7 @@ const AngularWorkflow = (props) => {
const cloudSyncEnabled = props.userdata !== undefined && props.userdata.active_org !== null && props.userdata.active_org !== undefined ? props.userdata.active_org.cloud_sync === true : false
//const triggerEnvironments = cloudSyncEnabled ? ["cloud", "onprem"] : environments
const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"
const triggerEnvironments = isCloud ? ["cloud"] : ["cloud", "onprem"]
const triggerEnvironments = isCloud ? ["cloud"] : ["onprem", "cloud"]
const unloadText = 'Are you sure you want to leave without saving (CTRL+S)?'
useBeforeunload(() => {
@@ -2663,7 +2663,6 @@ const AngularWorkflow = (props) => {
foundResult.result = foundResult.result.split(" None").join(" \"None\"")
foundResult.result = foundResult.result.split(" False").join(" false")
foundResult.result = foundResult.result.split(" True").join(" true")
foundResult.result = foundResult.result.split("\'").join("\"")
var jsonvalid = true
try {
@@ -2672,7 +2671,15 @@ const AngularWorkflow = (props) => {
jsonvalid = false
}
} catch (e) {
jsonvalid = false
try {
foundResult.result = foundResult.result.split("\'").join("\"")
const tmp = String(JSON.parse(foundResult.result))
if (!foundResult.result.includes("{") && !foundResult.result.includes("[")) {
jsonvalid = false
}
} catch (e) {
jsonvalid = false
}
}
// Finds the FIRST json only
@@ -5874,7 +5881,6 @@ const AngularWorkflow = (props) => {
const parsedExecutionArgument = () => {
var showResult = executionData.execution_argument.trim()
showResult = showResult.split(" None").join(" \"None\"")
showResult = showResult.split("\'").join("\"")
showResult = showResult.split(" False").join(" false")
showResult = showResult.split(" True").join(" true")
@@ -5885,7 +5891,16 @@ const AngularWorkflow = (props) => {
jsonvalid = false
}
} catch (e) {
jsonvalid = false
showResult = showResult.split("\'").join("\"")
try {
const tmp = String(JSON.parse(showResult))
if (!showResult.includes("{") && !showResult.includes("[")) {
jsonvalid = false
}
} catch (e) {
jsonvalid = false
}
}
if (jsonvalid) {
@@ -6070,21 +6085,28 @@ const AngularWorkflow = (props) => {
//
// FIXME: The latter replace doens't really work if ' is used in a string
var showResult = data.result.trim()
//console.log(showResult)
showResult = showResult.split(" None").join(" \"None\"")
showResult = showResult.split(" False").join(" false")
showResult = showResult.split(" True").join(" true")
showResult = showResult.split("\'").join("\"")
var jsonvalid = true
try {
const tmp = String(JSON.parse(showResult))
if (!showResult.includes("{") && !showResult.includes("[")) {
//console.log("IN HERE: ", tmp)
jsonvalid = false
}
} catch (e) {
//console.log("Error: ", e)
jsonvalid = false
showResult = showResult.split("\'").join("\"")
try {
const tmp = String(JSON.parse(showResult))
if (!showResult.includes("{") && !showResult.includes("[")) {
jsonvalid = false
}
} catch (e) {
jsonvalid = false
}
}
const curapp = apps.find(a => a.name === data.action.app_name && a.app_version === data.action.app_version)
+4
View File
@@ -46,6 +46,10 @@ const inputColor = "#383B40"
export const GetParsedPaths = (inputdata, basekey) => {
const splitkey = " > "
var parsedValues = []
if (inputdata === undefined || inputdata === null) {
return parsedValues
}
if (typeof(inputdata) !== "object") {
return parsedValues
}
+3 -2
View File
@@ -69,7 +69,7 @@ const LoginDialog = props => {
}),
)
.catch(error => {
setLoginInfo("Error in userdata: ", error)
setLoginInfo("Error logging in: ", error)
})
}
@@ -80,6 +80,7 @@ const LoginDialog = props => {
const onSubmit = (e) => {
e.preventDefault()
setLoginInfo("")
// FIXME - add some check here ROFL
// Just use this one?
@@ -114,7 +115,7 @@ const LoginDialog = props => {
}),
)
.catch(error => {
setLoginInfo("Error in userdata: " + error)
setLoginInfo("Error logging in: " + error)
});
} else {
url = baseurl + '/api/v1/users/register';