-
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] Data frame analytics: Adds map view #81666
Merged
alvarezmelissa87
merged 14 commits into
elastic:master
from
alvarezmelissa87:ml-dfanalytics-map-view
Nov 12, 2020
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c8106fd
add analytics map endpoint and server model
alvarezmelissa87 2533c79
add map action to job and models list
alvarezmelissa87 616f02c
wip:fetch models for jobs. Use url generator
alvarezmelissa87 3e3099f
get models when extending node. deduplicate elements
alvarezmelissa87 380dcd7
add job type icons. disable map action if job not finished.
alvarezmelissa87 ded6a59
move shared const to common dir
alvarezmelissa87 1d7341f
persist map tab. handle indexPattern from visualizer
alvarezmelissa87 05b82ec
use url generator in models list
alvarezmelissa87 701886a
temporarily disable delete action in flyout
alvarezmelissa87 3dbf6a4
update legend style. make map horizontal
alvarezmelissa87 7475434
update dfa model to use spaces changes
alvarezmelissa87 fd17d54
format creation time
alvarezmelissa87 d763ec1
update from indexPattern to index.remove refresh button
alvarezmelissa87 39728e2
handle index patterns with wildcard
alvarezmelissa87 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
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 |
---|---|---|
|
@@ -10,7 +10,8 @@ import { | |
OutlierAnalysis, | ||
RegressionAnalysis, | ||
} from '../types/data_frame_analytics'; | ||
import { ANALYSIS_CONFIG_TYPE } from '../../common/constants/data_frame_analytics'; | ||
import { ANALYSIS_CONFIG_TYPE } from '../constants/data_frame_analytics'; | ||
import { DataFrameAnalysisConfigType } from '../types/data_frame_analytics'; | ||
|
||
export const isOutlierAnalysis = (arg: any): arg is OutlierAnalysis => { | ||
if (typeof arg !== 'object' || arg === null) return false; | ||
|
@@ -80,3 +81,15 @@ export const getPredictedFieldName = ( | |
}`; | ||
return predictedField; | ||
}; | ||
|
||
export const getAnalysisType = ( | ||
analysis: AnalysisConfig | ||
): DataFrameAnalysisConfigType | 'unknown' => { | ||
const keys = Object.keys(analysis || {}); | ||
|
||
if (keys.length === 1) { | ||
return keys[0] as DataFrameAnalysisConfigType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth checking the actual key value instead of typecasting? |
||
} | ||
|
||
return 'unknown'; | ||
}; |
1 change: 1 addition & 0 deletions
1
x-pack/plugins/ml/public/application/data_frame_analytics/_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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
@import 'pages/analytics_exploration/components/regression_exploration/index'; | ||
@import 'pages/job_map/components/index'; | ||
@import 'pages/analytics_management/components/analytics_list/index'; | ||
@import 'pages/analytics_management/components/create_analytics_button/index'; | ||
@import 'pages/analytics_creation/components/index'; |
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
8 changes: 8 additions & 0 deletions
8
...pplication/data_frame_analytics/pages/analytics_management/components/action_map/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 { MapButton } from './map_button'; | ||
export { useMapAction } from './use_map_action'; |
51 changes: 51 additions & 0 deletions
51
...tion/data_frame_analytics/pages/analytics_management/components/action_map/map_button.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,51 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { EuiToolTip } from '@elastic/eui'; | ||
|
||
import { | ||
isRegressionAnalysis, | ||
isOutlierAnalysis, | ||
isClassificationAnalysis, | ||
} from '../../../../common/analytics'; | ||
|
||
import { DataFrameAnalyticsListRow } from '../analytics_list/common'; | ||
|
||
export const mapActionButtonText = i18n.translate( | ||
'xpack.ml.dataframe.analyticsList.mapActionName', | ||
{ | ||
defaultMessage: 'Map', | ||
} | ||
); | ||
interface MapButtonProps { | ||
item: DataFrameAnalyticsListRow; | ||
} | ||
|
||
export const MapButton: FC<MapButtonProps> = ({ item }) => { | ||
const disabled = | ||
!isRegressionAnalysis(item.config.analysis) && | ||
!isOutlierAnalysis(item.config.analysis) && | ||
!isClassificationAnalysis(item.config.analysis); | ||
|
||
if (disabled) { | ||
const toolTipContent = i18n.translate( | ||
'xpack.ml.dataframe.analyticsList.mapActionDisabledTooltipContent', | ||
{ | ||
defaultMessage: 'Unknown analysis type.', | ||
} | ||
); | ||
|
||
return ( | ||
<EuiToolTip position="top" content={toolTipContent}> | ||
<>{mapActionButtonText}</> | ||
darnautov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</EuiToolTip> | ||
); | ||
} | ||
|
||
return <>{mapActionButtonText}</>; | ||
}; |
44 changes: 44 additions & 0 deletions
44
.../data_frame_analytics/pages/analytics_management/components/action_map/use_map_action.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,44 @@ | ||
/* | ||
* 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, { useCallback, useMemo } from 'react'; | ||
import { useMlUrlGenerator, useNavigateToPath } from '../../../../../contexts/kibana'; | ||
import { DataFrameAnalyticsListAction, DataFrameAnalyticsListRow } from '../analytics_list/common'; | ||
import { ML_PAGES } from '../../../../../../../common/constants/ml_url_generator'; | ||
import { getViewLinkStatus } from '../action_view/get_view_link_status'; | ||
|
||
import { mapActionButtonText, MapButton } from './map_button'; | ||
|
||
export type MapAction = ReturnType<typeof useMapAction>; | ||
export const useMapAction = () => { | ||
const mlUrlGenerator = useMlUrlGenerator(); | ||
const navigateToPath = useNavigateToPath(); | ||
|
||
const clickHandler = useCallback(async (item: DataFrameAnalyticsListRow) => { | ||
const path = await mlUrlGenerator.createUrl({ | ||
page: ML_PAGES.DATA_FRAME_ANALYTICS_MAP, | ||
pageState: { jobId: item.id }, | ||
}); | ||
|
||
await navigateToPath(path, false); | ||
}, []); | ||
|
||
const action: DataFrameAnalyticsListAction = useMemo( | ||
() => ({ | ||
isPrimary: true, | ||
name: (item: DataFrameAnalyticsListRow) => <MapButton item={item} />, | ||
enabled: (item: DataFrameAnalyticsListRow) => !getViewLinkStatus(item).disabled, | ||
description: mapActionButtonText, | ||
icon: 'graphApp', | ||
type: 'icon', | ||
onClick: clickHandler, | ||
'data-test-subj': 'mlAnalyticsJobMapButton', | ||
}), | ||
[clickHandler] | ||
); | ||
|
||
return { action }; | ||
}; |
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
1 change: 1 addition & 0 deletions
1
...k/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/_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 'legend'; |
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.
'Trained model' is the term we are generally using now, so should probably rename these to be consistent.