2022-08-19 15:58:31 -04:00
|
|
|
import { Empty, Typography } from 'antd';
|
|
|
|
import React from 'react';
|
|
|
|
import styled from 'styled-components/macro';
|
|
|
|
import { StyledTable } from '../../entity/shared/components/styled/StyledTable';
|
|
|
|
import { ANTD_GRAY } from '../../entity/shared/constants';
|
|
|
|
import { CLI_EXECUTOR_ID } from './utils';
|
|
|
|
import {
|
|
|
|
LastStatusColumn,
|
|
|
|
TypeColumn,
|
|
|
|
ActionsColumn,
|
|
|
|
ScheduleColumn,
|
|
|
|
LastExecutionColumn,
|
|
|
|
} from './IngestionSourceTableColumns';
|
|
|
|
import { IngestionSource } from '../../../types.generated';
|
2022-08-29 19:11:59 -04:00
|
|
|
import { IngestionSourceExecutionList } from './executions/IngestionSourceExecutionList';
|
2022-08-19 15:58:31 -04:00
|
|
|
|
|
|
|
const StyledSourceTable = styled(StyledTable)`
|
|
|
|
.cliIngestion {
|
|
|
|
td {
|
|
|
|
background-color: ${ANTD_GRAY[2]} !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
` as typeof StyledTable;
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
lastRefresh: number;
|
|
|
|
sources: IngestionSource[];
|
|
|
|
setFocusExecutionUrn: (urn: string) => void;
|
|
|
|
onExecute: (urn: string) => void;
|
|
|
|
onEdit: (urn: string) => void;
|
|
|
|
onView: (urn: string) => void;
|
|
|
|
onDelete: (urn: string) => void;
|
|
|
|
onRefresh: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
function IngestionSourceTable({
|
|
|
|
lastRefresh,
|
|
|
|
sources,
|
|
|
|
setFocusExecutionUrn,
|
|
|
|
onExecute,
|
|
|
|
onEdit,
|
|
|
|
onView,
|
|
|
|
onDelete,
|
|
|
|
onRefresh,
|
|
|
|
}: Props) {
|
|
|
|
const tableColumns = [
|
|
|
|
{
|
|
|
|
title: 'Type',
|
|
|
|
dataIndex: 'type',
|
|
|
|
key: 'type',
|
|
|
|
render: TypeColumn,
|
2022-09-09 17:14:33 -04:00
|
|
|
sorter: (sourceA, sourceB) => sourceA.type.localeCompare(sourceB.type),
|
2022-08-19 15:58:31 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
dataIndex: 'name',
|
|
|
|
key: 'name',
|
|
|
|
render: (name: string) => name || '',
|
2022-09-09 17:14:33 -04:00
|
|
|
sorter: (sourceA, sourceB) => sourceA.name.localeCompare(sourceB.name),
|
2022-08-19 15:58:31 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Schedule',
|
|
|
|
dataIndex: 'schedule',
|
|
|
|
key: 'schedule',
|
|
|
|
render: ScheduleColumn,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Execution Count',
|
|
|
|
dataIndex: 'execCount',
|
|
|
|
key: 'execCount',
|
|
|
|
render: (execCount: any) => <Typography.Text>{execCount || '0'}</Typography.Text>,
|
2022-09-09 17:14:33 -04:00
|
|
|
sorter: (sourceA, sourceB) => sourceA.execCount - sourceB.execCount,
|
2022-08-19 15:58:31 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Last Execution',
|
|
|
|
dataIndex: 'lastExecTime',
|
|
|
|
key: 'lastExecTime',
|
|
|
|
render: LastExecutionColumn,
|
2022-09-09 17:14:33 -04:00
|
|
|
sorter: (sourceA, sourceB) => sourceA.lastExecTime - sourceB.lastExecTime,
|
2022-08-19 15:58:31 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Last Status',
|
|
|
|
dataIndex: 'lastExecStatus',
|
|
|
|
key: 'lastExecStatus',
|
|
|
|
render: (status: any, record) => (
|
|
|
|
<LastStatusColumn status={status} record={record} setFocusExecutionUrn={setFocusExecutionUrn} />
|
|
|
|
),
|
2022-09-09 17:14:33 -04:00
|
|
|
sorter: (sourceA, sourceB) => (sourceA.lastExecStatus || '').localeCompare(sourceB.lastExecStatus || ''),
|
2022-08-19 15:58:31 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '',
|
|
|
|
dataIndex: '',
|
|
|
|
key: 'x',
|
|
|
|
render: (_, record: any) => (
|
|
|
|
<ActionsColumn
|
|
|
|
record={record}
|
|
|
|
setFocusExecutionUrn={setFocusExecutionUrn}
|
|
|
|
onExecute={onExecute}
|
|
|
|
onDelete={onDelete}
|
|
|
|
onView={onView}
|
|
|
|
onEdit={onEdit}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const tableData = sources.map((source) => ({
|
|
|
|
urn: source.urn,
|
|
|
|
type: source.type,
|
|
|
|
name: source.name,
|
2022-09-13 13:27:12 -04:00
|
|
|
platformUrn: source.platform?.urn,
|
2022-08-19 15:58:31 -04:00
|
|
|
schedule: source.schedule?.interval,
|
|
|
|
timezone: source.schedule?.timezone,
|
|
|
|
execCount: source.executions?.total || 0,
|
|
|
|
lastExecUrn:
|
|
|
|
source.executions?.total && source.executions?.total > 0 && source.executions?.executionRequests[0].urn,
|
|
|
|
lastExecTime:
|
|
|
|
source.executions?.total &&
|
|
|
|
source.executions?.total > 0 &&
|
|
|
|
source.executions?.executionRequests[0].result?.startTimeMs,
|
|
|
|
lastExecStatus:
|
|
|
|
source.executions?.total &&
|
|
|
|
source.executions?.total > 0 &&
|
|
|
|
source.executions?.executionRequests[0].result?.status,
|
2022-12-05 22:20:24 -08:00
|
|
|
cliIngestion: source.config?.executorId === CLI_EXECUTOR_ID,
|
2022-08-19 15:58:31 -04:00
|
|
|
}));
|
|
|
|
|
|
|
|
return (
|
|
|
|
<StyledSourceTable
|
|
|
|
columns={tableColumns}
|
|
|
|
dataSource={tableData}
|
|
|
|
rowKey="urn"
|
|
|
|
rowClassName={(record, _) => (record.cliIngestion ? 'cliIngestion' : '')}
|
|
|
|
locale={{
|
|
|
|
emptyText: <Empty description="No Ingestion Sources!" image={Empty.PRESENTED_IMAGE_SIMPLE} />,
|
|
|
|
}}
|
|
|
|
expandable={{
|
2022-08-22 14:12:44 -04:00
|
|
|
expandedRowRender: (record, _index, _indent, expanded) => {
|
2022-08-19 15:58:31 -04:00
|
|
|
return (
|
|
|
|
<IngestionSourceExecutionList
|
|
|
|
urn={record.urn}
|
2022-08-22 14:12:44 -04:00
|
|
|
isExpanded={expanded}
|
2022-08-19 15:58:31 -04:00
|
|
|
lastRefresh={lastRefresh}
|
|
|
|
onRefresh={onRefresh}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
rowExpandable: (record) => {
|
|
|
|
return record.execCount > 0;
|
|
|
|
},
|
|
|
|
defaultExpandAllRows: false,
|
|
|
|
indentSize: 0,
|
|
|
|
}}
|
|
|
|
pagination={false}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default IngestionSourceTable;
|