fixing bugs in rule editing

This commit is contained in:
Hari Krishna
2024-06-13 09:54:50 +00:00
committed by satti-hari-krishna-reddy
parent 809fc2c202
commit e90b698f84
3 changed files with 35 additions and 21 deletions
+23 -13
View File
@@ -18,7 +18,7 @@ const ConnectedButton = styled(Button)({
const Detection = ({ globalUrl, ruleInfo, openEditBar }) => { const Detection = ({ globalUrl, ruleInfo, openEditBar }) => {
return ( return (
<Container sx={{ mt: 4 }}> <Container sx={{ mt: 4 }}>
<Box sx={{ border: "1px solid #ccc", borderRadius: 2, p: 3 }}> <Box sx={{ border: "1px solid #ccc", borderRadius: 2, p: 3}}>
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",
@@ -50,18 +50,28 @@ const Detection = ({ globalUrl, ruleInfo, openEditBar }) => {
<Switch defaultChecked /> <Switch defaultChecked />
</Box> </Box>
</Box> </Box>
{ruleInfo.length > 0 && <Box
ruleInfo.map((card) => ( sx={{
<RuleCard height: "500px",
key={card.file_id} width: "100%",
ruleName={card.title} overflowY: "auto",
description={card.description} border: "1px solid #ddd",
file_id={card.file_id} p: 1,
globalUrl={globalUrl} }}
openEditBar={() => openEditBar(card)} >
{...card} {ruleInfo.length > 0 &&
/> ruleInfo.map((card) => (
))} <RuleCard
key={card.file_id}
ruleName={card.title}
description={card.description}
file_id={card.file_id}
globalUrl={globalUrl}
openEditBar={() => openEditBar(card)}
{...card}
/>
))}
</Box>
</Box> </Box>
</Container> </Container>
); );
+9 -2
View File
@@ -39,6 +39,12 @@ const DetectionDashBoard = (props) => {
getSigmaInfo(globalUrl, setRuleInfo); getSigmaInfo(globalUrl, setRuleInfo);
}, [globalUrl]); }, [globalUrl]);
useEffect(() => {
if (ruleInfo.length > 0) {
openEditBar(ruleInfo[0]);
}
}, [ruleInfo]);
const openEditBar = (rule) => { const openEditBar = (rule) => {
setSelectedRule(rule); setSelectedRule(rule);
getFileContent(rule.file_id) getFileContent(rule.file_id)
@@ -50,6 +56,7 @@ const DetectionDashBoard = (props) => {
}; };
const getFileContent = (file_id) => { const getFileContent = (file_id) => {
setFileData("");
fetch(globalUrl + "/api/v1/files/" + file_id + "/content", { fetch(globalUrl + "/api/v1/files/" + file_id + "/content", {
method: "GET", method: "GET",
headers: { headers: {
@@ -82,10 +89,10 @@ const DetectionDashBoard = (props) => {
}; };
return ( return (
<Container style={{display: "flex", width: "100%"}}> <Container style={{display: "flex"}}>
{selectedRule ? ( {selectedRule ? (
<EditComponent <EditComponent
ruleName={selectedRule.ruleName} ruleName={selectedRule.title}
description={selectedRule.description} description={selectedRule.description}
content={fileData} content={fileData}
setContent={setFileData} setContent={setFileData}
+2 -5
View File
@@ -8,12 +8,9 @@ const EditComponent = ({ ruleName, description, content, setContent, lastEdited,
}; };
return ( return (
<Box sx={{ p: 2, border: '1px solid #ccc', borderRadius: 2, width: '100%' }}> <Box sx={{ p: 2, border: '1px solid #ccc', borderRadius: 2, height: '100%', width: '100%', marginTop:'30px'}}>
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Typography variant="body2" style={{ marginTop: '2%' }}>{ruleName}</Typography> <Typography variant="h6">{ruleName}</Typography>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<Switch checked={true} />
</Box>
</Box> </Box>
<Typography variant="body2" style={{ marginTop: '2%' }}> <Typography variant="body2" style={{ marginTop: '2%' }}>
{description} {description}