fix: restore missing API endpoints, fix chart rendering, and update date filter formatting
This commit is contained in:
4
.hypothesis/constants/0c493522e69881e5
Normal file
4
.hypothesis/constants/0c493522e69881e5
Normal file
@@ -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']
|
||||||
4
.hypothesis/constants/b43b9eaed24de8b9
Normal file
4
.hypothesis/constants/b43b9eaed24de8b9
Normal file
@@ -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']
|
||||||
Binary file not shown.
@@ -164,10 +164,12 @@ async def get_logs(
|
|||||||
limit: int = Query(50, ge=1, le=1000),
|
limit: int = Query(50, ge=1, le=1000),
|
||||||
offset: int = Query(0, ge=0),
|
offset: int = Query(0, ge=0),
|
||||||
search: Optional[str] = None,
|
search: Optional[str] = None,
|
||||||
|
start_time: Optional[str] = None,
|
||||||
|
end_time: Optional[str] = None,
|
||||||
current_user: str = Depends(get_current_user)
|
current_user: str = Depends(get_current_user)
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
_logs: list[dict[str, Any]] = await repo.get_logs(limit=limit, offset=offset, 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)
|
_total: int = await repo.get_total_logs(search=search, start_time=start_time, end_time=end_time)
|
||||||
return {
|
return {
|
||||||
"total": _total,
|
"total": _total,
|
||||||
"limit": limit,
|
"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):
|
class StatsResponse(BaseModel):
|
||||||
total_logs: int
|
total_logs: int
|
||||||
unique_attackers: int
|
unique_attackers: int
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ const LiveLogs: React.FC = () => {
|
|||||||
if (timeRange !== 'all') {
|
if (timeRange !== 'all') {
|
||||||
const minutes = timeRange === '15m' ? 15 : timeRange === '1h' ? 60 : timeRange === '24h' ? 1440 : 0;
|
const minutes = timeRange === '15m' ? 15 : timeRange === '1h' ? 60 : timeRange === '24h' ? 1440 : 0;
|
||||||
if (minutes > 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}`;
|
url += `&start_time=${startTime}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,8 @@ const LiveLogs: React.FC = () => {
|
|||||||
setTotalLogs(res.data.total);
|
setTotalLogs(res.data.total);
|
||||||
|
|
||||||
// Fetch histogram for historical view
|
// 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);
|
const histRes = await api.get(histUrl);
|
||||||
setHistogram(histRes.data);
|
setHistogram(histRes.data);
|
||||||
|
|
||||||
@@ -206,7 +207,7 @@ const LiveLogs: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Histogram Chart */}
|
{/* Histogram Chart */}
|
||||||
<div className="logs-section" style={{ height: '200px', padding: '20px', marginBottom: '24px' }}>
|
<div className="logs-section" style={{ height: '200px', padding: '20px', marginBottom: '24px', minWidth: 0 }}>
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '10px' }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '10px' }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px', fontSize: '0.7rem', color: 'var(--dim-color)' }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: '8px', fontSize: '0.7rem', color: 'var(--dim-color)' }}>
|
||||||
<Activity size={12} /> ATTACK VOLUME OVER TIME
|
<Activity size={12} /> ATTACK VOLUME OVER TIME
|
||||||
|
|||||||
Reference in New Issue
Block a user