You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.4 KiB
55 lines
1.4 KiB
import { faSync } from "@fortawesome/free-solid-svg-icons";
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
import React, { FunctionComponent, useMemo } from "react";
|
|
import { Column } from "react-table";
|
|
import { SystemApi } from "../../apis";
|
|
import { AsyncButton, SimpleTable } from "../../components";
|
|
|
|
interface Props {
|
|
tasks: readonly System.Task[];
|
|
}
|
|
|
|
const Table: FunctionComponent<Props> = ({ tasks }) => {
|
|
const columns: Column<System.Task>[] = useMemo<Column<System.Task>[]>(
|
|
() => [
|
|
{
|
|
Header: "Name",
|
|
accessor: "name",
|
|
className: "text-nowrap",
|
|
},
|
|
{
|
|
Header: "Interval",
|
|
accessor: "interval",
|
|
className: "text-nowrap",
|
|
},
|
|
{
|
|
Header: "Next Execution",
|
|
accessor: "next_run_in",
|
|
className: "text-nowrap",
|
|
},
|
|
{
|
|
accessor: "job_running",
|
|
Cell: (row) => {
|
|
const { job_id } = row.row.original;
|
|
return (
|
|
<AsyncButton
|
|
promise={() => SystemApi.runTask(job_id)}
|
|
variant="light"
|
|
size="sm"
|
|
disabled={row.value}
|
|
animation={false}
|
|
>
|
|
<FontAwesomeIcon icon={faSync} spin={row.value}></FontAwesomeIcon>
|
|
</AsyncButton>
|
|
);
|
|
},
|
|
},
|
|
],
|
|
[]
|
|
);
|
|
|
|
return <SimpleTable columns={columns} data={tasks}></SimpleTable>;
|
|
};
|
|
|
|
export default Table;
|