From 1118b3e08345110bec102f86bfbd3bf46cce969c Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Wed, 2 Sep 2020 11:18:58 -0500 Subject: [PATCH] [ML] Add constants, update descriptions --- x-pack/plugins/ml/common/constants/settings.ts | 6 ++++++ .../ml/public/application/explorer/explorer.js | 2 +- .../anomaly_detection_panel/actions.tsx | 2 -- .../timeseriesexplorer/timeseriesexplorer.js | 2 +- x-pack/plugins/ml/server/lib/register_settings.ts | 15 +++++++-------- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/ml/common/constants/settings.ts b/x-pack/plugins/ml/common/constants/settings.ts index bb0e0421026153..f024f07c2fbc67 100644 --- a/x-pack/plugins/ml/common/constants/settings.ts +++ b/x-pack/plugins/ml/common/constants/settings.ts @@ -7,3 +7,9 @@ export const FILE_DATA_VISUALIZER_MAX_FILE_SIZE = 'ml:fileDataVisualizerMaxFileSize'; export const ANOMALY_DETECTION_ENABLE_TIME_RANGE = 'ml:anomalyDetection:results:enableTmeDefaults'; export const ANOMALY_DETECTION_DEFAULT_TIME_RANGE = 'ml:anomalyDetection:results:timeDefaults'; + +export const DEFAULT_AD_RESULTS_TIME_FILTER = { + from: 'now-15m', + to: 'now', +}; +export const DEFAULT_ENABLE_AD_RESULTS_TIME_FILTER = false; diff --git a/x-pack/plugins/ml/public/application/explorer/explorer.js b/x-pack/plugins/ml/public/application/explorer/explorer.js index 0fd181342fcf6e..cea1159ebc14a2 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer.js +++ b/x-pack/plugins/ml/public/application/explorer/explorer.js @@ -153,7 +153,7 @@ export class Explorer extends React.Component { toastNotifications.addWarning( i18n.translate('xpack.ml.explorer.invalidTimeRangeInUrlCallout', { defaultMessage: - 'The time filter changed to the full range for this job due to invalid default time filter. Please check the advanced settings for {field}.', + 'The time filter was changed to the full range due to an invalid default time filter. Check the advanced settings for {field}.', values: { field: ANOMALY_DETECTION_DEFAULT_TIME_RANGE, }, diff --git a/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/actions.tsx b/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/actions.tsx index 365536f24e99b2..a71141d0356d07 100644 --- a/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/actions.tsx +++ b/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/actions.tsx @@ -10,8 +10,6 @@ import { i18n } from '@kbn/i18n'; import { MlSummaryJobs } from '../../../../../common/types/anomaly_detection_jobs'; import { useCreateADLinks } from '../../../components/custom_hooks/use_create_ad_links'; -// @ts-ignore no module file - interface Props { jobsList: MlSummaryJobs; } diff --git a/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js b/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js index 228af93a2c17f8..0e99d64cf202f8 100644 --- a/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js +++ b/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js @@ -842,7 +842,7 @@ export class TimeSeriesExplorer extends React.Component { toastNotifications.addWarning( i18n.translate('xpack.ml.timeSeriesExplorer.invalidTimeRangeInUrlCallout', { defaultMessage: - 'The time filter changed to the full range for this job due to invalid default time filter. Please check the advanced settings for {field}.', + 'The time filter was changed to the full range for this job due to an invalid default time filter. Check the advanced settings for {field}.', values: { field: ANOMALY_DETECTION_DEFAULT_TIME_RANGE, }, diff --git a/x-pack/plugins/ml/server/lib/register_settings.ts b/x-pack/plugins/ml/server/lib/register_settings.ts index 68c880288a95de..a9ee24fbb5cea9 100644 --- a/x-pack/plugins/ml/server/lib/register_settings.ts +++ b/x-pack/plugins/ml/server/lib/register_settings.ts @@ -11,6 +11,8 @@ import { FILE_DATA_VISUALIZER_MAX_FILE_SIZE, ANOMALY_DETECTION_DEFAULT_TIME_RANGE, ANOMALY_DETECTION_ENABLE_TIME_RANGE, + DEFAULT_AD_RESULTS_TIME_FILTER, + DEFAULT_ENABLE_AD_RESULTS_TIME_FILTER, } from '../../common/constants/settings'; import { MAX_FILE_SIZE } from '../../common/constants/file_datavisualizer'; @@ -36,28 +38,25 @@ export function registerKibanaSettings(coreSetup: CoreSetup) { }, [ANOMALY_DETECTION_ENABLE_TIME_RANGE]: { name: i18n.translate('xpack.ml.advancedSettings.enableAnomalyDetectionDefaultTimeRangeName', { - defaultMessage: 'Enable time filter defaults for anomaly detection jobs', + defaultMessage: 'Enable time filter defaults for anomaly detection results', }), - value: false, + value: DEFAULT_ENABLE_AD_RESULTS_TIME_FILTER, schema: schema.boolean(), description: i18n.translate( 'xpack.ml.advancedSettings.enableAnomalyDetectionDefaultTimeRangeDesc', { defaultMessage: - 'Use the default time filter in the Single Metric Viewer and Anomaly Explorer.', + 'Use the default time filter in the Single Metric Viewer and Anomaly Explorer. If not enabled, the results for the full time range of the job are displayed.', } ), category: ['Machine Learning'], }, [ANOMALY_DETECTION_DEFAULT_TIME_RANGE]: { name: i18n.translate('xpack.ml.advancedSettings.anomalyDetectionDefaultTimeRangeName', { - defaultMessage: 'Time filter defaults', + defaultMessage: 'Time filter defaults for anomaly detection results', }), type: 'json', - value: `{ - "from": "now-15m", - "to": "now" -}`, + value: JSON.stringify(DEFAULT_AD_RESULTS_TIME_FILTER, null, 2), description: i18n.translate( 'xpack.ml.advancedSettings.anomalyDetectionDefaultTimeRangeDesc', {