-
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.
Browse files
Browse the repository at this point in the history
…76561) Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
- Loading branch information
Showing
22 changed files
with
982 additions
and
208 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 const ML_APP_URL_GENERATOR = 'ML_APP_URL_GENERATOR'; | ||
|
||
export const ML_PAGES = { | ||
ANOMALY_DETECTION_JOBS_MANAGE: 'jobs', | ||
ANOMALY_EXPLORER: 'explorer', | ||
SINGLE_METRIC_VIEWER: 'timeseriesexplorer', | ||
DATA_FRAME_ANALYTICS_JOBS_MANAGE: 'data_frame_analytics', | ||
DATA_FRAME_ANALYTICS_EXPLORATION: 'data_frame_analytics/exploration', | ||
/** | ||
* Page: Data Visualizer | ||
*/ | ||
DATA_VISUALIZER: 'datavisualizer', | ||
/** | ||
* Page: Data Visualizer | ||
* Open data visualizer by selecting a Kibana index pattern or saved search | ||
*/ | ||
DATA_VISUALIZER_INDEX_SELECT: 'datavisualizer_index_select', | ||
/** | ||
* Page: Data Visualizer | ||
* Open data visualizer by importing data from a log file | ||
*/ | ||
DATA_VISUALIZER_FILE: 'filedatavisualizer', | ||
/** | ||
* Page: Data Visualizer | ||
* Open index data visualizer viewer page | ||
*/ | ||
DATA_VISUALIZER_INDEX_VIEWER: 'jobs/new_job/datavisualizer', | ||
ANOMALY_DETECTION_CREATE_JOB_SELECT_TYPE: `jobs/new_job/step/job_type`, | ||
SETTINGS: 'settings', | ||
CALENDARS_MANAGE: 'settings/calendars_list', | ||
FILTER_LISTS_MANAGE: 'settings/filter_lists', | ||
} as const; |
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,187 @@ | ||
/* | ||
* 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 { RefreshInterval, TimeRange } from '../../../../../src/plugins/data/common/query'; | ||
import { JobId } from '../../../reporting/common/types'; | ||
import { ML_PAGES } from '../constants/ml_url_generator'; | ||
|
||
type OptionalPageState = object | undefined; | ||
|
||
export type MLPageState<PageType, PageState> = PageState extends OptionalPageState | ||
? { page: PageType; pageState?: PageState } | ||
: PageState extends object | ||
? { page: PageType; pageState: PageState } | ||
: { page: PageType }; | ||
|
||
export const ANALYSIS_CONFIG_TYPE = { | ||
OUTLIER_DETECTION: 'outlier_detection', | ||
REGRESSION: 'regression', | ||
CLASSIFICATION: 'classification', | ||
} as const; | ||
|
||
type DataFrameAnalyticsType = typeof ANALYSIS_CONFIG_TYPE[keyof typeof ANALYSIS_CONFIG_TYPE]; | ||
|
||
export interface MlCommonGlobalState { | ||
time?: TimeRange; | ||
} | ||
export interface MlCommonAppState { | ||
[key: string]: any; | ||
} | ||
|
||
export interface MlIndexBasedSearchState { | ||
index?: string; | ||
savedSearchId?: string; | ||
} | ||
|
||
export interface MlGenericUrlPageState extends MlIndexBasedSearchState { | ||
globalState?: MlCommonGlobalState; | ||
appState?: MlCommonAppState; | ||
[key: string]: any; | ||
} | ||
|
||
export interface MlGenericUrlState { | ||
page: | ||
| typeof ML_PAGES.DATA_VISUALIZER_INDEX_VIEWER | ||
| typeof ML_PAGES.ANOMALY_DETECTION_CREATE_JOB_SELECT_TYPE; | ||
pageState: MlGenericUrlPageState; | ||
} | ||
|
||
export interface AnomalyDetectionQueryState { | ||
jobId?: JobId; | ||
groupIds?: string[]; | ||
} | ||
|
||
export type AnomalyDetectionUrlState = MLPageState< | ||
typeof ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, | ||
AnomalyDetectionQueryState | undefined | ||
>; | ||
export interface ExplorerAppState { | ||
mlExplorerSwimlane: { | ||
selectedType?: string; | ||
selectedLanes?: string[]; | ||
selectedTimes?: number[]; | ||
showTopFieldValues?: boolean; | ||
viewByFieldName?: string; | ||
viewByPerPage?: number; | ||
viewByFromPage?: number; | ||
}; | ||
mlExplorerFilter: { | ||
influencersFilterQuery?: unknown; | ||
filterActive?: boolean; | ||
filteredFields?: string[]; | ||
queryString?: string; | ||
}; | ||
query?: any; | ||
} | ||
export interface ExplorerGlobalState { | ||
ml: { jobIds: JobId[] }; | ||
time?: TimeRange; | ||
refreshInterval?: RefreshInterval; | ||
} | ||
|
||
export interface ExplorerUrlPageState { | ||
/** | ||
* Job IDs | ||
*/ | ||
jobIds: JobId[]; | ||
/** | ||
* Optionally set the time range in the time picker. | ||
*/ | ||
timeRange?: TimeRange; | ||
/** | ||
* Optionally set the refresh interval. | ||
*/ | ||
refreshInterval?: RefreshInterval; | ||
/** | ||
* Optionally set the query. | ||
*/ | ||
query?: any; | ||
/** | ||
* Optional state for the swim lane | ||
*/ | ||
mlExplorerSwimlane?: ExplorerAppState['mlExplorerSwimlane']; | ||
mlExplorerFilter?: ExplorerAppState['mlExplorerFilter']; | ||
} | ||
|
||
export type ExplorerUrlState = MLPageState<typeof ML_PAGES.ANOMALY_EXPLORER, ExplorerUrlPageState>; | ||
|
||
export interface TimeSeriesExplorerGlobalState { | ||
ml: { | ||
jobIds: JobId[]; | ||
}; | ||
time?: TimeRange; | ||
refreshInterval?: RefreshInterval; | ||
} | ||
|
||
export interface TimeSeriesExplorerAppState { | ||
zoom?: { | ||
from?: string; | ||
to?: string; | ||
}; | ||
mlTimeSeriesExplorer?: { | ||
detectorIndex?: number; | ||
entities?: Record<string, string>; | ||
}; | ||
query?: any; | ||
} | ||
|
||
export interface TimeSeriesExplorerPageState | ||
extends Pick<TimeSeriesExplorerAppState, 'zoom' | 'query'>, | ||
Pick<TimeSeriesExplorerGlobalState, 'refreshInterval'> { | ||
jobIds: JobId[]; | ||
timeRange?: TimeRange; | ||
detectorIndex?: number; | ||
entities?: Record<string, string>; | ||
} | ||
|
||
export type TimeSeriesExplorerUrlState = MLPageState< | ||
typeof ML_PAGES.SINGLE_METRIC_VIEWER, | ||
TimeSeriesExplorerPageState | ||
>; | ||
|
||
export interface DataFrameAnalyticsQueryState { | ||
jobId?: JobId | JobId[]; | ||
groupIds?: string[]; | ||
} | ||
|
||
export type DataFrameAnalyticsUrlState = MLPageState< | ||
typeof ML_PAGES.DATA_FRAME_ANALYTICS_JOBS_MANAGE, | ||
DataFrameAnalyticsQueryState | undefined | ||
>; | ||
|
||
export interface DataVisualizerUrlState { | ||
page: | ||
| typeof ML_PAGES.DATA_VISUALIZER | ||
| typeof ML_PAGES.DATA_VISUALIZER_FILE | ||
| typeof ML_PAGES.DATA_VISUALIZER_INDEX_SELECT; | ||
} | ||
|
||
export interface DataFrameAnalyticsExplorationQueryState { | ||
ml: { | ||
jobId: JobId; | ||
analysisType: DataFrameAnalyticsType; | ||
}; | ||
} | ||
|
||
export type DataFrameAnalyticsExplorationUrlState = MLPageState< | ||
typeof ML_PAGES.DATA_FRAME_ANALYTICS_EXPLORATION, | ||
{ | ||
jobId: JobId; | ||
analysisType: DataFrameAnalyticsType; | ||
} | ||
>; | ||
|
||
/** | ||
* Union type of ML URL state based on page | ||
*/ | ||
export type MlUrlGeneratorState = | ||
| AnomalyDetectionUrlState | ||
| ExplorerUrlState | ||
| TimeSeriesExplorerUrlState | ||
| DataFrameAnalyticsUrlState | ||
| DataFrameAnalyticsExplorationUrlState | ||
| DataVisualizerUrlState | ||
| MlGenericUrlState; |
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
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/ml/public/application/contexts/kibana/use_create_url.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,20 @@ | ||
/* | ||
* 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 { useMlKibana } from './kibana_context'; | ||
import { ML_APP_URL_GENERATOR } from '../../../../common/constants/ml_url_generator'; | ||
|
||
export const useMlUrlGenerator = () => { | ||
const { | ||
services: { | ||
share: { | ||
urlGenerators: { getUrlGenerator }, | ||
}, | ||
}, | ||
} = useMlKibana(); | ||
|
||
return getUrlGenerator(ML_APP_URL_GENERATOR); | ||
}; |
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
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.