From 9b710849e1413ff5241c3d23ea0efc2d9f107d9f Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 23 Aug 2022 02:10:54 +0200 Subject: [PATCH] first pass on runs refactor --- frontend/src/lib/utils.ts | 12 +- frontend/src/routes/run/[...run].svelte | 5 +- frontend/src/routes/runs/[...path].svelte | 156 ++++++++++++---------- 3 files changed, 95 insertions(+), 78 deletions(-) diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 5a0decfa7b..9f9326efd1 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -32,7 +32,12 @@ export function displayDaysAgo(dateString: string): string { } else if (isToday(date)) { return `today at ${date.toLocaleTimeString()}` } else { - return `${daysAgo(date) + 1} days ago` + let dAgo = daysAgo(date) + if (dAgo == 0) { + return `yday at ${date.toLocaleTimeString()}` + } else { + return `${dAgo + 1} days ago` + } } } @@ -41,9 +46,8 @@ export function displayDate(dateString: string | undefined): string { if (date.toString() === 'Invalid Date') { return '' } else { - return `${date.getFullYear()}/${ - date.getMonth() + 1 - }/${date.getDate()} at ${date.toLocaleTimeString()}` + return `${date.getFullYear()}/${date.getMonth() + 1 + }/${date.getDate()} at ${date.toLocaleTimeString()}` } } diff --git a/frontend/src/routes/run/[...run].svelte b/frontend/src/routes/run/[...run].svelte index 550b8ba2ac..ac0dc1e542 100644 --- a/frontend/src/routes/run/[...run].svelte +++ b/frontend/src/routes/run/[...run].svelte @@ -380,14 +380,15 @@ >{job.schedule_path} - {:else} + {/if} +
By {job.created_by} {#if job.permissioned_as != `u/${job.created_by}`}but permissioned as {job.permissioned_as}{/if} - {/if} +
run id: {job.id} diff --git a/frontend/src/routes/runs/[...path].svelte b/frontend/src/routes/runs/[...path].svelte index 17d940a0b0..df7ae9d547 100644 --- a/frontend/src/routes/runs/[...path].svelte +++ b/frontend/src/routes/runs/[...path].svelte @@ -15,7 +15,8 @@ forLater, setQuery, truncateHash, - msToSec + msToSec, + truncateRev } from '$lib/utils' import Icon from 'svelte-awesome' import { check } from 'svelte-awesome/icons' @@ -53,8 +54,7 @@ : false let showOlderJobs = true - // The API returns 30 jobs per page. We use it to display a next page button or not. - const jobsPerPage = 30 + const jobsPerPage = 100 let jobKindsCat: string | undefined = $page.url.searchParams.get('job_kinds') ?? 'runs' @@ -205,8 +205,8 @@ the bearer token they use has less privilege." {#if jobs} {#each jobs as job}
-
-
+
+
{#if job === undefined} No job found @@ -259,7 +259,7 @@ the bearer token they use has less privilege." {/if}
-

+

{#if job.script_path} {job.script_path} {:else if 'job_kind' in job && job.job_kind == 'preview'} @@ -285,90 +285,102 @@ the bearer token they use has less privilege." {/if}

- Run {job.id} + Run {job.id}
-
-
- - Created {displayDaysAgo(job.created_at ?? '')} -
- {#if 'started_at' in job && job.started_at} +
+
- Started {displayDaysAgo(job.started_at ?? '')}
- {/if} - {#if job && 'duration_ms' in job && job.duration_ms != undefined} + {#if 'started_at' in job && job.started_at} +
+ + Started {displayDaysAgo(job.started_at ?? '')} +
+ {/if} + {#if 'scheduled_for' in job && !job.running && job.scheduled_for && forLater(job.scheduled_for)} +
+ + Scheduled + for {displayDate(job.scheduled_for ?? '')} + +
+ {:else if 'scheduled_for' in job && !job.running} +
+ + Waiting for an executor + +
+ {/if} +
+
- Ran in {msToSec(job.duration_ms)}s -
- {/if} -
- {#if job && job.parent_job} - {#if job.is_flow_step} - - Step of flow {job.parent_job} - {:else} - - Triggered by parent {job.parent_job} - {/if} - {:else if job && job.schedule_path} - - Triggered by the schedule: {job.schedule_path} - {:else} By {job.created_by} +
+ {#if job && 'duration_ms' in job && job.duration_ms != undefined} +
+ Ran in {msToSec(job.duration_ms)}s +
{/if} -
- {#if 'scheduled_for' in job && !job.running && job.scheduled_for && forLater(job.scheduled_for)}
- - Scheduled - for {displayDate(job.scheduled_for ?? '')} - -
- {:else if 'scheduled_for' in job && !job.running} -
- - Waiting for an executor + Step of flow {truncateRev(job.parent_job, 6)} + {:else} + + Triggered by parent {job.parent_job} + {/if} + {:else if job && job.schedule_path} + + Triggered by the schedule: {job.schedule_path} - + {/if}
- {/if} +