diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/classification_exploration.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/classification_exploration.tsx
index 263d43ceb2630..41430b163c029 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/classification_exploration.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/classification_exploration.tsx
@@ -18,6 +18,7 @@ import { getIndexPatternIdFromName } from '../../../../../util/index_utils';
import { IIndexPattern } from '../../../../../../../../../../src/plugins/data/common/index_patterns';
import { newJobCapsService } from '../../../../../services/new_job_capabilities_service';
import { useMlContext } from '../../../../../contexts/ml';
+import { isGetDataFrameAnalyticsStatsResponseOk } from '../../../analytics_management/services/analytics_service/get_analytics';
export const ExplorationTitle: React.FC<{ jobId: string }> = ({ jobId }) => (
@@ -47,11 +48,11 @@ const jobCapsErrorTitle = i18n.translate(
interface Props {
jobId: string;
- jobStatus: DATA_FRAME_TASK_STATE;
}
-export const ClassificationExploration: FC = ({ jobId, jobStatus }) => {
+export const ClassificationExploration: FC = ({ jobId }) => {
const [jobConfig, setJobConfig] = useState(undefined);
+ const [jobStatus, setJobStatus] = useState(undefined);
const [isLoadingJobConfig, setIsLoadingJobConfig] = useState(false);
const [isInitialized, setIsInitialized] = useState(false);
const [jobConfigErrorMessage, setJobConfigErrorMessage] = useState(undefined);
@@ -65,6 +66,15 @@ export const ClassificationExploration: FC = ({ jobId, jobStatus }) => {
setIsLoadingJobConfig(true);
try {
const analyticsConfigs = await ml.dataFrameAnalytics.getDataFrameAnalytics(jobId);
+ const analyticsStats = await ml.dataFrameAnalytics.getDataFrameAnalyticsStats(jobId);
+ const stats = isGetDataFrameAnalyticsStatsResponseOk(analyticsStats)
+ ? analyticsStats.data_frame_analytics[0]
+ : undefined;
+
+ if (stats !== undefined && stats.state) {
+ setJobStatus(stats.state);
+ }
+
if (
Array.isArray(analyticsConfigs.data_frame_analytics) &&
analyticsConfigs.data_frame_analytics.length > 0
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx
index 1c5563bdb4f83..7bb334cfa3a74 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx
@@ -50,7 +50,7 @@ const defaultPanelWidth = 500;
interface Props {
jobConfig: DataFrameAnalyticsConfig;
- jobStatus: DATA_FRAME_TASK_STATE;
+ jobStatus?: DATA_FRAME_TASK_STATE;
searchQuery: ResultsSearchQuery;
}
@@ -268,9 +268,11 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery })
-
- {getTaskStateBadge(jobStatus)}
-
+ {jobStatus !== undefined && (
+
+ {getTaskStateBadge(jobStatus)}
+
+ )}
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/results_table.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/results_table.tsx
index 20d126f4ac6ca..dabb8db514226 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/results_table.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/results_table.tsx
@@ -86,7 +86,7 @@ const showingFirstDocs = i18n.translate(
interface Props {
jobConfig: DataFrameAnalyticsConfig;
- jobStatus: DATA_FRAME_TASK_STATE;
+ jobStatus?: DATA_FRAME_TASK_STATE;
setEvaluateSearchQuery: React.Dispatch>;
}
@@ -381,9 +381,11 @@ export const ResultsTable: FC = React.memo(
-
- {getTaskStateBadge(jobStatus)}
-
+ {jobStatus !== undefined && (
+
+ {getTaskStateBadge(jobStatus)}
+
+ )}
= React.memo(
-
- {getTaskStateBadge(jobStatus)}
-
+ {jobStatus !== undefined && (
+
+ {getTaskStateBadge(jobStatus)}
+
+ )}
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/outlier_exploration.test.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/outlier_exploration.test.tsx
index 030447873f6a5..7cdd15e49bd14 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/outlier_exploration.test.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/outlier_exploration.test.tsx
@@ -6,7 +6,6 @@
import { shallow } from 'enzyme';
import React from 'react';
-import { DATA_FRAME_TASK_STATE } from '../../../analytics_management/components/analytics_list/common';
import { MlContext } from '../../../../../contexts/ml';
import { kibanaContextValueMock } from '../../../../../contexts/ml/__mocks__/kibana_context_value';
@@ -22,7 +21,7 @@ describe('Data Frame Analytics: ', () => {
test('Minimal initialization', () => {
const wrapper = shallow(
-
+
);
// Without the jobConfig being loaded, the component will just return empty.
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/outlier_exploration.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/outlier_exploration.tsx
index 214bc01c6a2ef..d686c605f1912 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/outlier_exploration.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/outlier_exploration.tsx
@@ -27,7 +27,6 @@ import {
import { sortColumns, INDEX_STATUS, defaultSearchQuery } from '../../../../common';
-import { DATA_FRAME_TASK_STATE } from '../../../analytics_management/components/analytics_list/common';
import { getTaskStateBadge } from '../../../analytics_management/components/analytics_list/columns';
import { useExploreData, TableItem } from '../../hooks/use_explore_data';
@@ -50,7 +49,6 @@ const ExplorationTitle: FC<{ jobId: string }> = ({ jobId }) => (
interface ExplorationProps {
jobId: string;
- jobStatus: DATA_FRAME_TASK_STATE;
}
const getFeatureCount = (resultsField: string, tableItems: TableItem[] = []) => {
@@ -63,11 +61,12 @@ const getFeatureCount = (resultsField: string, tableItems: TableItem[] = []) =>
).length;
};
-export const OutlierExploration: FC = React.memo(({ jobId, jobStatus }) => {
+export const OutlierExploration: FC = React.memo(({ jobId }) => {
const {
errorMessage,
indexPattern,
jobConfig,
+ jobStatus,
pagination,
searchQuery,
selectedFields,
@@ -173,9 +172,11 @@ export const OutlierExploration: FC = React.memo(({ jobId, job
-
- {getTaskStateBadge(jobStatus)}
-
+ {jobStatus !== undefined && (
+
+ {getTaskStateBadge(jobStatus)}
+
+ )}
{(columns.length > 0 || searchQuery !== defaultSearchQuery) && (
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/evaluate_panel.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/evaluate_panel.tsx
index 74937bf761285..9f235ae6c45c0 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/evaluate_panel.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/evaluate_panel.tsx
@@ -39,7 +39,7 @@ import {
interface Props {
jobConfig: DataFrameAnalyticsConfig;
- jobStatus: DATA_FRAME_TASK_STATE;
+ jobStatus?: DATA_FRAME_TASK_STATE;
searchQuery: ResultsSearchQuery;
}
@@ -248,9 +248,11 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery })
-
- {getTaskStateBadge(jobStatus)}
-
+ {jobStatus !== undefined && (
+
+ {getTaskStateBadge(jobStatus)}
+
+ )}
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/regression_exploration.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/regression_exploration.tsx
index 3dfd95a27f8a7..4f3c4048d40d5 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/regression_exploration.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/regression_exploration.tsx
@@ -18,6 +18,7 @@ import { getIndexPatternIdFromName } from '../../../../../util/index_utils';
import { IIndexPattern } from '../../../../../../../../../../src/plugins/data/common/index_patterns';
import { newJobCapsService } from '../../../../../services/new_job_capabilities_service';
import { useMlContext } from '../../../../../contexts/ml';
+import { isGetDataFrameAnalyticsStatsResponseOk } from '../../../analytics_management/services/analytics_service/get_analytics';
export const ExplorationTitle: React.FC<{ jobId: string }> = ({ jobId }) => (
@@ -47,11 +48,11 @@ const jobCapsErrorTitle = i18n.translate(
interface Props {
jobId: string;
- jobStatus: DATA_FRAME_TASK_STATE;
}
-export const RegressionExploration: FC = ({ jobId, jobStatus }) => {
+export const RegressionExploration: FC = ({ jobId }) => {
const [jobConfig, setJobConfig] = useState(undefined);
+ const [jobStatus, setJobStatus] = useState(undefined);
const [isLoadingJobConfig, setIsLoadingJobConfig] = useState(false);
const [isInitialized, setIsInitialized] = useState(false);
const [jobConfigErrorMessage, setJobConfigErrorMessage] = useState(undefined);
@@ -65,6 +66,15 @@ export const RegressionExploration: FC = ({ jobId, jobStatus }) => {
setIsLoadingJobConfig(true);
try {
const analyticsConfigs = await ml.dataFrameAnalytics.getDataFrameAnalytics(jobId);
+ const analyticsStats = await ml.dataFrameAnalytics.getDataFrameAnalyticsStats(jobId);
+ const stats = isGetDataFrameAnalyticsStatsResponseOk(analyticsStats)
+ ? analyticsStats.data_frame_analytics[0]
+ : undefined;
+
+ if (stats !== undefined && stats.state) {
+ setJobStatus(stats.state);
+ }
+
if (
Array.isArray(analyticsConfigs.data_frame_analytics) &&
analyticsConfigs.data_frame_analytics.length > 0
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/results_table.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/results_table.tsx
index 7a6b2b23ba7a3..b896c34a582f7 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/results_table.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/results_table.tsx
@@ -86,7 +86,7 @@ const showingFirstDocs = i18n.translate(
interface Props {
jobConfig: DataFrameAnalyticsConfig;
- jobStatus: DATA_FRAME_TASK_STATE;
+ jobStatus?: DATA_FRAME_TASK_STATE;
setEvaluateSearchQuery: React.Dispatch>;
}
@@ -381,9 +381,11 @@ export const ResultsTable: FC = React.memo(
-
- {getTaskStateBadge(jobStatus)}
-
+ {jobStatus !== undefined && (
+
+ {getTaskStateBadge(jobStatus)}
+
+ )}
= React.memo(
-
- {getTaskStateBadge(jobStatus)}
-
+ {jobStatus !== undefined && (
+
+ {getTaskStateBadge(jobStatus)}
+
+ )}
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_explore_data/use_explore_data.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_explore_data/use_explore_data.ts
index 6ad0a1822e490..d637057a4430d 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_explore_data/use_explore_data.ts
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_explore_data/use_explore_data.ts
@@ -19,6 +19,7 @@ import { newJobCapsService } from '../../../../../services/new_job_capabilities_
import { getIndexPatternIdFromName } from '../../../../../util/index_utils';
import { getNestedProperty } from '../../../../../util/object_utils';
import { useMlContext } from '../../../../../contexts/ml';
+import { isGetDataFrameAnalyticsStatsResponseOk } from '../../../analytics_management/services/analytics_service/get_analytics';
import {
getDefaultSelectableFields,
@@ -31,6 +32,7 @@ import {
import { isKeywordAndTextType } from '../../../../common/fields';
import { getOutlierScoreFieldName } from './common';
+import { DATA_FRAME_TASK_STATE } from '../../../analytics_management/components/analytics_list/common';
export type TableItem = Record;
@@ -40,6 +42,7 @@ interface UseExploreDataReturnType {
errorMessage: string;
indexPattern: IndexPattern | undefined;
jobConfig: DataFrameAnalyticsConfig | undefined;
+ jobStatus: DATA_FRAME_TASK_STATE | undefined;
pagination: Pagination;
searchQuery: SavedSearchQuery;
selectedFields: EsFieldName[];
@@ -74,6 +77,7 @@ export const useExploreData = (jobId: string): UseExploreDataReturnType => {
const [indexPattern, setIndexPattern] = useState(undefined);
const [jobConfig, setJobConfig] = useState(undefined);
+ const [jobStatus, setJobStatus] = useState(undefined);
const [errorMessage, setErrorMessage] = useState('');
const [status, setStatus] = useState(INDEX_STATUS.UNUSED);
@@ -90,6 +94,15 @@ export const useExploreData = (jobId: string): UseExploreDataReturnType => {
useEffect(() => {
(async function() {
const analyticsConfigs = await ml.dataFrameAnalytics.getDataFrameAnalytics(jobId);
+ const analyticsStats = await ml.dataFrameAnalytics.getDataFrameAnalyticsStats(jobId);
+ const stats = isGetDataFrameAnalyticsStatsResponseOk(analyticsStats)
+ ? analyticsStats.data_frame_analytics[0]
+ : undefined;
+
+ if (stats !== undefined && stats.state) {
+ setJobStatus(stats.state);
+ }
+
if (
Array.isArray(analyticsConfigs.data_frame_analytics) &&
analyticsConfigs.data_frame_analytics.length > 0
@@ -215,6 +228,7 @@ export const useExploreData = (jobId: string): UseExploreDataReturnType => {
errorMessage,
indexPattern,
jobConfig,
+ jobStatus,
pagination,
rowCount,
searchQuery,
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/page.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/page.tsx
index efbebc1564bf9..c8349084dbda8 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/page.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/page.tsx
@@ -27,13 +27,11 @@ import { RegressionExploration } from './components/regression_exploration';
import { ClassificationExploration } from './components/classification_exploration';
import { ANALYSIS_CONFIG_TYPE } from '../../common/analytics';
-import { DATA_FRAME_TASK_STATE } from '../analytics_management/components/analytics_list/common';
export const Page: FC<{
jobId: string;
analysisType: ANALYSIS_CONFIG_TYPE;
- jobStatus: DATA_FRAME_TASK_STATE;
-}> = ({ jobId, analysisType, jobStatus }) => (
+}> = ({ jobId, analysisType }) => (
@@ -68,13 +66,13 @@ export const Page: FC<{
{analysisType === ANALYSIS_CONFIG_TYPE.OUTLIER_DETECTION && (
-
+
)}
{analysisType === ANALYSIS_CONFIG_TYPE.REGRESSION && (
-
+
)}
{analysisType === ANALYSIS_CONFIG_TYPE.CLASSIFICATION && (
-
+
)}
diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/actions.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/actions.tsx
index 425e3bc903d04..4e19df9ae22a8 100644
--- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/actions.tsx
+++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/actions.tsx
@@ -33,13 +33,12 @@ export const AnalyticsViewAction = {
isPrimary: true,
render: (item: DataFrameAnalyticsListRow) => {
const analysisType = getAnalysisType(item.config.analysis);
- const jobStatus = item.stats.state;
const isDisabled =
!isRegressionAnalysis(item.config.analysis) &&
!isOutlierAnalysis(item.config.analysis) &&
!isClassificationAnalysis(item.config.analysis);
- const url = getResultsUrl(item.id, analysisType, jobStatus);
+ const url = getResultsUrl(item.id, analysisType);
return (
= ({ location, deps }) => {
}
const jobId: string = globalState.ml.jobId;
const analysisType: ANALYSIS_CONFIG_TYPE = globalState.ml.analysisType;
- const jobStatus: DATA_FRAME_TASK_STATE = globalState.ml.jobStatus;
return (
-
+
);
};