43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from collections.abc import Awaitable, Callable
|
||
|
|
from typing import Any
|
||
|
|
|
||
|
|
from datastar_py.quart import DatastarResponse
|
||
|
|
from htpy import Renderable
|
||
|
|
from quart import Quart, Response
|
||
|
|
|
||
|
|
from repub.web.app import (
|
||
|
|
_page_patch_response,
|
||
|
|
_shim_page_response,
|
||
|
|
render_execution_logs,
|
||
|
|
)
|
||
|
|
|
||
|
|
RouteGuard = Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]
|
||
|
|
|
||
|
|
|
||
|
|
def register_log_routes(app: Quart, *, admin_required: RouteGuard) -> None:
|
||
|
|
@app.get("/admin/job/<int:job_id>/execution/<int:execution_id>/logs")
|
||
|
|
@admin_required
|
||
|
|
async def admin_logs_home(job_id: int, execution_id: int) -> Response:
|
||
|
|
return _shim_page_response(
|
||
|
|
current_path=f"/admin/job/{job_id}/execution/{execution_id}/logs",
|
||
|
|
static_prefix="/admin",
|
||
|
|
)
|
||
|
|
|
||
|
|
@app.post("/admin/job/<int:job_id>/execution/<int:execution_id>/logs")
|
||
|
|
@admin_required
|
||
|
|
async def admin_logs_patch(
|
||
|
|
job_id: int,
|
||
|
|
execution_id: int,
|
||
|
|
) -> DatastarResponse:
|
||
|
|
async def render() -> Renderable:
|
||
|
|
return await render_execution_logs(
|
||
|
|
app,
|
||
|
|
job_id=job_id,
|
||
|
|
execution_id=execution_id,
|
||
|
|
path_prefix="/admin",
|
||
|
|
)
|
||
|
|
|
||
|
|
return await _page_patch_response(app, lambda _tab_id: render())
|