2023-06-16 13:38:39 +03:00
|
|
|
import { Button, Col, Row } from 'antd';
|
|
|
|
|
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
2023-06-23 11:19:53 +03:00
|
|
|
import LogsExplorerViews from 'container/LogsExplorerViews';
|
2023-06-16 13:38:39 +03:00
|
|
|
import { QueryBuilder } from 'container/QueryBuilder';
|
2023-07-06 14:22:44 +03:00
|
|
|
import { QueryBuilderProps } from 'container/QueryBuilder/QueryBuilder.interfaces';
|
2023-06-16 13:38:39 +03:00
|
|
|
import { useGetPanelTypesQueryParam } from 'hooks/queryBuilder/useGetPanelTypesQueryParam';
|
|
|
|
|
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
|
|
|
|
import { useShareBuilderUrl } from 'hooks/queryBuilder/useShareBuilderUrl';
|
2023-06-23 11:19:53 +03:00
|
|
|
import { useMemo } from 'react';
|
2023-06-16 13:38:39 +03:00
|
|
|
import { DataSource } from 'types/common/queryBuilder';
|
|
|
|
|
|
|
|
|
|
// ** Styles
|
|
|
|
|
import { ButtonWrapperStyled, WrapperStyled } from './styles';
|
2023-07-06 14:22:44 +03:00
|
|
|
import { prepareQueryWithDefaultTimestamp } from './utils';
|
2023-06-16 13:38:39 +03:00
|
|
|
|
2023-06-23 21:39:59 +03:00
|
|
|
function LogsExplorer(): JSX.Element {
|
2023-06-23 11:19:53 +03:00
|
|
|
const { handleRunQuery, updateAllQueriesOperators } = useQueryBuilder();
|
2023-06-16 13:38:39 +03:00
|
|
|
const panelTypes = useGetPanelTypesQueryParam(PANEL_TYPES.LIST);
|
|
|
|
|
|
2023-07-06 14:22:44 +03:00
|
|
|
const defaultValue = useMemo(() => {
|
|
|
|
|
const updatedQuery = updateAllQueriesOperators(
|
|
|
|
|
initialQueriesMap.logs,
|
|
|
|
|
PANEL_TYPES.LIST,
|
|
|
|
|
DataSource.LOGS,
|
|
|
|
|
);
|
|
|
|
|
return prepareQueryWithDefaultTimestamp(updatedQuery);
|
|
|
|
|
}, [updateAllQueriesOperators]);
|
2023-06-23 11:19:53 +03:00
|
|
|
|
|
|
|
|
useShareBuilderUrl(defaultValue);
|
2023-06-16 13:38:39 +03:00
|
|
|
|
2023-07-06 14:22:44 +03:00
|
|
|
const inactiveLogsFilters: QueryBuilderProps['inactiveFilters'] = useMemo(() => {
|
|
|
|
|
if (panelTypes === PANEL_TYPES.TABLE) {
|
|
|
|
|
const result: QueryBuilderProps['inactiveFilters'] = { stepInterval: true };
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
}, [panelTypes]);
|
|
|
|
|
|
2023-06-16 13:38:39 +03:00
|
|
|
return (
|
|
|
|
|
<WrapperStyled>
|
|
|
|
|
<Row gutter={[0, 28]}>
|
|
|
|
|
<Col xs={24}>
|
|
|
|
|
<QueryBuilder
|
|
|
|
|
panelType={panelTypes}
|
|
|
|
|
config={{ initialDataSource: DataSource.LOGS, queryVariant: 'static' }}
|
2023-07-06 14:22:44 +03:00
|
|
|
inactiveFilters={inactiveLogsFilters}
|
2023-06-16 13:38:39 +03:00
|
|
|
actions={
|
|
|
|
|
<ButtonWrapperStyled>
|
|
|
|
|
<Button type="primary" onClick={handleRunQuery}>
|
|
|
|
|
Run Query
|
|
|
|
|
</Button>
|
|
|
|
|
</ButtonWrapperStyled>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col xs={24}>
|
|
|
|
|
<LogsExplorerViews />
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
</WrapperStyled>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-23 21:39:59 +03:00
|
|
|
export default LogsExplorer;
|