diff --git a/.hypothesis/constants/0c493522e69881e5 b/.hypothesis/constants/0c493522e69881e5 new file mode 100644 index 0000000..0add520 --- /dev/null +++ b/.hypothesis/constants/0c493522e69881e5 @@ -0,0 +1,4 @@ +# file: /home/anti/Tools/DECNET/decnet/web/api.py +# hypothesis_version: 6.151.11 + +[400, 404, 500, 512, 1000, 1024, '*', '/api/v1/auth/login', '/api/v1/deckies', '/api/v1/logs', '/api/v1/stats', '/api/v1/stream', '1.0.0', 'Authorization', 'Bearer', 'Bearer ', 'Decky not found', 'No active deployment', 'WWW-Authenticate', 'access_token', 'admin', 'bearer', 'data', 'decnet.web.api', 'histogram', 'id', 'lastEventId', 'limit', 'logs', 'message', 'must_change_password', 'offset', 'password_hash', 'role', 'stats', 'text/event-stream', 'token', 'token_type', 'total', 'type', 'unihost', 'username', 'uuid'] \ No newline at end of file diff --git a/.hypothesis/constants/b43b9eaed24de8b9 b/.hypothesis/constants/b43b9eaed24de8b9 new file mode 100644 index 0000000..0add520 --- /dev/null +++ b/.hypothesis/constants/b43b9eaed24de8b9 @@ -0,0 +1,4 @@ +# file: /home/anti/Tools/DECNET/decnet/web/api.py +# hypothesis_version: 6.151.11 + +[400, 404, 500, 512, 1000, 1024, '*', '/api/v1/auth/login', '/api/v1/deckies', '/api/v1/logs', '/api/v1/stats', '/api/v1/stream', '1.0.0', 'Authorization', 'Bearer', 'Bearer ', 'Decky not found', 'No active deployment', 'WWW-Authenticate', 'access_token', 'admin', 'bearer', 'data', 'decnet.web.api', 'histogram', 'id', 'lastEventId', 'limit', 'logs', 'message', 'must_change_password', 'offset', 'password_hash', 'role', 'stats', 'text/event-stream', 'token', 'token_type', 'total', 'type', 'unihost', 'username', 'uuid'] \ No newline at end of file diff --git a/.hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz b/.hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz index a73d774..8cf48f5 100644 Binary files a/.hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz and b/.hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz differ diff --git a/decnet/web/api.py b/decnet/web/api.py index 996dde2..323cd5e 100644 --- a/decnet/web/api.py +++ b/decnet/web/api.py @@ -164,10 +164,12 @@ async def get_logs( limit: int = Query(50, ge=1, le=1000), offset: int = Query(0, ge=0), search: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, current_user: str = Depends(get_current_user) ) -> dict[str, Any]: - _logs: list[dict[str, Any]] = await repo.get_logs(limit=limit, offset=offset, search=search) - _total: int = await repo.get_total_logs(search=search) + _logs: list[dict[str, Any]] = await repo.get_logs(limit=limit, offset=offset, search=search, start_time=start_time, end_time=end_time) + _total: int = await repo.get_total_logs(search=search, start_time=start_time, end_time=end_time) return { "total": _total, "limit": limit, @@ -176,6 +178,17 @@ async def get_logs( } +@app.get("/api/v1/logs/histogram") +async def get_logs_histogram( + search: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval_minutes: int = Query(15, ge=1), + current_user: str = Depends(get_current_user) +) -> list[dict[str, Any]]: + return await repo.get_log_histogram(search=search, start_time=start_time, end_time=end_time, interval_minutes=interval_minutes) + + class StatsResponse(BaseModel): total_logs: int unique_attackers: int diff --git a/decnet_web/src/components/LiveLogs.tsx b/decnet_web/src/components/LiveLogs.tsx index de311d4..8e5363a 100644 --- a/decnet_web/src/components/LiveLogs.tsx +++ b/decnet_web/src/components/LiveLogs.tsx @@ -66,7 +66,7 @@ const LiveLogs: React.FC = () => { if (timeRange !== 'all') { const minutes = timeRange === '15m' ? 15 : timeRange === '1h' ? 60 : timeRange === '24h' ? 1440 : 0; if (minutes > 0) { - startTime = new Date(now.getTime() - minutes * 60000).toISOString(); + startTime = new Date(now.getTime() - minutes * 60000).toISOString().replace('T', ' ').substring(0, 19); url += `&start_time=${startTime}`; } } @@ -76,7 +76,8 @@ const LiveLogs: React.FC = () => { setTotalLogs(res.data.total); // Fetch histogram for historical view - const histUrl = `/logs/histogram?search=${encodeURIComponent(query)}` + (startTime ? `&start_time=${startTime}` : ''); + let histUrl = `/logs/histogram?search=${encodeURIComponent(query)}`; + if (startTime) histUrl += `&start_time=${startTime}`; const histRes = await api.get(histUrl); setHistogram(histRes.data); @@ -206,7 +207,7 @@ const LiveLogs: React.FC = () => { {/* Histogram Chart */} -