feat: Implement Homelab Automation API v2, introducing a new dashboard, comprehensive backend models, and API routes.
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
This commit is contained in:
+34
-23
@@ -30,34 +30,45 @@ async def create_alert(
|
||||
db_session: AsyncSession = Depends(get_db)
|
||||
):
|
||||
"""Crée une nouvelle alerte."""
|
||||
repo = AlertRepository(db_session)
|
||||
alert = await repo.create(
|
||||
category=alert_data.category,
|
||||
level=alert_data.level,
|
||||
title=alert_data.title,
|
||||
message=alert_data.message,
|
||||
source=alert_data.source,
|
||||
)
|
||||
await db_session.commit()
|
||||
|
||||
await ws_manager.broadcast({
|
||||
"type": "alert_created",
|
||||
"data": {
|
||||
try:
|
||||
repo = AlertRepository(db_session)
|
||||
alert = await repo.create(
|
||||
category=alert_data.category,
|
||||
level=alert_data.level,
|
||||
title=alert_data.title,
|
||||
message=alert_data.message,
|
||||
source=alert_data.source,
|
||||
)
|
||||
|
||||
await db_session.refresh(alert)
|
||||
|
||||
# Access attributes before commit to avoid MissingGreenlet on async lazy loading
|
||||
alert_dict = {
|
||||
"id": alert.id,
|
||||
"title": alert.title,
|
||||
"message": alert.message,
|
||||
"level": alert.level,
|
||||
"category": alert.category,
|
||||
"created_at": alert.created_at,
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
"id": alert.id,
|
||||
"title": alert.title,
|
||||
"message": alert.message,
|
||||
"level": alert.level,
|
||||
"category": alert.category,
|
||||
"created_at": alert.created_at,
|
||||
}
|
||||
|
||||
await db_session.commit()
|
||||
|
||||
await ws_manager.broadcast({
|
||||
"type": "alert_created",
|
||||
"data": {
|
||||
"id": alert_dict["id"],
|
||||
"title": alert_dict["title"],
|
||||
"message": alert_dict["message"],
|
||||
"level": alert_dict["level"],
|
||||
}
|
||||
})
|
||||
|
||||
return alert_dict
|
||||
except Exception as e:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.get("")
|
||||
|
||||
@@ -624,7 +624,6 @@ async def create_terminal_session(
|
||||
|
||||
if existing_session:
|
||||
await session_repo.update_last_seen(existing_session.id)
|
||||
await db_session.commit()
|
||||
|
||||
terminal_service.record_session_created(reused=True)
|
||||
logger.info(f"session_reused session={existing_session.id[:8]}... user={username} host={host.name}")
|
||||
|
||||
Reference in New Issue
Block a user