diff --git a/frontend/src/lib/components/jobs/JobPreview.svelte b/frontend/src/lib/components/jobs/JobPreview.svelte index e8ca5d046c..fec0254dc8 100644 --- a/frontend/src/lib/components/jobs/JobPreview.svelte +++ b/frontend/src/lib/components/jobs/JobPreview.svelte @@ -15,8 +15,8 @@ const POPUP_HEIGHT = 240 as const export let job: Job | undefined + let hovered = false let timeout: NodeJS.Timeout | undefined - let loadDelay: NodeJS.Timeout | undefined let watchJob: (id: string) => Promise let args = job?.args let result: any @@ -26,34 +26,25 @@ $: open = $openStore === job?.id $: completed = job?.type === Job.type.COMPLETED_JOB + $: running = job && `running` in job ? job.running : false $: scheduled = job?.type === Job.type.QUEUED_JOB $: logs = job?.logs || logs async function instantOpen() { + hovered = true if (!job) { return } popupOnTop = wrapper.getBoundingClientRect().top > POPUP_HEIGHT openStore.set(job.id) if (!loaded) { - if (scheduled && 'scheduled_for' in job && job.scheduled_for) { - if (loadDelay) { - return - } - const time = new Date(job.scheduled_for).getTime() - Date.now() - loadDelay = setTimeout(async () => { - await tick() - job && watchJob && watchJob(job.id) - loadDelay = undefined - }, time) - } else { - await tick() - watchJob && watchJob(job.id) - } + await tick() + watchJob && watchJob(job.id) } } function staggeredOpen() { + hovered = true timeout = setTimeout( async () => { timeout = undefined @@ -64,6 +55,7 @@ } function close() { + hovered = false if (timeout) { clearTimeout(timeout) timeout = undefined @@ -81,12 +73,13 @@ onDestroy(() => { timeout && clearTimeout(timeout) - loadDelay && clearTimeout(loadDelay) }) ['Escape', 'Esc'].includes(key) && close()} /> - +{#if hovered} + +{/if}
- {#if completed} - - {:else if scheduled} + {#if scheduled}
-
Job is scheduled for
+
{running ? 'Next job' : 'Job'} is scheduled for
{new Date(job?.['scheduled_for']).toLocaleString()}
- {:else} + {/if} + {#if completed} + + {:else if running}
Job is still running
- + {/if}