diff --git a/client/src/App.tsx b/client/src/App.tsx index 0ed79af..9585a60 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -23,14 +23,14 @@ const App: React.FC = () => { } /> } /> - {user !== null && <> + {/* {user !== null && <> */} } /> } /> } /> - } + {/* } */} ); diff --git a/client/src/components/charts/AnomalyChart.tsx b/client/src/components/charts/AnomalyChart.tsx new file mode 100644 index 0000000..547195d --- /dev/null +++ b/client/src/components/charts/AnomalyChart.tsx @@ -0,0 +1,68 @@ +import React from 'react'; +import { + ScatterChart, + Scatter, + XAxis, + YAxis, + CartesianGrid, + Tooltip, + ResponsiveContainer, + Legend, +} from 'recharts'; + +interface DataPoint { + timestamp: string; + count: number; +} + +const dummyData: DataPoint[] = [ + { timestamp: '2024-10-29T09:00:00Z', count: 30 }, + { timestamp: '2024-10-29T09:10:00Z', count: 25 }, + { timestamp: '2024-10-29T09:20:00Z', count: 80 }, + { timestamp: '2024-10-29T09:30:00Z', count: 40 }, + { timestamp: '2024-10-29T09:40:00Z', count: 50 }, + { timestamp: '2024-10-29T09:50:00Z', count: 90 }, + { timestamp: '2024-10-29T10:00:00Z', count: 45 }, +]; + +const isAnomaly = (count: number): boolean => count > 70; // Define a threshold for anomalies + +const AnomalyChart: React.FC = () => { + return ( + + + + new Date(time).toLocaleTimeString()} + /> + + + + + {dummyData.map((entry, index) => { + const x = new Date(entry.timestamp).getTime(); + const y = entry.count; + return ( + + ); + })} + + + + ); +}; + +export default AnomalyChart; diff --git a/client/src/pages/Home.tsx b/client/src/pages/Home.tsx index b3c4f4e..4d58a2d 100644 --- a/client/src/pages/Home.tsx +++ b/client/src/pages/Home.tsx @@ -1,22 +1,38 @@ import React, { lazy, useState } from 'react'; -import { DragDropContext, Droppable, Draggable, DropResult } from '@hello-pangea/dnd'; +import { + DragDropContext, + Droppable, + Draggable, + DropResult, +} from '@hello-pangea/dnd'; import { CardState } from '../types'; const Card = lazy(() => import('../components/Card')); -const UserActivityChart = lazy(() => import('../components/charts/UserActivity')); +const UserActivityChart = lazy( + () => import('../components/charts/UserActivity') +); const HeatMap = lazy(() => import('../components/charts/HeatMap')); const IpAccessCombined = lazy(() => import('../components/IpAccessCombined')); const EventTypeChart = lazy(() => import('../components/charts/EventType')); const EventSourceChart = lazy(() => import('../components/charts/EventSource')); +const AnomalyChart = lazy(() => import('../components/charts/AnomalyChart')); const Home: React.FC<{ isDarkMode: boolean }> = ({ isDarkMode }) => { // State to track the current IP (null means no IP selected) const [currentIp, setCurrentIp] = useState(); const [cards, setCards] = useState([ - { id: 'userActivity', title: 'User Activity', component: }, + { + id: 'userActivity', + title: 'User Activity', + component: , + }, { id: 'eventTypes', title: 'Event Types', component: }, - { id: 'eventSources', title: 'Event Sources', component: }, + { + id: 'eventSources', + title: 'Event Sources', + component: , + }, { id: 'heatMap', title: 'IP Address Heat Map', component: }, { id: 'ipAccess', @@ -28,6 +44,11 @@ const Home: React.FC<{ isDarkMode: boolean }> = ({ isDarkMode }) => { /> ), }, + { + id: 'anomalyDetection', + title: 'Anomaly Detection', + component: , + }, ]); const handleDragEnd = (result: DropResult) => {