/** * Dashboard page. * * Composes the fail2ban server status bar at the top, a shared time-range * selector, and the ban list showing aggregate bans from the fail2ban * database. The time-range selection controls how far back to look. */ import { useState } from "react"; import { Text, makeStyles, tokens } from "@fluentui/react-components"; import { BanTable } from "../components/BanTable"; import { BanTrendChart } from "../components/BanTrendChart"; import { ChartStateWrapper } from "../components/ChartStateWrapper"; import { DashboardFilterBar } from "../components/DashboardFilterBar"; import { ServerStatusBar } from "../components/ServerStatusBar"; import { TopCountriesBarChart } from "../components/TopCountriesBarChart"; import { TopCountriesPieChart } from "../components/TopCountriesPieChart"; import { useDashboardCountryData } from "../hooks/useDashboardCountryData"; import type { BanOriginFilter, TimeRange } from "../types/ban"; // --------------------------------------------------------------------------- // Styles // --------------------------------------------------------------------------- const useStyles = makeStyles({ root: { display: "flex", flexDirection: "column", gap: tokens.spacingVerticalM, }, section: { display: "flex", flexDirection: "column", gap: tokens.spacingVerticalS, backgroundColor: tokens.colorNeutralBackground1, borderRadius: tokens.borderRadiusMedium, borderTopWidth: "1px", borderTopStyle: "solid", borderTopColor: tokens.colorNeutralStroke2, borderRightWidth: "1px", borderRightStyle: "solid", borderRightColor: tokens.colorNeutralStroke2, borderBottomWidth: "1px", borderBottomStyle: "solid", borderBottomColor: tokens.colorNeutralStroke2, borderLeftWidth: "1px", borderLeftStyle: "solid", borderLeftColor: tokens.colorNeutralStroke2, padding: tokens.spacingVerticalM, }, sectionHeader: { display: "flex", alignItems: "center", justifyContent: "space-between", flexWrap: "wrap", gap: tokens.spacingHorizontalM, paddingBottom: tokens.spacingVerticalS, borderBottomWidth: "1px", borderBottomStyle: "solid", borderBottomColor: tokens.colorNeutralStroke2, }, tabContent: { paddingTop: tokens.spacingVerticalS, }, chartsRow: { display: "flex", flexDirection: "row", gap: tokens.spacingHorizontalL, flexWrap: "wrap", }, chartCard: { flex: "1 1 300px", minWidth: "280px", }, }); // --------------------------------------------------------------------------- // Component // --------------------------------------------------------------------------- /** * Main dashboard landing page. * * Displays the fail2ban server status, a time-range selector, and the * ban list table. */ export function DashboardPage(): React.JSX.Element { const styles = useStyles(); const [timeRange, setTimeRange] = useState("24h"); const [originFilter, setOriginFilter] = useState("all"); const { countries, countryNames, isLoading: countryLoading, error: countryError, reload: reloadCountry } = useDashboardCountryData(timeRange, originFilter); return (
{/* ------------------------------------------------------------------ */} {/* Server status bar */} {/* ------------------------------------------------------------------ */} {/* ------------------------------------------------------------------ */} {/* Global filter bar */} {/* ------------------------------------------------------------------ */} {/* ------------------------------------------------------------------ */} {/* Ban Trend section */} {/* ------------------------------------------------------------------ */}
Ban Trend
{/* ------------------------------------------------------------------ */} {/* Charts section */} {/* ------------------------------------------------------------------ */}
Top Countries
{/* ------------------------------------------------------------------ */} {/* Ban list section */} {/* ------------------------------------------------------------------ */}
Ban List
{/* Ban table */}
); }