This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
frontend/src/components/self-service/SelfServiceRunTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import {millisToHumanTime} from "@/lib/utils.ts"; | ||
|
||
interface Props { | ||
runs: any[] | ||
} | ||
|
||
function getTotalExecutionTime(tasks: any[]): number { | ||
return tasks.reduce((acc, task) => { | ||
if (task.post_validate_output && task.post_validate_output.execution_time_in_millis) { | ||
return acc + task.post_validate_output.execution_time_in_millis | ||
} | ||
|
||
return acc | ||
}, 0) | ||
} | ||
|
||
export default function SelfServiceRunTable({runs}: Props): JSX.Element { | ||
return ( | ||
<div className="px-4 sm:px-6 lg:px-8"> | ||
<div className="mt-4 flow-root"> | ||
<div className="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> | ||
<div className="inline-block min-w-full py-2 align-middle"> | ||
<table className="min-w-full divide-y divide-gray-300"> | ||
<thead> | ||
<tr> | ||
<th | ||
scope="col" | ||
className="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg:pl-8" | ||
> | ||
Date | ||
</th> | ||
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"> | ||
Status | ||
</th> | ||
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"> | ||
Tasks | ||
</th> | ||
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"> | ||
Execution Time | ||
</th> | ||
<th scope="col" className="relative py-3.5 pl-3 pr-4 sm:pr-6 lg:pr-8"> | ||
<span className="sr-only">Edit</span> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody className="divide-y divide-gray-200 bg-white"> | ||
{runs.map((run) => ( | ||
<tr key={run.id}> | ||
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-500 sm:pl-6 lg:pl-8"> | ||
{run.created_at} | ||
</td> | ||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{run.status}</td> | ||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{run.tasks.length}/{run.tasks.length}</td> | ||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{millisToHumanTime(getTotalExecutionTime(run.tasks))}</td> | ||
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6 lg:pr-8"> | ||
<a href="#" className="text-indigo-600 hover:text-indigo-900"> | ||
Details<span className="sr-only">, {run.name}</span> | ||
</a> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
28 changes: 24 additions & 4 deletions
28
frontend/src/components/self-service/SelfServiceTabRun.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
import EmptyState from "@/components/common/EmptyState.tsx"; | ||
import {useQuery} from "@tanstack/react-query"; | ||
import {API_URL} from "@/config.ts"; | ||
import {useEffect, useState} from "react"; | ||
import SelfServiceRunTable from "@/components/self-service/SelfServiceRunTable.tsx"; | ||
|
||
interface Props { | ||
catalogSlug: string | ||
} | ||
|
||
export default function SelfServiceTabRun({catalogSlug}: Props) { | ||
console.log(catalogSlug); | ||
const [runs, setRuns] = useState([]) | ||
|
||
return <> | ||
<div className="my-5"> | ||
const {status, data} = useQuery({ | ||
queryKey: [`catalogs-${catalogSlug}-runs`], | ||
queryFn: () => | ||
fetch(`${API_URL}/catalogs/${catalogSlug}/runs`).then( | ||
(res) => res.json(), | ||
), | ||
}) | ||
|
||
useEffect(() => { | ||
if (status === 'success') { | ||
setRuns(data.results) | ||
} | ||
}, [status, data]); | ||
|
||
if (runs.length === 0) { | ||
return <div className="my-5"> | ||
<EmptyState text="No Runs" subText="This catalog has no runs"/> | ||
</div> | ||
</> | ||
} | ||
|
||
return <SelfServiceRunTable runs={runs}/> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters