mirror of
https://github.com/mblanke/ThreatHunt.git
synced 2026-03-01 14:00:20 -05:00
Refactoring pages. Added routing.
This commit is contained in:
@@ -1,11 +1,18 @@
|
|||||||
import React, { Suspense, useMemo, lazy } from "react";
|
import React, { Suspense, useMemo, lazy } from "react";
|
||||||
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
||||||
import { CssBaseline } from "@mui/material";
|
import { CssBaseline } from "@mui/material";
|
||||||
import { BrowserRouter, Routes, Route } from "react-router";
|
import { BrowserRouter, Routes, Route, Navigate } from "react-router";
|
||||||
|
|
||||||
import Sidebar from "./components/Sidebar";
|
import Sidebar from "./components/Sidebar";
|
||||||
const Baseline = lazy(() => import("./components/Baseline"));
|
|
||||||
const SecurityTools = lazy(() => import("./components/securitytools"));
|
const HomePage = lazy(() => import("./pages/HomePage"));
|
||||||
|
const ApplicationsPage = lazy(() => import("./pages/ApplicationsPage"));
|
||||||
|
const BaselinePage = lazy(() => import("./pages/BaselinePage"));
|
||||||
|
const CSVProcessingPage = lazy(() => import("./pages/CSVProcessingPage"));
|
||||||
|
const NetworkingPage = lazy(() => import("./pages/NetworkingPage"));
|
||||||
|
const SecurityToolsPage = lazy(() => import("./pages/SecurityToolsPage"));
|
||||||
|
const SettingsConfigPage = lazy(() => import("./pages/SettingsConfigPage"));
|
||||||
|
const VirusTotalPage = lazy(() => import("./pages/VirusTotalPage"));
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
|
||||||
@@ -22,19 +29,28 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
<CssBaseline />
|
<CssBaseline />
|
||||||
|
|
||||||
|
<BrowserRouter>
|
||||||
<div className="flex h-screen text-white">
|
<div className="flex h-screen text-white">
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<div className="flex-1 p-6 overflow-auto">
|
<div className="flex-1 p-6 overflow-auto">
|
||||||
<BrowserRouter>
|
|
||||||
<Suspense fallback={<div>Loading...</div>}>
|
<Suspense fallback={<div>Loading...</div>}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/baseline" element={<Baseline />} />
|
<Route index element={<HomePage />} />
|
||||||
<Route path="/securitytools" element={<SecurityTools />} />
|
<Route path="/baseline" element={<BaselinePage />} />
|
||||||
|
<Route path="/securitytools" element={<SecurityToolsPage />} />
|
||||||
|
<Route path="/applications" element={<ApplicationsPage />} />
|
||||||
|
<Route path="/csvprocessing" element={<CSVProcessingPage />} />
|
||||||
|
<Route path="/networking" element={<NetworkingPage />} />
|
||||||
|
<Route path="/settingsconfig" element={<SettingsConfigPage />} />
|
||||||
|
<Route path="/virustotal" element={<VirusTotalPage />} />
|
||||||
|
|
||||||
|
<Route path="*" element={<Navigate to="/" replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router';
|
||||||
import {
|
import {
|
||||||
ShieldCheck, Server, Bug, Lock, Globe, Settings,
|
ShieldCheck, Server, Bug, Lock, Globe, Settings,
|
||||||
ChevronDown, ChevronRight, Folder
|
ChevronDown, ChevronRight, Folder
|
||||||
@@ -8,15 +9,27 @@ import BugReportIcon from '@mui/icons-material/BugReport';
|
|||||||
import EngineeringIcon from '@mui/icons-material/Engineering';
|
import EngineeringIcon from '@mui/icons-material/Engineering';
|
||||||
|
|
||||||
|
|
||||||
const SidebarItem = ({ icon: Icon, label, children }) => {
|
const SidebarItem = ({ icon: Icon, label, href, children }) => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const hasChildren = !!children;
|
const hasChildren = !!children;
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const handleClick = () => {
|
||||||
|
if (hasChildren) {
|
||||||
|
setOpen(!open);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (href) {
|
||||||
|
navigate(href);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="text-sm w-full">
|
<div className="text-sm w-full">
|
||||||
<div
|
<div
|
||||||
className="flex items-center justify-between px-4 py-2 cursor-pointer rounded hover:bg-zinc-800 text-white transition-all"
|
className="flex items-center justify-between px-4 py-2 cursor-pointer rounded hover:bg-zinc-800 text-white transition-all"
|
||||||
onClick={() => hasChildren && setOpen(!open)}
|
onClick={handleClick}
|
||||||
>
|
>
|
||||||
<div className="flex items-center space-x-3">
|
<div className="flex items-center space-x-3">
|
||||||
<Icon className="w-5 h-5 text-cyan-400" />
|
<Icon className="w-5 h-5 text-cyan-400" />
|
||||||
@@ -38,18 +51,18 @@ const SidebarItem = ({ icon: Icon, label, children }) => {
|
|||||||
const Sidebar = () => (
|
const Sidebar = () => (
|
||||||
<div className="h-screen w-64 shadow-lg p-4 flex flex-col space-y-2">
|
<div className="h-screen w-64 shadow-lg p-4 flex flex-col space-y-2">
|
||||||
<h2 className="text-xl font-bold text-white mb-4">Threat Hunt Dashboard</h2>
|
<h2 className="text-xl font-bold text-white mb-4">Threat Hunt Dashboard</h2>
|
||||||
<SidebarItem icon={ShieldCheck} label="HomePage" />
|
<SidebarItem icon={ShieldCheck} label="HomePage" href="/" />
|
||||||
<SidebarItem icon={Server} label="Baseline" />
|
<SidebarItem icon={Server} label="Baseline" href="/baseline" />
|
||||||
<SidebarItem icon={Bug} label="Networking" />
|
<SidebarItem icon={Bug} label="Networking" href="/networking" />
|
||||||
<SidebarItem icon={Folder} label="Applications" />
|
<SidebarItem icon={Folder} label="Applications" href="/applications" />
|
||||||
<SidebarItem icon={Globe} label="CSV Processing" />
|
<SidebarItem icon={Globe} label="CSV Processing" href="/csvprocessing" />
|
||||||
<SidebarItem icon={Settings} label="Security Tools">
|
<SidebarItem icon={Settings} label="Security Tools">
|
||||||
<div>Anti Virus</div>
|
<div>Anti Virus</div>
|
||||||
<div>Endpoint Detection & Response</div>
|
<div>Endpoint Detection & Response</div>
|
||||||
<div>Virtual Private Networks</div>
|
<div>Virtual Private Networks</div>
|
||||||
</SidebarItem>
|
</SidebarItem>
|
||||||
<SidebarItem icon={BugReportIcon} label="Virus Totals" />
|
<SidebarItem icon={BugReportIcon} label="Virus Totals" href="/virustotal" />
|
||||||
<SidebarItem icon={EngineeringIcon} label="Settings & Config" />
|
<SidebarItem icon={EngineeringIcon} label="Settings & Config" href="/settingsconfig" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const Applications = () => {
|
const ApplicationsPage = () => {
|
||||||
return <div>Applications Placeholder</div>;
|
return <div>Applications Placeholder</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Applications;
|
export default ApplicationsPage;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
const Baseline = () => {
|
const BaselinePage = () => {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -77,4 +77,4 @@ const Baseline = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Baseline;
|
export default BaselinePage;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const CSVProcessing = () => {
|
const CSVProcessingPage = () => {
|
||||||
return <div>CSV Processing Placeholder</div>;
|
return <div>CSV Processing Placeholder</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CSVProcessing;
|
export default CSVProcessingPage;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const Networking = () => {
|
const NetworkingPage = () => {
|
||||||
return <div>Networking Placeholder</div>;
|
return <div>Networking Placeholder</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Networking;
|
export default NetworkingPage;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useCallback } from "react";
|
import React, { useState, useCallback } from "react";
|
||||||
import { useDropzone } from "react-dropzone";
|
import { useDropzone } from "react-dropzone";
|
||||||
|
|
||||||
const SecurityTools = () => {
|
const SecurityToolsPage = () => {
|
||||||
const [uploadStatus, setUploadStatus] = useState(null);
|
const [uploadStatus, setUploadStatus] = useState(null);
|
||||||
const [analysisResult, setAnalysisResult] = useState(null);
|
const [analysisResult, setAnalysisResult] = useState(null);
|
||||||
|
|
||||||
@@ -61,4 +61,4 @@ const SecurityTools = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SecurityTools;
|
export default SecurityToolsPage;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const SettingsConfig = () => {
|
const SettingsConfigPage = () => {
|
||||||
return <div>Settings & Config Placeholder</div>;
|
return <div>Settings & Config Placeholder</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SettingsConfig;
|
export default SettingsConfigPage;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const VirusTotal = () => {
|
const VirusTotalPage = () => {
|
||||||
return <div>Virus Total Placeholder</div>;
|
return <div>Virus Total Placeholder</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default VirusTotal;
|
export default VirusTotalPage;
|
||||||
Reference in New Issue
Block a user