Skip to content

Commit

Permalink
check if selected job still running
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Feb 16, 2021
1 parent 4de2426 commit 26bd68c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type MlSummaryJobs = MlSummaryJob[];

export interface MlJobWithTimeRange extends CombinedJobWithStats {
id: string;
isRunning?: boolean;
isNotSingleMetricViewerJobMessage?: string;
timeRange: {
from: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import { FormattedMessage } from '@kbn/i18n/react';

import { EuiEmptyPrompt } from '@elastic/eui';

export const ExplorerNoResultsFound = ({ hasResults, hasResultsWithAnomalies }) => {
export const ExplorerNoResultsFound = ({
hasResults,
hasResultsWithAnomalies,
selectedJobsRunning,
}) => {
const resultsHaveNoAnomalies = hasResults === true && hasResultsWithAnomalies === false;
const noResults = hasResults === false && hasResultsWithAnomalies === false;
return (
Expand All @@ -38,12 +42,22 @@ export const ExplorerNoResultsFound = ({ hasResults, hasResultsWithAnomalies })
}
body={
<React.Fragment>
<p>
<FormattedMessage
id="xpack.ml.explorer.tryWideningTimeSelectionLabel"
defaultMessage="Try widening the time selection or moving further back in time"
/>
</p>
{selectedJobsRunning && noResults && (
<p>
<FormattedMessage
id="xpack.ml.explorer.selectedJobsRunningLabel"
defaultMessage="One or more selected jobs are still running and results may not be available yet."
/>
</p>
)}
{!selectedJobsRunning && (
<p>
<FormattedMessage
id="xpack.ml.explorer.tryWideningTimeSelectionLabel"
defaultMessage="Try widening the time selection or moving further back in time"
/>
</p>
)}
</React.Fragment>
}
/>
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/ml/public/application/explorer/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export class Explorer extends React.Component {
setSelectedCells: PropTypes.func.isRequired,
severity: PropTypes.number.isRequired,
showCharts: PropTypes.bool.isRequired,
selectedJobsRunning: PropTypes.bool.isRequired,
};

state = { filterIconTriggeredQuery: undefined, language: DEFAULT_QUERY_LANG };
Expand Down Expand Up @@ -223,7 +224,7 @@ export class Explorer extends React.Component {
updateLanguage = (language) => this.setState({ language });

render() {
const { showCharts, severity, stoppedPartitions } = this.props;
const { showCharts, severity, stoppedPartitions, selectedJobsRunning } = this.props;

const {
annotations,
Expand Down Expand Up @@ -267,6 +268,7 @@ export class Explorer extends React.Component {
<ExplorerNoResultsFound
hasResults={hasResults}
hasResultsWithAnomalies={hasResultsWithAnomalies}
selectedJobsRunning={selectedJobsRunning}
/>
</ExplorerPage>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ const ExplorerUrlStateManager: FC<ExplorerUrlStateManagerProps> = ({ jobsWithTim
const timefilter = useTimefilter({ timeRangeSelector: true, autoRefreshSelector: true });

const { jobIds } = useJobSelection(jobsWithTimeRange);
const selectedJobsRunning = jobsWithTimeRange.some(
(job) => jobIds.includes(job.id) && job.isRunning === true
);

const explorerAppState = useObservable(explorerService.appState$);
const explorerState = useObservable(explorerService.state$);
Expand Down Expand Up @@ -261,6 +264,7 @@ const ExplorerUrlStateManager: FC<ExplorerUrlStateManagerProps> = ({ jobsWithTim
severity: tableSeverity.val,
stoppedPartitions,
invalidTimeRangeError,
selectedJobsRunning,
}}
/>
</div>
Expand Down

0 comments on commit 26bd68c

Please sign in to comment.