removing the hard coded ui

This commit is contained in:
Hari Krishna
2024-06-18 12:43:19 +00:00
committed by satti-hari-krishna-reddy
parent e1e0e4ad9c
commit 29f294f2ef
+45 -141
View File
@@ -1437,7 +1437,7 @@ const releaseToConnectLabel = "Release to Connect"
}); });
}; };
const handleKafkaSubmit = (trigger) => { const handleCommandSubmit = (trigger) => {
if (trigger.trigger_type !== "PIPELINE") { if (trigger.trigger_type !== "PIPELINE") {
toast("Unable to save the configuration"); toast("Unable to save the configuration");
return; return;
@@ -1445,38 +1445,18 @@ const releaseToConnectLabel = "Release to Connect"
trigger.parameters = [] trigger.parameters = []
const topic = document.getElementById('topic')?.value; const command = document.getElementById('sigma')?.value
const bootstrapServers = document.getElementById('bootstrap_servers')?.value;
const groupId = document.getElementById('group_id')?.value;
//const autoOffsetReset = document.getElementById('auto_offset_reset')?.value;
if(topic) { if(command) {
trigger.parameters.push({ trigger.parameters.push({
name: "topic", name: "command",
value: topic value: command
}); })
} else { } else {
toast("please enter the topic name"); toast("Please enter the comamnd");
return; return;
} }
if (bootstrapServers) {
trigger.parameters.push({
name: "bootstrap_servers",
value: bootstrapServers
});
} else {
toast("please enter bootstrap server details");
return;
}
if (groupId) {
trigger.parameters.push({
name: "group_id",
value: groupId
});
}
// if (autoOffsetReset) { // if (autoOffsetReset) {
// trigger.parameters.push({ // trigger.parameters.push({
// name: "auto_offset_reset", // name: "auto_offset_reset",
@@ -15366,14 +15346,18 @@ const releaseToConnectLabel = "Release to Connect"
<div <div
key="syslogListener" key="syslogListener"
onClick={() => { onClick={() => {
// setSelectedOption("Syslog listener") if(selectedTrigger.status === "running"){
// setTenzirConfigModalOpen(true); toast("please stop the trigger to edit the configuration");
}} return;
} else {
setSelectedOption("Syslog listener");
setTenzirConfigModalOpen(true);
}}}
style={{ style={{
border: "1px solid rgba(255,255,255,0.3)", border: "1px solid rgba(255,255,255,0.3)",
borderRadius: theme.palette.borderRadius, borderRadius: theme.palette.borderRadius,
padding: 10, padding: 10,
cursor: "not-allowed", cursor: "pointer",
marginTop: 5, marginTop: 5,
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
@@ -15386,7 +15370,6 @@ const releaseToConnectLabel = "Release to Connect"
onChange={() => setSelectedOption("Syslog listener")} onChange={() => setSelectedOption("Syslog listener")}
value={"Syslog listener"} value={"Syslog listener"}
name="option" name="option"
disabled={true}
/> />
} }
label="Start Syslog listener" label="Start Syslog listener"
@@ -15396,14 +15379,18 @@ const releaseToConnectLabel = "Release to Connect"
<div <div
key="sigmaRulesearch" key="sigmaRulesearch"
onClick={() => { onClick={() => {
// setSelectedOption("Sigma Rulesearch") if(selectedTrigger.status === "running"){
// setTenzirConfigModalOpen(true); toast("please stop the trigger to edit the configuration");
}} return;
} else {
setSelectedOption("Sigma Rulesearch");
setTenzirConfigModalOpen(true);
}}}
style={{ style={{
border: "1px solid rgba(255,255,255,0.3)", border: "1px solid rgba(255,255,255,0.3)",
borderRadius: theme.palette.borderRadius, borderRadius: theme.palette.borderRadius,
padding: 10, padding: 10,
cursor: "not-allowed", cursor: "pointer",
marginTop: 5, marginTop: 5,
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
@@ -15416,7 +15403,6 @@ const releaseToConnectLabel = "Release to Connect"
onChange={() => setSelectedOption("Sigma Rulesearch")} onChange={() => setSelectedOption("Sigma Rulesearch")}
value={"Sigma Rulesearch"} value={"Sigma Rulesearch"}
name="option" name="option"
disabled={true}
/> />
} }
label="Run Sigma Rulesearch" label="Run Sigma Rulesearch"
@@ -15463,39 +15449,7 @@ const releaseToConnectLabel = "Release to Connect"
disabled={selectedTrigger.status === "running"} disabled={selectedTrigger.status === "running"}
onClick={() => { onClick={() => {
const topic = (selectedTrigger?.parameters?.find(param => param.name === "topic")?.value) || '' const command = (selectedTrigger?.parameters?.find(param => param.name === "command")?.value) || ''
const bootstrapServers = (selectedTrigger?.parameters?.find(param => param.name === "bootstrap_servers")?.value) || ''
const groupId = (selectedTrigger?.parameters?.find(param => param.name === "group_id")?.value) || ''
// const autoOffsetReset = (selectedTrigger?.parameters?.find(param => param.name === "auto_offset_reset")?.value) || ''
let command = "from kafka"
if(topic) {
command = `${command} -t ${topic}`
} else {
toast("please enter the topic name")
return;
}
if(bootstrapServers) {
command = `${command} -e -o stored -X bootstrap.servers=${bootstrapServers}`
} else {
toast("please enter the bootstrap servers details")
return;
}
if(groupId) {
command = `${command},group.id=${groupId}`
} else {
command = `${command},group.id=${selectedTrigger.id}`
}
// if(autoOffsetReset) {
// command = `${command},auto.offset.reset=${autoOffsetReset}`
// } else {
// command = `${command},auto.offset.reset=earliest`
// }
command = `${command},auto.offset.reset=earliest`
command = `${command},client.id=${selectedTrigger.id},enable.auto.commit=true,auto.commit.interval.ms=1`
command = `${command} read json | to ${globalUrl}/api/v1/pipelines/pipeline_${selectedTrigger.id}`
const pipelineConfig = { const pipelineConfig = {
command: command, command: command,
@@ -21218,8 +21172,8 @@ const releaseToConnectLabel = "Release to Connect"
pointerEvents: "auto", pointerEvents: "auto",
color: "white", color: "white",
minWidth: 600, minWidth: 600,
minHeight: 450, minHeight: 200,
maxHeight: 450, maxHeight: 200,
padding: 15, padding: 15,
overflow: "hidden", overflow: "hidden",
zIndex: 10012, zIndex: 10012,
@@ -21236,75 +21190,25 @@ const releaseToConnectLabel = "Release to Connect"
overflowY: "auto", overflowY: "auto",
overflowX: isMobile ? "auto" : "hidden", overflowX: isMobile ? "auto" : "hidden",
}} }}
> >
<DialogTitle id="tenzir-config-modal" style={{ cursor: "move" }}>
<div style={{ color: "white" }}>Configuration options for {selectedOption}</div>
</DialogTitle>
<DialogContent> <DialogContent>
{selectedOption === "Kafka Queue" && (
<> <b>command</b>
<b>Topic</b> <TextField
<TextField id="sigma"
id="topic" style={{
style={{ backgroundColor: theme.palette.inputColor,
backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius,
borderRadius: theme.palette.borderRadius, }}
}} InputProps={{
InputProps={{ style: {},
style: {}, }}
}} fullWidth
fullWidth color="primary"
color="primary" placeholder={"command"}
placeholder={"topic name"} defaultValue={(selectedTrigger?.parameters?.find(param => param.name === "command")?.value) || ''}
defaultValue={(selectedTrigger?.parameters?.find(param => param.name === "topic")?.value) || ''} />
/>
<b>bootstrap.servers</b>
<TextField
id="bootstrap_servers"
style={{
backgroundColor: theme.palette.inputColor,
borderRadius: theme.palette.borderRadius,
}}
InputProps={{
style: {},
}}
fullWidth
color="primary"
placeholder={"broker1.example.com:9092,192.168.1.100:9092"}
defaultValue={(selectedTrigger?.parameters?.find(param => param.name === "bootstrap_servers")?.value) || ''}
/>
<b>group.id</b>
<TextField
id="group_id"
style={{
backgroundColor: theme.palette.inputColor,
borderRadius: theme.palette.borderRadius,
}}
InputProps={{
style: {},
}}
fullWidth
color="primary"
placeholder={"tenzir"}
defaultValue={(selectedTrigger?.parameters?.find(param => param.name === "group_id")?.value) || ''}
/>
{/* <b>auto.offest.reset</b>
<TextField
id="auto_offset_reset"
style={{
backgroundColor: theme.palette.inputColor,
borderRadius: theme.palette.borderRadius,
}}
InputProps={{
style: {},
}}
fullWidth
color="primary"
placeholder={"earliest"}
defaultValue={(selectedTrigger?.parameters?.find(param => param.name === "auto_offset_reset")?.value) || ''}
/> */}
</>
)}
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button <Button
@@ -21319,7 +21223,7 @@ const releaseToConnectLabel = "Release to Connect"
<Button <Button
style={{ borderRadius: "0px" }} style={{ borderRadius: "0px" }}
onClick={() => { onClick={() => {
handleKafkaSubmit(selectedTrigger); handleCommandSubmit(selectedTrigger);
}} }}
color="primary" color="primary"
> >