generated from john/python-template
coloring and page tweaks
This commit is contained in:
@@ -185,36 +185,15 @@ def render_document_panzoom(*, document: Document, height: str = "640px") -> Non
|
|||||||
document_url = _document_url(document)
|
document_url = _document_url(document)
|
||||||
document_kind = _document_kind(document)
|
document_kind = _document_kind(document)
|
||||||
|
|
||||||
with ui.card().classes("w-full bg-blue-grey-10 text-grey-1 q-pa-md"):
|
with ui.card().classes("w-full q-pa-md"):
|
||||||
with ui.row().classes("w-full items-center justify-between q-gutter-sm"):
|
with ui.column().classes("q-gutter-none"):
|
||||||
with ui.column().classes("q-gutter-none"):
|
with ui.row().classes("w-full items-center justify-between q-gutter-sm"):
|
||||||
ui.label("Document preview").classes("text-subtitle1 text-weight-medium")
|
ui.label("Document preview").classes("text-subtitle1 text-weight-medium")
|
||||||
ui.label(document.filename).classes("text-caption text-grey-4")
|
ui.label(document.filename).classes("text-caption text-grey-4")
|
||||||
|
|
||||||
with ui.button_group().props("flat outline"):
|
|
||||||
ui.button(
|
|
||||||
"Zoom In",
|
|
||||||
icon="add",
|
|
||||||
on_click=lambda: ui.run_javascript(f"window.__transcriptionPanzoom[{host_id!r}]?.zoomIn()"),
|
|
||||||
)
|
|
||||||
ui.button(
|
|
||||||
"Zoom Out",
|
|
||||||
icon="remove",
|
|
||||||
on_click=lambda: ui.run_javascript(f"window.__transcriptionPanzoom[{host_id!r}]?.zoomOut()"),
|
|
||||||
)
|
|
||||||
ui.button(
|
|
||||||
"Reset",
|
|
||||||
icon="restart_alt",
|
|
||||||
on_click=lambda: ui.run_javascript(f"window.__transcriptionPanzoom[{host_id!r}]?.reset()"),
|
|
||||||
)
|
|
||||||
|
|
||||||
ui.label("Scroll, pinch, or use the buttons to inspect the document.").classes(
|
|
||||||
"text-caption text-grey-4 q-mt-sm"
|
|
||||||
)
|
|
||||||
|
|
||||||
with (
|
with (
|
||||||
ui.element("div")
|
ui.element("div")
|
||||||
.classes("w-full document-panzoom-host bg-blue-grey-9 rounded-borders q-mt-md")
|
.classes("w-full document-panzoom-host rounded-borders q-mt-md")
|
||||||
.style(f"height: {height};") as host
|
.style(f"height: {height};") as host
|
||||||
):
|
):
|
||||||
host.props(f"id={host_id}")
|
host.props(f"id={host_id}")
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
|
||||||
from nicegui import ui
|
from nicegui import ui
|
||||||
@@ -11,6 +12,8 @@ from transcription.models import Job
|
|||||||
from transcription.models import Transcript
|
from transcription.models import Transcript
|
||||||
from transcription.ui.components.document_panzoom import render_document_panzoom
|
from transcription.ui.components.document_panzoom import render_document_panzoom
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _status_chip_classes(status: str) -> str:
|
def _status_chip_classes(status: str) -> str:
|
||||||
if status == "queued":
|
if status == "queued":
|
||||||
@@ -31,21 +34,21 @@ def _metadata_row(label: str, value: str) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def _render_document_section(document: Document) -> None:
|
def _render_document_section(document: Document) -> None:
|
||||||
with ui.card().classes("w-full bg-blue-grey-10 text-grey-1 q-pa-md"):
|
with ui.card().classes("w-full q-pa-md"):
|
||||||
ui.label("Document").classes("text-subtitle1 text-weight-medium")
|
ui.label("Document").classes("text-subtitle1 text-weight-medium")
|
||||||
ui.separator().classes("q-my-sm bg-blue-grey-7")
|
ui.separator().classes("q-my-sm")
|
||||||
with ui.column().classes("w-full q-gutter-y-xs"):
|
with ui.column().classes("w-full q-gutter-y-xs"):
|
||||||
_metadata_row("Filename", document.filename)
|
_metadata_row("Filename", document.filename)
|
||||||
_metadata_row("File path", document.file_path)
|
_metadata_row("File path", document.file_path)
|
||||||
|
|
||||||
ui.separator().classes("q-my-md bg-blue-grey-7")
|
ui.separator().classes("q-my-md")
|
||||||
render_document_panzoom(document=document)
|
render_document_panzoom(document=document)
|
||||||
|
|
||||||
|
|
||||||
def _render_transcript_section(transcripts: Sequence[Transcript]) -> None:
|
def _render_transcript_section(transcripts: Sequence[Transcript]) -> None:
|
||||||
with ui.card().classes("w-full bg-blue-grey-10 text-grey-1 q-pa-md"):
|
with ui.card().classes("w-full q-pa-md"):
|
||||||
ui.label("Transcripts").classes("text-subtitle1 text-weight-medium")
|
ui.label("Transcripts").classes("text-subtitle1 text-weight-medium")
|
||||||
ui.separator().classes("q-my-sm bg-blue-grey-7")
|
ui.separator().classes("q-my-sm")
|
||||||
|
|
||||||
if not transcripts:
|
if not transcripts:
|
||||||
ui.label("Transcript history is not available yet.").classes("text-body2 text-grey-3")
|
ui.label("Transcript history is not available yet.").classes("text-body2 text-grey-3")
|
||||||
@@ -59,11 +62,11 @@ def _render_transcript_section(transcripts: Sequence[Transcript]) -> None:
|
|||||||
_metadata_row("Created", transcript.created_at.isoformat())
|
_metadata_row("Created", transcript.created_at.isoformat())
|
||||||
|
|
||||||
if transcript.text:
|
if transcript.text:
|
||||||
ui.separator().classes("q-my-sm bg-blue-grey-7")
|
ui.separator().classes("q-my-sm")
|
||||||
with ui.card().classes("w-full bg-blue-grey-9 text-grey-1 q-pa-sm"):
|
with ui.card().classes("w-fullq-pa-sm"):
|
||||||
ui.markdown(transcript.text).classes("text-grey-1")
|
ui.markdown(transcript.text).classes("text-grey-1")
|
||||||
elif transcript.error_detail:
|
elif transcript.error_detail:
|
||||||
ui.separator().classes("q-my-sm bg-blue-grey-7")
|
ui.separator().classes("q-my-sm")
|
||||||
with ui.card().classes("w-full bg-red-1 text-red-10 q-pa-sm"):
|
with ui.card().classes("w-full bg-red-1 text-red-10 q-pa-sm"):
|
||||||
ui.label("Failure detail").classes("text-caption text-uppercase")
|
ui.label("Failure detail").classes("text-caption text-uppercase")
|
||||||
ui.label(transcript.error_detail).classes("text-body2")
|
ui.label(transcript.error_detail).classes("text-body2")
|
||||||
@@ -73,9 +76,10 @@ def _render_transcript_section(transcripts: Sequence[Transcript]) -> None:
|
|||||||
|
|
||||||
def render_job_detail(*, job: Job, document: Document | None, transcripts: Sequence[Transcript]) -> None:
|
def render_job_detail(*, job: Job, document: Document | None, transcripts: Sequence[Transcript]) -> None:
|
||||||
"""Render all sections for the job detail page."""
|
"""Render all sections for the job detail page."""
|
||||||
|
logger.debug("Rendering job detail for job ID %s with %d transcripts", job.id, len(transcripts))
|
||||||
status_text = job.status.value
|
status_text = job.status.value
|
||||||
with ui.column().classes("w-full max-w-4xl q-gutter-md"):
|
with ui.column().classes("w-full max-w-4xl q-gutter-md"):
|
||||||
with ui.card().classes("w-full bg-blue-grey-10 text-grey-1 q-pa-lg"):
|
with ui.card().classes("w-full q-pa-lg"):
|
||||||
with ui.row().classes("w-full items-center justify-between q-gutter-md"):
|
with ui.row().classes("w-full items-center justify-between q-gutter-md"):
|
||||||
with ui.column().classes("q-gutter-none"):
|
with ui.column().classes("q-gutter-none"):
|
||||||
ui.label("Job overview").classes("text-h6 text-weight-bold")
|
ui.label("Job overview").classes("text-h6 text-weight-bold")
|
||||||
|
|||||||
@@ -67,5 +67,3 @@ def register_page() -> None:
|
|||||||
|
|
||||||
transcripts = list(await transcription_service.list_transcripts_by_job(parsed_id))
|
transcripts = list(await transcription_service.list_transcripts_by_job(parsed_id))
|
||||||
render_job_detail(job=job, document=job.document, transcripts=transcripts)
|
render_job_detail(job=job, document=job.document, transcripts=transcripts)
|
||||||
|
|
||||||
ui.link("Back to jobs", "/jobs")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user