-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
261 additions
and
117 deletions.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
x-pack/legacy/plugins/uptime/public/components/connected/kuerybar/kuery_bar_container.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,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { connect } from 'react-redux'; | ||
import { AppState } from '../../../state'; | ||
import { selectIndexPattern } from '../../../state/selectors'; | ||
import { getIndexPattern } from '../../../state/actions'; | ||
import { KueryBarComponent } from '../../functional'; | ||
|
||
const mapStateToProps = (state: AppState) => ({ indexPattern: selectIndexPattern(state) }); | ||
|
||
const mapDispatchToProps = (dispatch: any) => ({ | ||
loadIndexPattern: () => { | ||
dispatch(getIndexPattern({})); | ||
}, | ||
}); | ||
|
||
export const KueryBar = connect(mapStateToProps, mapDispatchToProps)(KueryBarComponent); |
14 changes: 14 additions & 0 deletions
14
x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.ts
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,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { connect } from 'react-redux'; | ||
import { OverviewPageComponent } from '../../../pages/overview'; | ||
import { selectIndexPattern } from '../../../state/selectors'; | ||
import { AppState } from '../../../state'; | ||
|
||
const mapStateToProps = (state: AppState) => ({ indexPattern: selectIndexPattern(state) }); | ||
|
||
export const OverviewPage = connect(mapStateToProps)(OverviewPageComponent); |
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
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
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
50 changes: 50 additions & 0 deletions
50
x-pack/legacy/plugins/uptime/public/hooks/update_kuery_string.ts
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,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { combineFiltersAndUserSearch, stringifyKueries } from '../lib/helper'; | ||
import { esKuery } from '../../../../../../src/plugins/data/common/es_query'; | ||
import { store } from '../state'; | ||
import { setEsKueryString } from '../state/actions'; | ||
|
||
export const useUpdateKueryString = (indexPattern: any, search: string, urlFilters: string) => { | ||
let error: any; | ||
let kueryString: string = ''; | ||
try { | ||
if (urlFilters !== '') { | ||
const filterMap = new Map<string, Array<string | number>>(JSON.parse(urlFilters)); | ||
kueryString = stringifyKueries(filterMap); | ||
} | ||
} catch { | ||
kueryString = ''; | ||
} | ||
|
||
const filterQueryString = search || ''; | ||
let filters: any | undefined; | ||
try { | ||
if (filterQueryString || urlFilters) { | ||
if (indexPattern) { | ||
const staticIndexPattern = indexPattern; | ||
const combinedFilterString = combineFiltersAndUserSearch(filterQueryString, kueryString); | ||
const ast = esKuery.fromKueryExpression(combinedFilterString); | ||
const elasticsearchQuery = esKuery.toElasticsearchQuery(ast, staticIndexPattern); | ||
filters = JSON.stringify(elasticsearchQuery); | ||
const searchDSL: string = filterQueryString | ||
? JSON.stringify( | ||
esKuery.toElasticsearchQuery( | ||
esKuery.fromKueryExpression(filterQueryString), | ||
staticIndexPattern | ||
) | ||
) | ||
: ''; | ||
store.dispatch(setEsKueryString(searchDSL)); | ||
} | ||
} | ||
return [filters, error]; | ||
} catch (e) { | ||
error = e; | ||
return [urlFilters, error]; | ||
} | ||
}; |
21 changes: 0 additions & 21 deletions
21
x-pack/legacy/plugins/uptime/public/hooks/use_index_pattern.ts
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
12 changes: 12 additions & 0 deletions
12
x-pack/legacy/plugins/uptime/public/state/actions/index_patternts.ts
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,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { createAction } from 'redux-actions'; | ||
import { QueryParams } from './types'; | ||
|
||
export const getIndexPattern = createAction('GET_INDEX_PATTERN'); | ||
export const getIndexPatternSuccess = createAction<QueryParams>('GET_INDEX_PATTERN_SUCCESS'); | ||
export const getIndexPatternFail = createAction<Error>('GET_INDEX_PATTERN_FAIL'); |
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
21 changes: 21 additions & 0 deletions
21
x-pack/legacy/plugins/uptime/public/state/api/index_pattern.ts
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,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { getApiPath } from '../../lib/helper'; | ||
|
||
export interface APIParams { | ||
basePath: string; | ||
} | ||
|
||
export const fetchIndexPattern = async ({ basePath }: APIParams) => { | ||
const url = getApiPath(`/api/uptime/index_pattern`, basePath); | ||
|
||
const response = await fetch(url); | ||
if (!response.ok) { | ||
throw new Error(response.statusText); | ||
} | ||
return await response.json(); | ||
}; |
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
Oops, something went wrong.