diff --git a/frontend/src/views/Detection.jsx b/frontend/src/views/Detection.jsx
index f7e2d135..3f909758 100644
--- a/frontend/src/views/Detection.jsx
+++ b/frontend/src/views/Detection.jsx
@@ -10,12 +10,7 @@ import {
import { Publish as PublishIcon } from "@mui/icons-material";
import { toast } from "react-toastify";
import RuleCard from "./RuleCard";
-import { styled } from "@mui/system";
-
-const ConnectedButton = styled(Button)(({ theme, isConnected }) => ({
- backgroundColor: isConnected ? "green" : "red",
- color: "white",
-}));
+import CircularProgress from "@material-ui/core/CircularProgress";
const handleDirectoryChange = (folderDisabled, setFolderDisabled, globalUrl) => {
const action = folderDisabled ? "enable_folder" : "disable_folder";
@@ -54,6 +49,7 @@ const Detection = ({
}) => {
const [searchQuery, setSearchQuery] = useState("");
const uploadRef = useRef(null);
+ const [loading, setLoading] = useState(false);
const uploadFiles = (files) => {
for (const key in files) {
@@ -136,6 +132,41 @@ const Detection = ({
});
};
+ const handleConnectClick = () => {
+ if (!isTenzirActive) {
+ setLoading(true);
+ const url = `${globalUrl}/api/v1/detection/siem/connect`;
+
+ fetch(url, {
+ method: "GET",
+ credentials: "include",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ })
+ .then((response) =>
+ response.json().then((responseJson) => {
+ if (responseJson["success"] === true) {
+ setTimeout(() => {
+ setLoading(false);
+ window.location.reload();
+ }, 5000);
+ } else {
+ setLoading(false);
+ toast("Failed to connect to SIEM");
+ }
+ })
+ )
+ .catch((error) => {
+ setLoading(false);
+ console.log(`Error in connecting to SIEM: `, error);
+ toast("An error occurred while connecting to SIEM");
+ });
+ } else {
+ console.log("Already connected to SIEM");
+ }
+ };
+
const filteredRules = ruleInfo?.filter((rule) =>
rule.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
rule.description.toLowerCase().includes(searchQuery.toLowerCase())
@@ -155,9 +186,14 @@ const Detection = ({
Sigma Detection Rules
-
- {isTenzirActive ? "Connected to SIEM" : "Not Connected to SIEM"}
-
+
setSearchQuery(e.target.value)}
/>
-