v1.4.0: модули с веб-UI, правое меню, расширенные тесты

Реестр MODULE_MOUNTS: API, ui_router, фрагменты главной, EventBus.
Главная и страницы модулей с правой навигацией из реестра; wrap_module_html_page.
Ingress: публикация alert.received после сохранения в БД.
Документация MODULES.md; pytest покрывает API, UI и навигацию.

Made-with: Cursor
This commit is contained in:
Alexandr
2026-04-03 08:45:19 +03:00
parent 85eb61b576
commit 349cea85a3
17 changed files with 571 additions and 24 deletions

View File

@ -7,8 +7,9 @@ from starlette.responses import HTMLResponse, Response
from onguard24.config import get_settings
from onguard24.db import create_pool
from onguard24.domain.events import InMemoryEventBus
from onguard24.ingress import grafana as grafana_ingress
from onguard24.modules import contacts, schedules, statusboard
from onguard24.modules.registry import MODULE_MOUNTS, register_module_events
from onguard24.root_html import render_root_page
from onguard24.status_snapshot import build as build_status
from onguard24 import __version__ as app_version
@ -32,8 +33,11 @@ def parse_addr(http_addr: str) -> tuple[str, int]:
async def lifespan(app: FastAPI):
settings = get_settings()
pool = await create_pool(settings)
bus = InMemoryEventBus()
register_module_events(bus)
app.state.pool = pool
app.state.settings = settings
app.state.event_bus = bus
log.info("onGuard24 started, db=%s", "ok" if pool else "disabled")
yield
if pool:
@ -78,9 +82,10 @@ def create_app() -> FastAPI:
return await build_status(request)
app.include_router(grafana_ingress.router, prefix="/api/v1")
app.include_router(schedules.router, prefix="/api/v1/modules/schedules")
app.include_router(contacts.router, prefix="/api/v1/modules/contacts")
app.include_router(statusboard.router, prefix="/api/v1/modules/statusboard")
for mount in MODULE_MOUNTS:
app.include_router(mount.router, prefix=mount.url_prefix)
if mount.ui_router is not None:
app.include_router(mount.ui_router, prefix=f"/ui/modules/{mount.slug}")
return app