Skip to content

Commit

Permalink
Adding move to advanced job feature (elastic#18633)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic authored Apr 27, 2018
1 parent a80c669 commit 1249643
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,14 @@ module.controller('MlNewJob',
console.log('Editing job', mlJobService.currentJob);
$scope.ui.pageTitle = 'Editing Job ' + $scope.job.job_id;
} else {
$scope.mode = MODE.CLONE;
console.log('Cloning job', mlJobService.currentJob);
$scope.ui.pageTitle = 'Clone Job from ' + $scope.job.job_id;
$scope.job.job_id = '';
if (mlJobService.currentJob.job_version === undefined) {
$scope.mode = MODE.NEW;
} else {
$scope.mode = MODE.CLONE;
console.log('Cloning job', mlJobService.currentJob);
$scope.ui.pageTitle = 'Clone Job from ' + $scope.job.job_id;
$scope.job.job_id = '';
}
setDatafeedUIText();
setFieldDelimiterControlsFromText();

Expand Down Expand Up @@ -696,6 +700,7 @@ module.controller('MlNewJob',

const indicesText = datafeedConfig.indices.join(',');
$scope.ui.fieldsUpToDate = (indicesText === $scope.ui.datafeed.indicesText);
const types = Array.isArray(datafeedConfig.types) ? datafeedConfig.types : [];

$scope.ui.datafeed = {
queryText: angular.toJson(datafeedConfig.query, true),
Expand All @@ -706,7 +711,7 @@ module.controller('MlNewJob',
scrollSizeText: scrollSize,
scrollSizeDefault: scrollSizeDefault,
indicesText,
typesText: datafeedConfig.types.join(','),
typesText: types.join(','),
};

if ($scope.ui.fieldsUpToDate === false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ <h4 class="euiTitle euiTitle--small">Job Details</h4>
<div ng-show="ui.showJobInput && (jobState === JOB_STATE.NOT_STARTED || jobState === JOB_STATE.RUNNING || jobState === JOB_STATE.STOPPING)">
<ml-general-job-details></ml-general-job-details>

<div class="form-group">
<a href="" ng-click="moveToAdvancedJobCreation()">Move to advanced job configuration</a>
</div>

<div class="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter euiFlexGroup--responsive">
<div class="euiFlexItem euiFlexItem--flexGrowZero">
<ml-validate-job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { IntervalHelperProvider } from 'plugins/ml/util/ml_time_buckets';
import { filterAggTypes } from 'plugins/ml/jobs/new_job/simple/components/utils/filter_agg_types';
import { validateJob } from 'plugins/ml/jobs/new_job/simple/components/utils/validate_job';
import { adjustIntervalDisplayed } from 'plugins/ml/jobs/new_job/simple/components/utils/adjust_interval';
import { createSearchItems, createResultsUrl, addNewJobToRecentlyAccessed } from 'plugins/ml/jobs/new_job/utils/new_job_utils';
import { populateAppStateSettings } from 'plugins/ml/jobs/new_job/simple/components/utils/app_state_settings';
import { CHART_STATE, JOB_STATE } from 'plugins/ml/jobs/new_job/simple/components/constants/states';
import { createFields } from 'plugins/ml/jobs/new_job/simple/components/utils/create_fields';
Expand All @@ -33,6 +32,11 @@ import { ChartDataUtilsProvider } from 'plugins/ml/jobs/new_job/simple/component
import { checkMlNodesAvailable } from 'plugins/ml/ml_nodes_check/check_ml_nodes';
import { loadNewJobDefaults } from 'plugins/ml/jobs/new_job/utils/new_job_defaults';
import { mlEscape } from 'plugins/ml/util/string_utils';
import {
createSearchItems,
createResultsUrl,
addNewJobToRecentlyAccessed,
moveToAdvancedJobCreationProvider } from 'plugins/ml/jobs/new_job/utils/new_job_utils';
import template from './create_job.html';

uiRoutes
Expand Down Expand Up @@ -67,6 +71,7 @@ module
timefilter.disableAutoRefreshSelector();
const msgs = mlMessageBarService;
const MlTimeBuckets = Private(IntervalHelperProvider);
const moveToAdvancedJobCreation = Private(moveToAdvancedJobCreationProvider);
const calculateModelMemoryLimit = Private(CalculateModelMemoryLimitProvider);
const chartDataUtils = Private(ChartDataUtilsProvider);
$scope.addNewJobToRecentlyAccessed = addNewJobToRecentlyAccessed;
Expand Down Expand Up @@ -628,6 +633,11 @@ module
mlMultiMetricJobService.stopDatafeed($scope.formConfig);
};

$scope.moveToAdvancedJobCreation = function () {
const job = mlMultiMetricJobService.getJobFromConfig($scope.formConfig);
moveToAdvancedJobCreation(job);
};

$scope.setModelMemoryLimit = function () {
const formConfig = $scope.formConfig;
calculateModelMemoryLimit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ <h4 class="euiTitle euiTitle--small">Job Details</h4>
<div ng-show="ui.showJobInput && (jobState === JOB_STATE.NOT_STARTED || jobState === JOB_STATE.RUNNING || jobState === JOB_STATE.STOPPING)">
<ml-general-job-details></ml-general-job-details>

<div class="form-group">
<a href="" ng-click="moveToAdvancedJobCreation()">Move to advanced job configuration</a>
</div>

<div class="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter euiFlexGroup--responsive">
<div class="euiFlexItem euiFlexItem--flexGrowZero">
<ml-validate-job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { IntervalHelperProvider } from 'plugins/ml/util/ml_time_buckets';
import { filterAggTypes } from 'plugins/ml/jobs/new_job/simple/components/utils/filter_agg_types';
import { validateJob } from 'plugins/ml/jobs/new_job/simple/components/utils/validate_job';
import { adjustIntervalDisplayed } from 'plugins/ml/jobs/new_job/simple/components/utils/adjust_interval';
import { createSearchItems, createResultsUrl, addNewJobToRecentlyAccessed } from 'plugins/ml/jobs/new_job/utils/new_job_utils';
import { populateAppStateSettings } from 'plugins/ml/jobs/new_job/simple/components/utils/app_state_settings';
import { CHART_STATE, JOB_STATE } from 'plugins/ml/jobs/new_job/simple/components/constants/states';
import { createFields } from 'plugins/ml/jobs/new_job/simple/components/utils/create_fields';
Expand All @@ -32,6 +31,11 @@ import { ChartDataUtilsProvider } from 'plugins/ml/jobs/new_job/simple/component
import { checkMlNodesAvailable } from 'plugins/ml/ml_nodes_check/check_ml_nodes';
import { loadNewJobDefaults, newJobDefaults } from 'plugins/ml/jobs/new_job/utils/new_job_defaults';
import { mlEscape } from 'plugins/ml/util/string_utils';
import {
createSearchItems,
createResultsUrl,
addNewJobToRecentlyAccessed,
moveToAdvancedJobCreationProvider } from 'plugins/ml/jobs/new_job/utils/new_job_utils';
import template from './create_job.html';

uiRoutes
Expand Down Expand Up @@ -68,6 +72,7 @@ module
timefilter.disableAutoRefreshSelector();
const msgs = mlMessageBarService;
const MlTimeBuckets = Private(IntervalHelperProvider);
const moveToAdvancedJobCreation = Private(moveToAdvancedJobCreationProvider);
const chartDataUtils = Private(ChartDataUtilsProvider);
$scope.addNewJobToRecentlyAccessed = addNewJobToRecentlyAccessed;

Expand Down Expand Up @@ -655,6 +660,11 @@ module
mlPopulationJobService.stopDatafeed($scope.formConfig);
};

$scope.moveToAdvancedJobCreation = function () {
const job = mlPopulationJobService.getJobFromConfig($scope.formConfig);
moveToAdvancedJobCreation(job);
};

// resize the spilt cards on page resize.
// when the job starts the 'Analysis running' label appearing can cause a scroll bar to appear
// which will cause the split cards to look odd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ <h4 class="euiTitle euiTitle--small"><i class="fa fa-info-circle"></i> No result
</div>
</div>

<div class="form-group">
<a href="" ng-click="moveToAdvancedJobCreation()">Move to advanced job configuration</a>
</div>
<div class="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter euiFlexGroup--responsive">
<div class="euiFlexItem euiFlexItem--flexGrowZero">
<ml-validate-job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ import { IntervalHelperProvider } from 'plugins/ml/util/ml_time_buckets';
import { filterAggTypes } from 'plugins/ml/jobs/new_job/simple/components/utils/filter_agg_types';
import { validateJob } from 'plugins/ml/jobs/new_job/simple/components/utils/validate_job';
import { adjustIntervalDisplayed } from 'plugins/ml/jobs/new_job/simple/components/utils/adjust_interval';
import { createSearchItems, createResultsUrl, addNewJobToRecentlyAccessed } from 'plugins/ml/jobs/new_job/utils/new_job_utils';
import { populateAppStateSettings } from 'plugins/ml/jobs/new_job/simple/components/utils/app_state_settings';
import { getIndexedFields } from 'plugins/ml/jobs/new_job/simple/components/utils/create_fields';
import { changeJobIDCase } from 'plugins/ml/jobs/new_job/simple/components/general_job_details/change_job_id_case';
import { CHART_STATE, JOB_STATE } from 'plugins/ml/jobs/new_job/simple/components/constants/states';
import { getIndexPatternWithRoute, getSavedSearchWithRoute, timeBasedIndexCheck } from 'plugins/ml/util/index_utils';
import { checkMlNodesAvailable } from 'plugins/ml/ml_nodes_check/check_ml_nodes';
import { loadNewJobDefaults } from 'plugins/ml/jobs/new_job/utils/new_job_defaults';
import {
createSearchItems,
createResultsUrl,
addNewJobToRecentlyAccessed,
moveToAdvancedJobCreationProvider } from 'plugins/ml/jobs/new_job/utils/new_job_utils';

import template from './create_job.html';

uiRoutes
Expand Down Expand Up @@ -68,6 +73,7 @@ module
timefilter.disableAutoRefreshSelector();
const msgs = mlMessageBarService;
const MlTimeBuckets = Private(IntervalHelperProvider);
const moveToAdvancedJobCreation = Private(moveToAdvancedJobCreationProvider);

const stateDefaults = {
mlJobSettings: {}
Expand Down Expand Up @@ -550,6 +556,11 @@ module
mlSingleMetricJobService.stopDatafeed($scope.formConfig);
};

$scope.moveToAdvancedJobCreation = function () {
const job = mlSingleMetricJobService.getJobFromConfig($scope.formConfig);
moveToAdvancedJobCreation(job);
};

$scope.setFullTimeRange = function () {
mlFullTimeRangeSelectorService.setFullTimeRange($scope.ui.indexPattern, $scope.formConfig.combinedQuery);
};
Expand Down
7 changes: 7 additions & 0 deletions x-pack/plugins/ml/public/jobs/new_job/utils/new_job_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,10 @@ export function addNewJobToRecentlyAccessed(jobId, resultsUrl) {
const urlParts = resultsUrl.match(/ml#\/(.+?)(\?.+)/);
addItemToRecentlyAccessed(urlParts[1], jobId, urlParts[2]);
}

export function moveToAdvancedJobCreationProvider(mlJobService, $location) {
return function moveToAdvancedJobCreation(job) {
mlJobService.currentJob = job;
$location.path('jobs/new_job/advanced');
};
}

0 comments on commit 1249643

Please sign in to comment.