-
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] Data frame analytics: Adds map view (#81666)
* add analytics map endpoint and server model * add map action to job and models list * wip:fetch models for jobs. Use url generator * get models when extending node. deduplicate elements * add job type icons. disable map action if job not finished. * move shared const to common dir * persist map tab. handle indexPattern from visualizer * use url generator in models list * temporarily disable delete action in flyout * update legend style. make map horizontal * update dfa model to use spaces changes * format creation time * update from indexPattern to index.remove refresh button * handle index patterns with wildcard
- Loading branch information
1 parent
3151e7e
commit 6519b83
Showing
37 changed files
with
1,657 additions
and
27 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
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
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}</> | ||
</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.