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] Single metric viewer: Fix detector/entity selection #44772

Merged
merged 2 commits into from
Sep 4, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiFormRow,
EuiButton,
EuiSelect,
EuiSpacer,
EuiText,
Expand Down Expand Up @@ -170,10 +169,14 @@ export class TimeSeriesExplorer extends React.Component {
detectorIndexChangeHandler = (e) => {
const id = e.target.value;
if (id !== undefined) {
this.setState({ detectorId: id });
this.setState({ detectorId: id }, () => {
this.updateControlsForDetector(
() => this.loadEntityValues(
() => this.saveSeriesPropertiesAndRefresh()
)
);
});
}
this.updateControlsForDetector();
this.loadEntityValues();
};

toggleShowAnnotationsHandler = () => {
Expand Down Expand Up @@ -322,7 +325,7 @@ export class TimeSeriesExplorer extends React.Component {
}
return stateEntity;
})
}));
}), () => this.saveSeriesPropertiesAndRefresh());
};

loadAnomaliesTableData = (earliestMs, latestMs) => {
Expand Down Expand Up @@ -378,7 +381,7 @@ export class TimeSeriesExplorer extends React.Component {
});
}

loadEntityValues = () => {
loadEntityValues = (callback = () => {}) => {
const { timefilter } = this.props;
const { detectorId, entities, selectedJob } = this.state;

Expand Down Expand Up @@ -411,7 +414,7 @@ export class TimeSeriesExplorer extends React.Component {
}
return entity;
})
});
}, callback);
}
});
}
Expand Down Expand Up @@ -653,7 +656,7 @@ export class TimeSeriesExplorer extends React.Component {
});
}

updateControlsForDetector = () => {
updateControlsForDetector = (callback = () => {}) => {
const { appStateHandler } = this.props;
const { detectorId, selectedJob } = this.state;
// Update the entity dropdown control(s) according to the partitioning fields for the selected detector.
Expand Down Expand Up @@ -684,7 +687,7 @@ export class TimeSeriesExplorer extends React.Component {
entities.push({ fieldName: byFieldName, fieldValue: byFieldValue });
}

this.setState({ entities });
this.setState({ entities }, callback);
}

loadForJobId(jobId, jobs) {
Expand Down Expand Up @@ -739,16 +742,16 @@ export class TimeSeriesExplorer extends React.Component {
this.setState(
{ detectorId, detectors, selectedJob },
() => {
this.updateControlsForDetector();

// Populate the map of jobs / detectors / field formatters for the selected IDs and refresh.
mlFieldFormatService.populateFormats([jobId], getIndexPatterns())
.catch((err) => { console.log('Error populating field formats:', err); })
this.updateControlsForDetector(() => {
// Populate the map of jobs / detectors / field formatters for the selected IDs and refresh.
mlFieldFormatService.populateFormats([jobId], getIndexPatterns())
.catch((err) => { console.log('Error populating field formats:', err); })
// Load the data - if the FieldFormats failed to populate
// the default formatting will be used for metric values.
.then(() => {
this.refresh();
});
.then(() => {
this.refresh();
});
});
}
);
}
Expand Down Expand Up @@ -1024,19 +1027,6 @@ export class TimeSeriesExplorer extends React.Component {
/>
);
})}
<EuiFlexItem grow={false}>
<EuiFormRow hasEmptyLabelSpace>
<EuiButton
fill
iconType="refresh"
onClick={this.saveSeriesPropertiesAndRefresh}
>
{i18n.translate('xpack.ml.timeSeriesExplorer.refreshButtonAriaLabel', {
defaultMessage: 'Refresh'
})}
</EuiButton>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem style={{ textAlign: 'right' }}>
<EuiFormRow hasEmptyLabelSpace style={{ maxWidth: '100%' }}>
<ForecastingModal
Expand Down