/* * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. * * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. */ import { EuiText, EuiLink, EuiIcon, EuiFlexItem, EuiFlexGroup, EuiCheckbox, EuiSuperDatePicker, } from '@elastic/eui'; import { Field, FieldProps, FormikProps } from 'formik'; import { get } from 'lodash'; import React, { useState } from 'react'; import ContentPanel from '../../../../components/ContentPanel/ContentPanel'; import { FormattedFormRow } from '../../../../components/FormattedFormRow/FormattedFormRow'; import { DetectorJobsFormikValues } from '../../models/interfaces'; import { HISTORICAL_DATE_RANGE_COMMON_OPTIONS } from '../../utils/constants'; import { BASE_DOCS_LINK } from '../../../../utils/constants'; import { isInvalid, getError, convertTimestampToString, } from '../../../../utils/utils'; interface HistoricalJobProps { formikProps: FormikProps; setHistorical(historical: boolean): void; } export function HistoricalJob(props: HistoricalJobProps) { const [enabled, setEnabled] = useState( get(props, 'formikProps.values.historical', true) ); return ( Historical analysis detection lets you analyze and apply machine learning models over long historical data windows (weeks or months). You can identify anomaly patterns, seasonality, and trends.{' '} Learn more } > {({ field, form }: FieldProps) => ( { if (!enabled) { props.setHistorical(true); } if (enabled) { props.setHistorical(false); } setEnabled(!enabled); }} /> {enabled ? ( { form.setFieldValue('startTime', start); form.setFieldValue('endTime', end); }} isPaused={true} showUpdateButton={false} commonlyUsedRanges={HISTORICAL_DATE_RANGE_COMMON_OPTIONS} /> ) : null} )} ); }