2025-04-03 17:55:18 -04:00
|
|
|
import { Empty } from 'antd';
|
2022-08-19 15:58:31 -04:00
|
|
|
import React from 'react';
|
|
|
|
import styled from 'styled-components/macro';
|
2024-11-13 12:53:31 -05:00
|
|
|
import { SorterResult } from 'antd/lib/table/interface';
|
2025-01-29 20:42:01 -05:00
|
|
|
import { useShowNavBarRedesign } from '@src/app/useShowNavBarRedesign';
|
2022-08-19 15:58:31 -04:00
|
|
|
import { StyledTable } from '../../entity/shared/components/styled/StyledTable';
|
|
|
|
import { ANTD_GRAY } from '../../entity/shared/constants';
|
2024-07-01 09:59:44 -07:00
|
|
|
import { CLI_EXECUTOR_ID, getIngestionSourceStatus } from './utils';
|
2025-04-03 17:55:18 -04:00
|
|
|
import { LastStatusColumn, TypeColumn, ActionsColumn, ScheduleColumn } from './IngestionSourceTableColumns';
|
2022-08-19 15:58:31 -04:00
|
|
|
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
|
|
|
|
2025-01-29 20:42:01 -05:00
|
|
|
const PAGE_HEADER_HEIGHT = 395;
|
|
|
|
|
2022-08-19 15:58:31 -04:00
|
|
|
const StyledSourceTable = styled(StyledTable)`
|
|
|
|
.cliIngestion {
|
|
|
|
td {
|
|
|
|
background-color: ${ANTD_GRAY[2]} !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
` as typeof StyledTable;
|
|
|
|
|
2025-01-29 20:42:01 -05:00
|
|
|
const StyledSourceTableWithNavBarRedesign = styled(StyledSourceTable)`
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
&&& .ant-table-body {
|
|
|
|
overflow-y: auto;
|
|
|
|
height: calc(100vh - ${PAGE_HEADER_HEIGHT}px);
|
|
|
|
}
|
|
|
|
` as typeof StyledSourceTable;
|
|
|
|
|
2022-08-19 15:58:31 -04:00
|
|
|
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;
|
2024-11-13 12:53:31 -05:00
|
|
|
onChangeSort: (field: string, order: SorterResult<any>['order']) => void;
|
2022-08-19 15:58:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function IngestionSourceTable({
|
|
|
|
lastRefresh,
|
|
|
|
sources,
|
|
|
|
setFocusExecutionUrn,
|
|
|
|
onExecute,
|
|
|
|
onEdit,
|
|
|
|
onView,
|
|
|
|
onDelete,
|
|
|
|
onRefresh,
|
2024-11-13 12:53:31 -05:00
|
|
|
onChangeSort,
|
2022-08-19 15:58:31 -04:00
|
|
|
}: Props) {
|
2025-01-29 20:42:01 -05:00
|
|
|
const isShowNavBarRedesign = useShowNavBarRedesign();
|
|
|
|
|
2025-04-03 17:55:18 -04:00
|
|
|
const tableData = sources.map((source) => ({
|
|
|
|
urn: source.urn,
|
|
|
|
type: source.type,
|
|
|
|
name: source.name,
|
|
|
|
platformUrn: source.platform?.urn,
|
|
|
|
schedule: source.schedule?.interval,
|
|
|
|
timezone: source.schedule?.timezone,
|
|
|
|
execCount: source.executions?.total || 0,
|
|
|
|
lastExecUrn:
|
|
|
|
source.executions &&
|
|
|
|
source.executions?.executionRequests?.length > 0 &&
|
|
|
|
source.executions?.executionRequests[0]?.urn,
|
|
|
|
lastExecTime:
|
|
|
|
source.executions &&
|
|
|
|
source.executions?.executionRequests?.length > 0 &&
|
|
|
|
source.executions?.executionRequests[0]?.result?.startTimeMs,
|
|
|
|
lastExecStatus:
|
|
|
|
source.executions &&
|
|
|
|
source.executions?.executionRequests?.length > 0 &&
|
|
|
|
getIngestionSourceStatus(source.executions?.executionRequests[0]?.result),
|
|
|
|
cliIngestion: source.config?.executorId === CLI_EXECUTOR_ID,
|
|
|
|
}));
|
|
|
|
|
2022-08-19 15:58:31 -04:00
|
|
|
const tableColumns = [
|
|
|
|
{
|
|
|
|
title: 'Type',
|
|
|
|
dataIndex: 'type',
|
|
|
|
key: 'type',
|
2023-02-02 15:30:49 -08:00
|
|
|
render: (type: string, record: any) => <TypeColumn type={type} record={record} />,
|
2024-11-13 12:53:31 -05:00
|
|
|
sorter: true,
|
2022-08-19 15:58:31 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
dataIndex: 'name',
|
|
|
|
key: 'name',
|
|
|
|
render: (name: string) => name || '',
|
2024-11-13 12:53:31 -05:00
|
|
|
sorter: true,
|
2022-08-19 15:58:31 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Schedule',
|
|
|
|
dataIndex: 'schedule',
|
|
|
|
key: 'schedule',
|
|
|
|
render: ScheduleColumn,
|
|
|
|
},
|
|
|
|
{
|
2025-04-03 17:55:18 -04:00
|
|
|
title: 'Status',
|
2022-08-19 15:58:31 -04:00
|
|
|
dataIndex: 'lastExecStatus',
|
|
|
|
key: 'lastExecStatus',
|
|
|
|
render: (status: any, record) => (
|
|
|
|
<LastStatusColumn status={status} record={record} setFocusExecutionUrn={setFocusExecutionUrn} />
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '',
|
|
|
|
dataIndex: '',
|
|
|
|
key: 'x',
|
|
|
|
render: (_, record: any) => (
|
|
|
|
<ActionsColumn
|
|
|
|
record={record}
|
|
|
|
setFocusExecutionUrn={setFocusExecutionUrn}
|
|
|
|
onExecute={onExecute}
|
|
|
|
onDelete={onDelete}
|
|
|
|
onView={onView}
|
|
|
|
onEdit={onEdit}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2024-11-13 12:53:31 -05:00
|
|
|
const handleTableChange = (_: any, __: any, sorter: any) => {
|
|
|
|
const sorterTyped: SorterResult<any> = sorter;
|
|
|
|
const field = sorterTyped.field as string;
|
|
|
|
const { order } = sorterTyped;
|
|
|
|
onChangeSort(field, order);
|
|
|
|
};
|
|
|
|
|
2025-01-29 20:42:01 -05:00
|
|
|
const FinalStyledSourceTable = isShowNavBarRedesign ? StyledSourceTableWithNavBarRedesign : StyledSourceTable;
|
|
|
|
|
2022-08-19 15:58:31 -04:00
|
|
|
return (
|
2025-01-29 20:42:01 -05:00
|
|
|
<FinalStyledSourceTable
|
2022-08-19 15:58:31 -04:00
|
|
|
columns={tableColumns}
|
2024-11-13 12:53:31 -05:00
|
|
|
onChange={handleTableChange}
|
2022-08-19 15:58:31 -04:00
|
|
|
dataSource={tableData}
|
2025-01-29 20:42:01 -05:00
|
|
|
scroll={isShowNavBarRedesign ? { y: 'max-content', x: 'max-content' } : {}}
|
2022-08-19 15:58:31 -04:00
|
|
|
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;
|