From cd9c53514576432efbf2dde60595a803911e8cdb Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Wed, 21 Dec 2022 20:48:01 +0000 Subject: [PATCH] removed duplicate popout icon and ran prettier Signed-off-by: Amit Galitzky --- global-setup.js | 4 +- .../FormattedFormRow/FormattedFormRow.tsx | 2 +- public/models/interfaces.ts | 36 +- .../components/AnomaliesStat/AnomalyStat.tsx | 2 +- .../__snapshots__/AnomalyStat.test.tsx.snap | 28 +- .../components/FeatureChart/FeatureChart.tsx | 27 +- .../containers/AnomalyDetailsChart.tsx | 111 +-- .../containers/FeatureBreakDown.tsx | 8 +- .../AnomalyCharts/utils/anomalyChartUtils.tsx | 4 +- public/pages/AnomalyCharts/utils/constants.ts | 4 +- .../CategoryField/CategoryField.tsx | 2 +- .../__snapshots__/CategoryField.test.tsx.snap | 28 +- .../components/Features/Features.tsx | 2 +- .../containers/ConfigureModel.tsx | 2 +- .../containers/SampleAnomalies.tsx | 2 +- .../ConfigureModel.test.tsx.snap | 96 +- .../EmptyDashboard/EmptyDashboard.tsx | 3 +- .../EmptyDashboard.test.tsx.snap | 12 +- .../CustomResultIndex/CustomResultIndex.tsx | 2 +- .../components/Settings/Settings.tsx | 2 +- .../__snapshots__/Settings.test.tsx.snap | 24 +- .../DefineDetector.test.tsx.snap | 132 +-- .../MonitorCallout/MonitorCallout.tsx | 2 +- .../MonitorCallout.test.tsx.snap | 11 - .../HistoricalJob/HistoricalJob.tsx | 2 +- .../__snapshots__/HistoricalJob.test.tsx.snap | 12 +- .../components/RealTimeJob/RealTimeJob.tsx | 2 +- .../__snapshots__/RealTimeJob.test.tsx.snap | 12 +- .../__snapshots__/DetectorJobs.test.tsx.snap | 24 +- .../containers/AnomalyResults.tsx | 12 +- .../ConfirmActionModals/utils/helpers.tsx | 14 +- .../EmptyHistoricalDetectorResults.tsx | 3 +- ...ptyHistoricalDetectorResults.test.tsx.snap | 12 +- .../components/CreateWorkflowStepDetails.tsx | 2 +- .../containers/AnomalyDetectionOverview.tsx | 2 +- .../AnomalyDetectionOverview.test.tsx.snap | 220 +---- .../__tests__/anomalyResultUtils.test.ts | 837 ++++++++++++------ public/pages/utils/anomalyResultUtils.ts | 137 +-- server/routes/ad.ts | 29 +- test/jest.config.js | 2 +- 40 files changed, 813 insertions(+), 1055 deletions(-) diff --git a/global-setup.js b/global-setup.js index 3c5780008..67ca0db63 100644 --- a/global-setup.js +++ b/global-setup.js @@ -1,3 +1,3 @@ export default () => { - process.env.TZ = 'UTC'; - } \ No newline at end of file + process.env.TZ = 'UTC'; +}; diff --git a/public/components/FormattedFormRow/FormattedFormRow.tsx b/public/components/FormattedFormRow/FormattedFormRow.tsx index 7a1256646..20cf8daa6 100644 --- a/public/components/FormattedFormRow/FormattedFormRow.tsx +++ b/public/components/FormattedFormRow/FormattedFormRow.tsx @@ -35,7 +35,7 @@ export const FormattedFormRow = (props: FormattedFormRowProps) => { {props.hintLink ? ' ' : null} {props.hintLink ? ( - Learn more + Learn more ) : null} diff --git a/public/models/interfaces.ts b/public/models/interfaces.ts index e2eea1763..f8fbc2489 100644 --- a/public/models/interfaces.ts +++ b/public/models/interfaces.ts @@ -82,27 +82,27 @@ export type FeatureAttributes = { // all possible valid units accepted by the backend export enum UNITS { - NANOS = "Nanos", - MICROS = "Micros", - MILLIS = "Millis", - SECONDS = "Seconds", + NANOS = 'Nanos', + MICROS = 'Micros', + MILLIS = 'Millis', + SECONDS = 'Seconds', MINUTES = 'Minutes', - HOURS = "Hours", - HALF_DAYS = "HalfDays", - DAYS = "Days", - WEEKS = "Weeks", - MONTHS = "Months", - YEARS = "Years", - DECADES = "Decades", - CENTURIES = "Centuries", - MILLENNIA = "Millennia", - ERAS = "Eras", - FOREVER = "Forever" + HOURS = 'Hours', + HALF_DAYS = 'HalfDays', + DAYS = 'Days', + WEEKS = 'Weeks', + MONTHS = 'Months', + YEARS = 'Years', + DECADES = 'Decades', + CENTURIES = 'Centuries', + MILLENNIA = 'Millennia', + ERAS = 'Eras', + FOREVER = 'Forever', } // cannot create a method in enum, have to write function separately export function toDuration(units: UNITS): Duration { - switch(units) { + switch (units) { case UNITS.NANOS: { // Duration in moment library does not support return moment.duration(0.000000001, 'seconds'); @@ -155,7 +155,7 @@ export function toDuration(units: UNITS): Duration { default: break; } - throw new Error("Unexpected unit: " + units); + throw new Error('Unexpected unit: ' + units); } export type Schedule = { @@ -235,7 +235,7 @@ export type AnomalyData = { entity?: EntityData[]; features?: { [key: string]: FeatureAggregationData }; contributions?: { [key: string]: FeatureContributionData }; - aggInterval?: string; + aggInterval?: string; }; export type FeatureAggregationData = { diff --git a/public/pages/AnomalyCharts/components/AnomaliesStat/AnomalyStat.tsx b/public/pages/AnomalyCharts/components/AnomaliesStat/AnomalyStat.tsx index 56c4db8cd..2f82cccfa 100644 --- a/public/pages/AnomalyCharts/components/AnomaliesStat/AnomalyStat.tsx +++ b/public/pages/AnomalyCharts/components/AnomaliesStat/AnomalyStat.tsx @@ -91,7 +91,7 @@ export const AlertsStat = (props: { target="_blank" style={{ fontSize: '14px' }} > - View monitor + View monitor ) : null} diff --git a/public/pages/AnomalyCharts/components/AnomaliesStat/__tests__/__snapshots__/AnomalyStat.test.tsx.snap b/public/pages/AnomalyCharts/components/AnomaliesStat/__tests__/__snapshots__/AnomalyStat.test.tsx.snap index fbc59913e..4577f90a1 100644 --- a/public/pages/AnomalyCharts/components/AnomaliesStat/__tests__/__snapshots__/AnomalyStat.test.tsx.snap +++ b/public/pages/AnomalyCharts/components/AnomaliesStat/__tests__/__snapshots__/AnomalyStat.test.tsx.snap @@ -38,21 +38,7 @@ exports[` spec Alert Stat renders component with monitor and loadi style="font-size: 14px;" target="_blank" > - View monitor - + View monitor spec Alert Stat renders component with monitor and not l style="font-size: 14px;" target="_blank" > - View monitor - + View monitor
{featureName}: {dataString}
- ) - }) + ); + }); } else { for (const [, value] of Object.entries(contributionData)) { featureAttributionList.push(
{value.name}: {value.attribution}
- ) + ); } } return ( @@ -379,35 +382,33 @@ export const AnomalyDetailsChart = React.memo( Feature Contribution: {anomaly ? ( -

-


- {featureAttributionList} -

- ) : null} +

+


+ {featureAttributionList} +

+ ) : null}
); }; - const generateContributionAnomalyAnnotations = ( anomalies: AnomalyData[][] ): any[][] => { let annotations = [] as any[]; anomalies.forEach((anomalyTimeSeries: AnomalyData[]) => { annotations.push( - Array.isArray(anomalyTimeSeries) ? ( - anomalyTimeSeries - .filter((anomaly: AnomalyData) => anomaly.anomalyGrade > 0) - .map((anomaly: AnomalyData) => ( - { - coordinates: { - x0: anomaly.startTime, - x1: anomaly.endTime + (anomaly.endTime - anomaly.startTime), - }, - details: `${JSON.stringify(anomaly)}` - })) - ) : [] + Array.isArray(anomalyTimeSeries) + ? anomalyTimeSeries + .filter((anomaly: AnomalyData) => anomaly.anomalyGrade > 0) + .map((anomaly: AnomalyData) => ({ + coordinates: { + x0: anomaly.startTime, + x1: anomaly.endTime + (anomaly.endTime - anomaly.startTime), + }, + details: `${JSON.stringify(anomaly)}`, + })) + : [] ); }); return annotations; @@ -601,7 +602,9 @@ export const AnomalyDetailsChart = React.memo( /> )} - + /> + {alertAnnotations ? ( - ) + : props.anomalyGradeSeriesName; + return ( + + ); } )} diff --git a/public/pages/AnomalyCharts/containers/FeatureBreakDown.tsx b/public/pages/AnomalyCharts/containers/FeatureBreakDown.tsx index 51dd13183..e939e64d2 100644 --- a/public/pages/AnomalyCharts/containers/FeatureBreakDown.tsx +++ b/public/pages/AnomalyCharts/containers/FeatureBreakDown.tsx @@ -176,11 +176,9 @@ export const FeatureBreakDown = React.memo((props: FeatureBreakDownProps) => { detectorEnabledTime={props.detector.enabledTime} entityData={getEntityDataForChart(props.anomalyAndFeatureResults)} isHCDetector={props.isHCDetector} - windowDelay={ - get(props, `detector.windowDelay.period`, { - period: { interval: 0, unit: UNITS.MINUTES }, - }) - } + windowDelay={get(props, `detector.windowDelay.period`, { + period: { interval: 0, unit: UNITS.MINUTES }, + })} /> {index + 1 === get(props, 'detector.featureAttributes', []).length ? null : ( diff --git a/public/pages/AnomalyCharts/utils/anomalyChartUtils.tsx b/public/pages/AnomalyCharts/utils/anomalyChartUtils.tsx index 23c7031dc..b2603ada3 100644 --- a/public/pages/AnomalyCharts/utils/anomalyChartUtils.tsx +++ b/public/pages/AnomalyCharts/utils/anomalyChartUtils.tsx @@ -640,9 +640,7 @@ export const getFeatureBreakdownWording = ( return isNotSample ? 'Feature breakdown' : 'Sample feature breakdown'; }; -export const getFeatureDataWording = ( - isNotSample: boolean | undefined -) => { +export const getFeatureDataWording = (isNotSample: boolean | undefined) => { return isNotSample ? 'Feature output' : 'Sample feature output'; }; diff --git a/public/pages/AnomalyCharts/utils/constants.ts b/public/pages/AnomalyCharts/utils/constants.ts index 5b699a1bd..88afc9886 100644 --- a/public/pages/AnomalyCharts/utils/constants.ts +++ b/public/pages/AnomalyCharts/utils/constants.ts @@ -24,7 +24,7 @@ export enum CHART_FIELDS { CONFIDENCE = 'confidence', DATA = 'data', AGG_INTERVAL = 'aggInterval', - EXPECTED_VALUE = 'expectedValue' + EXPECTED_VALUE = 'expectedValue', } export enum CHART_COLORS { @@ -91,7 +91,7 @@ export const DEFAULT_ANOMALY_SUMMARY = { maxAnomalyGrade: 0, minConfidence: 0, maxConfidence: 0, - lastAnomalyOccurrence: '-' + lastAnomalyOccurrence: '-', }; export const HEATMAP_CHART_Y_AXIS_WIDTH = 30; diff --git a/public/pages/ConfigureModel/components/CategoryField/CategoryField.tsx b/public/pages/ConfigureModel/components/CategoryField/CategoryField.tsx index 9afe53a1c..130e64d51 100644 --- a/public/pages/ConfigureModel/components/CategoryField/CategoryField.tsx +++ b/public/pages/ConfigureModel/components/CategoryField/CategoryField.tsx @@ -76,7 +76,7 @@ export function CategoryField(props: CategoryFieldProps) { Split a single time series into multiple time series based on categorical fields. You can select up to 2.{' '} - Learn more + Learn more } diff --git a/public/pages/ConfigureModel/components/CategoryField/__tests__/__snapshots__/CategoryField.test.tsx.snap b/public/pages/ConfigureModel/components/CategoryField/__tests__/__snapshots__/CategoryField.test.tsx.snap index a1117607c..557d3b8de 100644 --- a/public/pages/ConfigureModel/components/CategoryField/__tests__/__snapshots__/CategoryField.test.tsx.snap +++ b/public/pages/ConfigureModel/components/CategoryField/__tests__/__snapshots__/CategoryField.test.tsx.snap @@ -50,17 +50,7 @@ exports[` spec renders the component when disabled 1`] = ` rel="noopener noreferrer" target="_blank" > - Learn more - + Learn more spec renders the component when enabled 1`] = ` rel="noopener noreferrer" target="_blank" > - Learn more - + Learn more - Learn more + Learn more } diff --git a/public/pages/ConfigureModel/containers/ConfigureModel.tsx b/public/pages/ConfigureModel/containers/ConfigureModel.tsx index 9c589374d..b2a21696c 100644 --- a/public/pages/ConfigureModel/containers/ConfigureModel.tsx +++ b/public/pages/ConfigureModel/containers/ConfigureModel.tsx @@ -249,7 +249,7 @@ export function ConfigureModel(props: ConfigureModelProps) { and other optional parameters, you can preview your anomalies from a sample feature output.{' '} - Learn more + Learn more diff --git a/public/pages/ConfigureModel/containers/SampleAnomalies.tsx b/public/pages/ConfigureModel/containers/SampleAnomalies.tsx index 7040215ca..a6ad30adc 100644 --- a/public/pages/ConfigureModel/containers/SampleAnomalies.tsx +++ b/public/pages/ConfigureModel/containers/SampleAnomalies.tsx @@ -204,7 +204,7 @@ export function SampleAnomalies(props: SampleAnomaliesProps) { ? 'You can preview how your anomalies may look like from sample feature output and adjust the feature settings as needed.' : 'Use the sample data as a reference to fine tune settings. To see the latest preview with your adjustments, click "Refresh preview". Once you are done with your edits, save your changes and run the detector to see real time anomalies for the new data set.'}{' '} - Learn more + Learn more diff --git a/public/pages/ConfigureModel/containers/__tests__/__snapshots__/ConfigureModel.test.tsx.snap b/public/pages/ConfigureModel/containers/__tests__/__snapshots__/ConfigureModel.test.tsx.snap index fdf2f51c5..3c171c09c 100644 --- a/public/pages/ConfigureModel/containers/__tests__/__snapshots__/ConfigureModel.test.tsx.snap +++ b/public/pages/ConfigureModel/containers/__tests__/__snapshots__/ConfigureModel.test.tsx.snap @@ -35,17 +35,7 @@ exports[` spec creating model configuration renders the compon rel="noopener noreferrer" target="_blank" > - Learn more - + Learn more spec creating model configuration renders the compon rel="noopener noreferrer" target="_blank" > - Learn more - + Learn more spec creating model configuration renders the compon rel="noopener noreferrer" target="_blank" > - Learn more - + Learn more spec creating model configuration renders the compon rel="noopener noreferrer" target="_blank" > - Learn more - + Learn more spec editing model configuration renders the compone rel="noopener noreferrer" target="_blank" > - Learn more - + Learn more spec editing model configuration renders the compone rel="noopener noreferrer" target="_blank" > - Learn more - + Learn more spec editing model configuration renders the compone rel="noopener noreferrer" target="_blank" > - Learn more - + Learn more {

Read about{' '} - Get started with Anomaly detection   - + Get started with Anomaly detection {' '}

diff --git a/public/pages/Dashboard/Components/EmptyDashboard/__tests__/__snapshots__/EmptyDashboard.test.tsx.snap b/public/pages/Dashboard/Components/EmptyDashboard/__tests__/__snapshots__/EmptyDashboard.test.tsx.snap index 57fb8f90b..03d27a8e8 100644 --- a/public/pages/Dashboard/Components/EmptyDashboard/__tests__/__snapshots__/EmptyDashboard.test.tsx.snap +++ b/public/pages/Dashboard/Components/EmptyDashboard/__tests__/__snapshots__/EmptyDashboard.test.tsx.snap @@ -34,17 +34,7 @@ exports[` spec Empty results renders component with empty messa rel="noopener noreferrer" target="_blank" > - Get started with Anomaly detection   - + Get started with Anomaly detection