-
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] Configure sorting for partition values on Single Metric Viewer #81510
Merged
darnautov
merged 34 commits into
elastic:master
from
darnautov:ML-69526-improve-partition-sorting
Nov 2, 2020
Merged
Changes from 12 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
593c9ea
[ML] fix callout styles
darnautov beb067e
[ML] refactor timeseriesexplorer.js, add series_controls.tsx, storage…
darnautov b648467
[ML] anomalousOnly support
darnautov 149287f
[ML] sort by control
darnautov 71487fc
[ML] update query
darnautov 5defba6
[ML] sort order controls
darnautov 953e1ff
Merge remote-tracking branch 'upstream/master' into ML-69526-improve-…
darnautov e1a5c45
[ML] adjust query
darnautov 4855208
[ML] merge default and local configs, add info
darnautov d2710c9
[ML] fix types, adjust sorting logic for model plot results
darnautov fa59221
[ML] fix translation keys
darnautov 799efd0
[ML] fixed size for the icon flex item
darnautov faeaf2f
[ML] fix time range condition, refactor
darnautov 79d10e7
[ML] change info messages and the icon color
darnautov ff0fb56
Fix model plot info message
darnautov b0df9a8
[ML] functional tests
darnautov 9139d1f
[ML] rename ML_ENTITY_FIELDS_CONFIG
darnautov 1f71210
[ML] support manual input
darnautov af2f0ef
[ML] show max record score color indicator
darnautov a8415b7
Merge remote-tracking branch 'upstream/master' into ML-69526-improve-…
darnautov 56ce1ad
[ML] use :checked selector
darnautov ca7c2fc
[ML] refactor functional tests
darnautov 9f094ea
[ML] extend config with "applyTimeRange", refactor with entity_config…
darnautov 6026d41
[ML] info messages
darnautov c0b348e
[ML] remove custom message
darnautov 044768a
[ML] adjust the endpoint
darnautov 3ad0468
[ML] customOptionText
darnautov accd14a
[ML] sort by name UI tweak
darnautov a9a810e
[ML] change text
darnautov 49f3d0e
[ML] remove TODO comment
darnautov 9783cfa
[ML] fix functional test
darnautov 8728e0f
Merge branch 'master' into ML-69526-improve-partition-sorting
kibanamachine 5d4b138
[ML] move "Anomalous only"/"Apply time range" control to the bottom o…
darnautov c4203a3
[ML] update types
darnautov 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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 { EntityFieldType } from './anomalies'; | ||
|
||
export const ML_PARTITION_FIELDS_CONFIG = 'ml.singleMetricViewer.partitionFields'; | ||
|
||
export type PartitionFieldConfig = | ||
| { | ||
anomalousOnly: boolean; | ||
sort: { | ||
by: string; // 'anomaly_score' | 'name'; | ||
order: string; // 'asc' | 'desc'; | ||
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. Should this type be updated with the commented code? 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. Yes, updated in c4203a3 |
||
}; | ||
} | ||
| undefined; | ||
|
||
export type PartitionFieldsConfig = | ||
| Partial<Record<EntityFieldType, PartitionFieldConfig>> | ||
| undefined; | ||
|
||
export type MlStorage = Partial<{ | ||
[ML_PARTITION_FIELDS_CONFIG]: PartitionFieldsConfig; | ||
}> | null; |
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
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/ml/public/application/contexts/ml/use_storage.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,32 @@ | ||
/* | ||
* 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 { useCallback, useState } from 'react'; | ||
import { useMlKibana } from '../kibana'; | ||
|
||
/** | ||
* Hook for accessing and changing a value in the storage. | ||
* @param key - Storage key | ||
* @param initValue | ||
*/ | ||
export function useStorage<T>(key: string, initValue?: T): [T, (value: T) => void] { | ||
const { | ||
services: { storage }, | ||
} = useMlKibana(); | ||
|
||
const [val, setVal] = useState<T>(storage.get(key) ?? initValue); | ||
|
||
const setStorage = useCallback((value: T): void => { | ||
try { | ||
storage.set(key, value); | ||
setVal(value); | ||
} catch (e) { | ||
throw new Error('Unable to update storage with provided value'); | ||
peteharverson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}, []); | ||
|
||
return [val, setStorage]; | ||
} |
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
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/ml/public/application/timeseriesexplorer/components/series_controls/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 { SeriesControls } from './series_controls'; |
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.
Maybe all the variables here should be referenced as 'entity fields' to make it clearer that they relate to
by
andover
fields, and not just thepartition
field? e.g.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.
Renamed in 9139d1f
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.
I think the key should be changed to be
ml.singleMetricViewer.entityFields
to match the name of the variable.