mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Improved progress status section layout
This commit is contained in:
1 parent
ecc0e4c8df
commit
badf12b991
9 files changed
+154
-32
No files matched your search
@@ -1461,6 +1461,8 @@ export default function App() {
|
||||
done: batchJobStatus.data?.done ?? 0,
|
||||
total: batchJobStatus.data?.total ?? 0,
|
||||
detail: batchJobStatus.data?.message,
|
||||
fraction: batchJobStatus.data?.fraction,
|
||||
status: batchJobStatus.data?.status,
|
||||
cancelling: batchCancelling,
|
||||
onCancel: () => {
|
||||
setBatchCancelling(true)
|
||||
|
||||
@@ -411,6 +411,11 @@ export interface JobStatus {
|
||||
* is written; '' when unspecified. */
|
||||
unit: string
|
||||
message: string
|
||||
/** The CURRENT item's own progress, 0..1 — so the overall bar moves within
|
||||
* a long item. Resets as each item starts. */
|
||||
fraction: number
|
||||
/** What the current item is doing, e.g. "separating 41 %". */
|
||||
status: string
|
||||
result: Record<string, unknown> | null
|
||||
error: string | null
|
||||
started_at: number
|
||||
|
||||
@@ -5,8 +5,14 @@ export interface StatusJob {
|
||||
done: number
|
||||
/** 0 until the job knows its size → indeterminate bar. */
|
||||
total: number
|
||||
/** What it is working on right now, e.g. the current track's title. */
|
||||
/** What it is working on right now, e.g. the current track's title. This is
|
||||
* the one part that shortens when space runs out. */
|
||||
detail?: string
|
||||
/** How far the current item has got, 0..1: the TOP half of a split bar (the
|
||||
* bottom half is the whole job, which moves within an item too). */
|
||||
fraction?: number
|
||||
/** What the current item is doing ("separating 41 %") — never truncated. */
|
||||
status?: string
|
||||
cancelling?: boolean
|
||||
onCancel: () => void
|
||||
/** `bytes`: done/total are byte counts (a download), shown in MB. */
|
||||
@@ -37,12 +43,16 @@ export function StatusBar({
|
||||
}: Props) {
|
||||
return (
|
||||
<div className="glass flex h-7 shrink-0 items-center gap-3 !rounded-full px-4 text-[11px] text-muted">
|
||||
<span className="font-medium text-text">{sourceName}</span>
|
||||
{/* The view's name gives way on a narrow window — the job section on the
|
||||
right is a fixed width and does not. */}
|
||||
<span className="min-w-0 truncate font-medium text-text" title={sourceName}>
|
||||
{sourceName}
|
||||
</span>
|
||||
<span className="text-faint">·</span>
|
||||
{loading ? (
|
||||
<span>Loading…</span>
|
||||
) : (
|
||||
<span className="tabular-nums">
|
||||
<span className="shrink-0 tabular-nums">
|
||||
{showing === total ? (
|
||||
<>{total.toLocaleString()} tracks</>
|
||||
) : (
|
||||
@@ -55,27 +65,76 @@ export function StatusBar({
|
||||
{selected > 0 && (
|
||||
<>
|
||||
<span className="text-faint">·</span>
|
||||
<span className="tabular-nums text-accent">{selected.toLocaleString()} selected</span>
|
||||
<span className="shrink-0 tabular-nums text-accent">{selected.toLocaleString()} selected</span>
|
||||
</>
|
||||
)}
|
||||
{job && (
|
||||
<div className="ml-auto flex min-w-0 items-center gap-2">
|
||||
<span className="shrink-0 tabular-nums text-text">
|
||||
{job.cancelling ? 'Cancelling…' : job.label}
|
||||
{job.total > 0 &&
|
||||
(job.unit === 'bytes'
|
||||
? ` ${Math.round(job.done / 1e6)}/${Math.round(job.total / 1e6)} MB`
|
||||
: ` ${Math.min(job.done + 1, job.total)}/${job.total}`)}
|
||||
</span>
|
||||
<span className="well h-1.5 w-32 shrink-0 overflow-hidden rounded-full">
|
||||
// FIXED positions: the section is a fixed width, and everything before
|
||||
// the name has a fixed width too (the count sized for its largest value,
|
||||
// the status a fixed slot), so neither a long track name nor
|
||||
// "decoding" → "separating" can move the bar. The name fills what is
|
||||
// left and is the only thing that shortens.
|
||||
<div className="ml-auto flex w-[560px] shrink-0 items-center gap-2">
|
||||
<span className="shrink-0 text-text">{job.label}</span>
|
||||
{job.total > 1 && job.unit !== 'bytes' && (
|
||||
<span
|
||||
className={`block h-full rounded-full bg-gradient-to-r from-[var(--amb-1)] to-accent shadow-[0_0_8px_var(--color-accent)] transition-[width] duration-300 ${
|
||||
job.total > 0 ? '' : 'w-1/3 animate-pulse'
|
||||
}`}
|
||||
style={job.total > 0 ? { width: `${(job.done / job.total) * 100}%` } : undefined}
|
||||
/>
|
||||
className="-ml-1 shrink-0 text-left tabular-nums text-text"
|
||||
style={{ minWidth: `${2 * String(job.total).length + 1}ch` }}
|
||||
>
|
||||
{Math.min(job.done + 1, job.total)}/{job.total}
|
||||
</span>
|
||||
)}
|
||||
{/* One bar, split horizontally when the job reports per-item progress
|
||||
(a stem conversion): TOP = the current item, 0-100 % across the
|
||||
full width; BOTTOM = the whole job, (done + fraction) / total, so
|
||||
it moves within a long item too. Other jobs: one full-height bar. */}
|
||||
{(() => {
|
||||
const fill =
|
||||
'absolute inset-y-0 left-0 rounded-full bg-gradient-to-r from-[var(--amb-1)] to-accent shadow-[0_0_6px_var(--color-accent)] transition-[width] duration-300'
|
||||
const pct = (v: number) => `${Math.max(0, Math.min(1, v)) * 100}%`
|
||||
if (job.total <= 0) {
|
||||
return (
|
||||
<span className="well h-2 w-32 shrink-0 overflow-hidden rounded-full">
|
||||
<span className="block h-full w-1/3 animate-pulse rounded-full bg-accent" />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
const overall = (job.done + (job.unit === 'bytes' ? 0 : job.fraction ?? 0)) / job.total
|
||||
if (job.unit === 'bytes' || !job.status) {
|
||||
return (
|
||||
<span className="well relative h-2 w-32 shrink-0 overflow-hidden rounded-full">
|
||||
<span className={fill} style={{ width: pct(overall) }} />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<span className="flex h-3.5 w-32 shrink-0 flex-col gap-[2px]" title="Top: this track · bottom: overall">
|
||||
<span className="well relative flex-1 overflow-hidden rounded-full">
|
||||
<span className={fill} style={{ width: pct(job.fraction ?? 0) }} />
|
||||
</span>
|
||||
<span className="well relative flex-1 overflow-hidden rounded-full">
|
||||
<span className={fill} style={{ width: pct(overall) }} />
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
})()}
|
||||
{/* Status at its natural width: it sits AFTER the bar, so it cannot
|
||||
move it — and a fixed slot left a gap before the name. */}
|
||||
{(job.cancelling || job.status || (job.unit === 'bytes' && job.total > 0)) && (
|
||||
<>
|
||||
<span className="shrink-0 tabular-nums text-muted">
|
||||
{job.cancelling
|
||||
? 'cancelling…'
|
||||
: job.unit === 'bytes'
|
||||
? `${Math.round(job.done / 1e6)} / ${Math.round(job.total / 1e6)} MB`
|
||||
: job.status}
|
||||
</span>
|
||||
{job.detail && <span className="shrink-0 text-faint">·</span>}
|
||||
</>
|
||||
)}
|
||||
<span className="min-w-0 flex-1 truncate text-faint" title={job.detail}>
|
||||
{job.detail}
|
||||
</span>
|
||||
{job.detail && <span className="max-w-[240px] truncate text-faint">{job.detail}</span>}
|
||||
<button
|
||||
onClick={job.onCancel}
|
||||
disabled={job.cancelling}
|
||||
|
||||
Reference in new issue
Block a user