Add publisher dashboard routes
This commit is contained in:
parent
96551c2788
commit
e4a5246ab3
31 changed files with 1603 additions and 516 deletions
1
repub/web/admin/pages/__init__.py
Normal file
1
repub/web/admin/pages/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from __future__ import annotations
|
||||
26
repub/web/admin/pages/dashboard.py
Normal file
26
repub/web/admin/pages/dashboard.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from typing import Any
|
||||
|
||||
from datastar_py.quart import DatastarResponse
|
||||
from quart import Quart, Response
|
||||
|
||||
from repub.web.app import _page_patch_response, _shim_page_response, render_dashboard
|
||||
|
||||
RouteGuard = Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]
|
||||
|
||||
|
||||
def register_dashboard_routes(app: Quart, *, admin_required: RouteGuard) -> None:
|
||||
@app.get("/admin")
|
||||
@admin_required
|
||||
async def admin_dashboard_home() -> Response:
|
||||
return _shim_page_response(current_path="/admin", static_prefix="/admin")
|
||||
|
||||
@app.post("/admin")
|
||||
@admin_required
|
||||
async def admin_dashboard_patch() -> DatastarResponse:
|
||||
return await _page_patch_response(
|
||||
app,
|
||||
lambda _tab_id: render_dashboard(app, path_prefix="/admin"),
|
||||
)
|
||||
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())
|
||||
26
repub/web/admin/pages/runs.py
Normal file
26
repub/web/admin/pages/runs.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from typing import Any
|
||||
|
||||
from datastar_py.quart import DatastarResponse
|
||||
from quart import Quart, Response
|
||||
|
||||
from repub.web.app import _page_patch_response, _shim_page_response, render_runs
|
||||
|
||||
RouteGuard = Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]
|
||||
|
||||
|
||||
def register_runs_routes(app: Quart, *, admin_required: RouteGuard) -> None:
|
||||
@app.get("/admin/runs")
|
||||
@admin_required
|
||||
async def admin_runs_home() -> Response:
|
||||
return _shim_page_response(current_path="/admin/runs", static_prefix="/admin")
|
||||
|
||||
@app.post("/admin/runs")
|
||||
@admin_required
|
||||
async def admin_runs_patch() -> DatastarResponse:
|
||||
return await _page_patch_response(
|
||||
app,
|
||||
lambda tab_id: render_runs(app, tab_id=tab_id, path_prefix="/admin"),
|
||||
)
|
||||
26
repub/web/admin/pages/settings.py
Normal file
26
repub/web/admin/pages/settings.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from typing import Any
|
||||
|
||||
from datastar_py.quart import DatastarResponse
|
||||
from quart import Quart, Response
|
||||
|
||||
from repub.web.app import _page_patch_response, _shim_page_response, render_settings
|
||||
|
||||
RouteGuard = Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]
|
||||
|
||||
|
||||
def register_settings_routes(app: Quart, *, admin_required: RouteGuard) -> None:
|
||||
@app.get("/admin/settings")
|
||||
@admin_required
|
||||
async def admin_settings_home() -> Response:
|
||||
return _shim_page_response(
|
||||
current_path="/admin/settings",
|
||||
static_prefix="/admin",
|
||||
)
|
||||
|
||||
@app.post("/admin/settings")
|
||||
@admin_required
|
||||
async def admin_settings_patch() -> DatastarResponse:
|
||||
return await _page_patch_response(app, lambda _tab_id: render_settings(app))
|
||||
48
repub/web/admin/pages/sources.py
Normal file
48
repub/web/admin/pages/sources.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from typing import Any
|
||||
|
||||
from datastar_py.quart import DatastarResponse
|
||||
from quart import Quart, Response, request
|
||||
|
||||
from repub.web.app import (
|
||||
_page_patch_response,
|
||||
_shim_page_response,
|
||||
render_create_source,
|
||||
render_edit_source,
|
||||
render_sources,
|
||||
)
|
||||
|
||||
RouteGuard = Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]
|
||||
|
||||
|
||||
def register_source_routes(app: Quart, *, admin_required: RouteGuard) -> None:
|
||||
@app.get("/admin/sources")
|
||||
@app.get("/admin/sources/create")
|
||||
@app.get("/admin/sources/<string:slug>/edit")
|
||||
@admin_required
|
||||
async def admin_sources_shim(slug: str | None = None) -> Response:
|
||||
del slug
|
||||
return _shim_page_response(current_path=request.path, static_prefix="/admin")
|
||||
|
||||
@app.post("/admin/sources")
|
||||
@admin_required
|
||||
async def admin_sources_patch() -> DatastarResponse:
|
||||
return await _page_patch_response(app, lambda _tab_id: render_sources(app))
|
||||
|
||||
@app.post("/admin/sources/create")
|
||||
@admin_required
|
||||
async def admin_create_source_patch() -> DatastarResponse:
|
||||
return await _page_patch_response(
|
||||
app,
|
||||
lambda _tab_id: render_create_source(app),
|
||||
)
|
||||
|
||||
@app.post("/admin/sources/<string:slug>/edit")
|
||||
@admin_required
|
||||
async def admin_edit_source_patch(slug: str) -> DatastarResponse:
|
||||
return await _page_patch_response(
|
||||
app,
|
||||
lambda _tab_id: render_edit_source(slug, app),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue