-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Converts index based data visualizer to React #42685
Merged
peteharverson
merged 5 commits into
elastic:master
from
peteharverson:ml-data-visualizer-react
Aug 8, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c645071
[ML] Converts index based data visualizer to React
peteharverson c4cddd1
[ML] Remove unused imports in React data visualizer
peteharverson 7b862b5
[ML] Address review feedback
peteharverson 992c67e
[ML] Address comments from code review
peteharverson fc4453d
[ML] Remove redundant ts-ignore
peteharverson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of
whilst
👍 😆