-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass on and use global search/filters to embeddable.
- Loading branch information
Showing
2 changed files
with
75 additions
and
27 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...ck/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_for_embeddable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useMemo, type FC } from 'react'; | ||
|
||
import datemath from '@elastic/datemath'; | ||
|
||
import type { TimeRange } from '@kbn/es-query'; | ||
|
||
import { createMergedEsQuery } from '../../application/utils/search_utils'; | ||
import { useAiopsAppContext } from '../../hooks/use_aiops_app_context'; | ||
import { useFilterQueryUpdates } from '../../hooks/use_filters_query'; | ||
import { useSearch } from '../../hooks/use_search'; | ||
import { useDataSource } from '../../hooks/use_data_source'; | ||
import { getDefaultLogRateAnalysisAppState } from '../../application/url_state/log_rate_analysis'; | ||
|
||
import { LogRateAnalysisDocumentCountChartData } from './log_rate_analysis_content/log_rate_analysis_document_count_chart_data'; | ||
import { LogRateAnalysisContent } from './log_rate_analysis_content/log_rate_analysis_content'; | ||
|
||
export interface LogRateAnalysisForEmbeddableProps { | ||
timeRange: TimeRange; | ||
} | ||
|
||
export const LogRateAnalysisForEmbeddable: FC<LogRateAnalysisForEmbeddableProps> = ({ | ||
timeRange, | ||
}) => { | ||
const { uiSettings } = useAiopsAppContext(); | ||
const { dataView } = useDataSource(); | ||
const { filters, query } = useFilterQueryUpdates(); | ||
const appState = getDefaultLogRateAnalysisAppState({ | ||
searchQuery: createMergedEsQuery(query, filters, dataView, uiSettings), | ||
filters, | ||
}); | ||
const { searchQuery } = useSearch({ dataView, savedSearch: null }, appState, true); | ||
|
||
const timeRangeParsed = useMemo(() => { | ||
if (timeRange) { | ||
const min = datemath.parse(timeRange.from); | ||
const max = datemath.parse(timeRange.to); | ||
if (min && max) { | ||
return { min, max }; | ||
} | ||
} | ||
}, [timeRange]); | ||
|
||
return ( | ||
<> | ||
<LogRateAnalysisDocumentCountChartData | ||
timeRange={timeRangeParsed} | ||
esSearchQuery={searchQuery} | ||
/> | ||
<LogRateAnalysisContent esSearchQuery={searchQuery} /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters