-
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.
[ML] Converts index based data visualizer to React (#42685)
* [ML] Converts index based data visualizer to React * [ML] Remove unused imports in React data visualizer * [ML] Address review feedback * [ML] Address comments from code review * [ML] Remove redundant ts-ignore
- Loading branch information
1 parent
9bddad0
commit 900ca2a
Showing
61 changed files
with
3,192 additions
and
18 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
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
28 changes: 28 additions & 0 deletions
28
x-pack/legacy/plugins/ml/public/components/create_job_link_card/create_job_link_card.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,28 @@ | ||
/* | ||
* 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 React, { FC } from 'react'; | ||
|
||
import { EuiCard, EuiIcon, IconType } from '@elastic/eui'; | ||
|
||
interface Props { | ||
iconType: IconType; | ||
title: string; | ||
description: string; | ||
onClick(): void; | ||
} | ||
|
||
// Component for rendering a card which links to the Create Job page, displaying an | ||
// icon, card title, description and link. | ||
export const CreateJobLinkCard: FC<Props> = ({ iconType, title, description, onClick }) => ( | ||
<EuiCard | ||
layout="horizontal" | ||
icon={<EuiIcon size="xl" type={iconType} />} | ||
title={title} | ||
description={description} | ||
onClick={onClick} | ||
/> | ||
); |
7 changes: 7 additions & 0 deletions
7
x-pack/legacy/plugins/ml/public/components/create_job_link_card/index.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,7 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { CreateJobLinkCard } from './create_job_link_card'; |
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
|
||
|
||
import './field_title_bar_directive'; | ||
|
||
export { FieldTitleBar } from './field_title_bar'; |
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 @@ | ||
@import 'components/field_data_card/index'; |
14 changes: 14 additions & 0 deletions
14
x-pack/legacy/plugins/ml/public/data_visualizer/breadcrumbs.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. | ||
*/ | ||
|
||
// @ts-ignore | ||
import { ML_BREADCRUMB } from '../breadcrumbs'; | ||
|
||
export function getDataVisualizerBreadcrumbs() { | ||
// Whilst top level nav menu with tabs remains, | ||
// use root ML breadcrumb. | ||
return [ML_BREADCRUMB]; | ||
} |
21 changes: 21 additions & 0 deletions
21
x-pack/legacy/plugins/ml/public/data_visualizer/common/field_vis_config.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 { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; | ||
|
||
// The internal representation of the configuration used to build the visuals | ||
// which display the field information. | ||
// TODO - type stats | ||
export interface FieldVisConfig { | ||
type: ML_JOB_FIELD_TYPES; | ||
fieldName?: string; | ||
existsInDocs: boolean; | ||
aggregatable: boolean; | ||
loading: boolean; | ||
stats?: any; | ||
fieldFormat?: any; | ||
isUnsupportedType?: boolean; | ||
} |
8 changes: 8 additions & 0 deletions
8
x-pack/legacy/plugins/ml/public/data_visualizer/common/index.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,8 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { FieldVisConfig } from './field_vis_config'; | ||
export { FieldRequestConfig } from './request'; |
13 changes: 13 additions & 0 deletions
13
x-pack/legacy/plugins/ml/public/data_visualizer/common/request.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,13 @@ | ||
/* | ||
* 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 { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; | ||
|
||
export interface FieldRequestConfig { | ||
fieldName?: string; | ||
type: ML_JOB_FIELD_TYPES; | ||
cardinality: number; | ||
} |
65 changes: 65 additions & 0 deletions
65
x-pack/legacy/plugins/ml/public/data_visualizer/components/actions_panel/actions_panel.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,65 @@ | ||
/* | ||
* 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 React, { FC } from 'react'; | ||
|
||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { IndexPattern } from 'ui/index_patterns'; | ||
|
||
import { EuiPanel, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui'; | ||
|
||
import { useUiChromeContext } from '../../../contexts/ui/use_ui_chrome_context'; | ||
import { CreateJobLinkCard } from '../../../components/create_job_link_card'; | ||
|
||
interface Props { | ||
indexPattern: IndexPattern; | ||
} | ||
|
||
export const ActionsPanel: FC<Props> = ({ indexPattern }) => { | ||
const basePath = useUiChromeContext().getBasePath(); | ||
|
||
function openAdvancedJobWizard() { | ||
// TODO - pass the search string to the advanced job page as well as the index pattern | ||
// (add in with new advanced job wizard?) | ||
window.open(`${basePath}/app/ml#/jobs/new_job/advanced?index=${indexPattern}`, '_self'); | ||
} | ||
|
||
return ( | ||
<EuiPanel data-test-subj="mlDataVisualizerActionsPanel"> | ||
<EuiTitle> | ||
<h2> | ||
<FormattedMessage | ||
id="xpack.ml.datavisualizer.actionsPanel.createJobTitle" | ||
defaultMessage="Create Job" | ||
/> | ||
</h2> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
<EuiText> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.ml.datavisualizer.actionsPanel.createJobDescription" | ||
defaultMessage="Use the Advanced job wizard to create a job to find anomalies in this data:" | ||
/> | ||
</p> | ||
</EuiText> | ||
<EuiSpacer size="m" /> | ||
<CreateJobLinkCard | ||
iconType="createAdvancedJob" | ||
title={i18n.translate('xpack.ml.datavisualizer.actionsPanel.advancedTitle', { | ||
defaultMessage: 'Advanced', | ||
})} | ||
description={i18n.translate('xpack.ml.datavisualizer.actionsPanel.advancedDescription', { | ||
defaultMessage: | ||
'Use the full range of options to create a job for more advanced use cases', | ||
})} | ||
onClick={openAdvancedJobWizard} | ||
/> | ||
</EuiPanel> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
x-pack/legacy/plugins/ml/public/data_visualizer/components/actions_panel/index.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,7 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { ActionsPanel } from './actions_panel'; |
62 changes: 62 additions & 0 deletions
62
...legacy/plugins/ml/public/data_visualizer/components/field_data_card/_field_data_card.scss
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,62 @@ | ||
.mlFieldDataCard { | ||
height: 420px; | ||
width: 360px; | ||
|
||
|
||
// Note the names of these styles need to match the type of the field they are displaying. | ||
.boolean { | ||
background-color: $euiColorVis5; | ||
} | ||
|
||
.date { | ||
background-color: $euiColorVis7; | ||
} | ||
|
||
.document_count { | ||
background-color: $euiColorVis2; | ||
} | ||
|
||
.geo_point { | ||
background-color: $euiColorVis8; | ||
} | ||
|
||
.ip { | ||
background-color: $euiColorVis3; | ||
} | ||
|
||
.keyword { | ||
background-color: $euiColorVis0; | ||
} | ||
|
||
.number { | ||
background-color: $euiColorVis1; | ||
} | ||
|
||
.text { | ||
background-color: $euiColorVis9; | ||
} | ||
|
||
.type-other, .unknown { | ||
background-color: $euiColorVis6; | ||
} | ||
|
||
|
||
// Use euiPanel styling | ||
@include euiPanel($selector: 'mlFieldDataCard__content'); | ||
|
||
.mlFieldDataCard__content { | ||
@include euiFontSizeS; | ||
height: 385px; | ||
border-radius: 0px 0px $euiBorderRadius $euiBorderRadius; | ||
overflow: hidden; | ||
} | ||
|
||
.mlFieldDataCard__codeContent { | ||
font-family: $euiCodeFontFamily; | ||
} | ||
|
||
.mlFieldDataCard__stats { | ||
padding: $euiSizeS $euiSizeS 0px $euiSizeS; | ||
text-align: center; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
x-pack/legacy/plugins/ml/public/data_visualizer/components/field_data_card/_index.scss
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 @@ | ||
@import 'field_data_card'; |
Oops, something went wrong.