runs queue order manipulation and whitespace tightnening
This commit is contained in:
parent
a88eba7dd1
commit
99fd33f770
10 changed files with 478 additions and 121 deletions
|
|
@ -31,19 +31,47 @@ def _flag(values: Mapping[str, object], key: str) -> bool:
|
|||
return bool(values[key])
|
||||
|
||||
|
||||
def _queue_icon(direction: str) -> Renderable:
|
||||
path = (
|
||||
"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"
|
||||
if direction == "up"
|
||||
else "M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3"
|
||||
)
|
||||
return h.svg(
|
||||
xmlns="http://www.w3.org/2000/svg",
|
||||
fill="none",
|
||||
viewBox="0 0 24 24",
|
||||
stroke_width="1.5",
|
||||
stroke="currentColor",
|
||||
class_="size-4",
|
||||
)[
|
||||
h.path(
|
||||
stroke_linecap="round",
|
||||
stroke_linejoin="round",
|
||||
d=path,
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def _queue_row_attrs(execution: Mapping[str, object]) -> dict[str, str]:
|
||||
return {
|
||||
"style": (
|
||||
"view-transition-name: " f"running-job-{_text(execution, 'execution_id')};"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
def _running_row(execution: Mapping[str, object]) -> tuple[Node, ...]:
|
||||
return (
|
||||
h.p(class_="w-px whitespace-nowrap font-medium text-slate-900")[
|
||||
f"#{_text(execution, 'execution_id')}"
|
||||
],
|
||||
h.div[
|
||||
h.div(class_="font-semibold text-slate-950")[_text(execution, "source")],
|
||||
h.p(class_="mt-0.5 font-mono text-xs text-slate-500")[
|
||||
_text(execution, "slug")
|
||||
],
|
||||
],
|
||||
h.div[
|
||||
h.p(class_="font-medium text-slate-900")[
|
||||
f"#{_text(execution, 'execution_id')}"
|
||||
],
|
||||
],
|
||||
h.div[
|
||||
h.p(class_="font-medium text-slate-900")[_text(execution, "started_at")],
|
||||
h.p(class_="mt-0.5 text-xs text-slate-500")[_text(execution, "runtime")],
|
||||
|
|
@ -84,34 +112,43 @@ def _queued_row(execution: Mapping[str, object]) -> tuple[Node, ...]:
|
|||
)[_text(execution, "queued_at")]
|
||||
|
||||
return (
|
||||
h.p(class_="w-px whitespace-nowrap font-medium text-slate-900")[
|
||||
f"#{_text(execution, 'execution_id')}"
|
||||
],
|
||||
h.div[
|
||||
h.div(class_="font-semibold text-slate-950")[_text(execution, "source")],
|
||||
h.p(class_="mt-0.5 font-mono text-xs text-slate-500")[
|
||||
_text(execution, "slug")
|
||||
],
|
||||
],
|
||||
h.div[
|
||||
h.p(class_="font-medium text-slate-900")[
|
||||
f"#{_text(execution, 'execution_id')}"
|
||||
],
|
||||
],
|
||||
queued_label,
|
||||
h.div[
|
||||
status_badge(label="Queued", tone="idle"),
|
||||
h.div(class_="max-w-xs whitespace-normal")[
|
||||
h.p(class_="font-medium text-slate-900")[
|
||||
f"#{_text(execution, 'queue_position')}"
|
||||
f"Queue position #{_text(execution, 'queue_position')}"
|
||||
],
|
||||
h.p(class_="mt-0.5 text-xs text-slate-500")["waiting for capacity"],
|
||||
],
|
||||
action_button(
|
||||
label=_text(execution, "run_label"),
|
||||
disabled=_flag(execution, "run_disabled"),
|
||||
post_path=_maybe_text(execution, "run_post_path"),
|
||||
),
|
||||
h.div(class_="flex flex-wrap items-center gap-2")[
|
||||
action_button(
|
||||
label=_queue_icon("up"),
|
||||
emphasis="icon",
|
||||
title="Move up",
|
||||
disabled=_flag(execution, "move_up_disabled"),
|
||||
post_path=_maybe_text(execution, "move_up_post_path"),
|
||||
),
|
||||
action_button(
|
||||
label=_queue_icon("down"),
|
||||
emphasis="icon",
|
||||
title="Move down",
|
||||
disabled=_flag(execution, "move_down_disabled"),
|
||||
post_path=_maybe_text(execution, "move_down_post_path"),
|
||||
),
|
||||
action_button(
|
||||
label="Cancel",
|
||||
tone="danger",
|
||||
post_path=_maybe_text(execution, "cancel_post_path"),
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -180,21 +217,16 @@ def _completed_row(execution: Mapping[str, object]) -> tuple[Node, ...]:
|
|||
)[_text(execution, "ended_at")]
|
||||
|
||||
return (
|
||||
h.p(class_="w-px whitespace-nowrap font-medium text-slate-900")[
|
||||
f"#{_text(execution, 'execution_id')}"
|
||||
],
|
||||
h.div[
|
||||
h.div(class_="font-semibold text-slate-950")[_text(execution, "source")],
|
||||
h.p(class_="mt-0.5 font-mono text-xs text-slate-500")[
|
||||
_text(execution, "slug")
|
||||
],
|
||||
],
|
||||
h.div[
|
||||
h.p(class_="font-medium text-slate-900")[
|
||||
f"#{_text(execution, 'execution_id')}"
|
||||
],
|
||||
],
|
||||
h.div[
|
||||
ended_at_label,
|
||||
h.p(class_="mt-0.5 text-xs text-slate-500")[_text(execution, "summary")],
|
||||
],
|
||||
h.div[ended_at_label,],
|
||||
status_badge(
|
||||
label=_text(execution, "status"),
|
||||
tone=_text(execution, "status_tone"),
|
||||
|
|
@ -224,6 +256,10 @@ def runs_page(
|
|||
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)
|
||||
|
||||
|
|
@ -237,31 +273,20 @@ def runs_page(
|
|||
content=(
|
||||
table_section(
|
||||
eyebrow="Live work",
|
||||
title="Running job executions",
|
||||
empty_message="No job executions are running.",
|
||||
title="Running jobs",
|
||||
empty_message="No jobs are running or queued.",
|
||||
headers=(
|
||||
"#",
|
||||
"Source",
|
||||
"Execution",
|
||||
"Started",
|
||||
"Status",
|
||||
"Stats",
|
||||
"Activity",
|
||||
"State",
|
||||
"Details",
|
||||
"Actions",
|
||||
),
|
||||
rows=running_rows,
|
||||
),
|
||||
table_section(
|
||||
eyebrow="Queue",
|
||||
title="Queued job executions",
|
||||
empty_message="No queued executions are waiting.",
|
||||
headers=(
|
||||
"Source",
|
||||
"Execution",
|
||||
"Queued",
|
||||
"Position",
|
||||
"Run now",
|
||||
"Actions",
|
||||
),
|
||||
rows=queued_rows,
|
||||
rows=live_rows,
|
||||
row_attrs=live_row_attrs,
|
||||
first_header_class="w-px py-2.5 pr-2 pl-3 text-left text-xs font-semibold uppercase tracking-[0.18em] whitespace-nowrap text-slate-500 sm:pl-3",
|
||||
first_cell_class="w-px py-3 pr-2 pl-3 text-sm font-medium text-slate-950 sm:pl-3",
|
||||
),
|
||||
table_section(
|
||||
eyebrow="Schedule",
|
||||
|
|
@ -282,14 +307,16 @@ def runs_page(
|
|||
title="Completed job executions",
|
||||
empty_message="No job executions have completed yet.",
|
||||
headers=(
|
||||
"#",
|
||||
"Source",
|
||||
"Execution",
|
||||
"Ended",
|
||||
"Status",
|
||||
"State",
|
||||
"Summary",
|
||||
"Log",
|
||||
),
|
||||
rows=completed_rows,
|
||||
first_header_class="w-px py-2.5 pr-2 pl-3 text-left text-xs font-semibold uppercase tracking-[0.18em] whitespace-nowrap text-slate-500 sm:pl-3",
|
||||
first_cell_class="w-px py-3 pr-2 pl-3 text-sm font-medium text-slate-950 sm:pl-3",
|
||||
),
|
||||
h.script[
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue