Skip to content
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

Change detector out of time range modal warning into a callout warning #384

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions public/pages/AnomalyCharts/containers/AnomaliesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export interface AnomaliesChartProps {
entityAnomalySummaries?: EntityAnomalySummaries[];
selectedCategoryFields?: any[];
handleCategoryFieldsChange(selectedOptions: any[]): void;
openOutOfRangeCallOut?: boolean;
}

export const AnomaliesChart = React.memo((props: AnomaliesChartProps) => {
Expand All @@ -96,6 +97,8 @@ export const AnomaliesChart = React.memo((props: AnomaliesChartProps) => {
: 'now',
});

const [showOutOfRangeCallOut, setShowOutOfRangeCallOut] = useState(false);

// for each time series of results, get the anomalies, ignoring feature data
let anomalyResults = [] as AnomalyData[][];
get(props, 'anomalyAndFeatureResults', []).forEach(
Expand All @@ -107,6 +110,14 @@ export const AnomaliesChart = React.memo((props: AnomaliesChartProps) => {
const handleDateRangeChange = (startDate: number, endDate: number) => {
props.onDateRangeChange(startDate, endDate);
props.onZoomRangeChange(startDate, endDate);
if (
!props.isHistorical &&
endDate < get(props, 'detector.enabledTime')
) {
setShowOutOfRangeCallOut(true)
} else {
setShowOutOfRangeCallOut(false)
}
};

const showLoader = useDelayedLoader(props.isLoading);
Expand Down Expand Up @@ -387,6 +398,7 @@ export const AnomaliesChart = React.memo((props: AnomaliesChartProps) => {
isHCDetector={props.isHCDetector}
isHistorical={props.isHistorical}
onDatePickerRangeChange={handleDatePickerRangeChange}
openOutOfRangeCallOut={showOutOfRangeCallOut}
/>
)}
</EuiFlexGroup>
Expand Down
12 changes: 12 additions & 0 deletions public/pages/AnomalyCharts/containers/AnomalyDetailsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
EuiStat,
EuiButtonGroup,
EuiText,
EuiCallOut,
} from '@elastic/eui';
import { forEach, get } from 'lodash';
import moment from 'moment';
Expand Down Expand Up @@ -111,6 +112,7 @@ interface AnomalyDetailsChartProps {
isHistorical?: boolean;
selectedHeatmapCell?: HeatmapCell;
onDatePickerRangeChange?(startDate: number, endDate: number): void;
openOutOfRangeCallOut?: boolean;
}

export const AnomalyDetailsChart = React.memo(
Expand Down Expand Up @@ -424,6 +426,16 @@ export const AnomalyDetailsChart = React.memo(

return (
<React.Fragment>
{props.openOutOfRangeCallOut ? (
<EuiCallOut data-test-subj='outOfRangeCallOut'
title='Selected dates are out of the range'
color='primary'>
{`Your selected dates are not in the range from when the detector
last started streaming data
(${moment(get(props, 'detector.enabledTime')).format('MM/DD/YYYY hh:mm A')}).`}
</EuiCallOut>
) : null}

<EuiFlexGroup style={{ padding: '20px' }}>
<EuiFlexItem>
<EuiStat
Expand Down

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions public/pages/DetectorResults/containers/AnomalyHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ interface AnomalyHistoryProps {
isHistorical?: boolean;
taskId?: string;
isNotSample?: boolean;
openOutOfRangeModal?(): void;
}

const useAsyncRef = (value: any) => {
Expand Down Expand Up @@ -691,13 +690,6 @@ export const AnomalyHistory = (props: AnomalyHistoryProps) => {
}
const handleDateRangeChange = useCallback(
(startDate: number, endDate: number) => {
if (
!props.isHistorical &&
startDate < get(props, 'detector.enabledTime') &&
props.openOutOfRangeModal
) {
props.openOutOfRangeModal();
}
setDateRange({
startDate: startDate,
endDate: endDate,
Expand Down
15 changes: 0 additions & 15 deletions public/pages/DetectorResults/containers/AnomalyResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import { detectorIsSample } from '../../Overview/utils/helpers';
import { SampleIndexDetailsCallout } from '../../Overview/components/SampleIndexDetailsCallout/SampleIndexDetailsCallout';
import { CoreStart } from '../../../../../../src/core/public';
import { CoreServicesContext } from '../../../components/CoreServices/CoreServices';
import { OutOfRangeModal } from '../components/OutOfRangeModal';

interface AnomalyResultsProps extends RouteComponentProps {
detectorId: string;
Expand All @@ -83,8 +82,6 @@ export function AnomalyResults(props: AnomalyResultsProps) {
const detector = useSelector(
(state: AppState) => state.ad.detectors[detectorId]
);
const [outOfRangeModalOpen, setOutOfRangeModalOpen] =
useState<boolean>(false);

useEffect(() => {
core.chrome.setBreadcrumbs([
Expand Down Expand Up @@ -417,17 +414,6 @@ export function AnomalyResults(props: AnomalyResultsProps) {
<EuiSpacer size="l" />
{
<Fragment>
{outOfRangeModalOpen ? (
<EuiOverlayMask>
<OutOfRangeModal
onClose={() => setOutOfRangeModalOpen(false)}
onConfirm={() => {
props.onSwitchToHistorical();
}}
lastEnabledTime={get(detector, 'enabledTime') as number}
/>
</EuiOverlayMask>
) : null}
{isDetectorRunning ||
isDetectorPaused ||
isDetectorInitializing ||
Expand Down Expand Up @@ -570,7 +556,6 @@ export function AnomalyResults(props: AnomalyResultsProps) {
isFeatureDataMissing={isDetectorMissingData}
isNotSample={true}
isHistorical={false}
openOutOfRangeModal={() => setOutOfRangeModalOpen(true)}
/>
</Fragment>
) : detector ? (
Expand Down