Stage 8: world map view — backend endpoint, map component, map page
- BansByCountryResponse model added to ban.py - bans_by_country() service: parallel geo lookup via asyncio.gather, aggregation by ISO alpha-2 country code (up to 2 000 bans) - GET /api/dashboard/bans/by-country endpoint in dashboard router - 290 tests pass (5 new), ruff + mypy clean (44 files) - isoNumericToAlpha2.ts: 249-entry ISO numeric → alpha-2 static map - types/map.ts, api/map.ts, hooks/useMapData.ts created - WorldMap.tsx: react-simple-maps Mercator SVG map, per-country ban count overlay, colour intensity scaling, country click filtering, GeoLayer nested-component pattern for useGeographies context - MapPage.tsx: time-range selector, WorldMap, country filter info bar, summary line, companion FluentUI Table with country filter - Frontend tsc + ESLint clean (0 errors/warnings)
This commit is contained in:
31
frontend/src/types/map.ts
Normal file
31
frontend/src/types/map.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* TypeScript types for the world-map / bans-by-country API.
|
||||
*/
|
||||
|
||||
/** Time-range preset for filtering queries. */
|
||||
export type TimeRange = "24h" | "7d" | "30d" | "365d";
|
||||
|
||||
/** A single enriched ban item as returned by the by-country endpoint. */
|
||||
export interface MapBanItem {
|
||||
ip: string;
|
||||
jail: string;
|
||||
banned_at: string;
|
||||
service: string | null;
|
||||
country_code: string | null;
|
||||
country_name: string | null;
|
||||
asn: string | null;
|
||||
org: string | null;
|
||||
ban_count: number;
|
||||
}
|
||||
|
||||
/** Response from GET /api/dashboard/bans/by-country */
|
||||
export interface BansByCountryResponse {
|
||||
/** ISO alpha-2 country code → ban count */
|
||||
countries: Record<string, number>;
|
||||
/** ISO alpha-2 country code → human-readable country name */
|
||||
country_names: Record<string, string>;
|
||||
/** All individual ban records in the window (up to server limit) */
|
||||
bans: MapBanItem[];
|
||||
/** Total ban count in the window */
|
||||
total: number;
|
||||
}
|
||||
Reference in New Issue
Block a user