diff --git a/x-pack/plugins/ml/public/components/paginated_table/index.js b/x-pack/plugins/ml/public/components/paginated_table/index.js deleted file mode 100644 index 753d5c46f9f3a7..00000000000000 --- a/x-pack/plugins/ml/public/components/paginated_table/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import './paginated_table'; diff --git a/x-pack/plugins/ml/public/components/paginated_table/open.html b/x-pack/plugins/ml/public/components/paginated_table/open.html deleted file mode 100644 index 3fb31ca48b01ca..00000000000000 --- a/x-pack/plugins/ml/public/components/paginated_table/open.html +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/x-pack/plugins/ml/public/components/paginated_table/paginated_table.html b/x-pack/plugins/ml/public/components/paginated_table/paginated_table.html deleted file mode 100644 index ace2535934c418..00000000000000 --- a/x-pack/plugins/ml/public/components/paginated_table/paginated_table.html +++ /dev/null @@ -1,55 +0,0 @@ - -
- - - - - - - - -
- - - - - - - - -
-
- - - -
- -
diff --git a/x-pack/plugins/ml/public/components/paginated_table/paginated_table.js b/x-pack/plugins/ml/public/components/paginated_table/paginated_table.js deleted file mode 100644 index 6aa1d2b7d66532..00000000000000 --- a/x-pack/plugins/ml/public/components/paginated_table/paginated_table.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - - -// copy of Kibana's ui/public/paginated_table/paginated_table.js -// but with the one-time binding removed from the scope columns object -// in the paginated_table.html template, to allow dynamic changes to -// the list of columns shown in the table. - -import './row'; - -import './styles/main.less'; -import 'ui/directives/paginate'; -import 'ui/styles/pagination.less'; -import _ from 'lodash'; -import template from './paginated_table.html'; - -import { uiModules } from 'ui/modules'; -const module = uiModules.get('apps/ml'); - -module.directive('mlPaginatedTable', function ($filter) { - const orderBy = $filter('orderBy'); - - return { - restrict: 'E', - template, - transclude: true, - scope: { - rows: '=', - columns: '=', - perPage: '=?', - sortHandler: '=?', - showSelector: '=?' - }, - controllerAs: 'mlPaginatedTable', - controller: function ($scope) { - const self = this; - self.sort = { - columnIndex: null, - direction: null - }; - - self.sortColumn = function (colIndex) { - const col = $scope.columns[colIndex]; - - if (!col) return; - if (col.sortable === false) return; - - let sortDirection; - - if (self.sort.columnIndex !== colIndex) { - sortDirection = 'asc'; - } else { - const directions = { - null: 'asc', - 'asc': 'desc', - 'desc': null - }; - sortDirection = directions[self.sort.direction]; - } - - self.sort.columnIndex = colIndex; - self.sort.direction = sortDirection; - self._setSortGetter(colIndex); - }; - - self._setSortGetter = function (index) { - if (_.isFunction($scope.sortHandler)) { - // use custom sort handler - self.sort.getter = $scope.sortHandler(index); - } else { - // use generic sort handler - self.sort.getter = function (row) { - const value = row[index]; - if (value && value.value !== undefined && value.value !== null) { - if (typeof value.value === 'function') { - return value.value(); - } else { - return value.value; - } - } else { - return value; - } - }; - } - }; - - // update the sortedRows result - $scope.$watchMulti([ - 'rows', - 'columns', - '[]mlPaginatedTable.sort' - ], function resortRows() { - if (!$scope.rows || !$scope.columns) { - $scope.sortedRows = false; - return; - } - - const sort = self.sort; - if (sort.direction == null) { - $scope.sortedRows = $scope.rows.slice(0); - } else { - $scope.sortedRows = orderBy($scope.rows, sort.getter, sort.direction === 'desc'); - } - }); - } - }; -}); diff --git a/x-pack/plugins/ml/public/components/paginated_table/row.js b/x-pack/plugins/ml/public/components/paginated_table/row.js deleted file mode 100644 index 2cf377eb08655d..00000000000000 --- a/x-pack/plugins/ml/public/components/paginated_table/row.js +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - - -// copy of ui/public/directives/row.js -// overridden to add the option for row expansion. - -import $ from 'jquery'; -import _ from 'lodash'; -import AggConfigResult from 'ui/vis/agg_config_result'; -import { FilterBarClickHandlerProvider } from 'ui/filter_bar/filter_bar_click_handler'; - -import { uiModules } from 'ui/modules'; -const module = uiModules.get('apps/ml'); - -module.directive('mlRows', function ($compile, getAppState, Private) { - const filterBarClickHandler = Private(FilterBarClickHandlerProvider); - return { - restrict: 'A', - - link: function ($scope, $el, attr) { - function addCell($tr, contents) { - let $cell = $(document.createElement('td')); - - // TODO: It would be better to actually check the type of the field, but we don't have - // access to it here. This may become a problem with the switch to BigNumber - if (_.isNumber(contents)) { - $cell.addClass('numeric-value'); - } - - const createAggConfigResultCell = function (aggConfigResult) { - const $resultCell = $(document.createElement('td')); - const $state = getAppState(); - const clickHandler = filterBarClickHandler($state); - $resultCell.scope = $scope.$new(); - $resultCell.addClass('cell-hover'); - $resultCell.attr('ng-click', 'clickHandler($event)'); - $resultCell.scope.clickHandler = function (event) { - if ($(event.target).is('a')) return; // Don't add filter if a link was clicked - clickHandler({ point: { aggConfigResult: aggConfigResult } }); - }; - return $compile($resultCell)($cell.scope); - }; - - if (contents instanceof AggConfigResult) { - if (contents.type === 'bucket' && contents.aggConfig.field() && contents.aggConfig.field().filterable) { - $cell = createAggConfigResultCell(contents); - } - contents = contents.toString('html'); - } - - if (_.isObject(contents)) { - if (contents.attr) { - $cell.attr(contents.attr); - } - - if (contents.class) { - $cell.addClass(contents.class); - } - - if (contents.scope) { - $cell = $compile($cell.html(contents.markup))(contents.scope); - } else { - $cell.html(contents.markup); - } - } else { - if (contents === '') { - $cell.html(' '); - } else { - $cell.html(contents); - } - } - - $tr.append($cell); - } - - $scope.$watchMulti([ - attr.mlRows, - attr.mlRowsMin - ], function (vals) { - let rows = vals[0]; - const min = vals[1]; - - $el.empty(); - - if (!_.isArray(rows)) { - rows = []; - } - - if (isFinite(min) && rows.length < min) { - // clone the rows so that we can add elements to it without upsetting the original - rows = _.clone(rows); - } - - rows.forEach(function (row) { - if (row.length) { - const rowScope = row[0].scope; - const $tr = $(document.createElement('tr')).appendTo($el); - - if (rowScope && - rowScope.mouseenterRow !== undefined && typeof rowScope.mouseenterRow === 'function') { - // Add mousenter and mouseleave events to the row - $tr.attr({ 'ng-mouseenter': 'mouseenterRow($event)' }); - $tr.attr({ 'ng-mouseleave': 'mouseleaveRow($event)' }); - $compile($tr)(rowScope); - } - - row.forEach(function (cell) { - addCell($tr, cell); - }); - - if (rowScope && - rowScope.expandable && - rowScope.expandElement && // the tag name of the element which contains the expanded row's contents - row.join('') !== '') { // empty rows are passed in as an array of empty cols, i.e., ['','',''] - - if (rowScope.open === undefined) { - rowScope.open = false; - } - - if (rowScope.rowInitialised === undefined) { - rowScope.rowInitialised = false; - } - - rowScope.toggleRow = function () { - this.open = !this.open; - if (this.initRow && this.rowInitialised === false) { - this.rowInitialised = true; - this.initRow(); - } - }; - - const $trExpand = $(document.createElement('tr')).appendTo($el); - $trExpand.attr('ng-show', 'open'); - $trExpand.addClass('row-expand'); - - const $td = $(document.createElement('td')).appendTo($trExpand); - $td.attr('colspan', row.length); - - const expEl = rowScope.expandElement; - const $exp = $(document.createElement(expEl)).appendTo($td); - - // if expand element already exits and has child elements, - // copy them to the new expand element - if (rowScope.$expandElement && rowScope.$expandElement.children().length) { - $exp.append(rowScope.$expandElement.children()[0]); - } - - $compile($trExpand)(rowScope); - rowScope.$expandElement = $exp; - } - - } - }); - }); - } - }; -}); diff --git a/x-pack/plugins/ml/public/components/paginated_table/styles/main.less b/x-pack/plugins/ml/public/components/paginated_table/styles/main.less deleted file mode 100644 index d9c93dabcaadcd..00000000000000 --- a/x-pack/plugins/ml/public/components/paginated_table/styles/main.less +++ /dev/null @@ -1,49 +0,0 @@ -@import "~ui/styles/variables"; - -ml-paginated-table { - - .col-expand-arrow { - width: 10px; - } - - .table-header-button { - border: none; - background: none; - padding: 0; - } - - table th { - font-weight: bold; - text-align: left; - } - - table th button.fa-sort { - color: @table-sort-color; - } - - tr.row-expand td:hover, - tr.row-expand td:hover td { - background-color: #FFFFFF; - } - - .discover-table-open-button { - background-color: #FFFFFF; - border: none; - min-width: 20px; - } - .discover-table-open-button:focus { - outline: none; - } - - paginate-controls { - button.euiPaginationButton { - padding: 1px 7px 2px; - } - - label { - line-height: 1.5; - font-size: 12px; - font-weight: bold; - } - } -} diff --git a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/custom_url_editor.html b/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/custom_url_editor.html deleted file mode 100644 index 7853ceeac03a72..00000000000000 --- a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/custom_url_editor.html +++ /dev/null @@ -1,140 +0,0 @@ -
-
- -
- Label - -
- -
- Link to -
-
- - - -
-
- -
- Dashboard name - -
- -
- Index pattern - -
- -
- Query entities - - -
- - -
- URL - -
- - -
-
- Time range - -
- -
- - -
Invalid interval format
-
-
- -
- -
- -
- -
diff --git a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/custom_url_editor_directive.js b/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/custom_url_editor_directive.js deleted file mode 100644 index 4cfeb6d9c0a8fd..00000000000000 --- a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/custom_url_editor_directive.js +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - - -/* - * ml-custom-url-editor directive for editing a custom URL link which allows the - * user to drill through from an anomaly to another URL such as a Kibana dashboard. - */ - -import _ from 'lodash'; -import rison from 'rison-node'; - -import template from './custom_url_editor.html'; -import 'plugins/ml/components/item_select'; -import { parseInterval } from 'plugins/ml/../common/util/parse_interval'; -import { escapeForElasticsearchQuery } from 'plugins/ml/util/string_utils'; -import { SavedObjectsClientProvider } from 'ui/saved_objects'; - -import { uiModules } from 'ui/modules'; -const module = uiModules.get('apps/ml'); - -module.directive('mlCustomUrlEditor', function (Private) { - return { - scope: { - addCustomUrl: '&', - job: '=' - }, - restrict: 'AE', - replace: true, - transclude: true, - template, - controller: function ($scope) { - const URL_TYPE = { - KIBANA_DASHBOARD: 'KIBANA_DASHBOARD', - KIBANA_DISCOVER: 'KIBANA_DISCOVER', - OTHER: 'OTHER' - }; - $scope.URL_TYPE = URL_TYPE; - - const TIME_RANGE_TYPE = { - AUTO: 'auto', - INTERVAL: 'interval' - }; - $scope.TIME_RANGE_TYPE = TIME_RANGE_TYPE; - - $scope.newCustomUrl = { - label: undefined, - type: URL_TYPE.OTHER, - // Note timeRange is only editable in new URLs for Dashboard and Discover URLs, - // as for other URLs we have no way of knowing how the field will be used in the URL. - timeRange: { - type: TIME_RANGE_TYPE.AUTO - }, - kibanaSettings: { - queryFieldNames: [] - }, - otherUrlSettings: { - urlValue: '' - } - }; - - $scope.dashboards = []; - $scope.indexPatterns = []; - $scope.timeRangeIntervalError = false; - - $scope.updateQueryFieldNames = {}; // External update function for Kibana query field names ml-item-select. - - // Query 1 - load the saved Kibana dashboards. - const savedObjectsClient = Private(SavedObjectsClientProvider); - function getSavedDashboards() { - return savedObjectsClient.find({ - type: 'dashboard', - fields: ['title'], - perPage: 1000 - }); - } - - // Query 2 - load the Kibana index patterns. - function getSavedIndexPatterns() { - return savedObjectsClient.find({ - type: 'index-pattern', - fields: ['title'], - perPage: 1000 - }); - } - - Promise.all([ - getSavedDashboards(), - getSavedIndexPatterns() - ]) - .then(response => { - $scope.dashboards = _.chain(response[0]) - .get('savedObjects', []) - .map(savedObj => ({ id: savedObj.id, title: savedObj.attributes.title })) - .sortBy(obj => obj.title.toLowerCase()) - .value(); - - $scope.indexPatterns = _.chain(response[1]) - .get('savedObjects', []) - .map(savedObj => ({ id: savedObj.id, title: savedObj.attributes.title })) - .sortBy(obj => obj.title.toLowerCase()) - .value(); - - initFields(); - }) - .catch((resp) => { - console.log('Custom URL editor - error loading saved dashboards and index patterns', resp); - }); - - - // Get the list of partitioning and influencer fields that can be used as - // entities to add to the query / filter used when linking to a Kibana dashboard. - const detectors = $scope.job.analysis_config.detectors; - const jobFieldNames = _.get($scope.job.analysis_config, 'influencers', []); - _.each(detectors, (detector) => { - if (_.has(detector, 'partition_field_name')) { - jobFieldNames.push(detector.partition_field_name); - } - if (_.has(detector, 'by_field_name')) { - jobFieldNames.push(detector.by_field_name); - } - if (_.has(detector, 'over_field_name')) { - jobFieldNames.push(detector.over_field_name); - } - }); - - // Remove duplicates, sort and get in format for use by the item-select component. - $scope.jobFieldNames = _.chain(jobFieldNames) - .uniq() - .sortBy(fieldName => fieldName.toLowerCase()) - .map(fieldName => ({ id: fieldName })) - .value(); - - $scope.addQueryEntity = function () { - if ($scope.jobFieldNames.length > 0) { - $scope.newCustomUrl.kibanaSettings.queryFieldNames.push($scope.jobFieldNames[0]); - } - }; - - $scope.removeQueryEntity = function (index) { - $scope.newCustomUrl.kibanaSettings.queryFieldNames.splice(index, 1); - }; - - $scope.timeRangeIntervalChanged = function () { - const interval = parseInterval($scope.newCustomUrl.timeRange.interval); - $scope.timeRangeIntervalError = (interval === null); - }; - - $scope.addUrl = function () { - const settings = $scope.newCustomUrl; - - if (settings.type === URL_TYPE.KIBANA_DASHBOARD) { - addDashboardUrl(); - } else if (settings.type === URL_TYPE.KIBANA_DISCOVER) { - addDiscoverUrl(); - } else { - const urlToAdd = { - url_name: settings.label, - url_value: settings.otherUrlSettings.urlValue - }; - - $scope.addCustomUrl()(urlToAdd); - - // Set the fields back to their defaults. - initFields(); - } - - }; - - function addDashboardUrl() { - const settings = $scope.newCustomUrl; - - // Get the complete list of attributes for the selected dashboard (query, filters). - savedObjectsClient.get('dashboard', settings.kibanaSettings.dashboardId) - .then((response) => { - // Use the filters from the saved dashboard if there are any. - let filters = []; - - // Use the query from the dashboard only if no job entities are selected. - let query = undefined; - - const searchSourceJSON = response.get('kibanaSavedObjectMeta.searchSourceJSON'); - if (searchSourceJSON !== undefined) { - const searchSourceData = JSON.parse(searchSourceJSON); - filters = _.get(searchSourceData, 'filter', []); - query = searchSourceData.query; - } - - // Add time settings to the global state URL parameter with $earliest$ and - // $latest$ tokens which get substituted for times around the time of the - // anomaly on which the URL will be run against. - const _g = rison.encode({ - time: { - from: '$earliest$', - to: '$latest$', - mode: 'absolute' - } - }); - - const appState = { - filters - }; - - // To put entities in filters section would involve creating parameters of the form - // filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:b30fd340-efb4-11e7-a600-0f58b1422b87, - // key:airline,negate:!f,params:(query:AAL,type:phrase),type:phrase,value:AAL),query:(match:(airline:(query:AAL,type:phrase))))) - // which includes the ID of the index holding the field used in the filter. - - // So for simplicity, put entities in the query, replacing any query which is there already. - // e.g. query:(language:lucene,query:'region:us-east-1%20AND%20instance:i-20d061fa') - if (settings.kibanaSettings.queryFieldNames.length > 0) { - let queryString = ''; - _.each(settings.kibanaSettings.queryFieldNames, (fieldName, index) => { - if (index > 0) { - queryString += ' AND '; - } - queryString += `${escapeForElasticsearchQuery(fieldName)}:"$${fieldName}$"`; - }); - - query = { - language: 'lucene', - query: queryString - }; - } - - if (query !== undefined) { - appState.query = query; - } - - const _a = rison.encode(appState); - - const urlValue = `kibana#/dashboard/${settings.kibanaSettings.dashboardId}?_g=${_g}&_a=${_a}`; - - const urlToAdd = { - url_name: settings.label, - url_value: urlValue, - time_range: TIME_RANGE_TYPE.AUTO - }; - - if (settings.timeRange.type === TIME_RANGE_TYPE.INTERVAL) { - urlToAdd.time_range = settings.timeRange.interval; - } - - $scope.addCustomUrl()(urlToAdd); - - // Set the fields back to their defaults. - initFields(); - }) - .catch((resp) => { - console.log('Custom URL editor - error getting details on dashboard', resp); - }); - } - - function addDiscoverUrl() { - const settings = $scope.newCustomUrl; - - // Add time settings to the global state URL parameter with $earliest$ and - // $latest$ tokens which get substituted for times around the time of the - // anomaly on which the URL will be run against. - const _g = rison.encode({ - time: { - from: '$earliest$', - to: '$latest$', - mode: 'absolute' - } - }); - - // Add the index pattern and query to the appState part of the URL. - const appState = { - index: settings.kibanaSettings.discoverIndexPatternId - }; - - // Use the query from the datafeed only if no job entities are selected. - let query = $scope.job.datafeed_config.query; - - // To put entities in filters section would involve creating parameters of the form - // filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:b30fd340-efb4-11e7-a600-0f58b1422b87, - // key:airline,negate:!f,params:(query:AAL,type:phrase),type:phrase,value:AAL),query:(match:(airline:(query:AAL,type:phrase))))) - // which includes the ID of the index holding the field used in the filter. - - // So for simplicity, put entities in the query, replacing any query which is there already. - // e.g. query:(language:lucene,query:'region:us-east-1%20AND%20instance:i-20d061fa') - if (settings.kibanaSettings.queryFieldNames.length > 0) { - let queryString = ''; - _.each(settings.kibanaSettings.queryFieldNames, (fieldName, i) => { - if (i > 0) { - queryString += ' AND '; - } - queryString += `${escapeForElasticsearchQuery(fieldName)}:"$${fieldName}$"`; - }); - - query = { - language: 'lucene', - query: queryString - }; - } - - if (query !== undefined) { - appState.query = query; - } - - const _a = rison.encode(appState); - - const urlValue = `kibana#/discover?_g=${_g}&_a=${_a}`; - - const urlToAdd = { - url_name: settings.label, - url_value: urlValue - }; - - if (settings.timeRange.type === TIME_RANGE_TYPE.INTERVAL) { - urlToAdd.time_range = settings.timeRange.interval; - } - - $scope.addCustomUrl()(urlToAdd); - - initFields(); - - } - - function initFields() { - $scope.newCustomUrl.label = ''; - $scope.newCustomUrl.otherUrlSettings = { - urlValue: '' - }; - $scope.newCustomUrl.timeRange = { - type: TIME_RANGE_TYPE.AUTO - }; - - $scope.newCustomUrl.kibanaSettings = { - queryFieldNames: [] - }; - - // Clear selections from the Entities select control. - if (typeof $scope.updateQueryFieldNames.update === 'function') { - $scope.updateQueryFieldNames.update([]); - } - - if ($scope.dashboards.length > 0) { - $scope.newCustomUrl.type = URL_TYPE.KIBANA_DASHBOARD; - $scope.newCustomUrl.kibanaSettings.dashboardId = $scope.dashboards[0].id; - } else { - $scope.newCustomUrl.type = $scope.indexPatterns.length > 0 ? - URL_TYPE.KIBANA_DASHBOARD : URL_TYPE.OTHER; - } - - if ($scope.indexPatterns.length > 0 && - $scope.job.datafeed_config.indices !== undefined && - $scope.job.datafeed_config.indices.length > 0) { - // For the Discover option, set the default index pattern to that - // which matches the (first) index configured in the job datafeed. - const datafeedIndex = $scope.job.datafeed_config.indices[0]; - let defaultIndexPattern = _.find($scope.indexPatterns, { title: datafeedIndex }); - if (defaultIndexPattern === undefined) { - defaultIndexPattern = $scope.indexPatterns[0]; - } - - $scope.newCustomUrl.kibanaSettings.discoverIndexPatternId = defaultIndexPattern.id; - } - - } - - } - }; -}); diff --git a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/custom_url_editor_service.js b/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/custom_url_editor_service.js deleted file mode 100644 index f9bad4f31076d6..00000000000000 --- a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/custom_url_editor_service.js +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - - -// Service for obtaining information for the custom URL editor. - -import { parseInterval } from 'ui/utils/parse_interval'; - -import { ML_RESULTS_INDEX_PATTERN } from 'plugins/ml/../common/constants/index_patterns'; -import { replaceTokensInUrlValue } from 'plugins/ml/util/custom_url_utils'; -import { mlJobService } from 'plugins/ml/services/job_service'; -import { ml } from 'plugins/ml/services/ml_api_service'; - - -// Builds the full URL for testing out a custom URL configuration, which -// may contain dollar delimited partition / influencer entity tokens and -// drilldown time range settings. -function getTestUrl(job, urlConfig) { - const urlValue = urlConfig.url_value; - const bucketSpanSecs = parseInterval(job.analysis_config.bucket_span).asSeconds(); - - // By default, return configured url_value. Look to substitute any dollar-delimited - // tokens with values from the highest scoring anomaly, or if no anomalies, with - // values from a document returned by the search in the job datafeed. - let testUrl = urlConfig.url_value; - - // Query to look for the highest scoring anomaly. - const body = { - query: { - bool: { - must: [ - { term: { job_id: job.job_id } }, - { term: { result_type: 'record' } } - ] - } - }, - size: 1, - _source: { - excludes: [] - }, - sort: [ - { record_score: { order: 'desc' } } - ] - }; - - return new Promise((resolve, reject) => { - ml.esSearch({ - index: ML_RESULTS_INDEX_PATTERN, - body - }) - .then((resp) => { - if (resp.hits.total > 0) { - const record = resp.hits.hits[0]._source; - testUrl = replaceTokensInUrlValue(urlConfig, bucketSpanSecs, record, 'timestamp'); - resolve(testUrl); - } else { - // No anomalies yet for this job, so do a preview of the search - // configured in the job datafeed to obtain sample docs. - mlJobService.searchPreview(job) - .then((response) => { - let testDoc; - const docTimeFieldName = job.data_description.time_field; - - // Handle datafeeds which use aggregations or documents. - if (response.aggregations) { - // Create a dummy object which contains the fields necessary to build the URL. - const firstBucket = response.aggregations.buckets.buckets[0]; - testDoc = { - [docTimeFieldName]: firstBucket.key - }; - - // Look for bucket aggregations which match the tokens in the URL. - urlValue.replace((/\$([^?&$\'"]{1,40})\$/g), (match, name) => { - if (name !== 'earliest' && name !== 'latest' && firstBucket[name] !== undefined) { - const tokenBuckets = firstBucket[name]; - if (tokenBuckets.buckets) { - testDoc[name] = tokenBuckets.buckets[0].key; - } - } - }); - - } else { - if (response.hits.total > 0) { - testDoc = response.hits.hits[0]._source; - } - } - - if (testDoc !== undefined) { - testUrl = replaceTokensInUrlValue(urlConfig, bucketSpanSecs, testDoc, docTimeFieldName); - } - - resolve(testUrl); - - }); - } - - }) - .catch((resp) => { - reject(resp); - }); - }); - -} - - -export const customUrlEditorService = { - getTestUrl -}; - diff --git a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/index.js b/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/index.js deleted file mode 100644 index 42ee1f0f53dde2..00000000000000 --- a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/index.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - - - -import './custom_url_editor_directive'; -import './styles/main.less'; diff --git a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/styles/main.less b/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/styles/main.less deleted file mode 100644 index da350e8cab5b38..00000000000000 --- a/x-pack/plugins/ml/public/jobs/components/custom_url_editor_old/styles/main.less +++ /dev/null @@ -1,45 +0,0 @@ -@import (reference) "~ui/styles/variables"; - -.ml-custom-url-manager { - .add-url-input { - display: block; - } - - select { - width: 100%; - } - - .link-to-label { - padding-right: 20px; - } - - label.disabled { - color: @globalColorLightGray; - } - - .entity-input { - display: inline-block; - margin-bottom: 5px; - } - - .custom-url, .add-url-time-range { - display: flex; - position: relative; - padding-right: 30px; - button.remove-button { - top: 27px; - position: absolute; - right: 6px; - } - - select { - height: 32px; - } - - .form-group { - margin-right: 10px; - } - } - -} - diff --git a/x-pack/plugins/ml/public/jobs/index.js b/x-pack/plugins/ml/public/jobs/index.js index d1f78238024618..cedf7d0455d30d 100644 --- a/x-pack/plugins/ml/public/jobs/index.js +++ b/x-pack/plugins/ml/public/jobs/index.js @@ -8,7 +8,6 @@ import './styles/main.less'; import './jobs_list'; -import './jobs_list_old'; import './new_job/advanced'; import './new_job/simple/single_metric'; import './new_job/simple/multi_metric'; diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/buttons_enabled_checks.js b/x-pack/plugins/ml/public/jobs/jobs_list_old/buttons_enabled_checks.js deleted file mode 100644 index 1b03bbe5f5fbe9..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/buttons_enabled_checks.js +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - - -import { JOB_STATE, DATAFEED_STATE } from 'plugins/ml/../common/constants/states'; -import { createPermissionFailureMessage } from 'plugins/ml/privilege/check_privilege'; - -export function buttonsEnabledChecks(permissions, job, mlNodesAvailable) { - const NO_ML_NODES_ERROR = 'No ML nodes available'; - - function startButtonWrapperClass() { - return (permissions.canStartStopDatafeed && mlNodesAvailable) ? 'button-wrapper' : ['button-wrapper', 'disabled']; - } - - function startButtonWrapperTooltip() { - let tooltip = undefined; - if (permissions.canStartStopDatafeed === false) { - tooltip = createPermissionFailureMessage('canStartStopDatafeed'); - } else if (mlNodesAvailable === false) { - tooltip = NO_ML_NODES_ERROR; - } - return tooltip; - } - - function startButtonVisible() { - return (job.datafeed_config && job.datafeed_config.state !== DATAFEED_STATE.STOPPING && - job.datafeed_config.state !== DATAFEED_STATE.STARTING); - } - - function startButtonTooltip() { - return `${(job.datafeed_config && job.datafeed_config.state === DATAFEED_STATE.STARTED) ? - 'Stop datafeed for' : 'Start datafeed for'} job.job_id`; - } - - function startButtonAriaLabel() { - return `${(job.datafeed_config && job.datafeed_config.state === DATAFEED_STATE.STARTED) ? 'Stop' : 'Start'} datafeed`; - } - - function startButtonDisabled() { - return ( - (job.datafeed_config.datafeed_id === undefined || permissions.canStartStopDatafeed === false) || - job.state === JOB_STATE.CLOSING || - job.state === JOB_STATE.OPENING || - job.state === JOB_STATE.FAILED || - mlNodesAvailable === false - ); - } - - function buttonIcon() { - if (job.datafeed_config && job.datafeed_config.state === DATAFEED_STATE.STARTED && job.state !== JOB_STATE.FAILED) { - return 'fa fa-stop'; - } else if (job.datafeed_config && job.datafeed_config.state === DATAFEED_STATE.STOPPED && - (job.state === JOB_STATE.OPENED || job.state === JOB_STATE.CLOSED)) { - return 'fa fa-play'; - }else if (job.state === JOB_STATE.FAILED) { - return 'fa fa-play'; - }else if (job.datafeed_config && job.datafeed_config.state === DATAFEED_STATE.STOPPED && - (job.state === JOB_STATE.CLOSING || job.state === JOB_STATE.OPENING)) { - return 'fa fa-clock-o'; - }else if (job.datafeed_config && job.datafeed_config.state === undefined) { - return 'fa fa-play'; - } - } - - function loadingButtonVisible() { - return (!job.datafeed_config) || (job.datafeed_config.state === DATAFEED_STATE.STOPPING || - job.datafeed_config.state === DATAFEED_STATE.STARTING); - } - - function editButtonWrapperClass() { - return permissions.canUpdateJob ? 'button-wrapper' : ['button-wrapper', 'disabled']; - } - - function editButtonWrapperTooltip() { - return permissions.canUpdateJob ? undefined : createPermissionFailureMessage('canUpdateJob'); - } - - function editButtonDisabled() { - return permissions.canUpdateJob === false || permissions.canUpdateDatafeed === false; - } - - function cloneButtonWrapperClass() { - return (permissions.canCreateJob && mlNodesAvailable) ? 'button-wrapper' : ['button-wrapper', 'disabled']; - } - - function cloneButtonWrapperTooltip() { - let tooltip = undefined; - if (permissions.canCreateJob === false) { - tooltip = createPermissionFailureMessage('canCreateJob'); - } else if (mlNodesAvailable === false) { - tooltip = NO_ML_NODES_ERROR; - } - return tooltip; - } - - function cloneButtonDisabled() { - return (permissions.canCreateJob === false || mlNodesAvailable === false); - } - - function deleteButtonWrapperClass() { - return permissions.canDeleteJob ? 'button-wrapper' : ['button-wrapper', 'disabled']; - } - - function deleteButtonWrapperTooltip() { - return permissions.canDeleteJob ? undefined : createPermissionFailureMessage('canDeleteJob'); - } - - function deleteButtonDisabled() { - return permissions.canDeleteJob === false; - } - - return { - startButtonWrapperClass, - startButtonWrapperTooltip, - startButtonVisible, - startButtonTooltip, - startButtonAriaLabel, - startButtonDisabled, - buttonIcon, - loadingButtonVisible, - editButtonWrapperClass, - editButtonWrapperTooltip, - editButtonDisabled, - cloneButtonWrapperClass, - cloneButtonWrapperTooltip, - cloneButtonDisabled, - deleteButtonWrapperClass, - deleteButtonWrapperTooltip, - deleteButtonDisabled, - }; -} diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/create_watch_modal.html b/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/create_watch_modal.html deleted file mode 100644 index af5adf653152d6..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/create_watch_modal.html +++ /dev/null @@ -1,54 +0,0 @@ - -
-

Create watch for {{jobId}}

-
- -
- - - -
- -
- - - -
-
- -
-
- -
- Watcher is not enabled. -
- -
- -
diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/create_watch_modal_controller.js b/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/create_watch_modal_controller.js deleted file mode 100644 index d075af58445a98..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/create_watch_modal_controller.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - -import { mlCreateWatchService } from 'plugins/ml/jobs/new_job/simple/components/watcher/create_watch_service'; -import { xpackFeatureProvider } from 'plugins/ml/license/check_license'; - -import { uiModules } from 'ui/modules'; -const module = uiModules.get('apps/ml'); - -import { mlMessageBarService } from 'plugins/ml/components/messagebar/messagebar_service'; - -module.controller('MlCreateWatchModal', function ($scope, $modalInstance, params, Private) { - const xpackFeature = Private(xpackFeatureProvider); - const msgs = mlMessageBarService; // set a reference to the message bar service - msgs.clear(); - - $scope.jobId = params.job.job_id; - $scope.bucketSpan = params.job.analysis_config.bucket_span; - - $scope.watcherEnabled = xpackFeature.isAvailable('watcher'); - $scope.status = mlCreateWatchService.status; - $scope.STATUS = mlCreateWatchService.STATUS; - - mlCreateWatchService.reset(); - mlCreateWatchService.config.includeInfluencers = params.job.analysis_config.influencers.length ? true : false; - - $scope.apply = function () { - mlCreateWatchService.createNewWatch($scope.jobId) - .catch((resp) => { - msgs.clear(); - msgs.error('Watch could not be saved'); - if (typeof resp === 'string') { - msgs.error(resp); - } - $scope.status.watch = null; - }); - }; - - $scope.close = function () { - $modalInstance.close(); - }; -}); diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/index.js b/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/index.js deleted file mode 100644 index 6f5a381c5bd758..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/index.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - - -import './styles/main.less'; -import './create_watch_modal_controller'; -import 'plugins/ml/jobs/new_job/simple/components/watcher'; diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/styles/main.less b/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/styles/main.less deleted file mode 100644 index a0d9440fb587eb..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/create_watch_modal/styles/main.less +++ /dev/null @@ -1,13 +0,0 @@ -.create-watch-modal { - font-size: 14px; - padding:20px; - cursor: auto; - - h3 { - margin-top: 0px; - } - - .create-watch { - padding-bottom: 0px; - } -} diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/delete_job_modal.html b/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/delete_job_modal.html deleted file mode 100644 index b8070fc268feae..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/delete_job_modal.html +++ /dev/null @@ -1,48 +0,0 @@ -
-

Delete job {{ui.jobId}}

-
-
Deleting datafeed... - - - -
- -
Deleting job... - - - -
-
-
- {{ui.status.errorMessage}} request may have timed out and may still be running in the background.
- Please check status and retry in a few minutes. -
- -
- -
- - - -
-
- -
-
diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/delete_job_modal_controller.js b/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/delete_job_modal_controller.js deleted file mode 100644 index 106990571e92c1..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/delete_job_modal_controller.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - - -import { uiModules } from 'ui/modules'; -const module = uiModules.get('apps/ml'); - -module.controller('MlDeleteJobModal', function ($scope, $modalInstance, params) { - - $scope.ui = { - stage: 0, - status: params.status, - jobId: params.jobId, - isDatafeed: params.isDatafeed - }; - - $scope.delete = function () { - $scope.ui.stage = 1; - params.doDelete(); - }; - - // once the job is saved and optional upload is complete. - // close modal and return to jobs list - $scope.close = function () { - $modalInstance.close(); - }; - -}); diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/index.js b/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/index.js deleted file mode 100644 index 91466952cea59e..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/index.js +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - - - -import './styles/main.less'; -import './delete_job_modal_controller'; diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/styles/main.less b/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/styles/main.less deleted file mode 100644 index 050e52fba8afa2..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/delete_job_modal/styles/main.less +++ /dev/null @@ -1,24 +0,0 @@ -.delete-job-modal { - padding:20px; - cursor: auto; - - h3 { - margin-top: 0px; - overflow: hidden; - text-overflow: ellipsis; - } - - .status-item-list { - margin-bottom: 10px; - - .status-item { - padding-top:8px; - font-weight: bold; - } - } - - .validation-error { - color: #fe5050; - font-size: 12px; - } -} diff --git a/x-pack/plugins/ml/public/jobs/jobs_list_old/edit_job_modal/edit_job_modal.html b/x-pack/plugins/ml/public/jobs/jobs_list_old/edit_job_modal/edit_job_modal.html deleted file mode 100644 index 696eedfe71f9f6..00000000000000 --- a/x-pack/plugins/ml/public/jobs/jobs_list_old/edit_job_modal/edit_job_modal.html +++ /dev/null @@ -1,268 +0,0 @@ -
- -

{{ui.title}}

- -
- - - - -
-
- Job description - -
- -
- -
- Job Groups - -
- -
- -
- Model memory limit - -
- {{ui.validation.tabs[0].checks.modelMemoryLimit.message}} -
-
- -
-
- - - -
-
-
-
- -
-
- - -
-
-
- -
-
- -
- {{ ( ui.validation.tabs[2].checks.categorizationFilters.message || "Categorization filters must all be valid regular expressions" ) }} -
- -
- - -
- -
-
- - -
- -
-
- Query - - -
-
- Query delay - - -
-
- Frequency - - -
-
- scroll_size - -
-
-
-
Datafeed settings cannot be edited while the datafeed is running.
-
Stop datafeed now
-
Stopping...
-
-
- - -
-
-
-
- -
- - -
Enter a label
-
- - -
-
- - -
-
- -
- - -
Invalid format
-
- - - - -
-
-
-