From 1986412f82ae6451c198f3cd7ffd2ececd7f99f2 Mon Sep 17 00:00:00 2001 From: Lukas Davidovic Date: Wed, 8 May 2024 17:55:29 +0200 Subject: [PATCH] public dashboard --- pages/dashboard.tsx | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 pages/dashboard.tsx diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx new file mode 100644 index 0000000..ad9016e --- /dev/null +++ b/pages/dashboard.tsx @@ -0,0 +1,52 @@ +import { useState, useEffect } from 'react' +import type { NextPage } from 'next' +import Head from 'next/head' +import Link from 'next/link' + +interface Stats { + total_sources: number + high_risk_sources: number + categories_breakdown: { [key: string]: number } + top_domains: { domain: string; count: number; risk_level: number }[] +} + +const Dashboard: NextPage = () => { + const [stats, setStats] = useState(null) + + useEffect(() => { + fetch('/api/stats') + .then(res => res.json()) + .then(setStats) + }, []) + + return ( +
+ Verejný dashboard - Infohliadka +
+

Verejný dashboard

+ {stats && ( +
+
+

Celkové štatistiky

+

Problematické zdroje: {stats.total_sources}

+

Vysoké riziko: {stats.high_risk_sources}

+
+
+

Top rizikoové domény

+ {stats.top_domains.slice(0, 5).map((domain, i) => ( +
+ {domain.domain} (riziko: {domain.risk_level}) +
+ ))} +
+
+ )} +
+ ← Späť na hlavnú stránku +
+
+
+ ) +} + +export default Dashboard \ No newline at end of file