Share live runs table between dashboard and runs
This commit is contained in:
parent
c04efeb189
commit
f3f4badaa2
5 changed files with 159 additions and 181 deletions
|
|
@ -496,81 +496,39 @@ def _completed_history_section(
|
|||
]
|
||||
|
||||
|
||||
def runs_page(
|
||||
def live_work_section(
|
||||
*,
|
||||
running_executions: tuple[Mapping[str, object], ...] | None = None,
|
||||
queued_executions: tuple[Mapping[str, object], ...] | None = None,
|
||||
upcoming_jobs: tuple[Mapping[str, object], ...] | None = None,
|
||||
completed_executions: tuple[Mapping[str, object], ...] | None = None,
|
||||
completed_page: int = 1,
|
||||
completed_page_size: int = 20,
|
||||
completed_total_count: int | None = None,
|
||||
completed_total_pages: int | None = None,
|
||||
source_count: int = 0,
|
||||
actions: Node | None = None,
|
||||
) -> Renderable:
|
||||
running_items = running_executions or ()
|
||||
queued_items = queued_executions or ()
|
||||
upcoming_items = upcoming_jobs or ()
|
||||
completed_items = completed_executions or ()
|
||||
running_rows = tuple(_running_row(execution) for execution in running_items)
|
||||
queued_rows = tuple(_queued_row(execution) for execution in queued_items)
|
||||
live_rows = running_rows + queued_rows
|
||||
live_row_attrs = tuple(
|
||||
_queue_row_attrs(execution) for execution in running_items + queued_items
|
||||
)
|
||||
upcoming_rows = tuple(_upcoming_row(job) for job in upcoming_items)
|
||||
completed_rows = tuple(_completed_row(execution) for execution in completed_items)
|
||||
resolved_completed_total_count = (
|
||||
len(completed_items) if completed_total_count is None else completed_total_count
|
||||
)
|
||||
resolved_completed_total_pages = (
|
||||
1 if completed_total_pages is None else completed_total_pages
|
||||
return table_section(
|
||||
eyebrow="Live work",
|
||||
title="Running jobs",
|
||||
empty_message="No jobs are running or queued.",
|
||||
headers=(
|
||||
"State",
|
||||
"Source",
|
||||
"Details",
|
||||
"Actions",
|
||||
),
|
||||
rows=live_rows,
|
||||
row_attrs=live_row_attrs,
|
||||
actions=actions,
|
||||
)
|
||||
|
||||
return page_shell(
|
||||
current_path="/runs",
|
||||
eyebrow="Execution control",
|
||||
title="Runs",
|
||||
actions=muted_action_link(href="/sources", label="Back to sources"),
|
||||
source_count=source_count,
|
||||
running_count=len(running_items),
|
||||
content=(
|
||||
table_section(
|
||||
eyebrow="Live work",
|
||||
title="Running jobs",
|
||||
empty_message="No jobs are running or queued.",
|
||||
headers=(
|
||||
"State",
|
||||
"Source",
|
||||
"Details",
|
||||
"Actions",
|
||||
),
|
||||
rows=live_rows,
|
||||
row_attrs=live_row_attrs,
|
||||
),
|
||||
table_section(
|
||||
eyebrow="Schedule",
|
||||
title="Scheduled jobs",
|
||||
empty_message="No jobs are scheduled.",
|
||||
headers=(
|
||||
"Source",
|
||||
"State",
|
||||
"Next run",
|
||||
"Cron",
|
||||
"Run now",
|
||||
"Actions",
|
||||
),
|
||||
rows=upcoming_rows,
|
||||
),
|
||||
_completed_history_section(
|
||||
completed_rows=completed_rows,
|
||||
completed_page=completed_page,
|
||||
completed_page_size=completed_page_size,
|
||||
completed_total_count=resolved_completed_total_count,
|
||||
completed_total_pages=resolved_completed_total_pages,
|
||||
),
|
||||
h.script[
|
||||
"""
|
||||
|
||||
def relative_time_formatter_script() -> Renderable:
|
||||
return h.script[
|
||||
"""
|
||||
window.repubFormatNextRuns = window.repubFormatNextRuns || (() => {
|
||||
const relativeFormatter = new Intl.RelativeTimeFormat(undefined, { numeric: 'auto' });
|
||||
const absoluteFormatter = new Intl.DateTimeFormat(undefined, {
|
||||
|
|
@ -612,8 +570,67 @@ window.repubFormatNextRuns = window.repubFormatNextRuns || (() => {
|
|||
}
|
||||
});
|
||||
window.repubFormatNextRuns();
|
||||
"""
|
||||
],
|
||||
"""
|
||||
]
|
||||
|
||||
|
||||
def runs_page(
|
||||
*,
|
||||
running_executions: tuple[Mapping[str, object], ...] | None = None,
|
||||
queued_executions: tuple[Mapping[str, object], ...] | None = None,
|
||||
upcoming_jobs: tuple[Mapping[str, object], ...] | None = None,
|
||||
completed_executions: tuple[Mapping[str, object], ...] | None = None,
|
||||
completed_page: int = 1,
|
||||
completed_page_size: int = 20,
|
||||
completed_total_count: int | None = None,
|
||||
completed_total_pages: int | None = None,
|
||||
source_count: int = 0,
|
||||
) -> Renderable:
|
||||
upcoming_items = upcoming_jobs or ()
|
||||
completed_items = completed_executions or ()
|
||||
upcoming_rows = tuple(_upcoming_row(job) for job in upcoming_items)
|
||||
completed_rows = tuple(_completed_row(execution) for execution in completed_items)
|
||||
resolved_completed_total_count = (
|
||||
len(completed_items) if completed_total_count is None else completed_total_count
|
||||
)
|
||||
resolved_completed_total_pages = (
|
||||
1 if completed_total_pages is None else completed_total_pages
|
||||
)
|
||||
|
||||
return page_shell(
|
||||
current_path="/runs",
|
||||
eyebrow="Execution control",
|
||||
title="Runs",
|
||||
actions=muted_action_link(href="/sources", label="Back to sources"),
|
||||
source_count=source_count,
|
||||
running_count=len(running_executions or ()),
|
||||
content=(
|
||||
live_work_section(
|
||||
running_executions=running_executions,
|
||||
queued_executions=queued_executions,
|
||||
),
|
||||
table_section(
|
||||
eyebrow="Schedule",
|
||||
title="Scheduled jobs",
|
||||
empty_message="No jobs are scheduled.",
|
||||
headers=(
|
||||
"Source",
|
||||
"State",
|
||||
"Next run",
|
||||
"Cron",
|
||||
"Run now",
|
||||
"Actions",
|
||||
),
|
||||
rows=upcoming_rows,
|
||||
),
|
||||
_completed_history_section(
|
||||
completed_rows=completed_rows,
|
||||
completed_page=completed_page,
|
||||
completed_page_size=completed_page_size,
|
||||
completed_total_count=resolved_completed_total_count,
|
||||
completed_total_pages=resolved_completed_total_pages,
|
||||
),
|
||||
relative_time_formatter_script(),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue