Add publisher dashboard routes
This commit is contained in:
parent
96551c2788
commit
e4a5246ab3
31 changed files with 1603 additions and 516 deletions
42
repub/web/admin/pages/logs.py
Normal file
42
repub/web/admin/pages/logs.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
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())
|
||||
Loading…
Add table
Add a link
Reference in a new issue