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

[ML] Create watch from new jobs list #21112

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
adding checkbox to start datafeed modal
  • Loading branch information
jgowdyelastic committed Jul 24, 2018
commit a17eaae9b7cd2acea125e5e1be3cc445e62caa02
Original file line number Diff line number Diff line change
@@ -19,6 +19,9 @@ import {
EuiModalHeader,
EuiModalHeaderTitle,
EuiOverlayMask,
EuiHorizontalRule,
EuiCheckbox,

} from '@elastic/eui';

import moment from 'moment';
@@ -36,6 +39,8 @@ export class StartDatafeedModal extends Component {
isModalVisible: false,
startTime: moment(),
endTime: moment(),
createWatch: false,
allowCreateWatch: false,
initialSpecifiedStartTime: moment()
};

@@ -64,6 +69,10 @@ export class StartDatafeedModal extends Component {
this.setState({ endTime: time });
}

setCreateWatch = (e) => {
this.setState({ createWatch: e.target.checked });
}

closeModal = () => {
this.setState({ isModalVisible: false });
}
@@ -72,13 +81,16 @@ export class StartDatafeedModal extends Component {
const startTime = undefined;
const endTime = moment();
const initialSpecifiedStartTime = getLowestLatestTime(jobs);
const allowCreateWatch = (jobs.length === 1);
this.setState({
jobs,
isModalVisible: true,
startTime,
endTime,
initialSpecifiedStartTime,
showCreateWatchModal,
allowCreateWatch,
createWatch: false,
});
}

@@ -87,7 +99,7 @@ export class StartDatafeedModal extends Component {
const start = moment.isMoment(this.state.startTime) ? this.state.startTime.valueOf() : this.state.startTime;
const end = moment.isMoment(this.state.endTime) ? this.state.endTime.valueOf() : this.state.endTime;
forceStartDatafeeds(jobs, start, end, () => {
if (jobs.length === 1) {
if (this.state.createWatch && jobs.length === 1) {
const jobId = jobs[0].id;
this.getShowCreateWatchModalFunction()(jobId);
}
@@ -97,7 +109,12 @@ export class StartDatafeedModal extends Component {
}

render() {
const { jobs } = this.state;
const {
jobs,
initialSpecifiedStartTime,
endTime,
createWatch
} = this.state;
const startableJobs = (jobs !== undefined) ? jobs.filter(j => j.hasDatafeed) : [];
let modal;

@@ -116,11 +133,23 @@ export class StartDatafeedModal extends Component {

<EuiModalBody>
<TimeRangeSelector
startTime={this.state.initialSpecifiedStartTime}
endTime={this.state.endTime}
startTime={initialSpecifiedStartTime}
endTime={endTime}
setStartTime={this.setStartTime}
setEndTime={this.setEndTime}
/>
{
this.state.endTime === undefined &&
<div className="create-watch">
<EuiHorizontalRule />
<EuiCheckbox
id="createWatch"
label="Create watch after datafeed has started"
checked={createWatch}
onChange={this.setCreateWatch}
/>
</div>
}
</EuiModalBody>

<EuiModalFooter>
Original file line number Diff line number Diff line change
@@ -51,6 +51,9 @@ export class TimeRangeSelector extends Component {
case 0:
this.setEndTime(undefined);
break;
case 1:
this.setEndTime(moment());
break;
default:
break;
}
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ export class CreateWatch extends Component {
if (status === null || status === STATUS.SAVING || status === STATUS.SAVE_FAILED) {
return (
<div className="create-watch">
<div className="form-group">
<div className="form-group form-group-flex">
<div className="sub-form-group">
<div>
<label
Original file line number Diff line number Diff line change
@@ -11,6 +11,10 @@
}
}

.form-group-flex {
display: flex;
}

.sub-form-group:first-child {
.euiFormControlLayout {
display: inline-block;