Add publisher dashboard routes
This commit is contained in:
parent
96551c2788
commit
e4a5246ab3
31 changed files with 1603 additions and 516 deletions
|
|
@ -9,7 +9,6 @@ from htpy import Node, Renderable
|
|||
from repub.components import (
|
||||
action_button,
|
||||
app_shell,
|
||||
header_action_link,
|
||||
inline_link,
|
||||
muted_action_link,
|
||||
stat_card,
|
||||
|
|
@ -19,7 +18,9 @@ from repub.components import (
|
|||
from repub.pages.runs import live_work_section, relative_time_formatter_script
|
||||
|
||||
|
||||
def dashboard_header() -> Renderable:
|
||||
def dashboard_header(
|
||||
*, path_prefix: str = "/admin", reader_app_url: str | None = None
|
||||
) -> Renderable:
|
||||
return h.section[
|
||||
h.div(
|
||||
class_="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
||||
|
|
@ -30,8 +31,20 @@ def dashboard_header() -> Renderable:
|
|||
],
|
||||
],
|
||||
h.div(class_="flex flex-wrap gap-2")[
|
||||
header_action_link(href="/sources/create", label="Create source"),
|
||||
muted_action_link(href="/sources", label="View sources"),
|
||||
(
|
||||
muted_action_link(
|
||||
href=reader_app_url,
|
||||
label="Open AnyNews",
|
||||
target="_blank",
|
||||
rel="noopener noreferrer",
|
||||
)
|
||||
if reader_app_url is not None
|
||||
else None
|
||||
),
|
||||
muted_action_link(
|
||||
href=f"{path_prefix}/publisher",
|
||||
label="Publisher View",
|
||||
),
|
||||
],
|
||||
]
|
||||
]
|
||||
|
|
@ -124,9 +137,6 @@ def _source_feed_row(source_feed: Mapping[str, object]) -> tuple[Node, ...]:
|
|||
),
|
||||
last_updated,
|
||||
next_run,
|
||||
h.p(class_="font-medium text-slate-900")[
|
||||
str(source_feed["artifact_footprint"])
|
||||
],
|
||||
action_button(
|
||||
label="Run now",
|
||||
disabled=bool(source_feed["run_disabled"]),
|
||||
|
|
@ -136,12 +146,15 @@ def _source_feed_row(source_feed: Mapping[str, object]) -> tuple[Node, ...]:
|
|||
|
||||
|
||||
def published_feeds_table(
|
||||
*, source_feeds: tuple[Mapping[str, object], ...] | None = None
|
||||
*,
|
||||
source_feeds: tuple[Mapping[str, object], ...] | None = None,
|
||||
manage_sources_href: str | None = "/admin/sources",
|
||||
show_heading: bool = True,
|
||||
) -> Renderable:
|
||||
rows = tuple(_source_feed_row(source_feed) for source_feed in (source_feeds or ()))
|
||||
return table_section(
|
||||
eyebrow="Published feeds",
|
||||
title="Published feeds",
|
||||
eyebrow="Published feeds" if show_heading else None,
|
||||
title="Published feeds" if show_heading else None,
|
||||
empty_message="No feeds have been published yet.",
|
||||
headers=(
|
||||
"Source",
|
||||
|
|
@ -149,11 +162,14 @@ def published_feeds_table(
|
|||
"Status",
|
||||
"Last updated",
|
||||
"Next run",
|
||||
"Disk usage",
|
||||
"Actions",
|
||||
),
|
||||
rows=rows,
|
||||
actions=muted_action_link(href="/sources", label="Manage sources"),
|
||||
actions=(
|
||||
muted_action_link(href=manage_sources_href, label="Manage sources")
|
||||
if manage_sources_href is not None
|
||||
else None
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -163,26 +179,32 @@ def dashboard_page() -> Renderable:
|
|||
|
||||
def dashboard_page_with_data(
|
||||
*,
|
||||
current_path: str = "/admin",
|
||||
path_prefix: str = "/admin",
|
||||
snapshot: Mapping[str, str] | None = None,
|
||||
running_executions: tuple[Mapping[str, object], ...] | None = None,
|
||||
queued_executions: tuple[Mapping[str, object], ...] | None = None,
|
||||
source_feeds: tuple[Mapping[str, object], ...] | None = None,
|
||||
reader_app_url: str | None = None,
|
||||
) -> Renderable:
|
||||
running_items = running_executions or ()
|
||||
queued_items = queued_executions or ()
|
||||
source_items = source_feeds or ()
|
||||
return app_shell(
|
||||
current_path="/",
|
||||
current_path=current_path,
|
||||
source_count=len(source_items),
|
||||
running_count=len(running_items),
|
||||
content=(
|
||||
dashboard_header(),
|
||||
dashboard_header(path_prefix=path_prefix, reader_app_url=reader_app_url),
|
||||
operational_snapshot(snapshot=snapshot),
|
||||
live_work_section(
|
||||
running_executions=running_items,
|
||||
queued_executions=queued_items,
|
||||
),
|
||||
published_feeds_table(source_feeds=source_items),
|
||||
published_feeds_table(
|
||||
source_feeds=source_items,
|
||||
manage_sources_href=f"{path_prefix}/sources",
|
||||
),
|
||||
relative_time_formatter_script(),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue