2024-03-12 12:20:45 +05:30
|
|
|
import './LogsExplorer.styles.scss';
|
|
|
|
|
|
2024-06-18 19:04:06 +05:30
|
|
|
import * as Sentry from '@sentry/react';
|
2023-08-30 20:24:16 +05:30
|
|
|
import ExplorerCard from 'components/ExplorerCard/ExplorerCard';
|
2023-07-07 15:49:35 +03:00
|
|
|
import LogExplorerQuerySection from 'container/LogExplorerQuerySection';
|
2023-06-23 11:19:53 +03:00
|
|
|
import LogsExplorerViews from 'container/LogsExplorerViews';
|
2024-02-12 00:23:19 +05:30
|
|
|
import LeftToolbarActions from 'container/QueryBuilder/components/ToolbarActions/LeftToolbarActions';
|
|
|
|
|
import RightToolbarActions from 'container/QueryBuilder/components/ToolbarActions/RightToolbarActions';
|
|
|
|
|
import Toolbar from 'container/Toolbar/Toolbar';
|
|
|
|
|
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
2023-11-15 16:46:20 +05:30
|
|
|
import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback';
|
2024-02-12 00:23:19 +05:30
|
|
|
import { useEffect, useMemo, useState } from 'react';
|
2023-08-30 20:24:16 +05:30
|
|
|
import { DataSource } from 'types/common/queryBuilder';
|
2023-06-16 13:38:39 +03:00
|
|
|
|
2023-07-07 15:49:35 +03:00
|
|
|
import { WrapperStyled } from './styles';
|
2024-02-12 00:23:19 +05:30
|
|
|
import { SELECTED_VIEWS } from './utils';
|
2023-06-16 13:38:39 +03:00
|
|
|
|
2023-06-23 21:39:59 +03:00
|
|
|
function LogsExplorer(): JSX.Element {
|
2024-07-08 20:02:10 +05:30
|
|
|
const [showFrequencyChart, setShowFrequencyChart] = useState(true);
|
2024-02-12 00:23:19 +05:30
|
|
|
const [selectedView, setSelectedView] = useState<SELECTED_VIEWS>(
|
|
|
|
|
SELECTED_VIEWS.SEARCH,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const { handleRunQuery, currentQuery } = useQueryBuilder();
|
|
|
|
|
|
2024-07-08 20:02:10 +05:30
|
|
|
const handleToggleShowFrequencyChart = (): void => {
|
|
|
|
|
setShowFrequencyChart(!showFrequencyChart);
|
2024-02-12 00:23:19 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleChangeSelectedView = (view: SELECTED_VIEWS): void => {
|
|
|
|
|
setSelectedView(view);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Switch to query builder view if there are more than 1 queries
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (currentQuery.builder.queryData.length > 1) {
|
|
|
|
|
handleChangeSelectedView(SELECTED_VIEWS.QUERY_BUILDER);
|
|
|
|
|
}
|
|
|
|
|
}, [currentQuery.builder.queryData.length]);
|
|
|
|
|
|
|
|
|
|
const isMultipleQueries = useMemo(
|
|
|
|
|
() =>
|
|
|
|
|
currentQuery.builder.queryData.length > 1 ||
|
|
|
|
|
currentQuery.builder.queryFormulas.length > 0,
|
|
|
|
|
[currentQuery],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const toolbarViews = useMemo(
|
|
|
|
|
() => ({
|
|
|
|
|
search: {
|
|
|
|
|
name: 'search',
|
|
|
|
|
label: 'Search',
|
|
|
|
|
disabled: isMultipleQueries,
|
|
|
|
|
show: true,
|
|
|
|
|
},
|
|
|
|
|
queryBuilder: {
|
|
|
|
|
name: 'query-builder',
|
|
|
|
|
label: 'Query Builder',
|
|
|
|
|
disabled: false,
|
|
|
|
|
show: true,
|
|
|
|
|
},
|
|
|
|
|
clickhouse: {
|
|
|
|
|
name: 'clickhouse',
|
|
|
|
|
label: 'Clickhouse',
|
|
|
|
|
disabled: false,
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
[isMultipleQueries],
|
|
|
|
|
);
|
|
|
|
|
|
2023-06-16 13:38:39 +03:00
|
|
|
return (
|
2024-06-18 19:04:06 +05:30
|
|
|
<Sentry.ErrorBoundary fallback={<ErrorBoundaryFallback />}>
|
2024-02-12 00:23:19 +05:30
|
|
|
<Toolbar
|
|
|
|
|
showAutoRefresh={false}
|
|
|
|
|
leftActions={
|
|
|
|
|
<LeftToolbarActions
|
|
|
|
|
items={toolbarViews}
|
|
|
|
|
selectedView={selectedView}
|
|
|
|
|
onChangeSelectedView={handleChangeSelectedView}
|
2024-07-08 20:02:10 +05:30
|
|
|
onToggleHistrogramVisibility={handleToggleShowFrequencyChart}
|
|
|
|
|
showFrequencyChart={showFrequencyChart}
|
2024-02-12 00:23:19 +05:30
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
rightActions={<RightToolbarActions onStageRunQuery={handleRunQuery} />}
|
|
|
|
|
showOldCTA
|
|
|
|
|
/>
|
|
|
|
|
|
2023-08-29 15:23:22 +03:00
|
|
|
<WrapperStyled>
|
2024-03-12 12:20:45 +05:30
|
|
|
<div className="log-explorer-query-container">
|
|
|
|
|
<div>
|
2023-08-30 20:24:16 +05:30
|
|
|
<ExplorerCard sourcepage={DataSource.LOGS}>
|
2024-02-12 00:23:19 +05:30
|
|
|
<LogExplorerQuerySection selectedView={selectedView} />
|
2023-08-29 15:23:22 +03:00
|
|
|
</ExplorerCard>
|
2024-03-12 12:20:45 +05:30
|
|
|
</div>
|
|
|
|
|
<div className="logs-explorer-views">
|
2024-02-12 00:23:19 +05:30
|
|
|
<LogsExplorerViews
|
|
|
|
|
selectedView={selectedView}
|
2024-07-08 20:02:10 +05:30
|
|
|
showFrequencyChart={showFrequencyChart}
|
2024-02-12 00:23:19 +05:30
|
|
|
/>
|
2024-03-12 12:20:45 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-08-29 15:23:22 +03:00
|
|
|
</WrapperStyled>
|
2024-06-18 19:04:06 +05:30
|
|
|
</Sentry.ErrorBoundary>
|
2023-06-16 13:38:39 +03:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-23 21:39:59 +03:00
|
|
|
export default LogsExplorer;
|