[ML] Use two weeks before now for default start time in job start date picker (#155312)

When starting an anomaly detection job, if you select "Specify start
time", the time chosen is two weeks before now, rounded down to the
start of the day.

<img width="917" alt="image"
src="https://user-images.githubusercontent.com/22172091/233178339-1e198068-aa8b-479a-92cb-085fc34691e0.png">

Fixes https://github.com/elastic/enhancements/issues/16467
This commit is contained in:
James Gowdy 2023-04-20 14:36:27 +01:00 committed by GitHub
parent d8fa5d6831
commit 2d576c575e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,7 @@ export class TimeRangeSelector extends Component {
};
this.latestTimestamp = this.props.startTime;
this.now = this.props.now;
this.twoWeeksAgo = moment(this.now).subtract(2, 'weeks').startOf('day');
}
setStartTab = (tab) => {
@ -38,6 +39,9 @@ export class TimeRangeSelector extends Component {
case 1:
this.setStartTime(this.now);
break;
case 2:
this.setStartTime(this.twoWeeksAgo);
break;
default:
break;
}