2022-08-19 17:16:04 +05:30
|
|
|
import { Typography } from 'antd';
|
2022-08-11 11:45:28 +05:30
|
|
|
import LogItem from 'components/Logs/LogItem';
|
|
|
|
|
import Spinner from 'components/Spinner';
|
2023-01-16 17:56:46 +05:30
|
|
|
import React, { memo, useCallback, useMemo } from 'react';
|
2022-11-23 13:42:36 +05:30
|
|
|
import { useSelector } from 'react-redux';
|
2023-01-16 17:56:46 +05:30
|
|
|
import { Virtuoso } from 'react-virtuoso';
|
2022-08-11 11:45:28 +05:30
|
|
|
import { AppState } from 'store/reducers';
|
2022-08-19 17:16:04 +05:30
|
|
|
import { ILogsReducer } from 'types/reducer/logs';
|
2022-08-11 11:45:28 +05:30
|
|
|
|
|
|
|
|
import { Container, Heading } from './styles';
|
|
|
|
|
|
2022-11-23 13:42:36 +05:30
|
|
|
function LogsTable(): JSX.Element {
|
|
|
|
|
const { logs, isLoading, liveTail } = useSelector<AppState, ILogsReducer>(
|
|
|
|
|
(state) => state.logs,
|
2022-08-11 11:45:28 +05:30
|
|
|
);
|
|
|
|
|
|
2023-01-16 17:56:46 +05:30
|
|
|
const isLiveTail = useMemo(() => logs.length === 0 && liveTail === 'PLAYING', [
|
|
|
|
|
logs?.length,
|
|
|
|
|
liveTail,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const isNoLogs = useMemo(() => logs.length === 0 && liveTail === 'STOPPED', [
|
|
|
|
|
logs?.length,
|
|
|
|
|
liveTail,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const getItemContent = useCallback(
|
|
|
|
|
(index: number): JSX.Element => {
|
|
|
|
|
const log = logs[index];
|
|
|
|
|
return <LogItem key={log.id} logData={log} />;
|
|
|
|
|
},
|
|
|
|
|
[logs],
|
|
|
|
|
);
|
|
|
|
|
|
2022-08-11 11:45:28 +05:30
|
|
|
if (isLoading) {
|
|
|
|
|
return <Spinner height={20} tip="Getting Logs" />;
|
|
|
|
|
}
|
2022-11-12 11:37:52 +05:30
|
|
|
|
2022-08-11 11:45:28 +05:30
|
|
|
return (
|
2022-08-19 17:16:04 +05:30
|
|
|
<Container flex="auto">
|
2022-08-11 11:45:28 +05:30
|
|
|
<Heading>
|
2023-01-11 14:39:06 +05:30
|
|
|
<Typography.Text>Event</Typography.Text>
|
2022-08-11 11:45:28 +05:30
|
|
|
</Heading>
|
2023-01-16 17:56:46 +05:30
|
|
|
{isLiveTail && <Typography>Getting live logs...</Typography>}
|
|
|
|
|
|
|
|
|
|
{isNoLogs && <Typography>No log lines found</Typography>}
|
|
|
|
|
|
|
|
|
|
<Virtuoso
|
|
|
|
|
useWindowScroll
|
|
|
|
|
totalCount={logs.length}
|
|
|
|
|
itemContent={getItemContent}
|
|
|
|
|
/>
|
2022-08-11 11:45:28 +05:30
|
|
|
</Container>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-23 13:42:36 +05:30
|
|
|
export default memo(LogsTable);
|