From 0500028127712dd55f7777f1cbf6f51774f48cb6 Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Thu, 14 Apr 2016 11:06:03 -0400 Subject: [PATCH] Backport PR #6907 --------- **Commit 1:** [internal] Replace var with let in ui/public A-D This change was applied to any .js files under directories beginning with `a` through `d` in src/ui/public. This was an automatic replacement from var to let for any variable declaration that doubles as the initial assignment. Ultimately we want most of these to be converted to const, but this commit is so large that it warrants breaking each step of automation up into its own commit. For example: `var foo = 'bar';` becomes `let foo = 'var';` This was accomplished by replacing: find: `var ([a-zA-Z_$][0-9a-zA-Z_$]*)(\s+)=` replace: `let $1$2=` * Original sha: 4c535f615500f78294726b4d087722bfa655c61e * Authored by Court Ewing on 2016-04-12T22:18:38Z --- src/ui/public/Binder/Binder.js | 16 ++--- .../geo_json/_tooltip_formatter.js | 20 +++--- .../public/agg_response/geo_json/geo_json.js | 18 ++--- .../agg_response/geo_json/rowsToFeatures.js | 14 ++-- .../hierarchical/_array_to_linked_list.js | 2 +- .../agg_response/hierarchical/_build_split.js | 6 +- .../hierarchical/_collect_branch.js | 6 +- .../hierarchical/_collect_keys.js | 6 +- .../hierarchical/_create_raw_data.js | 20 +++--- .../hierarchical/_extract_buckets.js | 4 +- .../_hierarchical_tooltip_formatter.js | 16 ++--- .../hierarchical/_transform_aggregation.js | 12 ++-- .../hierarchical/build_hierarchical_data.js | 44 ++++++------ .../point_series/_fake_x_aspect.js | 8 +-- .../agg_response/point_series/_get_aspects.js | 14 ++-- .../agg_response/point_series/_get_point.js | 8 +-- .../agg_response/point_series/_get_series.js | 30 ++++---- .../agg_response/point_series/_init_x_axis.js | 4 +- .../agg_response/point_series/_init_y_axis.js | 8 +-- .../point_series/_ordered_date_axis.js | 12 ++-- .../point_series/_tooltip_formatter.js | 18 ++--- .../agg_response/point_series/point_series.js | 20 +++--- src/ui/public/agg_response/tabify/_buckets.js | 4 +- .../agg_response/tabify/_get_columns.js | 10 +-- .../agg_response/tabify/_response_writer.js | 54 +++++++-------- src/ui/public/agg_response/tabify/_table.js | 2 +- .../agg_response/tabify/_table_group.js | 2 +- src/ui/public/agg_response/tabify/tabify.js | 24 +++---- src/ui/public/agg_table/agg_table.js | 26 +++---- src/ui/public/agg_table/agg_table_group.js | 6 +- src/ui/public/agg_types/AggParams.js | 12 ++-- src/ui/public/agg_types/AggType.js | 8 +-- .../agg_types/buckets/_bucket_agg_type.js | 4 +- .../buckets/_bucket_count_between.js | 10 +-- .../agg_types/buckets/_interval_options.js | 4 +- .../buckets/create_filter/date_histogram.js | 8 +-- .../buckets/create_filter/date_range.js | 8 +-- .../buckets/create_filter/filters.js | 8 +-- .../buckets/create_filter/histogram.js | 4 +- .../buckets/create_filter/ip_range.js | 6 +- .../agg_types/buckets/create_filter/range.js | 2 +- .../agg_types/buckets/create_filter/terms.js | 2 +- .../agg_types/buckets/date_histogram.js | 40 +++++------ src/ui/public/agg_types/buckets/date_range.js | 12 ++-- src/ui/public/agg_types/buckets/filters.js | 24 +++---- src/ui/public/agg_types/buckets/geo_hash.js | 10 +-- src/ui/public/agg_types/buckets/histogram.js | 12 ++-- src/ui/public/agg_types/buckets/ip_range.js | 8 +-- src/ui/public/agg_types/buckets/range.js | 18 ++--- .../agg_types/buckets/significant_terms.js | 6 +- src/ui/public/agg_types/buckets/terms.js | 46 ++++++------- src/ui/public/agg_types/index.js | 4 +- .../public/agg_types/metrics/MetricAggType.js | 10 +-- src/ui/public/agg_types/metrics/avg.js | 2 +- .../public/agg_types/metrics/cardinality.js | 4 +- src/ui/public/agg_types/metrics/count.js | 4 +- .../metrics/getResponseAggConfigClass.js | 4 +- src/ui/public/agg_types/metrics/max.js | 2 +- src/ui/public/agg_types/metrics/median.js | 8 +-- src/ui/public/agg_types/metrics/min.js | 2 +- .../agg_types/metrics/percentile_ranks.js | 18 ++--- .../public/agg_types/metrics/percentiles.js | 16 ++--- .../public/agg_types/metrics/stdDeviation.js | 14 ++-- src/ui/public/agg_types/metrics/sum.js | 2 +- src/ui/public/agg_types/param_types/base.js | 2 +- src/ui/public/agg_types/param_types/field.js | 12 ++-- .../public/agg_types/param_types/optioned.js | 6 +- .../public/agg_types/param_types/raw_json.js | 10 +-- src/ui/public/agg_types/param_types/regex.js | 14 ++-- src/ui/public/agg_types/param_types/string.js | 6 +- src/ui/public/bind/bind.js | 34 +++++----- src/ui/public/chrome/TabCollection.js | 12 ++-- src/ui/public/chrome/api/angular.js | 8 +-- src/ui/public/chrome/api/controls.js | 4 +- src/ui/public/chrome/api/nav.js | 6 +- src/ui/public/chrome/api/tabs.js | 6 +- src/ui/public/chrome/api/template.js | 2 +- src/ui/public/chrome/api/theme.js | 8 +-- src/ui/public/chrome/chrome.js | 12 ++-- src/ui/public/chrome/context.js | 6 +- .../directives/app_switcher/app_switcher.js | 18 ++--- .../collapsible_sidebar.js | 12 ++-- src/ui/public/config/_delayed_updater.js | 24 +++---- src/ui/public/config/config.js | 26 +++---- src/ui/public/config/defaults.js | 4 +- .../public/courier/_redirect_when_missing.js | 8 +-- src/ui/public/courier/_request_queue.js | 6 +- src/ui/public/courier/courier.js | 30 ++++---- .../public/courier/data_source/_abstract.js | 44 ++++++------ .../courier/data_source/_decorate_query.js | 4 +- .../courier/data_source/_doc_send_to_es.js | 20 +++--- .../data_source/_normalize_sort_request.js | 14 ++-- .../data_source/_root_search_source.js | 8 +-- .../public/courier/data_source/doc_source.js | 20 +++--- .../courier/data_source/search_source.js | 22 +++--- src/ui/public/courier/fetch/_call_client.js | 22 +++--- .../courier/fetch/_call_response_handlers.js | 14 ++-- .../courier/fetch/_continue_incomplete.js | 4 +- src/ui/public/courier/fetch/_fetch_these.js | 18 ++--- .../courier/fetch/_for_each_strategy.js | 8 +-- src/ui/public/courier/fetch/_is_request.js | 2 +- .../fetch/_merge_duplicate_requests.js | 8 +-- src/ui/public/courier/fetch/fetch.js | 14 ++-- .../courier/fetch/request/_error_handler.js | 6 +- .../fetch/request/_segmented_handle.js | 4 +- src/ui/public/courier/fetch/request/doc.js | 16 ++--- .../public/courier/fetch/request/request.js | 14 ++-- src/ui/public/courier/fetch/request/search.js | 8 +-- .../public/courier/fetch/request/segmented.js | 68 +++++++++---------- .../public/courier/fetch/strategy/search.js | 8 +-- src/ui/public/courier/looper/_looper.js | 6 +- src/ui/public/courier/looper/doc.js | 8 +-- src/ui/public/courier/looper/search.js | 12 ++-- .../courier/saved_object/saved_object.js | 46 ++++++------- src/ui/public/debounce/debounce.js | 8 +-- .../directives/auto_select_if_only_one.js | 4 +- src/ui/public/directives/click_focus.js | 8 +-- src/ui/public/directives/config.js | 16 ++--- src/ui/public/directives/confirm_click.js | 4 +- src/ui/public/directives/css_truncate.js | 6 +- src/ui/public/directives/field_name.js | 14 ++-- src/ui/public/directives/file_upload.js | 12 ++-- src/ui/public/directives/inequality.js | 8 +-- src/ui/public/directives/infinite_scroll.js | 16 ++--- src/ui/public/directives/info.js | 2 +- src/ui/public/directives/input_datetime.js | 16 ++--- src/ui/public/directives/input_focus.js | 2 +- .../public/directives/input_whole_number.js | 2 +- src/ui/public/directives/json_input.js | 6 +- src/ui/public/directives/paginate.js | 34 +++++----- src/ui/public/directives/pretty_duration.js | 22 +++--- src/ui/public/directives/rows.js | 30 ++++---- .../public/directives/saved_object_finder.js | 30 ++++---- src/ui/public/directives/spinner.js | 4 +- src/ui/public/directives/truncated.js | 10 +-- .../public/directives/validate_cidr_mask.js | 4 +- .../public/directives/validate_date_math.js | 6 +- .../public/directives/validate_index_name.js | 10 +-- src/ui/public/directives/validate_ip.js | 4 +- src/ui/public/directives/validate_json.js | 6 +- .../doc_table/components/table_header.js | 22 +++--- .../public/doc_table/components/table_row.js | 42 ++++++------ src/ui/public/doc_table/doc_table.js | 14 ++-- src/ui/public/doc_table/lib/get_sort.js | 4 +- src/ui/public/doc_title/doc_title.js | 12 ++-- src/ui/public/doc_viewer/doc_viewer.js | 8 +-- 146 files changed, 928 insertions(+), 928 deletions(-) diff --git a/src/ui/public/Binder/Binder.js b/src/ui/public/Binder/Binder.js index 9f5308a2210d..568b313b0f1b 100644 --- a/src/ui/public/Binder/Binder.js +++ b/src/ui/public/Binder/Binder.js @@ -1,8 +1,8 @@ -var $ = require('jquery'); -var d3 = require('d3'); -var callEach = require('lodash').callEach; -var bindKey = require('lodash').bindKey; -var rest = require('lodash').rest; +let $ = require('jquery'); +let d3 = require('d3'); +let callEach = require('lodash').callEach; +let bindKey = require('lodash').bindKey; +let rest = require('lodash').rest; function Binder($scope) { this.disposal = []; @@ -23,14 +23,14 @@ Binder.prototype.on = function (emitter/*, ...args */) { }; Binder.prototype.jqOn = function (el/*, ...args */) { - var $el = $(el); + let $el = $(el); this._bind($el.on, $el.off, $el, rest(arguments)); }; Binder.prototype.fakeD3Bind = function (el, event, handler) { this.jqOn(el, event, function (e) { // mimick https://github.com/mbostock/d3/blob/3abb00113662463e5c19eb87cd33f6d0ddc23bc0/src/selection/on.js#L87-L94 - var o = d3.event; // Events can be reentrant (e.g., focus). + let o = d3.event; // Events can be reentrant (e.g., focus). d3.event = e; try { handler.apply(this, [this.__data__]); @@ -41,7 +41,7 @@ Binder.prototype.fakeD3Bind = function (el, event, handler) { }; Binder.prototype.destroy = function () { - var destroyers = this.disposal; + let destroyers = this.disposal; this.disposal = []; callEach(destroyers); }; diff --git a/src/ui/public/agg_response/geo_json/_tooltip_formatter.js b/src/ui/public/agg_response/geo_json/_tooltip_formatter.js index 071fc482298b..d85c4732a474 100644 --- a/src/ui/public/agg_response/geo_json/_tooltip_formatter.js +++ b/src/ui/public/agg_response/geo_json/_tooltip_formatter.js @@ -1,22 +1,22 @@ define(function (require) { return function TileMapTooltipFormatter($compile, $rootScope, Private) { - var $ = require('jquery'); - var _ = require('lodash'); + let $ = require('jquery'); + let _ = require('lodash'); - var fieldFormats = Private(require('ui/registry/field_formats')); - var $tooltipScope = $rootScope.$new(); - var $el = $('
').html(require('ui/agg_response/geo_json/_tooltip.html')); + let fieldFormats = Private(require('ui/registry/field_formats')); + let $tooltipScope = $rootScope.$new(); + let $el = $('
').html(require('ui/agg_response/geo_json/_tooltip.html')); $compile($el)($tooltipScope); return function tooltipFormatter(feature) { if (!feature) return ''; - var value = feature.properties.value; - var acr = feature.properties.aggConfigResult; - var vis = acr.aggConfig.vis; + let value = feature.properties.value; + let acr = feature.properties.aggConfigResult; + let vis = acr.aggConfig.vis; - var metricAgg = acr.aggConfig; - var geoFormat = _.get(vis.aggs, 'byTypeName.geohash_grid[0].format'); + let metricAgg = acr.aggConfig; + let geoFormat = _.get(vis.aggs, 'byTypeName.geohash_grid[0].format'); if (!geoFormat) geoFormat = fieldFormats.getDefaultInstance('geo_point'); $tooltipScope.details = [ diff --git a/src/ui/public/agg_response/geo_json/geo_json.js b/src/ui/public/agg_response/geo_json/geo_json.js index 4b883f13820a..7919d853e48a 100644 --- a/src/ui/public/agg_response/geo_json/geo_json.js +++ b/src/ui/public/agg_response/geo_json/geo_json.js @@ -1,9 +1,9 @@ define(function (require) { return function TileMapConverterFn(Private, timefilter, $compile, $rootScope) { - var _ = require('lodash'); + let _ = require('lodash'); - var rowsToFeatures = require('ui/agg_response/geo_json/rowsToFeatures'); - var tooltipFormatter = Private(require('ui/agg_response/geo_json/_tooltip_formatter')); + let rowsToFeatures = require('ui/agg_response/geo_json/rowsToFeatures'); + let tooltipFormatter = Private(require('ui/agg_response/geo_json/_tooltip_formatter')); return function (vis, table) { @@ -13,13 +13,13 @@ define(function (require) { }); } - var geoI = columnIndex('segment'); - var metricI = columnIndex('metric'); - var geoAgg = _.get(table.columns, [geoI, 'aggConfig']); - var metricAgg = _.get(table.columns, [metricI, 'aggConfig']); + let geoI = columnIndex('segment'); + let metricI = columnIndex('metric'); + let geoAgg = _.get(table.columns, [geoI, 'aggConfig']); + let metricAgg = _.get(table.columns, [metricI, 'aggConfig']); - var features = rowsToFeatures(table, geoI, metricI); - var values = features.map(function (feature) { + let features = rowsToFeatures(table, geoI, metricI); + let values = features.map(function (feature) { return feature.properties.value; }); diff --git a/src/ui/public/agg_response/geo_json/rowsToFeatures.js b/src/ui/public/agg_response/geo_json/rowsToFeatures.js index 5ce58a6ddbec..dc1bac8b141e 100644 --- a/src/ui/public/agg_response/geo_json/rowsToFeatures.js +++ b/src/ui/public/agg_response/geo_json/rowsToFeatures.js @@ -1,7 +1,7 @@ define(function (require) { - var decodeGeoHash = require('ui/utils/decode_geo_hash'); - var AggConfigResult = require('ui/Vis/AggConfigResult'); - var _ = require('lodash'); + let decodeGeoHash = require('ui/utils/decode_geo_hash'); + let AggConfigResult = require('ui/Vis/AggConfigResult'); + let _ = require('lodash'); function getAcr(val) { return val instanceof AggConfigResult ? val : null; @@ -13,19 +13,19 @@ define(function (require) { function convertRowsToFeatures(table, geoI, metricI) { return _.transform(table.rows, function (features, row) { - var geohash = unwrap(row[geoI]); + let geohash = unwrap(row[geoI]); if (!geohash) return; // fetch latLn of northwest and southeast corners, and center point - var location = decodeGeoHash(geohash); + let location = decodeGeoHash(geohash); - var centerLatLng = [ + let centerLatLng = [ location.latitude[2], location.longitude[2] ]; // order is nw, ne, se, sw - var rectangle = [ + let rectangle = [ [location.latitude[0], location.longitude[0]], [location.latitude[0], location.longitude[1]], [location.latitude[1], location.longitude[1]], diff --git a/src/ui/public/agg_response/hierarchical/_array_to_linked_list.js b/src/ui/public/agg_response/hierarchical/_array_to_linked_list.js index db419aca2c4f..230e9cf63ac4 100644 --- a/src/ui/public/agg_response/hierarchical/_array_to_linked_list.js +++ b/src/ui/public/agg_response/hierarchical/_array_to_linked_list.js @@ -1,5 +1,5 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); return function (buckets) { let previous; _.each(buckets, function (bucket) { diff --git a/src/ui/public/agg_response/hierarchical/_build_split.js b/src/ui/public/agg_response/hierarchical/_build_split.js index 7c6bacc9c5f7..6ef6ccce2bcc 100644 --- a/src/ui/public/agg_response/hierarchical/_build_split.js +++ b/src/ui/public/agg_response/hierarchical/_build_split.js @@ -1,10 +1,10 @@ define(function (require) { return function biuldSplitProvider(Private) { - var transformer = Private(require('ui/agg_response/hierarchical/_transform_aggregation')); - var collectKeys = require('ui/agg_response/hierarchical/_collect_keys'); + let transformer = Private(require('ui/agg_response/hierarchical/_transform_aggregation')); + let collectKeys = require('ui/agg_response/hierarchical/_collect_keys'); return function (agg, metric, aggData) { // Ceate the split structure - var split = { label: '', slices: { children: [] } }; + let split = { label: '', slices: { children: [] } }; // Transform the aggData into splits split.slices.children = transformer(agg, metric, aggData); diff --git a/src/ui/public/agg_response/hierarchical/_collect_branch.js b/src/ui/public/agg_response/hierarchical/_collect_branch.js index 97370399f0e4..5ad651838827 100644 --- a/src/ui/public/agg_response/hierarchical/_collect_branch.js +++ b/src/ui/public/agg_response/hierarchical/_collect_branch.js @@ -3,13 +3,13 @@ define(function () { // walk up the branch for each parent function walk(item, memo) { // record the the depth - var depth = item.depth - 1; + let depth = item.depth - 1; // Using the aggConfig determine what the field name is. If the aggConfig // doesn't exist (which means it's an _all agg) then use the level for // the field name - var col = item.aggConfig; - var field = (col && col.params && col.params.field && col.params.field.displayName) + let col = item.aggConfig; + let field = (col && col.params && col.params.field && col.params.field.displayName) || (col && col.label) || ('level ' + item.depth); diff --git a/src/ui/public/agg_response/hierarchical/_collect_keys.js b/src/ui/public/agg_response/hierarchical/_collect_keys.js index 460e6c0091e2..53e720403f9c 100644 --- a/src/ui/public/agg_response/hierarchical/_collect_keys.js +++ b/src/ui/public/agg_response/hierarchical/_collect_keys.js @@ -1,8 +1,8 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); return function collectKeys(children) { - var nextChildren = _.pluck(children, 'children'); - var keys = _.pluck(children, 'name'); + let nextChildren = _.pluck(children, 'children'); + let keys = _.pluck(children, 'name'); return _(nextChildren) .map(collectKeys) .flattenDeep() diff --git a/src/ui/public/agg_response/hierarchical/_create_raw_data.js b/src/ui/public/agg_response/hierarchical/_create_raw_data.js index 9f4346a9fca5..a10a05ee1e84 100644 --- a/src/ui/public/agg_response/hierarchical/_create_raw_data.js +++ b/src/ui/public/agg_response/hierarchical/_create_raw_data.js @@ -1,15 +1,15 @@ define(function (require) { - var _ = require('lodash'); - var extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets'); + let _ = require('lodash'); + let extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets'); return function (vis, resp) { // Create the initial results structure - var results = { rows: [] }; + let results = { rows: [] }; // Create a reference to the buckets and metrics - var metrics = vis.aggs.bySchemaGroup.metrics; - var buckets = vis.aggs.bySchemaGroup.buckets; - var aggs = []; + let metrics = vis.aggs.bySchemaGroup.metrics; + let buckets = vis.aggs.bySchemaGroup.buckets; + let aggs = []; if (buckets) { _.each(buckets, function (bucket) { @@ -38,7 +38,7 @@ define(function (require) { // if there are no buckets then we need to just set the value and return if (!buckets) { - var value = resp.aggregations + let value = resp.aggregations && resp.aggregations[metrics[0].id] && resp.aggregations[metrics[0].id].value || resp.hits.total; @@ -61,9 +61,9 @@ define(function (require) { // iterate through all the buckets _.each(extractBuckets(data[agg.id], agg), function (bucket) { - var _record = _.flattenDeep([record, bucket.key]); + let _record = _.flattenDeep([record, bucket.key]); _.each(metrics, function (metric) { - var value = bucket.doc_count; + let value = bucket.doc_count; if (bucket[metric.id] && !_.isUndefined(bucket[metric.id].value)) { value = bucket[metric.id].value; } @@ -74,7 +74,7 @@ define(function (require) { // buckets. If it does then we need to keep on walking the tree. // This is where the recursion happens. if (agg._next) { - var nextBucket = bucket[agg._next.id]; + let nextBucket = bucket[agg._next.id]; if (nextBucket && nextBucket.buckets) { walkBuckets(agg._next, bucket, _record); } diff --git a/src/ui/public/agg_response/hierarchical/_extract_buckets.js b/src/ui/public/agg_response/hierarchical/_extract_buckets.js index e1866ea5d006..e5e6e7d580ff 100644 --- a/src/ui/public/agg_response/hierarchical/_extract_buckets.js +++ b/src/ui/public/agg_response/hierarchical/_extract_buckets.js @@ -1,9 +1,9 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); return function (bucket, agg) { if (bucket && _.isPlainObject(bucket.buckets)) { return _.map(bucket.buckets, function (value, key) { - var item = _.cloneDeep(value); + let item = _.cloneDeep(value); item.key = agg ? agg.getKey(value, key) : key; return item; }); diff --git a/src/ui/public/agg_response/hierarchical/_hierarchical_tooltip_formatter.js b/src/ui/public/agg_response/hierarchical/_hierarchical_tooltip_formatter.js index 57dd63516d70..e6478433c387 100644 --- a/src/ui/public/agg_response/hierarchical/_hierarchical_tooltip_formatter.js +++ b/src/ui/public/agg_response/hierarchical/_hierarchical_tooltip_formatter.js @@ -1,22 +1,22 @@ define(function (require) { return function HierarchicalTooltipFormaterProvider($rootScope, $compile, $sce) { - var _ = require('lodash'); - var $ = require('jquery'); - var $tooltip = $(require('ui/agg_response/hierarchical/_tooltip.html')); - var collectBranch = require('ui/agg_response/hierarchical/_collect_branch'); - var $tooltipScope = $rootScope.$new(); - var numeral = require('numeral'); + let _ = require('lodash'); + let $ = require('jquery'); + let $tooltip = $(require('ui/agg_response/hierarchical/_tooltip.html')); + let collectBranch = require('ui/agg_response/hierarchical/_collect_branch'); + let $tooltipScope = $rootScope.$new(); + let numeral = require('numeral'); $compile($tooltip)($tooltipScope); return function (columns) { return function (event) { - var datum = event.datum; + let datum = event.datum; // Collect the current leaf and parents into an array of values $tooltipScope.rows = collectBranch(datum); - var metricCol = $tooltipScope.metricCol = _.find(columns, { categoryName: 'metric' }); + let metricCol = $tooltipScope.metricCol = _.find(columns, { categoryName: 'metric' }); // Map those values to what the tooltipSource.rows format. _.forEachRight($tooltipScope.rows, function (row, i, rows) { diff --git a/src/ui/public/agg_response/hierarchical/_transform_aggregation.js b/src/ui/public/agg_response/hierarchical/_transform_aggregation.js index 0a3342ce8d23..b45eebe7a7f5 100644 --- a/src/ui/public/agg_response/hierarchical/_transform_aggregation.js +++ b/src/ui/public/agg_response/hierarchical/_transform_aggregation.js @@ -1,18 +1,18 @@ define(function (require) { - var _ = require('lodash'); - var extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets'); + let _ = require('lodash'); + let extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets'); return function transformAggregationProvider(Private) { - var AggConfigResult = require('ui/Vis/AggConfigResult'); + let AggConfigResult = require('ui/Vis/AggConfigResult'); return function transformAggregation(agg, metric, aggData, parent) { return _.map(extractBuckets(aggData, agg), function (bucket) { - var aggConfigResult = new AggConfigResult( + let aggConfigResult = new AggConfigResult( agg, parent && parent.aggConfigResult, metric.getValue(bucket), agg.getKey(bucket) ); - var branch = { + let branch = { name: agg.fieldFormatter()(bucket.key), size: aggConfigResult.value, aggConfig: agg, @@ -28,7 +28,7 @@ define(function (require) { // If the next bucket exists and it has children the we need to // transform it as well. This is where the recursion happens. if (agg._next) { - var nextBucket = bucket[agg._next.id]; + let nextBucket = bucket[agg._next.id]; if (nextBucket && nextBucket.buckets) { branch.children = transformAggregation(agg._next, metric, nextBucket, branch); } diff --git a/src/ui/public/agg_response/hierarchical/build_hierarchical_data.js b/src/ui/public/agg_response/hierarchical/build_hierarchical_data.js index 31ca1ca4b0b6..815335cf6e3f 100644 --- a/src/ui/public/agg_response/hierarchical/build_hierarchical_data.js +++ b/src/ui/public/agg_response/hierarchical/build_hierarchical_data.js @@ -1,38 +1,38 @@ define(function (require) { return function buildHierarchicalDataProvider(Private, Notifier) { - var _ = require('lodash'); - var buildSplit = Private(require('ui/agg_response/hierarchical/_build_split')); - var extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets'); - var createRawData = require('ui/agg_response/hierarchical/_create_raw_data'); - var arrayToLinkedList = require('ui/agg_response/hierarchical/_array_to_linked_list'); - var tooltipFormatter = Private(require('ui/agg_response/hierarchical/_hierarchical_tooltip_formatter')); + let _ = require('lodash'); + let buildSplit = Private(require('ui/agg_response/hierarchical/_build_split')); + let extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets'); + let createRawData = require('ui/agg_response/hierarchical/_create_raw_data'); + let arrayToLinkedList = require('ui/agg_response/hierarchical/_array_to_linked_list'); + let tooltipFormatter = Private(require('ui/agg_response/hierarchical/_hierarchical_tooltip_formatter')); - var AggConfigResult = require('ui/Vis/AggConfigResult'); + let AggConfigResult = require('ui/Vis/AggConfigResult'); - var notify = new Notifier({ + let notify = new Notifier({ location: 'Pie chart response converter' }); return function (vis, resp) { // Create a refrenece to the buckets - var buckets = vis.aggs.bySchemaGroup.buckets; + let buckets = vis.aggs.bySchemaGroup.buckets; // Find the metric so it's easier to reference. // TODO: Change this to support multiple metrics. - var metric = vis.aggs.bySchemaGroup.metrics[0]; + let metric = vis.aggs.bySchemaGroup.metrics[0]; // Link each agg to the next agg. This will be // to identify the next bucket aggregation buckets = arrayToLinkedList(buckets); // Create the raw data to be used in the spy panel - var raw = createRawData(vis, resp); + let raw = createRawData(vis, resp); // If buckets is falsy then we should just return the aggs if (!buckets) { - var label = 'Count'; - var value = resp.aggregations + let label = 'Count'; + let value = resp.aggregations && resp.aggregations[metric.id] && resp.aggregations[metric.id].value || resp.hits.total; @@ -49,8 +49,8 @@ define(function (require) { }; } - var firstAgg = buckets[0]; - var aggData = resp.aggregations[firstAgg.id]; + let firstAgg = buckets[0]; + let aggData = resp.aggregations[firstAgg.id]; if (!firstAgg._next && firstAgg.schema.name === 'split') { notify.error('Splitting charts without splitting slices is not supported. Pretending that we are just splitting slices.'); @@ -58,7 +58,7 @@ define(function (require) { // start with splitting slices if (!firstAgg._next || firstAgg.schema.name === 'segment') { - var split = buildSplit(firstAgg, metric, aggData); + let split = buildSplit(firstAgg, metric, aggData); split.hits = resp.hits.total; split.raw = raw; split.tooltipFormatter = tooltipFormatter(raw.columns); @@ -66,17 +66,17 @@ define(function (require) { } // map the split aggregations into rows. - var rows = _.map(extractBuckets(aggData, firstAgg), function (bucket) { - var agg = firstAgg._next; - var split = buildSplit(agg, metric, bucket[agg.id]); + let rows = _.map(extractBuckets(aggData, firstAgg), function (bucket) { + let agg = firstAgg._next; + let split = buildSplit(agg, metric, bucket[agg.id]); // Since splits display labels we need to set it. split.label = firstAgg.fieldFormatter()(agg.getKey(bucket)); - var displayName = firstAgg.fieldDisplayName(); + let displayName = firstAgg.fieldDisplayName(); if (!_.isEmpty(displayName)) split.label += ': ' + displayName; split.tooltipFormatter = tooltipFormatter(raw.columns); - var aggConfigResult = new AggConfigResult(firstAgg, null, null, firstAgg.getKey(bucket)); + let aggConfigResult = new AggConfigResult(firstAgg, null, null, firstAgg.getKey(bucket)); split.split = { aggConfig: firstAgg, aggConfigResult: aggConfigResult, key: bucket.key }; _.each(split.slices.children, function (child) { child.aggConfigResult.$parent = aggConfigResult; @@ -84,7 +84,7 @@ define(function (require) { return split; }); - var result = { hits: resp.hits.total, raw: raw }; + let result = { hits: resp.hits.total, raw: raw }; if (firstAgg.params.row) { result.rows = rows; } else { diff --git a/src/ui/public/agg_response/point_series/_fake_x_aspect.js b/src/ui/public/agg_response/point_series/_fake_x_aspect.js index 5de2c4928aff..32094060195c 100644 --- a/src/ui/public/agg_response/point_series/_fake_x_aspect.js +++ b/src/ui/public/agg_response/point_series/_fake_x_aspect.js @@ -1,9 +1,9 @@ define(function (require) { return function PointSeriesFakeXAxis(Private) { - var AggConfig = Private(require('ui/Vis/AggConfig')); - var AggType = Private(require('ui/agg_types/AggType')); + let AggConfig = Private(require('ui/Vis/AggConfig')); + let AggType = Private(require('ui/agg_types/AggType')); - var allAgg = new AggType({ + let allAgg = new AggType({ name: 'all', title: 'All docs', ordered: false, @@ -11,7 +11,7 @@ define(function (require) { }); return function makeFakeXAxis(vis) { - var fake = new AggConfig(vis, { + let fake = new AggConfig(vis, { type: allAgg, schema: vis.type.schemas.all.byName.segment }); diff --git a/src/ui/public/agg_response/point_series/_get_aspects.js b/src/ui/public/agg_response/point_series/_get_aspects.js index 58ce78b3549e..ff86b41ee317 100644 --- a/src/ui/public/agg_response/point_series/_get_aspects.js +++ b/src/ui/public/agg_response/point_series/_get_aspects.js @@ -1,9 +1,9 @@ define(function (require) { return function PointSeriesGetAspects(Private) { - var _ = require('lodash'); - var fakeXAspect = Private(require('ui/agg_response/point_series/_fake_x_aspect')); + let _ = require('lodash'); + let fakeXAspect = Private(require('ui/agg_response/point_series/_fake_x_aspect')); - var map = { + let map = { segment: 'x', metric: 'y', radius: 'z', @@ -12,12 +12,12 @@ define(function (require) { }; function columnToAspect(aspects, col, i) { - var schema = col.aggConfig.schema.name; + let schema = col.aggConfig.schema.name; - var name = map[schema]; + let name = map[schema]; if (!name) throw new TypeError('unknown schema name "' + schema + '"'); - var aspect = { + let aspect = { i: i, col: col, agg: col.aggConfig @@ -36,7 +36,7 @@ define(function (require) { * may be undefined, a single aspect, or an array of aspects. */ return function getAspects(vis, table) { - var aspects = _(table.columns) + let aspects = _(table.columns) // write each column into the aspects under it's group .transform(columnToAspect, {}) // unwrap groups that only have one value, and validate groups that have more diff --git a/src/ui/public/agg_response/point_series/_get_point.js b/src/ui/public/agg_response/point_series/_get_point.js index c0b4e30ef2f0..105d4675c0f2 100644 --- a/src/ui/public/agg_response/point_series/_get_point.js +++ b/src/ui/public/agg_response/point_series/_get_point.js @@ -1,15 +1,15 @@ define(function (require) { return function PointSeriesGetPoint() { - var _ = require('lodash'); + let _ = require('lodash'); function unwrap(aggConfigResult, def) { return aggConfigResult ? aggConfigResult.value : def; } return function getPoint(x, series, yScale, row, y, z) { - var zRow = z && row[z.i]; - var xRow = row[x.i]; + let zRow = z && row[z.i]; + let xRow = row[x.i]; - var point = { + let point = { x: unwrap(xRow, '_all'), xi: xRow && xRow.$order, y: unwrap(row[y.i]), diff --git a/src/ui/public/agg_response/point_series/_get_series.js b/src/ui/public/agg_response/point_series/_get_series.js index 60b6cf599278..331c1531a644 100644 --- a/src/ui/public/agg_response/point_series/_get_series.js +++ b/src/ui/public/agg_response/point_series/_get_series.js @@ -1,30 +1,30 @@ define(function (require) { return function PointSeriesGetSeries(Private) { - var _ = require('lodash'); - var getPoint = Private(require('ui/agg_response/point_series/_get_point')); - var addToSiri = Private(require('ui/agg_response/point_series/_add_to_siri')); + let _ = require('lodash'); + let getPoint = Private(require('ui/agg_response/point_series/_get_point')); + let addToSiri = Private(require('ui/agg_response/point_series/_add_to_siri')); return function getSeries(rows, chart) { - var aspects = chart.aspects; - var multiY = _.isArray(aspects.y); - var yScale = chart.yScale; - var partGetPoint = _.partial(getPoint, aspects.x, aspects.series, yScale); + let aspects = chart.aspects; + let multiY = _.isArray(aspects.y); + let yScale = chart.yScale; + let partGetPoint = _.partial(getPoint, aspects.x, aspects.series, yScale); - var series = _(rows) + let series = _(rows) .transform(function (series, row) { if (!multiY) { - var point = partGetPoint(row, aspects.y, aspects.z); + let point = partGetPoint(row, aspects.y, aspects.z); if (point) addToSiri(series, point, point.series); return; } aspects.y.forEach(function (y) { - var point = partGetPoint(row, y, aspects.z); + let point = partGetPoint(row, y, aspects.z); if (!point) return; - var prefix = point.series ? point.series + ': ' : ''; - var seriesId = prefix + y.agg.id; - var seriesLabel = prefix + y.col.title; + let prefix = point.series ? point.series + ': ' : ''; + let seriesId = prefix + y.agg.id; + let seriesLabel = prefix + y.col.title; addToSiri(series, point, seriesId, seriesLabel); }); @@ -35,11 +35,11 @@ define(function (require) { if (multiY) { series = _.sortBy(series, function (siri) { - var firstVal = siri.values[0]; + let firstVal = siri.values[0]; let y; if (firstVal) { - var agg = firstVal.aggConfigResult.aggConfig; + let agg = firstVal.aggConfigResult.aggConfig; y = _.find(aspects.y, function (y) { return y.agg === agg; }); diff --git a/src/ui/public/agg_response/point_series/_init_x_axis.js b/src/ui/public/agg_response/point_series/_init_x_axis.js index 3910621f701c..2a3584c3834f 100644 --- a/src/ui/public/agg_response/point_series/_init_x_axis.js +++ b/src/ui/public/agg_response/point_series/_init_x_axis.js @@ -1,14 +1,14 @@ define(function () { return function PointSeriesInitX() { return function initXAxis(chart) { - var x = chart.aspects.x; + let x = chart.aspects.x; chart.xAxisFormatter = x.agg ? x.agg.fieldFormatter() : String; chart.xAxisLabel = x.col.title; if (!x.agg || !x.agg.type.ordered) return; chart.ordered = {}; - var xAggOutput = x.agg.write(); + let xAggOutput = x.agg.write(); if (xAggOutput.params.interval) { chart.ordered.interval = xAggOutput.params.interval; } diff --git a/src/ui/public/agg_response/point_series/_init_y_axis.js b/src/ui/public/agg_response/point_series/_init_y_axis.js index b47ec2ef884c..a34039073e75 100644 --- a/src/ui/public/agg_response/point_series/_init_y_axis.js +++ b/src/ui/public/agg_response/point_series/_init_y_axis.js @@ -1,10 +1,10 @@ define(function (require) { return function PointSeriesInitYAxis() { - var _ = require('lodash'); + let _ = require('lodash'); return function initYAxis(chart) { - var y = chart.aspects.y; - var x = chart.aspects.x; + let y = chart.aspects.y; + let x = chart.aspects.x; if (_.isArray(y)) { // TODO: vis option should allow choosing this format @@ -15,7 +15,7 @@ define(function (require) { chart.yAxisLabel = y.col.title; } - var xAggOutput = x.agg.write(); + let xAggOutput = x.agg.write(); chart.yScale = xAggOutput.metricScale || null; }; }; diff --git a/src/ui/public/agg_response/point_series/_ordered_date_axis.js b/src/ui/public/agg_response/point_series/_ordered_date_axis.js index 805bea1c43bb..34662a7f1f94 100644 --- a/src/ui/public/agg_response/point_series/_ordered_date_axis.js +++ b/src/ui/public/agg_response/point_series/_ordered_date_axis.js @@ -1,11 +1,11 @@ define(function (require) { return function PointSeriesOrderedDateAxis(timefilter) { - var moment = require('moment'); + let moment = require('moment'); return function orderedDateAxis(vis, chart) { - var xAgg = chart.aspects.x.agg; - var buckets = xAgg.buckets; - var format = buckets.getScaledDateFormat(); + let xAgg = chart.aspects.x.agg; + let buckets = xAgg.buckets; + let format = buckets.getScaledDateFormat(); chart.xAxisFormatter = function (val) { return moment(val).format(format); @@ -16,8 +16,8 @@ define(function (require) { interval: buckets.getInterval(), }; - var axisOnTimeField = xAgg.fieldIsTimeField(); - var bounds = buckets.getBounds(); + let axisOnTimeField = xAgg.fieldIsTimeField(); + let bounds = buckets.getBounds(); if (bounds && axisOnTimeField) { chart.ordered.min = bounds.min; chart.ordered.max = bounds.max; diff --git a/src/ui/public/agg_response/point_series/_tooltip_formatter.js b/src/ui/public/agg_response/point_series/_tooltip_formatter.js index 97345117543a..edd245ab99d5 100644 --- a/src/ui/public/agg_response/point_series/_tooltip_formatter.js +++ b/src/ui/public/agg_response/point_series/_tooltip_formatter.js @@ -1,23 +1,23 @@ define(function (require) { return function PointSeriesTooltipFormatter($compile, $rootScope) { - var $ = require('jquery'); + let $ = require('jquery'); - var $tooltipScope = $rootScope.$new(); - var $tooltip = $(require('ui/agg_response/point_series/_tooltip.html')); + let $tooltipScope = $rootScope.$new(); + let $tooltip = $(require('ui/agg_response/point_series/_tooltip.html')); $compile($tooltip)($tooltipScope); return function tooltipFormatter(event) { - var datum = event.datum; + let datum = event.datum; if (!datum || !datum.aggConfigResult) return ''; - var details = $tooltipScope.details = []; - var result = { $parent: datum.aggConfigResult }; + let details = $tooltipScope.details = []; + let result = { $parent: datum.aggConfigResult }; function addDetail(result) { - var agg = result.aggConfig; - var value = result.value; + let agg = result.aggConfig; + let value = result.value; - var detail = { + let detail = { value: agg.fieldFormatter()(value), label: agg.makeLabel() }; diff --git a/src/ui/public/agg_response/point_series/point_series.js b/src/ui/public/agg_response/point_series/point_series.js index ddaf2c9beef2..1bdc88764b77 100644 --- a/src/ui/public/agg_response/point_series/point_series.js +++ b/src/ui/public/agg_response/point_series/point_series.js @@ -1,24 +1,24 @@ define(function (require) { return function PointSeriesProvider(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var getSeries = Private(require('ui/agg_response/point_series/_get_series')); - var getAspects = Private(require('ui/agg_response/point_series/_get_aspects')); - var initYAxis = Private(require('ui/agg_response/point_series/_init_y_axis')); - var initXAxis = Private(require('ui/agg_response/point_series/_init_x_axis')); - var setupOrderedDateXAxis = Private(require('ui/agg_response/point_series/_ordered_date_axis')); - var tooltipFormatter = Private(require('ui/agg_response/point_series/_tooltip_formatter')); + let getSeries = Private(require('ui/agg_response/point_series/_get_series')); + let getAspects = Private(require('ui/agg_response/point_series/_get_aspects')); + let initYAxis = Private(require('ui/agg_response/point_series/_init_y_axis')); + let initXAxis = Private(require('ui/agg_response/point_series/_init_x_axis')); + let setupOrderedDateXAxis = Private(require('ui/agg_response/point_series/_ordered_date_axis')); + let tooltipFormatter = Private(require('ui/agg_response/point_series/_tooltip_formatter')); return function pointSeriesChartDataFromTable(vis, table) { - var chart = {}; - var aspects = chart.aspects = getAspects(vis, table); + let chart = {}; + let aspects = chart.aspects = getAspects(vis, table); chart.tooltipFormatter = tooltipFormatter; initXAxis(chart); initYAxis(chart); - var datedX = aspects.x.agg.type.ordered && aspects.x.agg.type.ordered.date; + let datedX = aspects.x.agg.type.ordered && aspects.x.agg.type.ordered.date; if (datedX) { setupOrderedDateXAxis(vis, chart); } diff --git a/src/ui/public/agg_response/tabify/_buckets.js b/src/ui/public/agg_response/tabify/_buckets.js index 6fc08cd41e75..40c9ed62913d 100644 --- a/src/ui/public/agg_response/tabify/_buckets.js +++ b/src/ui/public/agg_response/tabify/_buckets.js @@ -1,6 +1,6 @@ define(function (require) { return function AggResponseBucketsProvider() { - var _ = require('lodash'); + let _ = require('lodash'); function Buckets(aggResp) { aggResp = aggResp || false; @@ -16,7 +16,7 @@ define(function (require) { } Buckets.prototype.forEach = function (fn) { - var buckets = this.buckets; + let buckets = this.buckets; if (this.objectMode) { this._keys.forEach(function (key) { diff --git a/src/ui/public/agg_response/tabify/_get_columns.js b/src/ui/public/agg_response/tabify/_get_columns.js index e652cf0f61e0..13a3ad8a64b9 100644 --- a/src/ui/public/agg_response/tabify/_get_columns.js +++ b/src/ui/public/agg_response/tabify/_get_columns.js @@ -1,10 +1,10 @@ define(function (require) { return function GetColumnsProvider(Private) { - var _ = require('lodash'); - var AggConfig = Private(require('ui/Vis/AggConfig')); + let _ = require('lodash'); + let AggConfig = Private(require('ui/Vis/AggConfig')); return function getColumns(vis, minimal) { - var aggs = vis.aggs.getResponseAggs(); + let aggs = vis.aggs.getResponseAggs(); if (minimal == null) minimal = !vis.isHierarchical(); @@ -23,10 +23,10 @@ define(function (require) { } // supposed to be bucket,...metrics,bucket,...metrics - var columns = []; + let columns = []; // seperate the metrics - var grouped = _.groupBy(aggs, function (agg) { + let grouped = _.groupBy(aggs, function (agg) { return agg.schema.group; }); diff --git a/src/ui/public/agg_response/tabify/_response_writer.js b/src/ui/public/agg_response/tabify/_response_writer.js index f6da52f7b422..a4f4f6f47528 100644 --- a/src/ui/public/agg_response/tabify/_response_writer.js +++ b/src/ui/public/agg_response/tabify/_response_writer.js @@ -1,11 +1,11 @@ define(function (require) { return function TabbedAggResponseWriterProvider(Private) { - var _ = require('lodash'); - var Table = Private(require('ui/agg_response/tabify/_table')); - var TableGroup = Private(require('ui/agg_response/tabify/_table_group')); - var getColumns = Private(require('ui/agg_response/tabify/_get_columns')); + let _ = require('lodash'); + let Table = Private(require('ui/agg_response/tabify/_table')); + let TableGroup = Private(require('ui/agg_response/tabify/_table_group')); + let getColumns = Private(require('ui/agg_response/tabify/_get_columns')); - var AggConfigResult = require('ui/Vis/AggConfigResult'); + let AggConfigResult = require('ui/Vis/AggConfigResult'); _.class(SplitAcr).inherits(AggConfigResult); function SplitAcr(agg, parent, key) { @@ -23,7 +23,7 @@ define(function (require) { this.opts = opts || {}; this.rowBuffer = []; - var visIsHier = vis.isHierarchical(); + let visIsHier = vis.isHierarchical(); // do the options allow for splitting? we will only split if true and // tabify calls the split method. @@ -65,9 +65,9 @@ define(function (require) { * @return {Table/TableGroup} table - the created table */ TabbedAggResponseWriter.prototype._table = function (group, agg, key) { - var Class = (group) ? TableGroup : Table; - var table = new Class(); - var parent = this.splitStack[0]; + let Class = (group) ? TableGroup : Table; + let table = new Class(); + let parent = this.splitStack[0]; if (group) { table.aggConfig = agg; @@ -93,7 +93,7 @@ define(function (require) { * @param {function} block - a function to execute for each sub bucket */ TabbedAggResponseWriter.prototype.split = function (agg, buckets, block) { - var self = this; + let self = this; if (!self.canSplit) { throw new Error('attempted to split when splitting is disabled'); @@ -103,11 +103,11 @@ define(function (require) { buckets.forEach(function (bucket, key) { // find the existing split that we should extend - var tableGroup = _.find(self.splitStack[0].tables, { aggConfig: agg, key: key }); + let tableGroup = _.find(self.splitStack[0].tables, { aggConfig: agg, key: key }); // create the split if it doesn't exist yet if (!tableGroup) tableGroup = self._table(true, agg, key); - var splitAcr = false; + let splitAcr = false; if (self.asAggConfigResults) { splitAcr = self._injectParentSplit(agg, key); } @@ -125,7 +125,7 @@ define(function (require) { }; TabbedAggResponseWriter.prototype._removeAggFromColumns = function (agg) { - var i = _.findIndex(this.columns, function (col) { + let i = _.findIndex(this.columns, function (col) { return col.aggConfig === agg; }); @@ -138,8 +138,8 @@ define(function (require) { // hierarchical vis creats additional columns for each bucket // we will remove those too - var mCol = this.columns.splice(i, 1).pop(); - var mI = _.findIndex(this.aggStack, function (agg) { + let mCol = this.columns.splice(i, 1).pop(); + let mI = _.findIndex(this.aggStack, function (agg) { return agg === mCol.aggConfig; }); @@ -158,12 +158,12 @@ define(function (require) { * @return {SplitAcr} - the AggConfigResult created for the split bucket */ TabbedAggResponseWriter.prototype._injectParentSplit = function (agg, key) { - var oldList = this.acrStack; - var newList = this.acrStack = []; + let oldList = this.acrStack; + let newList = this.acrStack = []; // walk from right to left through the old stack // and move things to the new stack - var injected = false; + let injected = false; if (!oldList.length) { injected = new SplitAcr(agg, null, key); @@ -173,7 +173,7 @@ define(function (require) { // walk from right to left, emptying the previous list while (oldList.length) { - var acr = oldList.pop(); + let acr = oldList.pop(); // ignore other splits if (acr instanceof SplitAcr) { @@ -187,11 +187,11 @@ define(function (require) { newList.unshift(injected); } - var newAcr = new AggConfigResult(acr.aggConfig, newList[0], acr.value, acr.aggConfig.getKey(acr)); + let newAcr = new AggConfigResult(acr.aggConfig, newList[0], acr.value, acr.aggConfig.getKey(acr)); newList.unshift(newAcr); // and replace the acr in the row buffer if its there - var rowI = this.rowBuffer.indexOf(acr); + let rowI = this.rowBuffer.indexOf(acr); if (rowI > -1) { this.rowBuffer[rowI] = newAcr; } @@ -213,7 +213,7 @@ define(function (require) { value = new AggConfigResult(agg, this.acrStack[0], value, value); } - var staskResult = this.asAggConfigResults && value.type === 'bucket'; + let staskResult = this.asAggConfigResults && value.type === 'bucket'; this.rowBuffer.push(value); if (staskResult) this.acrStack.unshift(value); @@ -235,14 +235,14 @@ define(function (require) { * @return {undefined} */ TabbedAggResponseWriter.prototype.row = function (buffer) { - var cells = buffer || this.rowBuffer.slice(0); + let cells = buffer || this.rowBuffer.slice(0); if (!this.partialRows && cells.length < this.columns.length) { return; } - var split = this.splitStack[0]; - var table = split.tables[0] || this._table(false); + let split = this.splitStack[0]; + let table = split.tables[0] || this._table(false); while (cells.length < this.columns.length) cells.push(''); table.rows.push(cells); @@ -255,7 +255,7 @@ define(function (require) { * @return {object} - the final table-tree */ TabbedAggResponseWriter.prototype.response = function () { - var columns = this.columns; + let columns = this.columns; // give the columns some metadata columns.map(function (col) { @@ -270,7 +270,7 @@ define(function (require) { if (this.canSplit) return this.root; - var table = this.root.tables[0]; + let table = this.root.tables[0]; if (!table) return; delete table.$parent; diff --git a/src/ui/public/agg_response/tabify/_table.js b/src/ui/public/agg_response/tabify/_table.js index 855a72a6b4df..ce8c800d984c 100644 --- a/src/ui/public/agg_response/tabify/_table.js +++ b/src/ui/public/agg_response/tabify/_table.js @@ -1,6 +1,6 @@ define(function (require) { return function TableProvider() { - var _ = require('lodash'); + let _ = require('lodash'); /** * Simple table class that is used to contain the rows and columns that create diff --git a/src/ui/public/agg_response/tabify/_table_group.js b/src/ui/public/agg_response/tabify/_table_group.js index 28830e82493b..9512d07b50b9 100644 --- a/src/ui/public/agg_response/tabify/_table_group.js +++ b/src/ui/public/agg_response/tabify/_table_group.js @@ -1,6 +1,6 @@ define(function (require) { return function TableGroupProvider() { - var _ = require('lodash'); + let _ = require('lodash'); /** * Simple object that wraps multiple tables. It contains information about the aggConfig diff --git a/src/ui/public/agg_response/tabify/tabify.js b/src/ui/public/agg_response/tabify/tabify.js index 4caa8ee92a93..68e78d06b673 100644 --- a/src/ui/public/agg_response/tabify/tabify.js +++ b/src/ui/public/agg_response/tabify/tabify.js @@ -1,16 +1,16 @@ define(function (require) { return function tabifyAggResponseProvider(Private, Notifier) { - var _ = require('lodash'); + let _ = require('lodash'); - var AggConfig = Private(require('ui/Vis/AggConfig')); - var TabbedAggResponseWriter = Private(require('ui/agg_response/tabify/_response_writer')); - var Buckets = Private(require('ui/agg_response/tabify/_buckets')); - var notify = new Notifier({ location: 'agg_response/tabify'}); + let AggConfig = Private(require('ui/Vis/AggConfig')); + let TabbedAggResponseWriter = Private(require('ui/agg_response/tabify/_response_writer')); + let Buckets = Private(require('ui/agg_response/tabify/_buckets')); + let notify = new Notifier({ location: 'agg_response/tabify'}); function tabifyAggResponse(vis, esResponse, respOpts) { - var write = new TabbedAggResponseWriter(vis, respOpts); + let write = new TabbedAggResponseWriter(vis, respOpts); - var topLevelBucket = _.assign({}, esResponse.aggregations, { + let topLevelBucket = _.assign({}, esResponse.aggregations, { doc_count: esResponse.hits.total }); @@ -29,13 +29,13 @@ define(function (require) { * @returns {undefined} */ function collectBucket(write, bucket, key) { - var agg = write.aggStack.shift(); + let agg = write.aggStack.shift(); switch (agg.schema.group) { case 'buckets': - var buckets = new Buckets(bucket[agg.id]); + let buckets = new Buckets(bucket[agg.id]); if (buckets.length) { - var splitting = write.canSplit && agg.schema.name === 'split'; + let splitting = write.canSplit && agg.schema.name === 'split'; if (splitting) { write.split(agg, buckets, function forEachBucket(subBucket, key) { collectBucket(write, subBucket, agg.getKey(subBucket), key); @@ -61,7 +61,7 @@ define(function (require) { } break; case 'metrics': - var value = agg.getValue(bucket); + let value = agg.getValue(bucket); write.cell(agg, value, function () { if (!write.aggStack.length) { // row complete @@ -80,7 +80,7 @@ define(function (require) { // write empty values for each bucket agg, then write // the metrics from the initial bucket using collectBucket() function passEmptyBuckets(write, bucket, key) { - var agg = write.aggStack.shift(); + let agg = write.aggStack.shift(); switch (agg.schema.group) { case 'metrics': diff --git a/src/ui/public/agg_table/agg_table.js b/src/ui/public/agg_table/agg_table.js index 2b6fe0cceccd..910dde46a5c0 100644 --- a/src/ui/public/agg_table/agg_table.js +++ b/src/ui/public/agg_table/agg_table.js @@ -6,7 +6,7 @@ define(function (require) { require('ui/modules') .get('kibana') .directive('kbnAggTable', function ($filter, config, Private, compileRecursiveDirective) { - var _ = require('lodash'); + let _ = require('lodash'); return { restrict: 'E', @@ -23,7 +23,7 @@ define(function (require) { return compileRecursiveDirective.compile($el); }, controller: function ($scope) { - var self = this; + let self = this; self.sort = null; self._saveAs = require('@spalger/filesaver').saveAs; @@ -33,15 +33,15 @@ define(function (require) { }; self.exportAsCsv = function (formatted) { - var csv = new Blob([self.toCsv(formatted)], { type: 'text/plain' }); + let csv = new Blob([self.toCsv(formatted)], { type: 'text/plain' }); self._saveAs(csv, self.csv.filename); }; self.toCsv = function (formatted) { - var rows = $scope.table.rows; - var columns = formatted ? $scope.formattedColumns : $scope.table.columns; - var nonAlphaNumRE = /[^a-zA-Z0-9]/; - var allDoubleQuoteRE = /"/g; + let rows = $scope.table.rows; + let columns = formatted ? $scope.formattedColumns : $scope.table.columns; + let nonAlphaNumRE = /[^a-zA-Z0-9]/; + let allDoubleQuoteRE = /"/g; function escape(val) { if (!formatted && _.isObject(val)) val = val.valueOf(); @@ -53,7 +53,7 @@ define(function (require) { } // escape each cell in each row - var csvRows = rows.map(function (row) { + let csvRows = rows.map(function (row) { return row.map(escape); }); @@ -68,7 +68,7 @@ define(function (require) { }; $scope.$watch('table', function () { - var table = $scope.table; + let table = $scope.table; if (!table) { $scope.rows = null; @@ -79,14 +79,14 @@ define(function (require) { self.csv.filename = ($scope.exportTitle || table.title() || 'table') + '.csv'; $scope.rows = table.rows; $scope.formattedColumns = table.columns.map(function (col, i) { - var agg = $scope.table.aggConfig(col); - var field = agg.field(); - var formattedColumn = { + let agg = $scope.table.aggConfig(col); + let field = agg.field(); + let formattedColumn = { title: col.title, filterable: field && field.filterable && agg.schema.group === 'buckets' }; - var last = i === (table.columns.length - 1); + let last = i === (table.columns.length - 1); if (last || (agg.schema.group === 'metrics')) { formattedColumn.class = 'visualize-table-right'; diff --git a/src/ui/public/agg_table/agg_table_group.js b/src/ui/public/agg_table/agg_table_group.js index c057bb051287..1476730c0032 100644 --- a/src/ui/public/agg_table/agg_table_group.js +++ b/src/ui/public/agg_table/agg_table_group.js @@ -24,10 +24,10 @@ define(function (require) { if (!group || !group.tables.length) return; - var firstTable = group.tables[0]; - var params = firstTable.aggConfig && firstTable.aggConfig.params; + let firstTable = group.tables[0]; + let params = firstTable.aggConfig && firstTable.aggConfig.params; // render groups that have Table children as if they were rows, because iteration is cleaner - var childLayout = (params && !params.row) ? 'columns' : 'rows'; + let childLayout = (params && !params.row) ? 'columns' : 'rows'; $scope[childLayout] = group.tables; }); diff --git a/src/ui/public/agg_types/AggParams.js b/src/ui/public/agg_types/AggParams.js index 503335d9c567..7713f6ee3832 100644 --- a/src/ui/public/agg_types/AggParams.js +++ b/src/ui/public/agg_types/AggParams.js @@ -2,10 +2,10 @@ define(function (require) { return function AggParamsFactory(Private) { require('ui/filters/label'); - var _ = require('lodash'); - var IndexedArray = require('ui/IndexedArray'); + let _ = require('lodash'); + let IndexedArray = require('ui/IndexedArray'); - var paramTypeMap = { + let paramTypeMap = { field: Private(require('ui/agg_types/param_types/field')), optioned: Private(require('ui/agg_types/param_types/optioned')), regex: Private(require('ui/agg_types/param_types/regex')), @@ -32,8 +32,8 @@ define(function (require) { AggParams.Super.call(this, { index: ['name'], initialSet: params.map(function (config) { - var type = config.name === 'field' ? config.name : config.type; - var Class = paramTypeMap[type] || paramTypeMap._default; + let type = config.name === 'field' ? config.name : config.type; + let Class = paramTypeMap[type] || paramTypeMap._default; return new Class(config); }) }); @@ -54,7 +54,7 @@ define(function (require) { * are dependent on the AggParam#write methods which should be studied for each AggType. */ AggParams.prototype.write = function (aggConfig, locals) { - var output = { params: {} }; + let output = { params: {} }; locals = locals || {}; this.forEach(function (param) { diff --git a/src/ui/public/agg_types/AggType.js b/src/ui/public/agg_types/AggType.js index 49e87f6253d6..e163bf7d70ed 100644 --- a/src/ui/public/agg_types/AggType.js +++ b/src/ui/public/agg_types/AggType.js @@ -1,8 +1,8 @@ define(function (require) { return function AggTypeFactory(Private) { - var _ = require('lodash'); - var AggParams = Private(require('ui/agg_types/AggParams')); - var fieldFormats = Private(require('ui/registry/field_formats')); + let _ = require('lodash'); + let AggParams = Private(require('ui/agg_types/AggParams')); + let fieldFormats = Private(require('ui/registry/field_formats')); /** * Generic AggType Constructor @@ -141,7 +141,7 @@ define(function (require) { * @return {FieldFromat} */ AggType.prototype.getFormat = function (agg) { - var field = agg.field(); + let field = agg.field(); return field ? field.format : fieldFormats.getDefaultInstance('string'); }; diff --git a/src/ui/public/agg_types/buckets/_bucket_agg_type.js b/src/ui/public/agg_types/buckets/_bucket_agg_type.js index b76e3911e0c8..d2310489e73c 100644 --- a/src/ui/public/agg_types/buckets/_bucket_agg_type.js +++ b/src/ui/public/agg_types/buckets/_bucket_agg_type.js @@ -1,7 +1,7 @@ define(function (require) { return function BucketAggTypeProvider(Private) { - var _ = require('lodash'); - var AggType = Private(require('ui/agg_types/AggType')); + let _ = require('lodash'); + let AggType = Private(require('ui/agg_types/AggType')); _.class(BucketAggType).inherits(AggType); function BucketAggType(config) { diff --git a/src/ui/public/agg_types/buckets/_bucket_count_between.js b/src/ui/public/agg_types/buckets/_bucket_count_between.js index a969011a9cfe..6e14f38040ee 100644 --- a/src/ui/public/agg_types/buckets/_bucket_count_between.js +++ b/src/ui/public/agg_types/buckets/_bucket_count_between.js @@ -14,19 +14,19 @@ define(function (require) { * @return {null|number} */ function bucketCountBetween(aggConfigA, aggConfigB) { - var aggs = aggConfigA.vis.aggs.getRequestAggs(); + let aggs = aggConfigA.vis.aggs.getRequestAggs(); - var aIndex = aggs.indexOf(aggConfigA); - var bIndex = aggs.indexOf(aggConfigB); + let aIndex = aggs.indexOf(aggConfigA); + let bIndex = aggs.indexOf(aggConfigB); if (aIndex === -1 || bIndex === -1) { return null; } // return a negative distance, if b is before a - var negative = (aIndex > bIndex); + let negative = (aIndex > bIndex); - var count = aggs + let count = aggs .slice(Math.min(aIndex, bIndex), Math.max(aIndex, bIndex)) .reduce(function (count, cfg) { if (cfg === aggConfigA || cfg === aggConfigB || cfg.schema.group !== 'buckets') { diff --git a/src/ui/public/agg_types/buckets/_interval_options.js b/src/ui/public/agg_types/buckets/_interval_options.js index fa27d2291a01..6d29637b3978 100644 --- a/src/ui/public/agg_types/buckets/_interval_options.js +++ b/src/ui/public/agg_types/buckets/_interval_options.js @@ -1,10 +1,10 @@ define(function (require) { return function IntervalOptionsService(Private) { - var moment = require('moment'); + let moment = require('moment'); require('ui/directives/input_whole_number'); // shorthand - var ms = function (type) { return moment.duration(1, type).asMilliseconds(); }; + let ms = function (type) { return moment.duration(1, type).asMilliseconds(); }; return [ { diff --git a/src/ui/public/agg_types/buckets/create_filter/date_histogram.js b/src/ui/public/agg_types/buckets/create_filter/date_histogram.js index 6040c31ac207..280e1db1173b 100644 --- a/src/ui/public/agg_types/buckets/create_filter/date_histogram.js +++ b/src/ui/public/agg_types/buckets/create_filter/date_histogram.js @@ -1,11 +1,11 @@ define(function (require) { return function createDateHistogramFilterProvider(Private) { - var moment = require('moment'); - var buildRangeFilter = require('ui/filter_manager/lib/range'); + let moment = require('moment'); + let buildRangeFilter = require('ui/filter_manager/lib/range'); return function (agg, key) { - var start = moment(key); - var interval = agg.buckets.getInterval(); + let start = moment(key); + let interval = agg.buckets.getInterval(); return buildRangeFilter(agg.params.field, { gte: start.valueOf(), diff --git a/src/ui/public/agg_types/buckets/create_filter/date_range.js b/src/ui/public/agg_types/buckets/create_filter/date_range.js index 9b075ee023f0..c5a5839bec6b 100644 --- a/src/ui/public/agg_types/buckets/create_filter/date_range.js +++ b/src/ui/public/agg_types/buckets/create_filter/date_range.js @@ -1,13 +1,13 @@ define(function (require) { - var dateRange = require('ui/utils/date_range'); + let dateRange = require('ui/utils/date_range'); return function createDateRangeFilterProvider(config) { - var buildRangeFilter = require('ui/filter_manager/lib/range'); + let buildRangeFilter = require('ui/filter_manager/lib/range'); return function (agg, key) { - var range = dateRange.parse(key, config.get('dateFormat')); + let range = dateRange.parse(key, config.get('dateFormat')); - var filter = {}; + let filter = {}; if (range.from) filter.gte = +range.from; if (range.to) filter.lt = +range.to; if (range.to && range.from) filter.format = 'epoch_millis'; diff --git a/src/ui/public/agg_types/buckets/create_filter/filters.js b/src/ui/public/agg_types/buckets/create_filter/filters.js index 89b22f6adc06..e6b6fb844ac9 100644 --- a/src/ui/public/agg_types/buckets/create_filter/filters.js +++ b/src/ui/public/agg_types/buckets/create_filter/filters.js @@ -1,11 +1,11 @@ define(function (require) { - var buildQueryFilter = require('ui/filter_manager/lib/query'); - var _ = require('lodash'); + let buildQueryFilter = require('ui/filter_manager/lib/query'); + let _ = require('lodash'); return function CreateFilterFiltersProvider(Private) { return function (aggConfig, key) { // have the aggConfig write agg dsl params - var dslFilters = _.get(aggConfig.toDsl(), 'filters.filters'); - var filter = dslFilters[key]; + let dslFilters = _.get(aggConfig.toDsl(), 'filters.filters'); + let filter = dslFilters[key]; if (filter) { return buildQueryFilter(filter.query, aggConfig.vis.indexPattern.id); diff --git a/src/ui/public/agg_types/buckets/create_filter/histogram.js b/src/ui/public/agg_types/buckets/create_filter/histogram.js index c84883a8fd5b..271d6c5a3ca1 100644 --- a/src/ui/public/agg_types/buckets/create_filter/histogram.js +++ b/src/ui/public/agg_types/buckets/create_filter/histogram.js @@ -1,9 +1,9 @@ define(function (require) { - var buildRangeFilter = require('ui/filter_manager/lib/range'); + let buildRangeFilter = require('ui/filter_manager/lib/range'); return function createHistogramFitlerProvider(Private) { return function (aggConfig, key) { - var value = parseInt(key, 10); + let value = parseInt(key, 10); return buildRangeFilter( aggConfig.params.field, diff --git a/src/ui/public/agg_types/buckets/create_filter/ip_range.js b/src/ui/public/agg_types/buckets/create_filter/ip_range.js index 7410cb5e4494..cf08d3668515 100644 --- a/src/ui/public/agg_types/buckets/create_filter/ip_range.js +++ b/src/ui/public/agg_types/buckets/create_filter/ip_range.js @@ -1,13 +1,13 @@ define(function (require) { - var CidrMask = require('ui/utils/CidrMask'); - var buildRangeFilter = require('ui/filter_manager/lib/range'); + let CidrMask = require('ui/utils/CidrMask'); + let buildRangeFilter = require('ui/filter_manager/lib/range'); return function createIpRangeFilterProvider() { return function (aggConfig, key) { let range; if (aggConfig.params.ipRangeType === 'mask') { range = new CidrMask(key).getRange(); } else { - var addresses = key.split(/\-/); + let addresses = key.split(/\-/); range = { from: addresses[0], to: addresses[1] diff --git a/src/ui/public/agg_types/buckets/create_filter/range.js b/src/ui/public/agg_types/buckets/create_filter/range.js index 70af0a2c1909..ecec60143e03 100644 --- a/src/ui/public/agg_types/buckets/create_filter/range.js +++ b/src/ui/public/agg_types/buckets/create_filter/range.js @@ -1,5 +1,5 @@ define(function (require) { - var buildRangeFilter = require('ui/filter_manager/lib/range'); + let buildRangeFilter = require('ui/filter_manager/lib/range'); return function createRangeFilterProvider(Private) { return function (aggConfig, key) { return buildRangeFilter( diff --git a/src/ui/public/agg_types/buckets/create_filter/terms.js b/src/ui/public/agg_types/buckets/create_filter/terms.js index db2361bffe2f..7ebc9a91e849 100644 --- a/src/ui/public/agg_types/buckets/create_filter/terms.js +++ b/src/ui/public/agg_types/buckets/create_filter/terms.js @@ -1,5 +1,5 @@ define(function (require) { - var buildPhraseFilter = require('ui/filter_manager/lib/phrase'); + let buildPhraseFilter = require('ui/filter_manager/lib/phrase'); return function createTermsFilterProvider(Private) { return function (aggConfig, key) { return buildPhraseFilter(aggConfig.params.field, key, aggConfig.vis.indexPattern); diff --git a/src/ui/public/agg_types/buckets/date_histogram.js b/src/ui/public/agg_types/buckets/date_histogram.js index afe98ec5c6ff..e871b221bc09 100644 --- a/src/ui/public/agg_types/buckets/date_histogram.js +++ b/src/ui/public/agg_types/buckets/date_histogram.js @@ -1,19 +1,19 @@ define(function (require) { return function DateHistogramAggType(timefilter, config, Private) { - var _ = require('lodash'); - var moment = require('moment'); - var tzDetect = require('jstimezonedetect').jstz; - var BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); - var TimeBuckets = Private(require('ui/time_buckets')); - var createFilter = Private(require('ui/agg_types/buckets/create_filter/date_histogram')); - var intervalOptions = Private(require('ui/agg_types/buckets/_interval_options')); - var configDefaults = Private(require('ui/config/defaults')); - - var detectedTimezone = tzDetect.determine().name(); - var tzOffset = moment().format('Z'); + let _ = require('lodash'); + let moment = require('moment'); + let tzDetect = require('jstimezonedetect').jstz; + let BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); + let TimeBuckets = Private(require('ui/time_buckets')); + let createFilter = Private(require('ui/agg_types/buckets/create_filter/date_histogram')); + let intervalOptions = Private(require('ui/agg_types/buckets/_interval_options')); + let configDefaults = Private(require('ui/config/defaults')); + + let detectedTimezone = tzDetect.determine().name(); + let tzOffset = moment().format('Z'); function getInterval(agg) { - var interval = _.get(agg, ['params', 'interval']); + let interval = _.get(agg, ['params', 'interval']); if (interval && interval.val === 'custom') interval = _.get(agg, ['params', 'customInterval']); return interval; } @@ -34,8 +34,8 @@ define(function (require) { date: true }, makeLabel: function (agg) { - var output = this.params.write(agg); - var params = output.params; + let output = this.params.write(agg); + let params = output.params; return params.field + ' per ' + (output.metricScaleText || output.bucketInterval.description); }, createFilter: createFilter, @@ -76,7 +76,7 @@ define(function (require) { name: 'interval', type: 'optioned', deserialize: function (state) { - var interval = _.find(intervalOptions, {val: state}); + let interval = _.find(intervalOptions, {val: state}); return interval || _.find(intervalOptions, function (option) { // For upgrading from 4.0.x to 4.1.x - intervals are now stored as 'y' instead of 'year', // but this maps the old values to the new values @@ -93,16 +93,16 @@ define(function (require) { setBounds(agg); agg.buckets.setInterval(getInterval(agg)); - var interval = agg.buckets.getInterval(); + let interval = agg.buckets.getInterval(); output.bucketInterval = interval; output.params.interval = interval.expression; - var isDefaultTimezone = config.get('dateFormat:tz') === configDefaults['dateFormat:tz'].value; + let isDefaultTimezone = config.get('dateFormat:tz') === configDefaults['dateFormat:tz'].value; output.params.time_zone = isDefaultTimezone ? (detectedTimezone || tzOffset) : config.get('dateFormat:tz'); - var scaleMetrics = interval.scaled && interval.scale < 1; + let scaleMetrics = interval.scaled && interval.scale < 1; if (scaleMetrics) { scaleMetrics = _.every(agg.vis.aggs.bySchemaGroup.metrics, function (agg) { return agg.type && (agg.type.name === 'count' || agg.type.name === 'sum'); @@ -135,7 +135,7 @@ define(function (require) { name: 'extended_bounds', default: {}, write: function (agg, output) { - var val = agg.params.extended_bounds; + let val = agg.params.extended_bounds; if (val.min != null || val.max != null) { output.params.extended_bounds = { @@ -146,7 +146,7 @@ define(function (require) { return; } - var bounds = timefilter.getActiveBounds(); + let bounds = timefilter.getActiveBounds(); if (bounds) { output.params.extended_bounds = { min: moment(bounds.min).valueOf(), diff --git a/src/ui/public/agg_types/buckets/date_range.js b/src/ui/public/agg_types/buckets/date_range.js index 9296485a425b..a9144d66a1d5 100644 --- a/src/ui/public/agg_types/buckets/date_range.js +++ b/src/ui/public/agg_types/buckets/date_range.js @@ -1,12 +1,12 @@ define(function (require) { - var moment = require('moment'); - var dateRange = require('ui/utils/date_range'); + let moment = require('moment'); + let dateRange = require('ui/utils/date_range'); require('ui/directives/validate_date_math'); return function DateRangeAggDefinition(Private, config) { - var BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); - var createFilter = Private(require('ui/agg_types/buckets/create_filter/date_range')); - var fieldFormats = Private(require('ui/registry/field_formats')); + let BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); + let createFilter = Private(require('ui/agg_types/buckets/create_filter/date_range')); + let fieldFormats = Private(require('ui/registry/field_formats')); return new BucketAggType({ @@ -14,7 +14,7 @@ define(function (require) { title: 'Date Range', createFilter: createFilter, getKey: function (bucket, key, agg) { - var formatter = agg.fieldOwnFormatter('text', fieldFormats.getDefaultInstance('date')); + let formatter = agg.fieldOwnFormatter('text', fieldFormats.getDefaultInstance('date')); return dateRange.toString(bucket, formatter); }, getFormat: function () { diff --git a/src/ui/public/agg_types/buckets/filters.js b/src/ui/public/agg_types/buckets/filters.js index 07d9fffe2268..da31d270a055 100644 --- a/src/ui/public/agg_types/buckets/filters.js +++ b/src/ui/public/agg_types/buckets/filters.js @@ -1,11 +1,11 @@ define(function (require) { return function FiltersAggDefinition(Private, Notifier) { - var _ = require('lodash'); - var angular = require('angular'); - var BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); - var createFilter = Private(require('ui/agg_types/buckets/create_filter/filters')); - var decorateQuery = Private(require('ui/courier/data_source/_decorate_query')); - var notif = new Notifier({ location: 'Filters Agg' }); + let _ = require('lodash'); + let angular = require('angular'); + let BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); + let createFilter = Private(require('ui/agg_types/buckets/create_filter/filters')); + let decorateQuery = Private(require('ui/courier/data_source/_decorate_query')); + let notif = new Notifier({ location: 'Filters Agg' }); return new BucketAggType({ name: 'filters', @@ -18,25 +18,25 @@ define(function (require) { editor: require('ui/agg_types/controls/filters.html'), default: [ {input: {}, label: ''} ], write: function (aggConfig, output) { - var inFilters = aggConfig.params.filters; + let inFilters = aggConfig.params.filters; if (!_.size(inFilters)) return; - var outFilters = _.transform(inFilters, function (filters, filter) { - var input = filter.input; + let outFilters = _.transform(inFilters, function (filters, filter) { + let input = filter.input; if (!input) return notif.log('malformed filter agg params, missing "input" query'); - var query = input.query; + let query = input.query; if (!query) return notif.log('malformed filter agg params, missing "query" on input'); decorateQuery(query); - var label = filter.label || _.get(query, 'query_string.query') || angular.toJson(query); + let label = filter.label || _.get(query, 'query_string.query') || angular.toJson(query); filters[label] = input; }, {}); if (!_.size(outFilters)) return; - var params = output.params || (output.params = {}); + let params = output.params || (output.params = {}); params.filters = outFilters; } } diff --git a/src/ui/public/agg_types/buckets/geo_hash.js b/src/ui/public/agg_types/buckets/geo_hash.js index 471b051fc7df..9cb202c32c12 100644 --- a/src/ui/public/agg_types/buckets/geo_hash.js +++ b/src/ui/public/agg_types/buckets/geo_hash.js @@ -1,12 +1,12 @@ define(function (require) { return function GeoHashAggDefinition(Private, config) { - var _ = require('lodash'); - var moment = require('moment'); - var BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); - var defaultPrecision = 2; + let _ = require('lodash'); + let moment = require('moment'); + let BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); + let defaultPrecision = 2; function getPrecision(precision) { - var maxPrecision = _.parseInt(config.get('visualization:tileMap:maxPrecision')); + let maxPrecision = _.parseInt(config.get('visualization:tileMap:maxPrecision')); precision = parseInt(precision, 10); diff --git a/src/ui/public/agg_types/buckets/histogram.js b/src/ui/public/agg_types/buckets/histogram.js index 416b387d0162..13f67952607c 100644 --- a/src/ui/public/agg_types/buckets/histogram.js +++ b/src/ui/public/agg_types/buckets/histogram.js @@ -1,9 +1,9 @@ define(function (require) { return function HistogramAggDefinition(Private) { - var _ = require('lodash'); - var moment = require('moment'); - var BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); - var createFilter = Private(require('ui/agg_types/buckets/create_filter/histogram')); + let _ = require('lodash'); + let moment = require('moment'); + let BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); + let createFilter = Private(require('ui/agg_types/buckets/create_filter/histogram')); require('ui/validateDateInterval'); @@ -45,7 +45,7 @@ define(function (require) { default: {}, editor: require('ui/agg_types/controls/extended_bounds.html'), write: function (aggConfig, output) { - var val = aggConfig.params.extended_bounds; + let val = aggConfig.params.extended_bounds; if (val.min != null || val.max != null) { output.params.extended_bounds = { @@ -57,7 +57,7 @@ define(function (require) { // called from the editor shouldShow: function (aggConfig) { - var field = aggConfig.params.field; + let field = aggConfig.params.field; if ( field && (field.type === 'number' || field.type === 'date') diff --git a/src/ui/public/agg_types/buckets/ip_range.js b/src/ui/public/agg_types/buckets/ip_range.js index 2eeee56bd026..a8e4dc2822a7 100644 --- a/src/ui/public/agg_types/buckets/ip_range.js +++ b/src/ui/public/agg_types/buckets/ip_range.js @@ -1,11 +1,11 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); require('ui/directives/validate_ip'); require('ui/directives/validate_cidr_mask'); return function RangeAggDefinition(Private) { - var BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); - var createFilter = Private(require('ui/agg_types/buckets/create_filter/ip_range')); + let BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); + let createFilter = Private(require('ui/agg_types/buckets/create_filter/ip_range')); return new BucketAggType({ name: 'ip_range', @@ -36,7 +36,7 @@ define(function (require) { }, editor: require('ui/agg_types/controls/ip_ranges.html'), write: function (aggConfig, output) { - var ipRangeType = aggConfig.params.ipRangeType; + let ipRangeType = aggConfig.params.ipRangeType; output.params.ranges = aggConfig.params.ranges[ipRangeType]; } } diff --git a/src/ui/public/agg_types/buckets/range.js b/src/ui/public/agg_types/buckets/range.js index d5cb36398718..31fc2bd03449 100644 --- a/src/ui/public/agg_types/buckets/range.js +++ b/src/ui/public/agg_types/buckets/range.js @@ -1,13 +1,13 @@ define(function (require) { return function RangeAggDefinition(Private) { - var _ = require('lodash'); - var BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); - var createFilter = Private(require('ui/agg_types/buckets/create_filter/range')); - var FieldFormat = Private(require('ui/index_patterns/_field_format/FieldFormat')); - var RangeKey = Private(require('./RangeKey')); + let _ = require('lodash'); + let BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); + let createFilter = Private(require('ui/agg_types/buckets/create_filter/range')); + let FieldFormat = Private(require('ui/index_patterns/_field_format/FieldFormat')); + let RangeKey = Private(require('./RangeKey')); - var keyCaches = new WeakMap(); - var formats = new WeakMap(); + let keyCaches = new WeakMap(); + let formats = new WeakMap(); return new BucketAggType({ name: 'range', @@ -17,14 +17,14 @@ define(function (require) { return aggConfig.params.field.displayName + ' ranges'; }, getKey: function (bucket, key, agg) { - var keys = keyCaches.get(agg); + let keys = keyCaches.get(agg); if (!keys) { keys = new Map(); keyCaches.set(agg, keys); } - var id = RangeKey.idBucket(bucket); + let id = RangeKey.idBucket(bucket); key = keys.get(id); if (!key) { diff --git a/src/ui/public/agg_types/buckets/significant_terms.js b/src/ui/public/agg_types/buckets/significant_terms.js index 65b833ea124c..ebd74ebd8370 100644 --- a/src/ui/public/agg_types/buckets/significant_terms.js +++ b/src/ui/public/agg_types/buckets/significant_terms.js @@ -1,8 +1,8 @@ define(function (require) { return function SignificantTermsAggDefinition(Private) { - var _ = require('lodash'); - var BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); - var createFilter = Private(require('ui/agg_types/buckets/create_filter/terms')); + let _ = require('lodash'); + let BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); + let createFilter = Private(require('ui/agg_types/buckets/create_filter/terms')); return new BucketAggType({ name: 'significant_terms', diff --git a/src/ui/public/agg_types/buckets/terms.js b/src/ui/public/agg_types/buckets/terms.js index c9eecec142e1..1bfc5bbf4852 100644 --- a/src/ui/public/agg_types/buckets/terms.js +++ b/src/ui/public/agg_types/buckets/terms.js @@ -1,13 +1,13 @@ define(function (require) { return function TermsAggDefinition(Private) { - var _ = require('lodash'); - var BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); - var bucketCountBetween = Private(require('ui/agg_types/buckets/_bucket_count_between')); - var AggConfig = Private(require('ui/Vis/AggConfig')); - var Schemas = Private(require('ui/Vis/Schemas')); - var createFilter = Private(require('ui/agg_types/buckets/create_filter/terms')); - - var orderAggSchema = (new Schemas([ + let _ = require('lodash'); + let BucketAggType = Private(require('ui/agg_types/buckets/_bucket_agg_type')); + let bucketCountBetween = Private(require('ui/agg_types/buckets/_bucket_count_between')); + let AggConfig = Private(require('ui/Vis/AggConfig')); + let Schemas = Private(require('ui/Vis/Schemas')); + let createFilter = Private(require('ui/agg_types/buckets/create_filter/terms')); + + let orderAggSchema = (new Schemas([ { group: 'none', name: 'orderAgg', @@ -18,7 +18,7 @@ define(function (require) { function isNotType(type) { return function (agg) { - var field = agg.params.field; + let field = agg.params.field; return !field || field.type !== type; }; } @@ -27,7 +27,7 @@ define(function (require) { name: 'terms', title: 'Terms', makeLabel: function (agg) { - var params = agg.params; + let params = agg.params; return params.field.displayName + ': ' + params.order.display; }, createFilter: createFilter, @@ -67,7 +67,7 @@ define(function (require) { makeOrderAgg: function (termsAgg, state) { state = state || {}; state.schema = orderAggSchema; - var orderAgg = new AggConfig(termsAgg.vis, state); + let orderAgg = new AggConfig(termsAgg.vis, state); orderAgg.id = termsAgg.id + '-orderAgg'; return orderAgg; }, @@ -80,18 +80,18 @@ define(function (require) { } }; - var INIT = {}; // flag to know when prevOrderBy has changed - var prevOrderBy = INIT; + let INIT = {}; // flag to know when prevOrderBy has changed + let prevOrderBy = INIT; $scope.$watch('responseValueAggs', updateOrderAgg); $scope.$watch('agg.params.orderBy', updateOrderAgg); function updateOrderAgg() { - var agg = $scope.agg; - var aggs = agg.vis.aggs; - var params = agg.params; - var orderBy = params.orderBy; - var paramDef = agg.type.params.byName.orderAgg; + let agg = $scope.agg; + let aggs = agg.vis.aggs; + let params = agg.params; + let orderBy = params.orderBy; + let paramDef = agg.type.params.byName.orderAgg; // setup the initial value of orderBy if (!orderBy && prevOrderBy === INIT) { @@ -124,11 +124,11 @@ define(function (require) { } }, write: function (agg, output) { - var vis = agg.vis; - var dir = agg.params.order.val; - var order = output.params.order = {}; + let vis = agg.vis; + let dir = agg.params.order.val; + let order = output.params.order = {}; - var orderAgg = agg.params.orderAgg || vis.aggs.getResponseAggById(agg.params.orderBy); + let orderAgg = agg.params.orderAgg || vis.aggs.getResponseAggById(agg.params.orderBy); // TODO: This works around an Elasticsearch bug the always casts terms agg scripts to strings // thus causing issues with filtering. This probably causes other issues since float might not @@ -147,7 +147,7 @@ define(function (require) { return; } - var orderAggId = orderAgg.id; + let orderAggId = orderAgg.id; if (orderAgg.parentId) { orderAgg = vis.aggs.byId[orderAgg.parentId]; } diff --git a/src/ui/public/agg_types/index.js b/src/ui/public/agg_types/index.js index 16395c10f8aa..c50aad6aecaa 100644 --- a/src/ui/public/agg_types/index.js +++ b/src/ui/public/agg_types/index.js @@ -1,8 +1,8 @@ define(function (require) { return function AggTypeService(Private) { - var IndexedArray = require('ui/IndexedArray'); + let IndexedArray = require('ui/IndexedArray'); - var aggs = { + let aggs = { metrics: [ Private(require('ui/agg_types/metrics/count')), Private(require('ui/agg_types/metrics/avg')), diff --git a/src/ui/public/agg_types/metrics/MetricAggType.js b/src/ui/public/agg_types/metrics/MetricAggType.js index a33d7a9c1643..08a305843c1e 100644 --- a/src/ui/public/agg_types/metrics/MetricAggType.js +++ b/src/ui/public/agg_types/metrics/MetricAggType.js @@ -1,8 +1,8 @@ define(function (require) { return function MetricAggTypeProvider(Private) { - var _ = require('lodash'); - var AggType = Private(require('ui/agg_types/AggType')); - var fieldFormats = Private(require('ui/registry/field_formats')); + let _ = require('lodash'); + let AggType = Private(require('ui/agg_types/AggType')); + let fieldFormats = Private(require('ui/registry/field_formats')); _.class(MetricAggType).inherits(AggType); function MetricAggType(config) { @@ -23,7 +23,7 @@ define(function (require) { */ MetricAggType.prototype.getValue = function (agg, bucket) { // Metric types where an empty set equals `zero` - var isSettableToZero = ['cardinality', 'sum'].indexOf(agg.__type.name) !== -1; + let isSettableToZero = ['cardinality', 'sum'].indexOf(agg.__type.name) !== -1; // Return proper values when no buckets are present // `Count` handles empty sets properly @@ -41,7 +41,7 @@ define(function (require) { * @return {FieldFromat} */ MetricAggType.prototype.getFormat = function (agg) { - var field = agg.field(); + let field = agg.field(); return field ? field.format : fieldFormats.getDefaultInstance('number'); }; diff --git a/src/ui/public/agg_types/metrics/avg.js b/src/ui/public/agg_types/metrics/avg.js index 1a7a1abb755c..9059c9cf46ce 100644 --- a/src/ui/public/agg_types/metrics/avg.js +++ b/src/ui/public/agg_types/metrics/avg.js @@ -1,6 +1,6 @@ define(function (require) { return function AggTypeMetricAvgProvider(Private) { - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); return new MetricAggType({ name: 'avg', diff --git a/src/ui/public/agg_types/metrics/cardinality.js b/src/ui/public/agg_types/metrics/cardinality.js index f4eef38de8b4..556ef1d142dc 100644 --- a/src/ui/public/agg_types/metrics/cardinality.js +++ b/src/ui/public/agg_types/metrics/cardinality.js @@ -1,7 +1,7 @@ define(function (require) { return function AggTypeMetricCardinalityProvider(Private) { - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); - var fieldFormats = Private(require('ui/registry/field_formats')); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let fieldFormats = Private(require('ui/registry/field_formats')); return new MetricAggType({ name: 'cardinality', diff --git a/src/ui/public/agg_types/metrics/count.js b/src/ui/public/agg_types/metrics/count.js index a4d49d3084dc..d455c974d749 100644 --- a/src/ui/public/agg_types/metrics/count.js +++ b/src/ui/public/agg_types/metrics/count.js @@ -1,7 +1,7 @@ define(function (require) { return function AggTypeMetricCountProvider(Private) { - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); - var fieldFormats = Private(require('ui/registry/field_formats')); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let fieldFormats = Private(require('ui/registry/field_formats')); return new MetricAggType({ name: 'count', diff --git a/src/ui/public/agg_types/metrics/getResponseAggConfigClass.js b/src/ui/public/agg_types/metrics/getResponseAggConfigClass.js index 69314d64a80b..53ae902a3c70 100644 --- a/src/ui/public/agg_types/metrics/getResponseAggConfigClass.js +++ b/src/ui/public/agg_types/metrics/getResponseAggConfigClass.js @@ -1,6 +1,6 @@ define(function (require) { return function ResponseAggConfigProvider() { - var _ = require('lodash'); + let _ = require('lodash'); /** * Get the ResponseAggConfig class for an aggConfig, @@ -31,7 +31,7 @@ define(function (require) { this.key = key; this.parentId = this.id; - var subId = String(key); + let subId = String(key); if (subId.indexOf('.') > -1) { this.id = this.parentId + '[\'' + subId.replace(/'/g, '\\\'') + '\']'; } else { diff --git a/src/ui/public/agg_types/metrics/max.js b/src/ui/public/agg_types/metrics/max.js index aef10513b421..b1f26dfeafc2 100644 --- a/src/ui/public/agg_types/metrics/max.js +++ b/src/ui/public/agg_types/metrics/max.js @@ -1,6 +1,6 @@ define(function (require) { return function AggTypeMetricMaxProvider(Private) { - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); return new MetricAggType({ name: 'max', diff --git a/src/ui/public/agg_types/metrics/median.js b/src/ui/public/agg_types/metrics/median.js index 9b8f982ded54..72d390d99974 100644 --- a/src/ui/public/agg_types/metrics/median.js +++ b/src/ui/public/agg_types/metrics/median.js @@ -1,9 +1,9 @@ define(function (require) { return function AggTypeMetricMaxProvider(Private) { - var _ = require('lodash'); - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); - var getResponseAggConfigClass = Private(require('ui/agg_types/metrics/getResponseAggConfigClass')); - var percentiles = Private(require('ui/agg_types/metrics/percentiles')); + let _ = require('lodash'); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let getResponseAggConfigClass = Private(require('ui/agg_types/metrics/getResponseAggConfigClass')); + let percentiles = Private(require('ui/agg_types/metrics/percentiles')); return new MetricAggType({ name: 'median', diff --git a/src/ui/public/agg_types/metrics/min.js b/src/ui/public/agg_types/metrics/min.js index 250a5001b148..e12d0f547e8b 100644 --- a/src/ui/public/agg_types/metrics/min.js +++ b/src/ui/public/agg_types/metrics/min.js @@ -1,6 +1,6 @@ define(function (require) { return function AggTypeMetricMinProvider(Private) { - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); return new MetricAggType({ name: 'min', diff --git a/src/ui/public/agg_types/metrics/percentile_ranks.js b/src/ui/public/agg_types/metrics/percentile_ranks.js index 15c3a74e9839..376b8fff62b8 100644 --- a/src/ui/public/agg_types/metrics/percentile_ranks.js +++ b/src/ui/public/agg_types/metrics/percentile_ranks.js @@ -1,19 +1,19 @@ define(function (require) { return function AggTypeMetricPercentileRanksProvider(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); - var getResponseAggConfigClass = Private(require('ui/agg_types/metrics/getResponseAggConfigClass')); - var fieldFormats = Private(require('ui/registry/field_formats')); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let getResponseAggConfigClass = Private(require('ui/agg_types/metrics/getResponseAggConfigClass')); + let fieldFormats = Private(require('ui/registry/field_formats')); - var valuesEditor = require('ui/agg_types/controls/percentile_ranks.html'); + let valuesEditor = require('ui/agg_types/controls/percentile_ranks.html'); // required by the values editor require('ui/number_list'); - var valueProps = { + let valueProps = { makeLabel: function () { - var field = this.field(); - var format = (field && field.format) || fieldFormats.getDefaultInstance('number'); + let field = this.field(); + let format = (field && field.format) || fieldFormats.getDefaultInstance('number'); return 'Percentile rank ' + format.convert(this.key, 'text') + ' of "' + this.fieldDisplayName() + '"'; } @@ -37,7 +37,7 @@ define(function (require) { } ], getResponseAggs: function (agg) { - var ValueAggConfig = getResponseAggConfigClass(agg, valueProps); + let ValueAggConfig = getResponseAggConfigClass(agg, valueProps); return agg.params.values.map(function (value) { return new ValueAggConfig(value); diff --git a/src/ui/public/agg_types/metrics/percentiles.js b/src/ui/public/agg_types/metrics/percentiles.js index 1b859a4293d4..10a244ea843c 100644 --- a/src/ui/public/agg_types/metrics/percentiles.js +++ b/src/ui/public/agg_types/metrics/percentiles.js @@ -1,17 +1,17 @@ define(function (require) { return function AggTypeMetricPercentilesProvider(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); - var getResponseAggConfigClass = Private(require('ui/agg_types/metrics/getResponseAggConfigClass')); - var ordinalSuffix = require('ui/utils/ordinal_suffix'); - var fieldFormats = Private(require('ui/registry/field_formats')); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let getResponseAggConfigClass = Private(require('ui/agg_types/metrics/getResponseAggConfigClass')); + let ordinalSuffix = require('ui/utils/ordinal_suffix'); + let fieldFormats = Private(require('ui/registry/field_formats')); - var percentsEditor = require('ui/agg_types/controls/percentiles.html'); + let percentsEditor = require('ui/agg_types/controls/percentiles.html'); // required by the percentiles editor require('ui/number_list'); - var valueProps = { + let valueProps = { makeLabel: function () { return ordinalSuffix(this.key) + ' percentile of ' + this.fieldDisplayName(); } @@ -35,7 +35,7 @@ define(function (require) { } ], getResponseAggs: function (agg) { - var ValueAggConfig = getResponseAggConfigClass(agg, valueProps); + let ValueAggConfig = getResponseAggConfigClass(agg, valueProps); return agg.params.percents.map(function (percent) { return new ValueAggConfig(percent); diff --git a/src/ui/public/agg_types/metrics/stdDeviation.js b/src/ui/public/agg_types/metrics/stdDeviation.js index 9a7a7ad27ddc..5888715cb70d 100644 --- a/src/ui/public/agg_types/metrics/stdDeviation.js +++ b/src/ui/public/agg_types/metrics/stdDeviation.js @@ -1,16 +1,16 @@ define(function (require) { return function AggTypeMetricStandardDeviationProvider(Private) { - var _ = require('lodash'); - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); - var getResponseAggConfigClass = Private(require('ui/agg_types/metrics/getResponseAggConfigClass')); + let _ = require('lodash'); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let getResponseAggConfigClass = Private(require('ui/agg_types/metrics/getResponseAggConfigClass')); - var responseAggConfigProps = { + let responseAggConfigProps = { valProp: function () { - var details = this.keyedDetails[this.key]; + let details = this.keyedDetails[this.key]; return details.valProp; }, makeLabel: function () { - var details = this.keyedDetails[this.key]; + let details = this.keyedDetails[this.key]; return details.title + ' of ' + this.fieldDisplayName(); }, keyedDetails: { @@ -44,7 +44,7 @@ define(function (require) { ], getResponseAggs: function (agg) { - var ValueAggConfig = getResponseAggConfigClass(agg, responseAggConfigProps); + let ValueAggConfig = getResponseAggConfigClass(agg, responseAggConfigProps); return [ new ValueAggConfig('std_lower'), diff --git a/src/ui/public/agg_types/metrics/sum.js b/src/ui/public/agg_types/metrics/sum.js index 5eced3aea75b..75eb482d726b 100644 --- a/src/ui/public/agg_types/metrics/sum.js +++ b/src/ui/public/agg_types/metrics/sum.js @@ -1,6 +1,6 @@ define(function (require) { return function AggTypeMetricSumProvider(Private) { - var MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); + let MetricAggType = Private(require('ui/agg_types/metrics/MetricAggType')); return new MetricAggType({ name: 'sum', diff --git a/src/ui/public/agg_types/param_types/base.js b/src/ui/public/agg_types/param_types/base.js index e0be2ae5b13e..19d8cfb331db 100644 --- a/src/ui/public/agg_types/param_types/base.js +++ b/src/ui/public/agg_types/param_types/base.js @@ -1,6 +1,6 @@ define(function (require) { return function BaseAggParamFactory() { - var _ = require('lodash'); + let _ = require('lodash'); function BaseAggParam(config) { _.assign(this, config); diff --git a/src/ui/public/agg_types/param_types/field.js b/src/ui/public/agg_types/param_types/field.js index 8a697da80f9a..0d6550867d63 100644 --- a/src/ui/public/agg_types/param_types/field.js +++ b/src/ui/public/agg_types/param_types/field.js @@ -1,10 +1,10 @@ define(function (require) { return function FieldAggParamFactory(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var editorHtml = require('ui/agg_types/controls/field.html'); - var BaseAggParam = Private(require('ui/agg_types/param_types/base')); - var SavedObjectNotFound = require('ui/errors').SavedObjectNotFound; + let editorHtml = require('ui/agg_types/controls/field.html'); + let BaseAggParam = Private(require('ui/agg_types/param_types/base')); + let SavedObjectNotFound = require('ui/errors').SavedObjectNotFound; _.class(FieldAggParam).inherits(BaseAggParam); function FieldAggParam(config) { @@ -33,7 +33,7 @@ define(function (require) { * @return {field} */ FieldAggParam.prototype.deserialize = function (fieldName, aggConfig) { - var field = aggConfig.vis.indexPattern.fields.byName[fieldName]; + let field = aggConfig.vis.indexPattern.fields.byName[fieldName]; if (!field) { throw new SavedObjectNotFound('index-pattern-field', fieldName); @@ -53,7 +53,7 @@ define(function (require) { * @return {undefined} */ FieldAggParam.prototype.write = function (aggConfig, output) { - var field = aggConfig.params.field; + let field = aggConfig.params.field; if (field.scripted) { output.params.script = field.script; diff --git a/src/ui/public/agg_types/param_types/optioned.js b/src/ui/public/agg_types/param_types/optioned.js index 5d42ddf4e89b..fd7e692d8c36 100644 --- a/src/ui/public/agg_types/param_types/optioned.js +++ b/src/ui/public/agg_types/param_types/optioned.js @@ -1,9 +1,9 @@ define(function (require) { return function OptionedAggParamFactory(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var IndexedArray = require('ui/IndexedArray'); - var BaseAggParam = Private(require('ui/agg_types/param_types/base')); + let IndexedArray = require('ui/IndexedArray'); + let BaseAggParam = Private(require('ui/agg_types/param_types/base')); _.class(OptionedAggParam).inherits(BaseAggParam); function OptionedAggParam(config) { diff --git a/src/ui/public/agg_types/param_types/raw_json.js b/src/ui/public/agg_types/param_types/raw_json.js index 5cc0dcd14770..ad4f2b48712a 100644 --- a/src/ui/public/agg_types/param_types/raw_json.js +++ b/src/ui/public/agg_types/param_types/raw_json.js @@ -1,9 +1,9 @@ define(function (require) { return function RawJSONAggParamFactory(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var BaseAggParam = Private(require('ui/agg_types/param_types/base')); - var editorHtml = require('ui/agg_types/controls/raw_json.html'); + let BaseAggParam = Private(require('ui/agg_types/param_types/base')); + let editorHtml = require('ui/agg_types/controls/raw_json.html'); _.class(RawJSONAggParam).inherits(BaseAggParam); function RawJSONAggParam(config) { @@ -26,7 +26,7 @@ define(function (require) { */ RawJSONAggParam.prototype.write = function (aggConfig, output) { let paramJSON; - var param = aggConfig.params[this.name]; + let param = aggConfig.params[this.name]; if (!param) { return; @@ -45,7 +45,7 @@ define(function (require) { .keys() .union(_.keys(b)) .transform(function (dest, key) { - var val = compare(a[key], b[key]); + let val = compare(a[key], b[key]); if (val !== undefined) dest[key] = val; }, {}) .value(); diff --git a/src/ui/public/agg_types/param_types/regex.js b/src/ui/public/agg_types/param_types/regex.js index ea1a3165b5c4..9b5ef8cd6400 100644 --- a/src/ui/public/agg_types/param_types/regex.js +++ b/src/ui/public/agg_types/param_types/regex.js @@ -1,14 +1,14 @@ define(function (require) { return function RegexAggParamFactory(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var BaseAggParam = Private(require('ui/agg_types/param_types/base')); - var editorHtml = require('ui/agg_types/controls/regular_expression.html'); + let BaseAggParam = Private(require('ui/agg_types/param_types/base')); + let editorHtml = require('ui/agg_types/controls/regular_expression.html'); _.class(RegexAggParam).inherits(BaseAggParam); function RegexAggParam(config) { // Java RegExp flags - var flags = [ + let flags = [ 'CANON_EQ', 'CASE_INSENSITIVE', 'COMMENTS', @@ -46,15 +46,15 @@ define(function (require) { * @return {undefined} */ RegexAggParam.prototype.write = function (aggConfig, output) { - var param = aggConfig.params[this.name]; - var paramType = aggConfig.type.params.byName[this.name]; + let param = aggConfig.params[this.name]; + let paramType = aggConfig.type.params.byName[this.name]; // clear aggParam if pattern is not set or is disabled if (!param || !param.pattern || !param.pattern.length || paramType.disabled(aggConfig)) { return; } - var obj = { + let obj = { pattern: param.pattern }; diff --git a/src/ui/public/agg_types/param_types/string.js b/src/ui/public/agg_types/param_types/string.js index e6135741e897..76014d93d75e 100644 --- a/src/ui/public/agg_types/param_types/string.js +++ b/src/ui/public/agg_types/param_types/string.js @@ -1,9 +1,9 @@ define(function (require) { return function FieldAggParamFactory(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var editorHtml = require('ui/agg_types/controls/string.html'); - var BaseAggParam = Private(require('ui/agg_types/param_types/base')); + let editorHtml = require('ui/agg_types/controls/string.html'); + let BaseAggParam = Private(require('ui/agg_types/param_types/base')); _.class(ScriptAggParam).inherits(BaseAggParam); function ScriptAggParam(config) { diff --git a/src/ui/public/bind/bind.js b/src/ui/public/bind/bind.js index fe229ad68ade..7863a202d3f4 100644 --- a/src/ui/public/bind/bind.js +++ b/src/ui/public/bind/bind.js @@ -1,6 +1,6 @@ define(function (require) { - var _ = require('lodash'); - var angular = require('angular'); + let _ = require('lodash'); + let angular = require('angular'); require('ui/modules').get('kibana') .config(function ($provide) { @@ -27,26 +27,26 @@ define(function (require) { * @return {undefined} */ $delegate.constructor.prototype.$bind = function (to, from, $sourceScope) { - var $source = $sourceScope || this.$parent; - var $target = this; + let $source = $sourceScope || this.$parent; + let $target = this; // parse expressions - var $to = $parse(to); + let $to = $parse(to); if (!$to.assign) errorNotAssignable(to, from); - var $from = $parse(from); + let $from = $parse(from); // bind scopes to expressions - var getTarget = function () { return $to($target); }; - var setTarget = function (v) { return $to.assign($target, v); }; - var getSource = function () { return $from($source); }; - var setSource = function (v) { return $from.assignOrFail($source, v); }; + let getTarget = function () { return $to($target); }; + let setTarget = function (v) { return $to.assign($target, v); }; + let getSource = function () { return $from($source); }; + let setSource = function (v) { return $from.assignOrFail($source, v); }; // to support writing from the child to the parent we need to know // which source has changed. Track the source value and anytime it // changes (even if the target value changed too) push from source // to target. If the source hasn't changed then the change is from // the target and push accordingly - var lastSourceVal = getSource(); + let lastSourceVal = getSource(); $from.assignOrFail = $from.assign || function () { // revert the change and throw an error, child writes aren't supported @@ -55,19 +55,19 @@ define(function (require) { }; // if we are syncing down a literal, then we use loose equality check - var strict = !$from.literal; - var compare = strict ? strictEquality : angular.equals; + let strict = !$from.literal; + let compare = strict ? strictEquality : angular.equals; // push the initial value down, start off in sync setTarget(lastSourceVal); $target.$watch(function () { - var sourceVal = getSource(); - var targetVal = getTarget(); + let sourceVal = getSource(); + let targetVal = getTarget(); - var outOfSync = !compare(sourceVal, targetVal); - var sourceChanged = outOfSync && !compare(sourceVal, lastSourceVal); + let outOfSync = !compare(sourceVal, targetVal); + let sourceChanged = outOfSync && !compare(sourceVal, lastSourceVal); if (sourceChanged) setTarget(sourceVal); else if (outOfSync) setSource(targetVal); diff --git a/src/ui/public/chrome/TabCollection.js b/src/ui/public/chrome/TabCollection.js index 7287d1a0e7b6..e8617319ef3d 100644 --- a/src/ui/public/chrome/TabCollection.js +++ b/src/ui/public/chrome/TabCollection.js @@ -1,13 +1,13 @@ -var _ = require('lodash'); +let _ = require('lodash'); var { startsWith, get, set, omit, wrap, pick } = require('lodash'); -var Tab = require('ui/chrome/Tab'); +let Tab = require('ui/chrome/Tab'); var { parse } = require('url'); function TabCollection(opts = {}) { - var tabs = []; - var specs = null; - var defaults = opts.defaults || {}; - var activeTab = null; + let tabs = []; + let specs = null; + let defaults = opts.defaults || {}; + let activeTab = null; this.set = function (_specs) { specs = _.cloneDeep([].concat(_specs || [])); diff --git a/src/ui/public/chrome/api/angular.js b/src/ui/public/chrome/api/angular.js index f9a0eba6c0a9..79af632c405b 100644 --- a/src/ui/public/chrome/api/angular.js +++ b/src/ui/public/chrome/api/angular.js @@ -1,10 +1,10 @@ -var _ = require('lodash'); +let _ = require('lodash'); module.exports = function (chrome, internals) { chrome.setupAngular = function () { - var modules = require('ui/modules'); - var kibana = modules.get('kibana'); + let modules = require('ui/modules'); + let kibana = modules.get('kibana'); _.forOwn(chrome.getInjected(), function (val, name) { kibana.value(name, val); @@ -16,7 +16,7 @@ module.exports = function (chrome, internals) { .value('buildSha', internals.buildSha) .value('sessionId', Date.now()) .value('esUrl', (function () { - var a = document.createElement('a'); + let a = document.createElement('a'); a.href = chrome.addBasePath('/elasticsearch'); return a.href; }())) diff --git a/src/ui/public/chrome/api/controls.js b/src/ui/public/chrome/api/controls.js index 116e37411cff..4473e23d0e95 100644 --- a/src/ui/public/chrome/api/controls.js +++ b/src/ui/public/chrome/api/controls.js @@ -1,4 +1,4 @@ -var _ = require('lodash'); +let _ = require('lodash'); module.exports = function (chrome, internals) { /** @@ -10,7 +10,7 @@ module.exports = function (chrome, internals) { * determines if the Kibana chrome should be displayed */ - var def = true; + let def = true; internals.setVisibleDefault = (_def) => def = Boolean(_def); /** diff --git a/src/ui/public/chrome/api/nav.js b/src/ui/public/chrome/api/nav.js index adc854c61cff..75b9dca2d046 100644 --- a/src/ui/public/chrome/api/nav.js +++ b/src/ui/public/chrome/api/nav.js @@ -15,10 +15,10 @@ export default function (chrome, internals) { }; chrome.addBasePath = function (url) { - var isUrl = url && isString(url); + let isUrl = url && isString(url); if (!isUrl) return url; - var parsed = parse(url, true); + let parsed = parse(url, true); if (!parsed.host && parsed.pathname) { if (parsed.pathname[0] === '/') { parsed.pathname = chrome.getBasePath() + parsed.pathname; @@ -46,7 +46,7 @@ export default function (chrome, internals) { internals.nav.forEach(link => { // convert all link urls to absolute urls - var a = document.createElement('a'); + let a = document.createElement('a'); a.setAttribute('href', link.url); link.url = a.href; link.lastSubUrl = chrome.getLastSubUrlFor(link.url); diff --git a/src/ui/public/chrome/api/tabs.js b/src/ui/public/chrome/api/tabs.js index 128f5ca8c267..a88c2d4e3f1a 100644 --- a/src/ui/public/chrome/api/tabs.js +++ b/src/ui/public/chrome/api/tabs.js @@ -1,5 +1,5 @@ -var _ = require('lodash'); -var TabCollection = require('../TabCollection'); +let _ = require('lodash'); +let TabCollection = require('../TabCollection'); module.exports = function (chrome, internals) { @@ -91,7 +91,7 @@ module.exports = function (chrome, internals) { // create a getter for properties of the active tab function activeGetter(prop) { return function (def) { - var active = chrome.getActiveTab(); + let active = chrome.getActiveTab(); return !active ? def : active[prop]; }; } diff --git a/src/ui/public/chrome/api/template.js b/src/ui/public/chrome/api/template.js index f45e3776caa8..32e39474163c 100644 --- a/src/ui/public/chrome/api/template.js +++ b/src/ui/public/chrome/api/template.js @@ -1,4 +1,4 @@ -var _ = require('lodash'); +let _ = require('lodash'); module.exports = function (chrome, internals) { diff --git a/src/ui/public/chrome/api/theme.js b/src/ui/public/chrome/api/theme.js index 59b2dea3b3c2..440ca2a55bc7 100644 --- a/src/ui/public/chrome/api/theme.js +++ b/src/ui/public/chrome/api/theme.js @@ -1,4 +1,4 @@ -var _ = require('lodash'); +let _ = require('lodash'); module.exports = function (chrome, internals) { /** @@ -66,7 +66,7 @@ module.exports = function (chrome, internals) { * @return {chrome} */ chrome.addApplicationClass = function (val) { - var classes = internals.applicationClasses || []; + let classes = internals.applicationClasses || []; classes.push(val); classes = _.uniq(classes); @@ -81,8 +81,8 @@ module.exports = function (chrome, internals) { * @return {chrome} */ chrome.removeApplicationClass = function (val) { - var classesToRemove = [].concat(val || []); - var classes = internals.applicationClasses || []; + let classesToRemove = [].concat(val || []); + let classes = internals.applicationClasses || []; _.pull(classes, ...classesToRemove); internals.applicationClasses = classes; diff --git a/src/ui/public/chrome/chrome.js b/src/ui/public/chrome/chrome.js index 62d353623c18..d7bda2109c13 100644 --- a/src/ui/public/chrome/chrome.js +++ b/src/ui/public/chrome/chrome.js @@ -1,17 +1,17 @@ require('babel/polyfill'); -var _ = require('lodash'); -var $ = require('jquery'); -var angular = require('angular'); +let _ = require('lodash'); +let $ = require('jquery'); +let angular = require('angular'); require('ui/timefilter'); require('ui/private'); require('ui/promises'); -var metadata = require('ui/metadata'); +let metadata = require('ui/metadata'); -var chrome = {}; -var internals = _.defaults( +let chrome = {}; +let internals = _.defaults( _.cloneDeep(metadata), { basePath: '', diff --git a/src/ui/public/chrome/context.js b/src/ui/public/chrome/context.js index 2202f7900311..96280e17d74f 100644 --- a/src/ui/public/chrome/context.js +++ b/src/ui/public/chrome/context.js @@ -1,13 +1,13 @@ define(function (require) { - var _ = require('lodash'); - var ConfigTemplate = require('ui/ConfigTemplate'); + let _ = require('lodash'); + let ConfigTemplate = require('ui/ConfigTemplate'); require('ui/modules') .get('kibana') // TODO: all of this really belongs in the timepicker .directive('chromeContext', function (timefilter, globalState) { - var listenForUpdates = _.once(function ($scope) { + let listenForUpdates = _.once(function ($scope) { $scope.$listen(timefilter, 'update', function (newVal, oldVal) { globalState.time = _.clone(timefilter.time); globalState.refreshInterval = _.clone(timefilter.refreshInterval); diff --git a/src/ui/public/chrome/directives/app_switcher/app_switcher.js b/src/ui/public/chrome/directives/app_switcher/app_switcher.js index 70571d2f31f2..94ebb3c83e47 100644 --- a/src/ui/public/chrome/directives/app_switcher/app_switcher.js +++ b/src/ui/public/chrome/directives/app_switcher/app_switcher.js @@ -1,8 +1,8 @@ -var parse = require('url').parse; -var bindKey = require('lodash').bindKey; +let parse = require('url').parse; +let bindKey = require('lodash').bindKey; require('../app_switcher/app_switcher.less'); -var DomLocationProvider = require('ui/domLocation'); +let DomLocationProvider = require('ui/domLocation'); require('ui/modules') .get('kibana') @@ -12,7 +12,7 @@ require('ui/modules') template: require('./app_switcher.html'), controllerAs: 'switcher', controller: function ($scope, Private) { - var domLocation = Private(DomLocationProvider); + let domLocation = Private(DomLocationProvider); // since we render this in an isolate scope we can't "require: ^chrome", but // rather than remove all helpfull checks we can just check here. @@ -29,11 +29,11 @@ require('ui/modules') return; } - var toParsed = parse(event.delegateTarget.href); - var fromParsed = parse(domLocation.href); - var sameProto = toParsed.protocol === fromParsed.protocol; - var sameHost = toParsed.host === fromParsed.host; - var samePath = toParsed.path === fromParsed.path; + let toParsed = parse(event.delegateTarget.href); + let fromParsed = parse(domLocation.href); + let sameProto = toParsed.protocol === fromParsed.protocol; + let sameHost = toParsed.host === fromParsed.host; + let samePath = toParsed.path === fromParsed.path; if (sameProto && sameHost && samePath) { toParsed.hash && domLocation.reload(); diff --git a/src/ui/public/collapsible_sidebar/collapsible_sidebar.js b/src/ui/public/collapsible_sidebar/collapsible_sidebar.js index b880ebfbf37c..269faf797a9e 100644 --- a/src/ui/public/collapsible_sidebar/collapsible_sidebar.js +++ b/src/ui/public/collapsible_sidebar/collapsible_sidebar.js @@ -1,22 +1,22 @@ define(function (require) { require('ui/collapsible_sidebar/collapsible_sidebar.less'); - var _ = require('lodash'); - var $ = require('jquery'); + let _ = require('lodash'); + let $ = require('jquery'); require('ui/modules') .get('kibana') .directive('collapsibleSidebar', function () { // simply a list of all of all of angulars .col-md-* classes except 12 - var listOfWidthClasses = _.times(11, function (i) { return 'col-md-' + i; }); + let listOfWidthClasses = _.times(11, function (i) { return 'col-md-' + i; }); return { restrict: 'C', link: function ($scope, $elem) { - var $collapser = $(''); - var $siblings = $elem.siblings(); + let $collapser = $(''); + let $siblings = $elem.siblings(); - var siblingsClass = listOfWidthClasses.reduce(function (prev, className) { + let siblingsClass = listOfWidthClasses.reduce(function (prev, className) { if (prev) return prev; return $siblings.hasClass(className) && className; }, false); diff --git a/src/ui/public/config/_delayed_updater.js b/src/ui/public/config/_delayed_updater.js index 0db77a70ba95..b6d82869c4b5 100644 --- a/src/ui/public/config/_delayed_updater.js +++ b/src/ui/public/config/_delayed_updater.js @@ -1,15 +1,15 @@ define(function (require) { return function DelayedUpdaterFactory(Private, $rootScope, Promise, Notifier) { - var notify = new Notifier(); - var _ = require('lodash'); - var angular = require('angular'); + let notify = new Notifier(); + let _ = require('lodash'); + let angular = require('angular'); - var vals = Private(require('ui/config/_vals')); + let vals = Private(require('ui/config/_vals')); return function DelayedUpdater(doc) { - var updater = this; - var queue = []; - var log = {}; + let updater = this; + let queue = []; + let log = {}; let timer; updater.fire = function () { @@ -21,8 +21,8 @@ define(function (require) { let method; let body; - var updated = []; - var deleted = []; + let updated = []; + let deleted = []; // seperate the log into lists Object.keys(log).forEach(function (key) { @@ -53,8 +53,8 @@ define(function (require) { }; updater.update = function (key, val, silentAndLocal) { - var newVal = val; - var oldVal = vals[key]; + let newVal = val; + let oldVal = vals[key]; if (angular.equals(newVal, oldVal)) { return Promise.resolve(); @@ -70,7 +70,7 @@ define(function (require) { if (silentAndLocal) return Promise.resolve(); - var defer = Promise.defer(); + let defer = Promise.defer(); queue.push(defer); notify.log('config change: ' + key + ': ' + oldVal + ' -> ' + newVal); $rootScope.$broadcast('change:config.' + key, newVal, oldVal); diff --git a/src/ui/public/config/config.js b/src/ui/public/config/config.js index ce713254aa6d..15c7757a8e26 100644 --- a/src/ui/public/config/config.js +++ b/src/ui/public/config/config.js @@ -1,5 +1,5 @@ define(function (require) { - var module = require('ui/modules').get('kibana/config', [ + let module = require('ui/modules').get('kibana/config', [ 'kibana/notify' ]); @@ -9,15 +9,15 @@ define(function (require) { // service for delivering config variables to everywhere else module.service('config', function (Private, Notifier, kbnVersion, kbnIndex, $rootScope, buildNum) { - var config = this; + let config = this; - var angular = require('angular'); - var _ = require('lodash'); - var defaults = Private(require('ui/config/defaults')); - var DelayedUpdater = Private(require('ui/config/_delayed_updater')); - var vals = Private(require('ui/config/_vals')); + let angular = require('angular'); + let _ = require('lodash'); + let defaults = Private(require('ui/config/defaults')); + let DelayedUpdater = Private(require('ui/config/_delayed_updater')); + let vals = Private(require('ui/config/_vals')); - var notify = new Notifier({ + let notify = new Notifier({ location: 'Config' }); @@ -25,8 +25,8 @@ define(function (require) { // update once it is requested by calling #set() or #clear(). let updater; - var DocSource = Private(require('ui/courier/data_source/doc_source')); - var doc = (new DocSource()) + let DocSource = Private(require('ui/courier/data_source/doc_source')); + let doc = (new DocSource()) .index(kbnIndex) .type('config') .id(kbnVersion); @@ -42,13 +42,13 @@ define(function (require) { * @return {Promise} - Resolved when the config loads initially */ config.init = _.once(function () { - var complete = notify.lifecycle('config init'); + let complete = notify.lifecycle('config init'); return (function getDoc() { // used to apply an entire es response to the vals, silentAndLocal will prevent // event/notifications/writes from occuring. - var applyMassUpdate = function (resp, silentAndLocal) { + let applyMassUpdate = function (resp, silentAndLocal) { _.union(_.keys(resp._source), _.keys(vals)).forEach(function (key) { change(key, resp._source[key], silentAndLocal); }); @@ -127,7 +127,7 @@ define(function (require) { config.$bind = function ($scope, key, property) { if (!property) property = key; - var update = function () { + let update = function () { $scope[property] = config.get(key); }; diff --git a/src/ui/public/config/defaults.js b/src/ui/public/config/defaults.js index b2643442db3d..7122b56366c5 100644 --- a/src/ui/public/config/defaults.js +++ b/src/ui/public/config/defaults.js @@ -1,6 +1,6 @@ define(function (require) { - var moment = require('moment-timezone'); - var _ = require('lodash'); + let moment = require('moment-timezone'); + let _ = require('lodash'); return function configDefaultsProvider() { // wraped in provider so that a new instance is given to each app/test diff --git a/src/ui/public/courier/_redirect_when_missing.js b/src/ui/public/courier/_redirect_when_missing.js index b7d9d4770d34..f208e01f89ad 100644 --- a/src/ui/public/courier/_redirect_when_missing.js +++ b/src/ui/public/courier/_redirect_when_missing.js @@ -1,10 +1,10 @@ define(function (require) { - var errors = require('ui/errors'); + let errors = require('ui/errors'); return function RedirectWhenMissingFn($location, kbnUrl, Notifier, Promise) { - var SavedObjectNotFound = errors.SavedObjectNotFound; + let SavedObjectNotFound = errors.SavedObjectNotFound; - var notify = new Notifier(); + let notify = new Notifier(); /** * Creates an error handler that will redirect to a url when a SavedObjectNotFound @@ -23,7 +23,7 @@ define(function (require) { // if this error is not "404", rethrow if (!(err instanceof SavedObjectNotFound)) throw err; - var url = mapping[err.savedObjectType] || mapping['*']; + let url = mapping[err.savedObjectType] || mapping['*']; if (!url) url = '/'; url += (url.indexOf('?') >= 0 ? '&' : '?') + `notFound=${err.savedObjectType}`; diff --git a/src/ui/public/courier/_request_queue.js b/src/ui/public/courier/_request_queue.js index e6dcf78957c6..f4e99c1a1696 100644 --- a/src/ui/public/courier/_request_queue.js +++ b/src/ui/public/courier/_request_queue.js @@ -1,13 +1,13 @@ define(function (require) { return function PendingRequestList() { - var _ = require('lodash'); + let _ = require('lodash'); /** * Queue of pending requests, requests are removed as * they are processed by fetch.[sourceType](). * @type {Array} */ - var queue = []; + let queue = []; queue.getInactive = function (/* strategies */) { return queue.get.apply(queue, arguments) @@ -22,7 +22,7 @@ define(function (require) { queue.get = function (...strategies) { return queue.filter(function (req) { - var strategyMatch = !strategies.length; + let strategyMatch = !strategies.length; if (!strategyMatch) { strategyMatch = strategies.some(function (strategy) { return req.strategy === strategy; diff --git a/src/ui/public/courier/courier.js b/src/ui/public/courier/courier.js index a9caf469089d..5ccfeedbb481 100644 --- a/src/ui/public/courier/courier.js +++ b/src/ui/public/courier/courier.js @@ -1,6 +1,6 @@ define(function (require) { - var errors = require('ui/errors'); - var _ = require('lodash'); + let errors = require('ui/errors'); + let _ = require('lodash'); require('ui/es'); require('ui/promises'); @@ -10,18 +10,18 @@ define(function (require) { require('ui/modules').get('kibana/courier') .service('courier', function ($rootScope, Private, Promise, indexPatterns, Notifier) { function Courier() { - var self = this; + let self = this; - var DocSource = Private(require('ui/courier/data_source/doc_source')); - var SearchSource = Private(require('ui/courier/data_source/search_source')); - var searchStrategy = Private(require('ui/courier/fetch/strategy/search')); + let DocSource = Private(require('ui/courier/data_source/doc_source')); + let SearchSource = Private(require('ui/courier/data_source/search_source')); + let searchStrategy = Private(require('ui/courier/fetch/strategy/search')); - var requestQueue = Private(require('ui/courier/_request_queue')); - var errorHandlers = Private(require('ui/courier/_error_handlers')); + let requestQueue = Private(require('ui/courier/_request_queue')); + let errorHandlers = Private(require('ui/courier/_error_handlers')); - var fetch = Private(require('ui/courier/fetch/fetch')); - var docLooper = self.docLooper = Private(require('ui/courier/looper/doc')); - var searchLooper = self.searchLooper = Private(require('ui/courier/looper/search')); + let fetch = Private(require('ui/courier/fetch/fetch')); + let docLooper = self.docLooper = Private(require('ui/courier/looper/doc')); + let searchLooper = self.searchLooper = Private(require('ui/courier/looper/search')); // expose some internal modules self.setRootSearchSource = Private(require('ui/courier/data_source/_root_search_source')).set; @@ -33,7 +33,7 @@ define(function (require) { self.DocSource = DocSource; self.SearchSource = SearchSource; - var HastyRefresh = errors.HastyRefresh; + let HastyRefresh = errors.HastyRefresh; /** * update the time between automatic search requests @@ -121,8 +121,8 @@ define(function (require) { // Listen for refreshInterval changes $rootScope.$watchCollection('timefilter.refreshInterval', function () { - var refreshValue = _.get($rootScope, 'timefilter.refreshInterval.value'); - var refreshPause = _.get($rootScope, 'timefilter.refreshInterval.pause'); + let refreshValue = _.get($rootScope, 'timefilter.refreshInterval.value'); + let refreshPause = _.get($rootScope, 'timefilter.refreshInterval.pause'); if (_.isNumber(refreshValue) && !refreshPause) { self.fetchInterval(refreshValue); } else { @@ -130,7 +130,7 @@ define(function (require) { } }); - var onFatalDefer = Promise.defer(); + let onFatalDefer = Promise.defer(); onFatalDefer.promise.then(self.close); Notifier.fatalCallbacks.push(onFatalDefer.resolve); } diff --git a/src/ui/public/courier/data_source/_abstract.js b/src/ui/public/courier/data_source/_abstract.js index f66996048e1c..cbd13a879d7a 100644 --- a/src/ui/public/courier/data_source/_abstract.js +++ b/src/ui/public/courier/data_source/_abstract.js @@ -1,14 +1,14 @@ define(function (require) { - var _ = require('lodash'); - var angular = require('angular'); + let _ = require('lodash'); + let angular = require('angular'); return function SourceAbstractFactory(Private, Promise, PromiseEmitter) { - var requestQueue = Private(require('ui/courier/_request_queue')); - var errorHandlers = Private(require('ui/courier/_error_handlers')); - var courierFetch = Private(require('ui/courier/fetch/fetch')); + let requestQueue = Private(require('ui/courier/_request_queue')); + let errorHandlers = Private(require('ui/courier/_error_handlers')); + let courierFetch = Private(require('ui/courier/fetch/fetch')); function SourceAbstract(initialState, strategy) { - var self = this; + let self = this; self._instanceid = _.uniqueId('data_source'); self._state = (function () { @@ -51,7 +51,7 @@ define(function (require) { * @return {any} - the value found */ SourceAbstract.prototype.get = function (name) { - var self = this; + let self = this; while (self) { if (self._state[name] !== void 0) return self._state[name]; self = self.getParent(); @@ -73,7 +73,7 @@ define(function (require) { * string of the state value to set */ SourceAbstract.prototype.set = function (state, val) { - var self = this; + let self = this; if (typeof state === 'string') { // the getter and setter methods check for undefined explicitly @@ -119,7 +119,7 @@ define(function (require) { * @return {Promise} */ SourceAbstract.prototype.onResults = function (handler) { - var self = this; + let self = this; return new PromiseEmitter(function (resolve, reject) { const defer = Promise.defer(); @@ -143,7 +143,7 @@ define(function (require) { * @return {Promise} */ SourceAbstract.prototype.onError = function (handler) { - var self = this; + let self = this; return new PromiseEmitter(function (resolve, reject) { const defer = Promise.defer(); @@ -166,8 +166,8 @@ define(function (require) { * @async */ SourceAbstract.prototype.fetch = function () { - var self = this; - var req = _.first(self._myStartableQueued()); + let self = this; + let req = _.first(self._myStartableQueued()); if (!req) { req = self._createRequest(); @@ -226,16 +226,16 @@ define(function (require) { * @resolved {Object|null} - the flat state of the SourceAbstract */ SourceAbstract.prototype._flatten = function () { - var type = this._getType(); + let type = this._getType(); // the merged state of this dataSource and it's ancestors - var flatState = {}; + let flatState = {}; // function used to write each property from each state object in the chain to flat state - var root = this; + let root = this; // start the chain at this source - var current = this; + let current = this; // call the ittr and return it's promise return (function ittr() { @@ -249,12 +249,12 @@ define(function (require) { }); } - var prom = root._mergeProp(flatState, value, key); + let prom = root._mergeProp(flatState, value, key); return Promise.is(prom) ? prom : null; })) .then(function () { // move to this sources parent - var parent = current.getParent(); + let parent = current.getParent(); // keep calling until we reach the top parent if (parent) { current = parent; @@ -265,7 +265,7 @@ define(function (require) { .then(function () { if (type === 'search') { // This is down here to prevent the circular dependency - var decorateQuery = Private(require('ui/courier/data_source/_decorate_query')); + let decorateQuery = Private(require('ui/courier/data_source/_decorate_query')); flatState.body = flatState.body || {}; @@ -279,7 +279,7 @@ define(function (require) { if (flatState.body.size === 0) { flatState.search_type = 'count'; } else { - var computedFields = flatState.index.getComputedFields(); + let computedFields = flatState.index.getComputedFields(); flatState.body.fields = computedFields.fields; flatState.body.script_fields = flatState.body.script_fields || {}; flatState.body.fielddata_fields = flatState.body.fielddata_fields || []; @@ -297,7 +297,7 @@ define(function (require) { * through otherwise it will filter out * @returns {function} */ - var filterNegate = function (reverse) { + let filterNegate = function (reverse) { return function (filter) { if (_.isUndefined(filter.meta) || _.isUndefined(filter.meta.negate)) return !reverse; return filter.meta && filter.meta.negate === reverse; @@ -309,7 +309,7 @@ define(function (require) { * @param {object} filter The filter to clean * @returns {object} */ - var cleanFilter = function (filter) { + let cleanFilter = function (filter) { return _.omit(filter, ['meta']); }; diff --git a/src/ui/public/courier/data_source/_decorate_query.js b/src/ui/public/courier/data_source/_decorate_query.js index 45038fe0f448..6a12ebe3a7dd 100644 --- a/src/ui/public/courier/data_source/_decorate_query.js +++ b/src/ui/public/courier/data_source/_decorate_query.js @@ -1,5 +1,5 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); return function DecorateQuery(config) { /** * Decorate queries with default parameters @@ -7,7 +7,7 @@ define(function (require) { * @returns {object} */ return function (query) { - var queryOptions = config.get('query:queryString:options'); + let queryOptions = config.get('query:queryString:options'); if (_.has(query, 'query_string.query')) { _.extend(query.query_string, queryOptions); diff --git a/src/ui/public/courier/data_source/_doc_send_to_es.js b/src/ui/public/courier/data_source/_doc_send_to_es.js index ea3d5f49b5f2..c01c46f6ffc3 100644 --- a/src/ui/public/courier/data_source/_doc_send_to_es.js +++ b/src/ui/public/courier/data_source/_doc_send_to_es.js @@ -1,10 +1,10 @@ define(function (require) { - var _ = require('lodash'); - var errors = require('ui/errors'); + let _ = require('lodash'); + let errors = require('ui/errors'); return function (Promise, Private, es) { - var requestQueue = Private(require('ui/courier/_request_queue')); - var courierFetch = Private(require('ui/courier/fetch/fetch')); + let requestQueue = Private(require('ui/courier/_request_queue')); + let courierFetch = Private(require('ui/courier/fetch/fetch')); /** * Backend for doUpdate and doIndex @@ -14,9 +14,9 @@ define(function (require) { * @param {String} body - HTTP request body */ return function (method, validateVersion, body, ignore) { - var doc = this; + let doc = this; // straight assignment will causes undefined values - var params = _.pick(this._state, ['id', 'type', 'index']); + let params = _.pick(this._state, ['id', 'type', 'index']); params.body = body; params.ignore = ignore || [409]; @@ -49,13 +49,13 @@ define(function (require) { // notify pending request for this same document that we have updates docFetchProm.then(function (fetchResp) { // use the key to compair sources - var key = doc._versionKey(); + let key = doc._versionKey(); // clear the queue and filter out the removed items, pushing the // unmatched ones back in. - var respondTo = requestQueue.splice(0).filter(function (req) { - var isDoc = req.source._getType() === 'doc'; - var keyMatches = isDoc && req.source._versionKey() === key; + let respondTo = requestQueue.splice(0).filter(function (req) { + let isDoc = req.source._getType() === 'doc'; + let keyMatches = isDoc && req.source._versionKey() === key; // put some request back into the queue if (!keyMatches) { diff --git a/src/ui/public/courier/data_source/_normalize_sort_request.js b/src/ui/public/courier/data_source/_normalize_sort_request.js index c5e38e2b42bf..37313291e454 100644 --- a/src/ui/public/courier/data_source/_normalize_sort_request.js +++ b/src/ui/public/courier/data_source/_normalize_sort_request.js @@ -1,7 +1,7 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); return function normalizeSortRequest(config) { - var defaultSortOptions = config.get('sort:options'); + let defaultSortOptions = config.get('sort:options'); /** * Decorate queries with default parameters @@ -9,7 +9,7 @@ define(function (require) { * @returns {object} */ return function (sortObject, indexPattern) { - var normalizedSort = []; + let normalizedSort = []; // [].concat({}) -> [{}], [].concat([{}]) -> [{}] return [].concat(sortObject).map(function (sortable) { @@ -22,10 +22,10 @@ define(function (require) { { someField: "desc" } into { someField: { "order": "desc"}} */ function normalize(sortable, indexPattern) { - var normalized = {}; - var sortField = _.keys(sortable)[0]; - var sortValue = sortable[sortField]; - var indexField = indexPattern.fields.byName[sortField]; + let normalized = {}; + let sortField = _.keys(sortable)[0]; + let sortValue = sortable[sortField]; + let indexField = indexPattern.fields.byName[sortField]; if (indexField && indexField.scripted && indexField.sortable) { let direction; diff --git a/src/ui/public/courier/data_source/_root_search_source.js b/src/ui/public/courier/data_source/_root_search_source.js index 1f676175c156..fb68bef72d9f 100644 --- a/src/ui/public/courier/data_source/_root_search_source.js +++ b/src/ui/public/courier/data_source/_root_search_source.js @@ -1,10 +1,10 @@ define(function (require) { return function RootSearchSource(Private, $rootScope, timefilter, Notifier) { - var SearchSource = Private(require('ui/courier/data_source/search_source')); + let SearchSource = Private(require('ui/courier/data_source/search_source')); - var notify = new Notifier({ location: 'Root Search Source' }); + let notify = new Notifier({ location: 'Root Search Source' }); - var globalSource = new SearchSource(); + let globalSource = new SearchSource(); globalSource.inherits(false); // this is the final source, it has no parents globalSource.filter(function (globalSource) { // dynamic time filter will be called in the _flatten phase of things @@ -34,7 +34,7 @@ define(function (require) { // walk the parent chain until we get to the global source or nothing // that's where we will attach to the globalSource - var literalRoot = source; + let literalRoot = source; while (literalRoot._parent && literalRoot._parent !== globalSource) { literalRoot = literalRoot._parent; } diff --git a/src/ui/public/courier/data_source/doc_source.js b/src/ui/public/courier/data_source/doc_source.js index f6f32eeddf28..6c60d87f9799 100644 --- a/src/ui/public/courier/data_source/doc_source.js +++ b/src/ui/public/courier/data_source/doc_source.js @@ -1,11 +1,11 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); return function DocSourceFactory(Private, Promise, es, sessionStorage) { - var sendToEs = Private(require('ui/courier/data_source/_doc_send_to_es')); - var SourceAbstract = Private(require('ui/courier/data_source/_abstract')); - var DocRequest = Private(require('ui/courier/fetch/request/doc')); - var docStrategy = Private(require('ui/courier/fetch/strategy/doc')); + let sendToEs = Private(require('ui/courier/data_source/_doc_send_to_es')); + let SourceAbstract = Private(require('ui/courier/data_source/_abstract')); + let DocRequest = Private(require('ui/courier/fetch/request/doc')); + let docStrategy = Private(require('ui/courier/fetch/strategy/doc')); _.class(DocSource).inherits(SourceAbstract); function DocSource(initialState) { @@ -92,7 +92,7 @@ define(function (require) { * @return {string} */ DocSource.prototype._versionKey = function () { - var state = this._state; + let state = this._state; if (!state.index || !state.type || !state.id) return; return 'DocVersion:' + ( @@ -118,10 +118,10 @@ define(function (require) { * @return {[type]} [description] */ DocSource.prototype._getStoredVersion = function () { - var key = this._versionKey(); + let key = this._versionKey(); if (!key) return; - var v = sessionStorage.get(key); + let v = sessionStorage.get(key); this._version = v ? _.parseInt(v) : void 0; return this._version; }; @@ -134,7 +134,7 @@ define(function (require) { DocSource.prototype._storeVersion = function (version) { if (!version) return this._clearVersion(); - var key = this._versionKey(); + let key = this._versionKey(); if (!key) return; this._version = version; sessionStorage.set(key, version); @@ -144,7 +144,7 @@ define(function (require) { * Clears the stored version for a DocSource */ DocSource.prototype._clearVersion = function () { - var key = this._versionKey(); + let key = this._versionKey(); if (!key) return; sessionStorage.remove(key); }; diff --git a/src/ui/public/courier/data_source/search_source.js b/src/ui/public/courier/data_source/search_source.js index 6deaa47f2395..63aee2464372 100644 --- a/src/ui/public/courier/data_source/search_source.js +++ b/src/ui/public/courier/data_source/search_source.js @@ -1,12 +1,12 @@ define(function (require) { return function SearchSourceFactory(Promise, Private) { - var _ = require('lodash'); - var SourceAbstract = Private(require('ui/courier/data_source/_abstract')); - var SearchRequest = Private(require('ui/courier/fetch/request/search')); - var SegmentedRequest = Private(require('ui/courier/fetch/request/segmented')); - var searchStrategy = Private(require('ui/courier/fetch/strategy/search')); - var normalizeSortRequest = Private(require('ui/courier/data_source/_normalize_sort_request')); - var rootSearchSource = require('ui/courier/data_source/_root_search_source'); + let _ = require('lodash'); + let SourceAbstract = Private(require('ui/courier/data_source/_abstract')); + let SearchRequest = Private(require('ui/courier/fetch/request/search')); + let SegmentedRequest = Private(require('ui/courier/fetch/request/segmented')); + let searchStrategy = Private(require('ui/courier/fetch/strategy/search')); + let normalizeSortRequest = Private(require('ui/courier/data_source/_normalize_sort_request')); + let rootSearchSource = require('ui/courier/data_source/_root_search_source'); _.class(SearchSource).inherits(SourceAbstract); function SearchSource(initialState) { @@ -65,7 +65,7 @@ define(function (require) { * @return {undefined|searchSource} */ SearchSource.prototype.getParent = function (onlyHardLinked) { - var self = this; + let self = this; if (self._parent === false) return; if (self._parent) return self._parent; return onlyHardLinked ? undefined : Private(rootSearchSource).get(); @@ -86,9 +86,9 @@ define(function (require) { }; SearchSource.prototype.onBeginSegmentedFetch = function (initFunction) { - var self = this; + let self = this; return Promise.try(function addRequest() { - var req = new SegmentedRequest(self, Promise.defer(), initFunction); + let req = new SegmentedRequest(self, Promise.defer(), initFunction); // return promises created by the completion handler so that // errors will bubble properly @@ -133,7 +133,7 @@ define(function (require) { */ SearchSource.prototype._mergeProp = function (state, val, key) { if (typeof val === 'function') { - var source = this; + let source = this; return Promise.cast(val(this)) .then(function (newVal) { return source._mergeProp(state, newVal, key); diff --git a/src/ui/public/courier/fetch/_call_client.js b/src/ui/public/courier/fetch/_call_client.js index 2f47ebad76b8..75f24d891b82 100644 --- a/src/ui/public/courier/fetch/_call_client.js +++ b/src/ui/public/courier/fetch/_call_client.js @@ -1,29 +1,29 @@ define(function (require) { return function CourierFetchCallClient(Private, Promise, es, esShardTimeout, sessionId) { - var _ = require('lodash'); + let _ = require('lodash'); - var isRequest = Private(require('ui/courier/fetch/_is_request')); - var mergeDuplicateRequests = Private(require('ui/courier/fetch/_merge_duplicate_requests')); + let isRequest = Private(require('ui/courier/fetch/_is_request')); + let mergeDuplicateRequests = Private(require('ui/courier/fetch/_merge_duplicate_requests')); - var ABORTED = Private(require('ui/courier/fetch/_req_status')).ABORTED; - var DUPLICATE = Private(require('ui/courier/fetch/_req_status')).DUPLICATE; + let ABORTED = Private(require('ui/courier/fetch/_req_status')).ABORTED; + let DUPLICATE = Private(require('ui/courier/fetch/_req_status')).DUPLICATE; function callClient(strategy, requests) { // merging docs can change status to DUPLICATE, capture new statuses - var statuses = mergeDuplicateRequests(requests); + let statuses = mergeDuplicateRequests(requests); // get the actual list of requests that we will be fetching - var executable = statuses.filter(isRequest); - var execCount = executable.length; + let executable = statuses.filter(isRequest); + let execCount = executable.length; if (!execCount) return Promise.resolve([]); // resolved by respond() let esPromise; - var defer = Promise.defer(); + let defer = Promise.defer(); // for each respond with either the response or ABORTED - var respond = function (responses) { + let respond = function (responses) { responses = responses || []; return Promise.map(requests, function (req, i) { switch (statuses[i]) { @@ -43,7 +43,7 @@ define(function (require) { // handle a request being aborted while being fetched - var requestWasAborted = Promise.method(function (req, i) { + let requestWasAborted = Promise.method(function (req, i) { if (statuses[i] === ABORTED) { defer.reject(new Error('Request was aborted twice?')); } diff --git a/src/ui/public/courier/fetch/_call_response_handlers.js b/src/ui/public/courier/fetch/_call_response_handlers.js index 15fcd8bf9cf8..0e75a13742e6 100644 --- a/src/ui/public/courier/fetch/_call_response_handlers.js +++ b/src/ui/public/courier/fetch/_call_response_handlers.js @@ -1,12 +1,12 @@ define(function (require) { return function CourierFetchCallResponseHandlers(Private, Promise) { - var ABORTED = Private(require('ui/courier/fetch/_req_status')).ABORTED; - var INCOMPLETE = Private(require('ui/courier/fetch/_req_status')).INCOMPLETE; - var notify = Private(require('ui/courier/fetch/_notifier')); + let ABORTED = Private(require('ui/courier/fetch/_req_status')).ABORTED; + let INCOMPLETE = Private(require('ui/courier/fetch/_req_status')).INCOMPLETE; + let notify = Private(require('ui/courier/fetch/_notifier')); - var SearchTimeout = require('ui/errors').SearchTimeout; - var RequestFailure = require('ui/errors').RequestFailure; - var ShardFailure = require('ui/errors').ShardFailure; + let SearchTimeout = require('ui/errors').SearchTimeout; + let RequestFailure = require('ui/errors').RequestFailure; + let ShardFailure = require('ui/errors').ShardFailure; function callResponseHandlers(requests, responses) { return Promise.map(requests, function (req, i) { @@ -14,7 +14,7 @@ define(function (require) { return ABORTED; } - var resp = responses[i]; + let resp = responses[i]; if (resp.timed_out) { notify.warning(new SearchTimeout()); diff --git a/src/ui/public/courier/fetch/_continue_incomplete.js b/src/ui/public/courier/fetch/_continue_incomplete.js index 45f911c69152..30b3853e2b57 100644 --- a/src/ui/public/courier/fetch/_continue_incomplete.js +++ b/src/ui/public/courier/fetch/_continue_incomplete.js @@ -1,9 +1,9 @@ define(function (require) { return function CourierFetchContinueIncompleteRequests(Private) { - var INCOMPLETE = Private(require('ui/courier/fetch/_req_status')).INCOMPLETE; + let INCOMPLETE = Private(require('ui/courier/fetch/_req_status')).INCOMPLETE; function continueIncompleteRequests(strategy, requests, responses, fetchWithStrategy) { - var incomplete = []; + let incomplete = []; responses.forEach(function (resp, i) { if (resp === INCOMPLETE) { diff --git a/src/ui/public/courier/fetch/_fetch_these.js b/src/ui/public/courier/fetch/_fetch_these.js index 7b96dadae468..2858cad846ed 100644 --- a/src/ui/public/courier/fetch/_fetch_these.js +++ b/src/ui/public/courier/fetch/_fetch_these.js @@ -1,16 +1,16 @@ define(function (require) { return function FetchTheseProvider(Private, Promise) { - var notify = Private(require('ui/courier/fetch/_notifier')); - var forEachStrategy = Private(require('ui/courier/fetch/_for_each_strategy')); + let notify = Private(require('ui/courier/fetch/_notifier')); + let forEachStrategy = Private(require('ui/courier/fetch/_for_each_strategy')); // core tasks - var callClient = Private(require('ui/courier/fetch/_call_client')); - var callResponseHandlers = Private(require('ui/courier/fetch/_call_response_handlers')); - var continueIncomplete = Private(require('ui/courier/fetch/_continue_incomplete')); + let callClient = Private(require('ui/courier/fetch/_call_client')); + let callResponseHandlers = Private(require('ui/courier/fetch/_call_response_handlers')); + let continueIncomplete = Private(require('ui/courier/fetch/_continue_incomplete')); - var ABORTED = Private(require('ui/courier/fetch/_req_status')).ABORTED; - var DUPLICATE = Private(require('ui/courier/fetch/_req_status')).DUPLICATE; - var INCOMPLETE = Private(require('ui/courier/fetch/_req_status')).INCOMPLETE; + let ABORTED = Private(require('ui/courier/fetch/_req_status')).ABORTED; + let DUPLICATE = Private(require('ui/courier/fetch/_req_status')).DUPLICATE; + let INCOMPLETE = Private(require('ui/courier/fetch/_req_status')).INCOMPLETE; function fetchThese(requests) { return forEachStrategy(requests, function (strategy, reqsForStrategy) { @@ -64,7 +64,7 @@ define(function (require) { } return new Promise(function (resolve) { - var action = req.started ? req.continue : req.start; + let action = req.started ? req.continue : req.start; resolve(action.call(req)); }) .catch(err => req.handleFailure(err)); diff --git a/src/ui/public/courier/fetch/_for_each_strategy.js b/src/ui/public/courier/fetch/_for_each_strategy.js index cc13fe238124..269da403f09f 100644 --- a/src/ui/public/courier/fetch/_for_each_strategy.js +++ b/src/ui/public/courier/fetch/_for_each_strategy.js @@ -1,14 +1,14 @@ define(function (require) { return function FetchForEachRequestStrategy(Private, Promise) { - var _ = require('lodash'); + let _ = require('lodash'); function forEachStrategy(requests, block) { block = Promise.method(block); - var sets = []; + let sets = []; requests.forEach(function (req) { - var strategy = req.strategy; - var set = _.find(sets, { 0: strategy }); + let strategy = req.strategy; + let set = _.find(sets, { 0: strategy }); if (set) set[1].push(req); else sets.push([strategy, [req]]); }); diff --git a/src/ui/public/courier/fetch/_is_request.js b/src/ui/public/courier/fetch/_is_request.js index 4a0eab4019cf..64c34eeec85b 100644 --- a/src/ui/public/courier/fetch/_is_request.js +++ b/src/ui/public/courier/fetch/_is_request.js @@ -1,6 +1,6 @@ define(function (require) { return function CourierFetchIsRequestProvider(Private) { - var AbstractRequest = Private(require('ui/courier/fetch/request/request')); + let AbstractRequest = Private(require('ui/courier/fetch/request/request')); return function isRequest(obj) { return obj instanceof AbstractRequest; diff --git a/src/ui/public/courier/fetch/_merge_duplicate_requests.js b/src/ui/public/courier/fetch/_merge_duplicate_requests.js index fb79e6bf6148..b1d9237032f7 100644 --- a/src/ui/public/courier/fetch/_merge_duplicate_requests.js +++ b/src/ui/public/courier/fetch/_merge_duplicate_requests.js @@ -1,15 +1,15 @@ define(function (require) { return function FetchMergeDuplicateRequests(Private) { - var isRequest = Private(require('ui/courier/fetch/_is_request')); - var DUPLICATE = Private(require('ui/courier/fetch/_req_status')).DUPLICATE; + let isRequest = Private(require('ui/courier/fetch/_is_request')); + let DUPLICATE = Private(require('ui/courier/fetch/_req_status')).DUPLICATE; function mergeDuplicateRequests(requests) { // dedupe requests - var index = {}; + let index = {}; return requests.map(function (req) { if (!isRequest(req)) return req; - var iid = req.source._instanceid; + let iid = req.source._instanceid; if (!index[iid]) { // this request is unique so far index[iid] = req; diff --git a/src/ui/public/courier/fetch/fetch.js b/src/ui/public/courier/fetch/fetch.js index adf1871bb425..e7095c49b8fc 100644 --- a/src/ui/public/courier/fetch/fetch.js +++ b/src/ui/public/courier/fetch/fetch.js @@ -1,15 +1,15 @@ define(function (require) { return function fetchService(Private, Promise) { - var _ = require('lodash'); + let _ = require('lodash'); - var requestQueue = Private(require('ui/courier/_request_queue')); - var fetchThese = Private(require('ui/courier/fetch/_fetch_these')); + let requestQueue = Private(require('ui/courier/_request_queue')); + let fetchThese = Private(require('ui/courier/fetch/_fetch_these')); - var callResponseHandlers = Private(require('ui/courier/fetch/_call_response_handlers')); - var INCOMPLETE = Private(require('ui/courier/fetch/_req_status')).INCOMPLETE; + let callResponseHandlers = Private(require('ui/courier/fetch/_call_response_handlers')); + let INCOMPLETE = Private(require('ui/courier/fetch/_req_status')).INCOMPLETE; function fetchQueued(strategy) { - var requests = requestQueue.getStartable(strategy); + let requests = requestQueue.getStartable(strategy); if (!requests.length) return Promise.resolve(); else return fetchThese(requests); } @@ -17,7 +17,7 @@ define(function (require) { this.fetchQueued = fetchQueued; function fetchASource(source, strategy) { - var defer = Promise.defer(); + let defer = Promise.defer(); fetchThese([ source._createRequest(defer) diff --git a/src/ui/public/courier/fetch/request/_error_handler.js b/src/ui/public/courier/fetch/request/_error_handler.js index b4f8deba1823..220d65125060 100644 --- a/src/ui/public/courier/fetch/request/_error_handler.js +++ b/src/ui/public/courier/fetch/request/_error_handler.js @@ -1,13 +1,13 @@ define(function (require) { return function RequestErrorHandlerFactory(Private, Notifier) { - var errHandlers = Private(require('ui/courier/_error_handlers')); + let errHandlers = Private(require('ui/courier/_error_handlers')); - var notify = new Notifier({ + let notify = new Notifier({ location: 'Courier Fetch Error' }); function handleError(req, error) { - var myHandlers = []; + let myHandlers = []; errHandlers.splice(0).forEach(function (handler) { (handler.source === req.source ? myHandlers : errHandlers).push(handler); diff --git a/src/ui/public/courier/fetch/request/_segmented_handle.js b/src/ui/public/courier/fetch/request/_segmented_handle.js index ad46cd350c4e..e83c6858e576 100644 --- a/src/ui/public/courier/fetch/request/_segmented_handle.js +++ b/src/ui/public/courier/fetch/request/_segmented_handle.js @@ -1,7 +1,7 @@ define(function (require) { return function CourierSegmentedReqHandle(Private) { - var _ = require('lodash'); - var Events = Private(require('ui/events')); + let _ = require('lodash'); + let Events = Private(require('ui/events')); /** diff --git a/src/ui/public/courier/fetch/request/doc.js b/src/ui/public/courier/fetch/request/doc.js index b135fc2366ed..487b570d390b 100644 --- a/src/ui/public/courier/fetch/request/doc.js +++ b/src/ui/public/courier/fetch/request/doc.js @@ -1,9 +1,9 @@ define(function (require) { return function DocRequestProvider(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var docStrategy = Private(require('ui/courier/fetch/strategy/doc')); - var AbstractRequest = Private(require('ui/courier/fetch/request/request')); + let docStrategy = Private(require('ui/courier/fetch/strategy/doc')); + let AbstractRequest = Private(require('ui/courier/fetch/request/request')); _.class(DocRequest).inherits(AbstractRequest); function DocRequest(source, defer) { @@ -14,15 +14,15 @@ define(function (require) { } DocRequest.prototype.canStart = function () { - var parent = DocRequest.Super.prototype.canStart.call(this); + let parent = DocRequest.Super.prototype.canStart.call(this); if (!parent) return false; - var version = this.source._version; - var storedVersion = this.source._getStoredVersion(); + let version = this.source._version; + let storedVersion = this.source._getStoredVersion(); // conditions that equal "fetch This DOC!" - var unknown = !version && !storedVersion; - var mismatch = version !== storedVersion; + let unknown = !version && !storedVersion; + let mismatch = version !== storedVersion; return Boolean(mismatch || (unknown && !this.started)); }; diff --git a/src/ui/public/courier/fetch/request/request.js b/src/ui/public/courier/fetch/request/request.js index 30d72080fea0..017380387523 100644 --- a/src/ui/public/courier/fetch/request/request.js +++ b/src/ui/public/courier/fetch/request/request.js @@ -1,10 +1,10 @@ define(function (require) { return function AbstractReqProvider(Private, Promise) { - var _ = require('lodash'); - var moment = require('moment'); - var errors = require('ui/errors'); - var requestQueue = Private(require('ui/courier/_request_queue')); - var requestErrorHandler = Private(require('ui/courier/fetch/request/_error_handler')); + let _ = require('lodash'); + let moment = require('moment'); + let errors = require('ui/errors'); + let requestQueue = Private(require('ui/courier/_request_queue')); + let requestErrorHandler = Private(require('ui/courier/fetch/request/_error_handler')); function AbstractReq(source, defer) { if (!(this instanceof AbstractReq) || !this.constructor || this.constructor === AbstractReq) { @@ -29,7 +29,7 @@ define(function (require) { this.started = true; this.moment = moment(); - var source = this.source; + let source = this.source; if (source.activeFetchCount) { source.activeFetchCount += 1; } else { @@ -72,7 +72,7 @@ define(function (require) { }; AbstractReq.prototype.retry = function () { - var clone = this.clone(); + let clone = this.clone(); this.abort(); return clone; }; diff --git a/src/ui/public/courier/fetch/request/search.js b/src/ui/public/courier/fetch/request/search.js index ad2eca53e9af..f13c6df0bbb3 100644 --- a/src/ui/public/courier/fetch/request/search.js +++ b/src/ui/public/courier/fetch/request/search.js @@ -1,12 +1,12 @@ define(function (require) { return function SearchReqProvider(Private) { - var _ = require('lodash'); + let _ = require('lodash'); - var searchStrategy = Private(require('ui/courier/fetch/strategy/search')); - var AbstractRequest = Private(require('ui/courier/fetch/request/request')); + let searchStrategy = Private(require('ui/courier/fetch/strategy/search')); + let AbstractRequest = Private(require('ui/courier/fetch/request/request')); _.class(SearchReq).inherits(AbstractRequest); - var Super = SearchReq.Super; + let Super = SearchReq.Super; function SearchReq(source, defer) { Super.call(this, source, defer); diff --git a/src/ui/public/courier/fetch/request/segmented.js b/src/ui/public/courier/fetch/request/segmented.js index f7741b0ba584..142da71ebf2c 100644 --- a/src/ui/public/courier/fetch/request/segmented.js +++ b/src/ui/public/courier/fetch/request/segmented.js @@ -1,11 +1,11 @@ define(function (require) { return function CourierSegmentedReqProvider(es, Private, Promise, Notifier, timefilter, config) { - var _ = require('lodash'); - var isNumber = require('lodash').isNumber; - var SearchReq = Private(require('ui/courier/fetch/request/search')); - var SegmentedHandle = Private(require('ui/courier/fetch/request/_segmented_handle')); + let _ = require('lodash'); + let isNumber = require('lodash').isNumber; + let SearchReq = Private(require('ui/courier/fetch/request/search')); + let SegmentedHandle = Private(require('ui/courier/fetch/request/_segmented_handle')); - var notify = new Notifier({ + let notify = new Notifier({ location: 'Segmented Fetch' }); @@ -37,7 +37,7 @@ define(function (require) { *********/ SegmentedReq.prototype.start = function () { - var self = this; + let self = this; SearchReq.prototype.start.call(this); @@ -74,20 +74,20 @@ define(function (require) { }; SegmentedReq.prototype.getFetchParams = function () { - var self = this; + let self = this; return self._getFlattenedSource().then(function (flatSource) { - var params = _.cloneDeep(flatSource); + let params = _.cloneDeep(flatSource); // calculate the number of indices to fetch in this request in order to prevent // more than self._maxSegments requests. We use Math.max(1, n) to ensure that each request // has at least one index pattern, and Math.floor() to make sure that if the // number of indices does not round out evenly the extra index is tacked onto the last // request, making sure the first request returns faster. - var remainingSegments = self._maxSegments - self._segments.length; - var indexCount = Math.max(1, Math.floor(self._queue.length / remainingSegments)); + let remainingSegments = self._maxSegments - self._segments.length; + let indexCount = Math.max(1, Math.floor(self._queue.length / remainingSegments)); - var indices = self._active = self._queue.splice(0, indexCount); + let indices = self._active = self._queue.splice(0, indexCount); params.index = _.pluck(indices, 'index'); if (isNumber(self._desiredSize)) { @@ -112,8 +112,8 @@ define(function (require) { }; SegmentedReq.prototype.isIncomplete = function () { - var queueNotCreated = !this._queueCreated; - var queueNotEmpty = this._queue.length > 0; + let queueNotCreated = !this._queueCreated; + let queueNotEmpty = this._queue.length > 0; return queueNotCreated || queueNotEmpty; }; @@ -181,9 +181,9 @@ define(function (require) { }; SegmentedReq.prototype._createQueue = function () { - var self = this; - var timeBounds = timefilter.getBounds(); - var indexPattern = self.source.get('index'); + let self = this; + let timeBounds = timefilter.getBounds(); + let indexPattern = self.source.get('index'); self._queueCreated = false; return indexPattern.toDetailedIndexList(timeBounds.min, timeBounds.max, self._direction) @@ -211,14 +211,14 @@ define(function (require) { }; SegmentedReq.prototype._consumeSegment = function (seg) { - var index = this._active; + let index = this._active; this._complete.push(index); if (!seg) return; // segment was ignored/filtered, don't store it - var hadHits = _.get(this._mergedResp, 'hits.hits.length') > 0; - var gotHits = _.get(seg, 'hits.hits.length') > 0; - var firstHits = !hadHits && gotHits; - var haveHits = hadHits || gotHits; + let hadHits = _.get(this._mergedResp, 'hits.hits.length') > 0; + let gotHits = _.get(seg, 'hits.hits.length') > 0; + let firstHits = !hadHits && gotHits; + let haveHits = hadHits || gotHits; this._mergeSegment(seg); this.resp = _.omit(this._mergedResp, '_bucketIndex'); @@ -229,9 +229,9 @@ define(function (require) { }; SegmentedReq.prototype._mergeHits = function (hits) { - var mergedHits = this._mergedResp.hits.hits; - var desiredSize = this._desiredSize; - var sortFn = this._sortFn; + let mergedHits = this._mergedResp.hits.hits; + let desiredSize = this._desiredSize; + let sortFn = this._sortFn; _.pushAll(hits, mergedHits); @@ -247,7 +247,7 @@ define(function (require) { }; SegmentedReq.prototype._mergeSegment = notify.timed('merge response segment', function (seg) { - var merged = this._mergedResp; + let merged = this._mergedResp; this._segments.push(seg); @@ -277,7 +277,7 @@ define(function (require) { } seg.aggregations[aggKey].buckets.forEach(function (bucket) { - var mbucket = merged._bucketIndex[bucket.key]; + let mbucket = merged._bucketIndex[bucket.key]; if (mbucket) { mbucket.doc_count += bucket.doc_count; return; @@ -291,10 +291,10 @@ define(function (require) { SegmentedReq.prototype._detectHitsWindow = function (hits) { hits = hits || []; - var indexPattern = this.source.get('index'); - var desiredSize = this._desiredSize; + let indexPattern = this.source.get('index'); + let desiredSize = this._desiredSize; - var size = _.size(hits); + let size = _.size(hits); if (!isNumber(desiredSize) || size < desiredSize) { this._hitWindow = { size: size, @@ -308,8 +308,8 @@ define(function (require) { let max; hits.forEach(function (deepHit) { - var hit = indexPattern.flattenHit(deepHit); - var time = hit[indexPattern.timeFieldName]; + let hit = indexPattern.flattenHit(deepHit); + let time = hit[indexPattern.timeFieldName]; if (min == null || time < min) min = time; if (max == null || time > max) max = time; }); @@ -318,8 +318,8 @@ define(function (require) { }; SegmentedReq.prototype._pickSizeForIndices = function (indices) { - var hitWindow = this._hitWindow; - var desiredSize = this._desiredSize; + let hitWindow = this._hitWindow; + let desiredSize = this._desiredSize; if (!isNumber(desiredSize)) return null; // we don't have any hits yet, get us more info! @@ -327,7 +327,7 @@ define(function (require) { // the order of documents isn't important, just get us more if (!this._sortFn) return Math.max(desiredSize - hitWindow.size, 0); // if all of the documents in every index fall outside of our current doc set, we can ignore them. - var someOverlap = indices.some(function (index) { + let someOverlap = indices.some(function (index) { return index.min <= hitWindow.max && hitWindow.min <= index.max; }); diff --git a/src/ui/public/courier/fetch/strategy/search.js b/src/ui/public/courier/fetch/strategy/search.js index 6616c2931e4c..434ad86da7dd 100644 --- a/src/ui/public/courier/fetch/strategy/search.js +++ b/src/ui/public/courier/fetch/strategy/search.js @@ -1,8 +1,8 @@ define(function (require) { return function FetchStrategyForSearch(Private, Promise, timefilter) { - var _ = require('lodash'); - var angular = require('angular'); - var toJson = require('ui/utils/aggressive_parse').toJson; + let _ = require('lodash'); + let angular = require('angular'); + let toJson = require('ui/utils/aggressive_parse').toJson; return { clientMethod: 'msearch', @@ -21,7 +21,7 @@ define(function (require) { return indexList; } - var timeBounds = timefilter.getBounds(); + let timeBounds = timefilter.getBounds(); return indexList.toIndexList(timeBounds.min, timeBounds.max); }) .then(function (indexList) { diff --git a/src/ui/public/courier/looper/_looper.js b/src/ui/public/courier/looper/_looper.js index 8a980ad10ef3..0df02c698809 100644 --- a/src/ui/public/courier/looper/_looper.js +++ b/src/ui/public/courier/looper/_looper.js @@ -1,7 +1,7 @@ define(function (require) { return function LooperFactory($timeout, Notifier, Promise) { - var _ = require('lodash'); - var notify = new Notifier(); + let _ = require('lodash'); + let notify = new Notifier(); function Looper(ms, fn) { this._fn = fn; @@ -127,7 +127,7 @@ define(function (require) { * @return {undefined} */ Looper.prototype._loopTheLoop = function () { - var self = this; + let self = this; if (self.active) { self.onHastyLoop(); diff --git a/src/ui/public/courier/looper/doc.js b/src/ui/public/courier/looper/doc.js index 1bb9bf23ae5e..1ecbc838d417 100644 --- a/src/ui/public/courier/looper/doc.js +++ b/src/ui/public/courier/looper/doc.js @@ -1,14 +1,14 @@ define(function (require) { return function DocLooperService(Private) { - var fetch = Private(require('ui/courier/fetch/fetch')); - var Looper = Private(require('ui/courier/looper/_looper')); - var docStrategy = Private(require('ui/courier/fetch/strategy/doc')); + let fetch = Private(require('ui/courier/fetch/fetch')); + let Looper = Private(require('ui/courier/looper/_looper')); + let docStrategy = Private(require('ui/courier/fetch/strategy/doc')); /** * The Looper which will manage the doc fetch interval * @type {Looper} */ - var docLooper = new Looper(1500, function () { + let docLooper = new Looper(1500, function () { fetch.fetchQueued(docStrategy); }); diff --git a/src/ui/public/courier/looper/search.js b/src/ui/public/courier/looper/search.js index 11ddc5f2fa1b..41cc8edfb38a 100644 --- a/src/ui/public/courier/looper/search.js +++ b/src/ui/public/courier/looper/search.js @@ -1,17 +1,17 @@ define(function (require) { return function SearchLooperService(Private, Promise, Notifier, $rootScope) { - var fetch = Private(require('ui/courier/fetch/fetch')); - var searchStrategy = Private(require('ui/courier/fetch/strategy/search')); - var requestQueue = Private(require('ui/courier/_request_queue')); + let fetch = Private(require('ui/courier/fetch/fetch')); + let searchStrategy = Private(require('ui/courier/fetch/strategy/search')); + let requestQueue = Private(require('ui/courier/_request_queue')); - var Looper = Private(require('ui/courier/looper/_looper')); - var notif = new Notifier({ location: 'Search Looper' }); + let Looper = Private(require('ui/courier/looper/_looper')); + let notif = new Notifier({ location: 'Search Looper' }); /** * The Looper which will manage the doc fetch interval * @type {Looper} */ - var searchLooper = new Looper(null, function () { + let searchLooper = new Looper(null, function () { $rootScope.$broadcast('courier:searchRefresh'); return fetch.these( requestQueue.getInactive(searchStrategy) diff --git a/src/ui/public/courier/saved_object/saved_object.js b/src/ui/public/courier/saved_object/saved_object.js index 3d48bdf4a370..077ba04845b5 100644 --- a/src/ui/public/courier/saved_object/saved_object.js +++ b/src/ui/public/courier/saved_object/saved_object.js @@ -1,42 +1,42 @@ define(function (require) { return function SavedObjectFactory(es, kbnIndex, Promise, Private, Notifier, safeConfirm, indexPatterns) { - var angular = require('angular'); - var errors = require('ui/errors'); - var _ = require('lodash'); - var slugifyId = require('ui/utils/slugify_id'); + let angular = require('angular'); + let errors = require('ui/errors'); + let _ = require('lodash'); + let slugifyId = require('ui/utils/slugify_id'); - var DocSource = Private(require('ui/courier/data_source/doc_source')); - var SearchSource = Private(require('ui/courier/data_source/search_source')); - var mappingSetup = Private(require('ui/utils/mapping_setup')); + let DocSource = Private(require('ui/courier/data_source/doc_source')); + let SearchSource = Private(require('ui/courier/data_source/search_source')); + let mappingSetup = Private(require('ui/utils/mapping_setup')); function SavedObject(config) { if (!_.isObject(config)) config = {}; // save an easy reference to this - var self = this; + let self = this; /************ * Initialize config vars ************/ // the doc which is used to store this object - var docSource = new DocSource(); + let docSource = new DocSource(); // type name for this object, used as the ES-type - var type = config.type; + let type = config.type; // Create a notifier for sending alerts - var notify = new Notifier({ + let notify = new Notifier({ location: 'Saved ' + type }); // mapping definition for the fields that this object will expose - var mapping = mappingSetup.expandShorthand(config.mapping); + let mapping = mappingSetup.expandShorthand(config.mapping); // default field values, assigned when the source is loaded - var defaults = config.defaults || {}; + let defaults = config.defaults || {}; - var afterESResp = config.afterESResp || _.noop; - var customInit = config.init || _.noop; + let afterESResp = config.afterESResp || _.noop; + let customInit = config.init || _.noop; // optional search source which this object configures self.searchSource = config.searchSource && new SearchSource(); @@ -108,7 +108,7 @@ define(function (require) { if (resp.found != null && !resp.found) throw new errors.SavedObjectNotFound(type, self.id); - var meta = resp._source.kibanaSavedObjectMeta || {}; + let meta = resp._source.kibanaSavedObjectMeta || {}; delete resp._source.kibanaSavedObjectMeta; if (!config.indexPattern && self._source.indexPattern) { @@ -153,8 +153,8 @@ define(function (require) { state = {}; } - var oldState = self.searchSource.toJSON(); - var fnProps = _.transform(oldState, function (dynamic, val, name) { + let oldState = self.searchSource.toJSON(); + let fnProps = _.transform(oldState, function (dynamic, val, name) { if (_.isFunction(val)) dynamic[name] = val; }, {}); @@ -171,7 +171,7 @@ define(function (require) { return Promise.try(function () { if (self.searchSource) { - var index = config.indexPattern || self.searchSource.getOwn('index'); + let index = config.indexPattern || self.searchSource.getOwn('index'); if (!index) return; if (config.clearSavedIndexPattern) { self.searchSource.set('index', undefined); @@ -195,7 +195,7 @@ define(function (require) { * @return {Object} */ self.serialize = function () { - var body = {}; + let body = {}; _.forOwn(mapping, function (fieldMapping, fieldName) { if (self[fieldName] != null) { @@ -222,7 +222,7 @@ define(function (require) { */ self.save = function () { - var body = self.serialize(); + let body = self.serialize(); // Slugify the object id self.id = slugifyId(self.id); @@ -235,7 +235,7 @@ define(function (require) { }; self.saveSource = function (source) { - var finish = function (id) { + let finish = function (id) { self.id = id; return es.indices.refresh({ index: kbnIndex @@ -250,7 +250,7 @@ define(function (require) { .catch(function (err) { // record exists, confirm overwriting if (_.get(err, 'origError.status') === 409) { - var confirmMessage = 'Are you sure you want to overwrite ' + self.title + '?'; + let confirmMessage = 'Are you sure you want to overwrite ' + self.title + '?'; return safeConfirm(confirmMessage).then( function () { diff --git a/src/ui/public/debounce/debounce.js b/src/ui/public/debounce/debounce.js index 7cf725f6bf02..a5b375099aa6 100644 --- a/src/ui/public/debounce/debounce.js +++ b/src/ui/public/debounce/debounce.js @@ -2,8 +2,8 @@ // borrowed heavily from https://github.com/shahata/angular-debounce define(function (require) { - var _ = require('lodash'); - var module = require('ui/modules').get('kibana'); + let _ = require('lodash'); + let module = require('ui/modules').get('kibana'); module.service('debounce', ['$timeout', function ($timeout) { return function (func, wait, options) { @@ -20,14 +20,14 @@ define(function (require) { self = this; args = arguments; - var later = function () { + let later = function () { timeout = null; if (!options.leading || options.trailing) { result = func.apply(self, args); } }; - var callNow = options.leading && !timeout; + let callNow = options.leading && !timeout; if (timeout) { $timeout.cancel(timeout); diff --git a/src/ui/public/directives/auto_select_if_only_one.js b/src/ui/public/directives/auto_select_if_only_one.js index f0b62d32c96f..0e46737d4128 100644 --- a/src/ui/public/directives/auto_select_if_only_one.js +++ b/src/ui/public/directives/auto_select_if_only_one.js @@ -1,5 +1,5 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); + let module = require('ui/modules').get('kibana'); module.directive('autoSelectIfOnlyOne', function ($parse) { return { @@ -7,7 +7,7 @@ define(function (require) { require: 'ngModel', link: function (scope, element, attributes, ngModelCtrl) { attributes.$observe('autoSelectIfOnlyOne', function (result) { - var options = $parse(result)(scope); + let options = $parse(result)(scope); if (options && options.length === 1) { ngModelCtrl.$setViewValue(options[0]); ngModelCtrl.$render(); diff --git a/src/ui/public/directives/click_focus.js b/src/ui/public/directives/click_focus.js index d996664e069f..e005afd2cf97 100644 --- a/src/ui/public/directives/click_focus.js +++ b/src/ui/public/directives/click_focus.js @@ -1,7 +1,7 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); - var _ = require('lodash'); - var $ = require('jquery'); + let module = require('ui/modules').get('kibana'); + let _ = require('lodash'); + let $ = require('jquery'); module.directive('clickFocus', function () { return { @@ -11,7 +11,7 @@ define(function (require) { restrict: 'A', link: function ($scope, $elem) { function handler() { - var focusElem = $.find('input[name=' + $scope.clickFocus + ']'); + let focusElem = $.find('input[name=' + $scope.clickFocus + ']'); if (focusElem[0]) focusElem[0].focus(); } diff --git a/src/ui/public/directives/config.js b/src/ui/public/directives/config.js index a8f69b28ca5e..44ae5a102a3e 100644 --- a/src/ui/public/directives/config.js +++ b/src/ui/public/directives/config.js @@ -1,9 +1,9 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); require('ui/watch_multi'); - var ConfigTemplate = require('ui/ConfigTemplate'); - var angular = require('angular'); - var module = require('ui/modules').get('kibana'); + let ConfigTemplate = require('ui/ConfigTemplate'); + let angular = require('angular'); + let module = require('ui/modules').get('kibana'); require('ui/directives/input_focus'); @@ -26,13 +26,13 @@ define(function (require) { configObject: '=' }, link: function ($scope, element, attr) { - var tmpScope = $scope.$new(); + let tmpScope = $scope.$new(); $scope.$watch('configObject', function (newVal) { $scope[attr.configObject] = $scope.configObject; }); - var wrapTmpl = function (tmpl) { + let wrapTmpl = function (tmpl) { if ($scope.configSubmit) { return '
' + tmpl + '
'; } else { @@ -44,7 +44,7 @@ define(function (require) { 'configSubmit', 'configTemplate.current || configTemplate' ], function () { - var tmpl = $scope.configTemplate; + let tmpl = $scope.configTemplate; if (tmpl instanceof ConfigTemplate) { tmpl = tmpl.toString(); } @@ -52,7 +52,7 @@ define(function (require) { tmpScope.$destroy(); tmpScope = $scope.$new(); - var html = ''; + let html = ''; if (tmpl) { html = $compile('' + '
' + diff --git a/src/ui/public/directives/confirm_click.js b/src/ui/public/directives/confirm_click.js index c4f10462948d..b2e710740cf0 100644 --- a/src/ui/public/directives/confirm_click.js +++ b/src/ui/public/directives/confirm_click.js @@ -6,9 +6,9 @@ define(function (require) { restrict: 'A', link: function ($scope, $elem, attrs) { $elem.bind('click', function () { - var message = attrs.confirmation || 'Are you sure?'; + let message = attrs.confirmation || 'Are you sure?'; if (window.confirm(message)) { // eslint-disable-line no-alert - var action = attrs.confirmClick; + let action = attrs.confirmClick; if (action) { $scope.$apply($scope.$eval(action)); } diff --git a/src/ui/public/directives/css_truncate.js b/src/ui/public/directives/css_truncate.js index 1b6afcdd2d07..13c38b7c11b6 100644 --- a/src/ui/public/directives/css_truncate.js +++ b/src/ui/public/directives/css_truncate.js @@ -1,7 +1,7 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); - var $ = require('jquery'); - var _ = require('lodash'); + let module = require('ui/modules').get('kibana'); + let $ = require('jquery'); + let _ = require('lodash'); module.directive('cssTruncate', function ($timeout) { return { diff --git a/src/ui/public/directives/field_name.js b/src/ui/public/directives/field_name.js index 21bf398c825f..b6fa45fb0e44 100644 --- a/src/ui/public/directives/field_name.js +++ b/src/ui/public/directives/field_name.js @@ -1,5 +1,5 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); + let module = require('ui/modules').get('kibana'); require('ui/filters/short_dots'); module.directive('fieldName', function ($compile, $rootScope, $filter) { @@ -12,7 +12,7 @@ define(function (require) { }, link: function ($scope, $el) { - var typeIcon = function (fieldType) { + let typeIcon = function (fieldType) { switch (fieldType) { case 'source': return ''; @@ -44,12 +44,12 @@ define(function (require) { 'field.rowCount' ], function () { - var type = $scope.field ? $scope.field.type : $scope.fieldType; - var name = $scope.field ? $scope.field.name : $scope.fieldName; - var results = $scope.field ? !$scope.field.rowCount && !$scope.field.scripted : false; - var scripted = $scope.field ? $scope.field.scripted : false; + let type = $scope.field ? $scope.field.type : $scope.fieldType; + let name = $scope.field ? $scope.field.name : $scope.fieldName; + let results = $scope.field ? !$scope.field.rowCount && !$scope.field.scripted : false; + let scripted = $scope.field ? $scope.field.scripted : false; - var displayName = $filter('shortDots')(name); + let displayName = $filter('shortDots')(name); $el .text(displayName) diff --git a/src/ui/public/directives/file_upload.js b/src/ui/public/directives/file_upload.js index c9cb4a9f669b..0bb64bc000bd 100644 --- a/src/ui/public/directives/file_upload.js +++ b/src/ui/public/directives/file_upload.js @@ -1,25 +1,25 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); - var $ = require('jquery'); + let module = require('ui/modules').get('kibana'); + let $ = require('jquery'); module.directive('fileUpload', function ($parse) { return { restrict: 'A', link: function ($scope, $elem, attrs) { - var onUpload = $parse(attrs.fileUpload); + let onUpload = $parse(attrs.fileUpload); - var $fileInput = $(''); + let $fileInput = $(''); $elem.after($fileInput); $fileInput.on('change', function (e) { - var reader = new FileReader(); + let reader = new FileReader(); reader.onload = function (e) { $scope.$apply(function () { onUpload($scope, {fileContents: e.target.result}); }); }; - var target = e.srcElement || e.target; + let target = e.srcElement || e.target; if (target && target.files && target.files.length) reader.readAsText(target.files[0]); }); diff --git a/src/ui/public/directives/inequality.js b/src/ui/public/directives/inequality.js index 68e83ed378d0..71d3b1b0df6f 100644 --- a/src/ui/public/directives/inequality.js +++ b/src/ui/public/directives/inequality.js @@ -5,8 +5,8 @@ define(function (require) { return { require: 'ngModel', link: function ($scope, $el, $attr, ngModel) { - var getBound = function () { return $parse($attr[id])(); }; - var defaultVal = { + let getBound = function () { return $parse($attr[id])(); }; + let defaultVal = { 'greaterThan': -Infinity, 'lessThan': Infinity }[id]; @@ -19,8 +19,8 @@ define(function (require) { }); function validate(val) { - var bound = !isNaN(getBound()) ? +getBound() : defaultVal; - var valid = !isNaN(bound) && !isNaN(val) && compare(val, bound); + let bound = !isNaN(getBound()) ? +getBound() : defaultVal; + let valid = !isNaN(bound) && !isNaN(val) && compare(val, bound); ngModel.$setValidity(id, valid); return val; } diff --git a/src/ui/public/directives/infinite_scroll.js b/src/ui/public/directives/infinite_scroll.js index 2acfe3768116..52b1479634f7 100644 --- a/src/ui/public/directives/infinite_scroll.js +++ b/src/ui/public/directives/infinite_scroll.js @@ -1,6 +1,6 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); - var $ = require('jquery'); + let module = require('ui/modules').get('kibana'); + let $ = require('jquery'); module.directive('kbnInfiniteScroll', function () { return { @@ -9,20 +9,20 @@ define(function (require) { more: '=' }, link: function ($scope, $element, attrs) { - var $window = $(window); + let $window = $(window); let checkTimer; function onScroll() { if (!$scope.more) return; - var winHeight = $window.height(); - var winBottom = winHeight + $window.scrollTop(); - var elTop = $element.offset().top; - var remaining = elTop - winBottom; + let winHeight = $window.height(); + let winBottom = winHeight + $window.scrollTop(); + let elTop = $element.offset().top; + let remaining = elTop - winBottom; if (remaining <= winHeight * 0.50) { $scope[$scope.$$phase ? '$eval' : '$apply'](function () { - var more = $scope.more(); + let more = $scope.more(); }); } } diff --git a/src/ui/public/directives/info.js b/src/ui/public/directives/info.js index a9a69f8a1482..7e47e6315502 100644 --- a/src/ui/public/directives/info.js +++ b/src/ui/public/directives/info.js @@ -1,5 +1,5 @@ define(function (require) { - var html = require('ui/partials/info.html'); + let html = require('ui/partials/info.html'); require('ui/modules') .get('kibana') diff --git a/src/ui/public/directives/input_datetime.js b/src/ui/public/directives/input_datetime.js index c37aa31318cf..77cb5669778e 100644 --- a/src/ui/public/directives/input_datetime.js +++ b/src/ui/public/directives/input_datetime.js @@ -1,8 +1,8 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); - var $ = require('jquery'); - var _ = require('lodash'); - var moment = require('moment'); + let module = require('ui/modules').get('kibana'); + let $ = require('jquery'); + let _ = require('lodash'); + let moment = require('moment'); module.directive('inputDatetime', function () { return { @@ -10,18 +10,18 @@ define(function (require) { require: 'ngModel', link: function ($scope, $elem, attrs, ngModel) { - var format = 'YYYY-MM-DD HH:mm:ss.SSS'; + let format = 'YYYY-MM-DD HH:mm:ss.SSS'; $elem.after('
' + format + '
'); // What should I make with the input from the user? - var fromUser = function (text) { - var parsed = moment(text, format); + let fromUser = function (text) { + let parsed = moment(text, format); return parsed.isValid() ? parsed : undefined; }; // How should I present the data back to the user in the input field? - var toUser = function (datetime) { + let toUser = function (datetime) { return moment(datetime).format(format); }; diff --git a/src/ui/public/directives/input_focus.js b/src/ui/public/directives/input_focus.js index 99cf9dd5d085..0202e38cf144 100644 --- a/src/ui/public/directives/input_focus.js +++ b/src/ui/public/directives/input_focus.js @@ -1,5 +1,5 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); + let module = require('ui/modules').get('kibana'); module.directive('inputFocus', function ($timeout) { return { diff --git a/src/ui/public/directives/input_whole_number.js b/src/ui/public/directives/input_whole_number.js index 1b77b66772ab..a7307cd1374a 100644 --- a/src/ui/public/directives/input_whole_number.js +++ b/src/ui/public/directives/input_whole_number.js @@ -1,5 +1,5 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); + let module = require('ui/modules').get('kibana'); module.directive('inputWholeNumber', function () { return { diff --git a/src/ui/public/directives/json_input.js b/src/ui/public/directives/json_input.js index a8351ed1c7fa..48cedb5e5dec 100644 --- a/src/ui/public/directives/json_input.js +++ b/src/ui/public/directives/json_input.js @@ -1,6 +1,6 @@ define(function (require) { - var _ = require('lodash'); - var angular = require('angular'); + let _ = require('lodash'); + let angular = require('angular'); require('ui/modules') .get('kibana') @@ -15,7 +15,7 @@ define(function (require) { function fromJSON(value) { try { value = JSON.parse(value); - var validity = !scope.$eval(attrs.requireKeys) ? true : _.keys(value).length > 0; + let validity = !scope.$eval(attrs.requireKeys) ? true : _.keys(value).length > 0; ngModelCntrl.$setValidity('json', validity); } catch (e) { ngModelCntrl.$setValidity('json', false); diff --git a/src/ui/public/directives/paginate.js b/src/ui/public/directives/paginate.js index cac3ee123afc..8f4110a49b33 100644 --- a/src/ui/public/directives/paginate.js +++ b/src/ui/public/directives/paginate.js @@ -1,7 +1,7 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); - var PER_PAGE_DEFAULT = 10; + let PER_PAGE_DEFAULT = 10; require('ui/modules').get('kibana') .directive('paginate', function ($parse, $compile) { @@ -21,7 +21,7 @@ define(function (require) { $el.prepend($compile('')($scope)); } - var paginate = $scope.paginate; + let paginate = $scope.paginate; // add some getters to the controller powered by attributes paginate.getList = $parse(attrs.list); @@ -41,8 +41,8 @@ define(function (require) { }, controllerAs: 'paginate', controller: function ($scope) { - var self = this; - var ALL = 0; + let self = this; + let ALL = 0; self.sizeOptions = [ { title: '10', value: 10 }, @@ -61,8 +61,8 @@ define(function (require) { self.perPageProp, self.otherWidthGetter ], function (vals, oldVals) { - var intChanges = vals[0] !== oldVals[0]; - var extChanges = vals[1] !== oldVals[1]; + let intChanges = vals[0] !== oldVals[0]; + let extChanges = vals[1] !== oldVals[1]; if (intChanges) { if (!setPerPage(self.perPage)) { @@ -101,14 +101,14 @@ define(function (require) { $scope.pages = []; if (!$scope.list) return; - var perPage = _.parseInt(self.perPage); - var count = perPage ? Math.ceil($scope.list.length / perPage) : 1; + let perPage = _.parseInt(self.perPage); + let count = perPage ? Math.ceil($scope.list.length / perPage) : 1; _.times(count, function (i) { let page; if (perPage) { - var start = perPage * i; + let start = perPage * i; page = $scope.list.slice(start, start + perPage); } else { page = $scope.list.slice(0); @@ -143,9 +143,9 @@ define(function (require) { // setup the list of the other pages to link to $scope.otherPages = []; - var width = +self.otherWidthGetter($scope) || 5; - var left = page.i - Math.round((width - 1) / 2); - var right = left + width - 1; + let width = +self.otherWidthGetter($scope) || 5; + let left = page.i - Math.round((width - 1) / 2); + let right = left + width - 1; // shift neg count from left to right if (left < 0) { @@ -154,14 +154,14 @@ define(function (require) { } // shift extra right nums to left - var lastI = page.count - 1; + let lastI = page.count - 1; if (right > lastI) { right = lastI; left = right - width + 1; } - for (var i = left; i <= right; i++) { - var other = $scope.pages[i]; + for (let i = left; i <= right; i++) { + let other = $scope.pages[i]; if (!other) continue; @@ -172,7 +172,7 @@ define(function (require) { }; function setPerPage(val) { - var $ppParent = $scope; + let $ppParent = $scope; while ($ppParent && !_.has($ppParent, self.perPageProp)) { $ppParent = $ppParent.$parent; diff --git a/src/ui/public/directives/pretty_duration.js b/src/ui/public/directives/pretty_duration.js index dab9106b325a..0706c47bf39f 100644 --- a/src/ui/public/directives/pretty_duration.js +++ b/src/ui/public/directives/pretty_duration.js @@ -1,8 +1,8 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); - var _ = require('lodash'); - var dateMath = require('ui/utils/dateMath'); - var moment = require('moment'); + let module = require('ui/modules').get('kibana'); + let _ = require('lodash'); + let dateMath = require('ui/utils/dateMath'); + let moment = require('moment'); require('ui/timepicker/quick_ranges'); require('ui/timepicker/time_units'); @@ -15,9 +15,9 @@ define(function (require) { to: '=' }, link: function ($scope, $elem) { - var dateFormat = config.get('dateFormat'); + let dateFormat = config.get('dateFormat'); - var lookupByRange = {}; + let lookupByRange = {}; _.each(quickRanges, function (frame) { lookupByRange[frame.from + ' to ' + frame.to] = frame; }); @@ -26,13 +26,13 @@ define(function (require) { let text; // If both parts are date math, try to look up a reasonable string if ($scope.from && $scope.to && !moment.isMoment($scope.from) && !moment.isMoment($scope.to)) { - var tryLookup = lookupByRange[$scope.from.toString() + ' to ' + $scope.to.toString()]; + let tryLookup = lookupByRange[$scope.from.toString() + ' to ' + $scope.to.toString()]; if (tryLookup) { $elem.text(tryLookup.display); } else { - var fromParts = $scope.from.toString().split('-'); + let fromParts = $scope.from.toString().split('-'); if ($scope.to.toString() === 'now' && fromParts[0] === 'now' && fromParts[1]) { - var rounded = fromParts[1].split('/'); + let rounded = fromParts[1].split('/'); text = 'Last ' + rounded[0]; if (rounded[1]) { text = text + ' rounded to the ' + timeUnits[rounded[1]]; @@ -49,7 +49,7 @@ define(function (require) { }; function cantLookup() { - var display = {}; + let display = {}; _.each(['from', 'to'], function (time) { if (moment.isMoment($scope[time])) { display[time] = $scope[time].format(dateFormat); @@ -57,7 +57,7 @@ define(function (require) { if ($scope[time] === 'now') { display[time] = 'now'; } else { - var tryParse = dateMath.parse($scope[time], time === 'to' ? true : false); + let tryParse = dateMath.parse($scope[time], time === 'to' ? true : false); display[time] = moment.isMoment(tryParse) ? '~ ' + tryParse.fromNow() : $scope[time]; } } diff --git a/src/ui/public/directives/rows.js b/src/ui/public/directives/rows.js index dc29d3338908..55479a376648 100644 --- a/src/ui/public/directives/rows.js +++ b/src/ui/public/directives/rows.js @@ -1,25 +1,25 @@ define(function (require) { - var $ = require('jquery'); - var _ = require('lodash'); - var module = require('ui/modules').get('kibana'); - var AggConfigResult = require('ui/Vis/AggConfigResult'); + let $ = require('jquery'); + let _ = require('lodash'); + let module = require('ui/modules').get('kibana'); + let AggConfigResult = require('ui/Vis/AggConfigResult'); module.directive('kbnRows', function ($compile, $rootScope, getAppState, Private) { - var filterBarClickHandler = Private(require('ui/filter_bar/filter_bar_click_handler')); + let filterBarClickHandler = Private(require('ui/filter_bar/filter_bar_click_handler')); return { restrict: 'A', link: function ($scope, $el, attr) { function addCell($tr, contents) { - var $cell = $(document.createElement('td')); + 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 (_.isNumeric(contents)) $cell.addClass('numeric-value'); - var createAggConfigResultCell = function (aggConfigResult) { - var $cell = $(document.createElement('td')); - var $state = getAppState(); - var clickHandler = filterBarClickHandler($state); + let createAggConfigResultCell = function (aggConfigResult) { + let $cell = $(document.createElement('td')); + let $state = getAppState(); + let clickHandler = filterBarClickHandler($state); $cell.scope = $scope.$new(); $cell.addClass('cell-hover'); $cell.attr('ng-click', 'clickHandler($event)'); @@ -70,19 +70,19 @@ define(function (require) { attr.kbnRows, attr.kbnRowsMin ], function (vals) { - var rows = vals[0]; - var min = vals[1]; + let rows = vals[0]; + let min = vals[1]; $el.empty(); if (!_.isArray(rows)) rows = []; - var width = rows.reduce(maxRowSize, 0); + let width = rows.reduce(maxRowSize, 0); if (isFinite(min) && rows.length < min) { // clone the rows so that we can add elements to it without upsetting the original rows = _.clone(rows); // crate the empty row which will be pushed into the row list over and over - var emptyRow = new Array(width); + let emptyRow = new Array(width); // fill the empty row with values _.times(width, function (i) { emptyRow[i] = ''; }); // push as many empty rows into the row array as needed @@ -90,7 +90,7 @@ define(function (require) { } rows.forEach(function (row) { - var $tr = $(document.createElement('tr')).appendTo($el); + let $tr = $(document.createElement('tr')).appendTo($el); row.forEach(function (cell) { addCell($tr, cell); }); diff --git a/src/ui/public/directives/saved_object_finder.js b/src/ui/public/directives/saved_object_finder.js index 0cd80f51150a..3b2ae43a2aeb 100644 --- a/src/ui/public/directives/saved_object_finder.js +++ b/src/ui/public/directives/saved_object_finder.js @@ -1,12 +1,12 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); - var _ = require('lodash'); - var rison = require('ui/utils/rison'); - var keymap = require('ui/utils/key_map'); + let module = require('ui/modules').get('kibana'); + let _ = require('lodash'); + let rison = require('ui/utils/rison'); + let keymap = require('ui/utils/key_map'); module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Private, config) { - var services = Private(require('ui/saved_objects/saved_object_registry')).byLoaderPropertiesName; + let services = Private(require('ui/saved_objects/saved_object_registry')).byLoaderPropertiesName; return { restrict: 'E', @@ -21,19 +21,19 @@ define(function (require) { template: require('ui/partials/saved_object_finder.html'), controllerAs: 'finder', controller: function ($scope, $element, $timeout) { - var self = this; + let self = this; // The number of items to show in the list $scope.perPage = config.get('savedObjects:perPage'); // the text input element - var $input = $element.find('input[ng-model=filter]'); + let $input = $element.find('input[ng-model=filter]'); // the list that will hold the suggestions - var $list = $element.find('ul'); + let $list = $element.find('ul'); // the current filter string, used to check that returned results are still useful - var currentFilter = $scope.filter; + let currentFilter = $scope.filter; // the most recently entered search/filter let prevSearch; @@ -76,7 +76,7 @@ define(function (require) { $scope.userOnChoose(hit, $event); } - var url = self.makeUrl(hit); + let url = self.makeUrl(hit); if (!url || url === '#' || url.charAt(0) !== '#') return; $event.preventDefault(); @@ -114,7 +114,7 @@ define(function (require) { case 'enter': if (self.hitCount !== 1) return; - var hit = self.hits[0]; + let hit = self.hits[0]; if (!hit) return; self.onChoose(hit, $event); @@ -187,8 +187,8 @@ define(function (require) { case 'enter': if (!self.selector.enabled) break; - var hitIndex = ((page.number - 1) * paginate.perPage) + self.selector.index; - var hit = self.hits[hitIndex]; + let hitIndex = ((page.number - 1) * paginate.perPage) + self.selector.index; + let hit = self.hits[hitIndex]; if (!hit) break; self.onChoose(hit, $event); @@ -230,7 +230,7 @@ define(function (require) { // but ensure that we don't search for the same // thing twice. This is called from multiple places // and needs to be smart about when it actually searches - var filter = currentFilter; + let filter = currentFilter; if (prevSearch === filter) return; prevSearch = filter; @@ -246,7 +246,7 @@ define(function (require) { } function scrollIntoView($element, snapTop) { - var el = $element[0]; + let el = $element[0]; if (!el) return; diff --git a/src/ui/public/directives/spinner.js b/src/ui/public/directives/spinner.js index 504cd89de8b4..f96fb9a8935c 100644 --- a/src/ui/public/directives/spinner.js +++ b/src/ui/public/directives/spinner.js @@ -1,6 +1,6 @@ define(function (require) { - var html = '
'; - var module = require('ui/modules').get('kibana'); + let html = '
'; + let module = require('ui/modules').get('kibana'); module.directive('spinner', function () { return { diff --git a/src/ui/public/directives/truncated.js b/src/ui/public/directives/truncated.js index 7ae46defff41..ef6882b77585 100644 --- a/src/ui/public/directives/truncated.js +++ b/src/ui/public/directives/truncated.js @@ -1,6 +1,6 @@ define(function (require) { - var module = require('ui/modules').get('kibana'); - var $ = require('jquery'); + let module = require('ui/modules').get('kibana'); + let $ = require('jquery'); module.directive('kbnTruncated', function ($compile) { return { @@ -10,14 +10,14 @@ define(function (require) { length: '@' }, template: function ($element, attrs) { - var template = '{{text}}'; + let template = '{{text}}'; template += ' {{action}}'; return template; }, link: function ($scope, $element, attrs) { - var fullText = $scope.orig; - var truncated = fullText.substring(0, $scope.length); + let fullText = $scope.orig; + let truncated = fullText.substring(0, $scope.length); if (fullText === truncated) { $scope.text = fullText; diff --git a/src/ui/public/directives/validate_cidr_mask.js b/src/ui/public/directives/validate_cidr_mask.js index 64295872a637..c8d4e2b6838e 100644 --- a/src/ui/public/directives/validate_cidr_mask.js +++ b/src/ui/public/directives/validate_cidr_mask.js @@ -1,6 +1,6 @@ define(function (require) { - var _ = require('lodash'); - var CidrMask = require('ui/utils/CidrMask'); + let _ = require('lodash'); + let CidrMask = require('ui/utils/CidrMask'); require('ui/modules').get('kibana').directive('validateCidrMask', function () { return { diff --git a/src/ui/public/directives/validate_date_math.js b/src/ui/public/directives/validate_date_math.js index 9ab572b59d60..89e9c920d078 100644 --- a/src/ui/public/directives/validate_date_math.js +++ b/src/ui/public/directives/validate_date_math.js @@ -1,6 +1,6 @@ define(function (require) { - var _ = require('lodash'); - var dateMath = require('ui/utils/dateMath'); + let _ = require('lodash'); + let dateMath = require('ui/utils/dateMath'); require('ui/modules').get('kibana').directive('validateDateMath', function () { return { @@ -19,7 +19,7 @@ define(function (require) { return null; } - var moment = dateMath.parse(input); + let moment = dateMath.parse(input); ngModel.$setValidity('validDateMath', moment != null && moment.isValid()); return input; } diff --git a/src/ui/public/directives/validate_index_name.js b/src/ui/public/directives/validate_index_name.js index 6f5248a7c4c6..84149f50b502 100644 --- a/src/ui/public/directives/validate_index_name.js +++ b/src/ui/public/directives/validate_index_name.js @@ -1,6 +1,6 @@ // See https://github.com/elastic/elasticsearch/issues/6736 define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); require('ui/modules') .get('kibana') @@ -12,11 +12,11 @@ define(function (require) { 'ngModel': '=' }, link: function ($scope, elem, attr, ngModel) { - var illegalCharacters = ['\\', '/', '?', '"', '<', '>', '|', ' ', ',']; - var isValid = function (input) { + let illegalCharacters = ['\\', '/', '?', '"', '<', '>', '|', ' ', ',']; + let isValid = function (input) { if (input == null || input === '' || input === '.' || input === '..') return false; - var match = _.find(illegalCharacters, function (character) { + let match = _.find(illegalCharacters, function (character) { return input.indexOf(character) >= 0; }); return !match; @@ -24,7 +24,7 @@ define(function (require) { // From User ngModel.$parsers.unshift(function (value) { - var valid = isValid(value); + let valid = isValid(value); ngModel.$setValidity('indexNameInput', valid); return valid ? value : undefined; }); diff --git a/src/ui/public/directives/validate_ip.js b/src/ui/public/directives/validate_ip.js index 6306adaa54ae..1049603f74c7 100644 --- a/src/ui/public/directives/validate_ip.js +++ b/src/ui/public/directives/validate_ip.js @@ -1,6 +1,6 @@ define(function (require) { - var _ = require('lodash'); - var Ipv4Address = require('ui/utils/Ipv4Address'); + let _ = require('lodash'); + let Ipv4Address = require('ui/utils/Ipv4Address'); require('ui/modules') .get('kibana') diff --git a/src/ui/public/directives/validate_json.js b/src/ui/public/directives/validate_json.js index 7c429745e450..c542eb95c394 100644 --- a/src/ui/public/directives/validate_json.js +++ b/src/ui/public/directives/validate_json.js @@ -1,8 +1,8 @@ define(function (require) { - var _ = require('lodash'); - var $ = require('jquery'); + let _ = require('lodash'); + let $ = require('jquery'); - var module = require('ui/modules').get('kibana'); + let module = require('ui/modules').get('kibana'); module.directive('validateJson', function ($compile) { return { diff --git a/src/ui/public/doc_table/components/table_header.js b/src/ui/public/doc_table/components/table_header.js index 9f6de699c32c..f1f131b7923a 100644 --- a/src/ui/public/doc_table/components/table_header.js +++ b/src/ui/public/doc_table/components/table_header.js @@ -1,11 +1,11 @@ define(function (require) { - var _ = require('lodash'); - var module = require('ui/modules').get('app/discover'); + let _ = require('lodash'); + let module = require('ui/modules').get('app/discover'); require('ui/filters/short_dots'); module.directive('kbnTableHeader', function (shortDotsFilter) { - var headerHtml = require('ui/doc_table/components/table_header.html'); + let headerHtml = require('ui/doc_table/components/table_header.html'); return { restrict: 'A', scope: { @@ -16,9 +16,9 @@ define(function (require) { template: headerHtml, controller: function ($scope) { - var sortableField = function (field) { + let sortableField = function (field) { if (!$scope.indexPattern) return; - var sortable = _.get($scope.indexPattern.fields.byName[field], 'sortable'); + let sortable = _.get($scope.indexPattern.fields.byName[field], 'sortable'); return sortable; }; @@ -34,22 +34,22 @@ define(function (require) { $scope.headerClass = function (column) { if (!sortableField(column)) return; - var sorting = $scope.sorting; - var defaultClass = ['fa', 'fa-sort-up', 'table-header-sortchange']; + let sorting = $scope.sorting; + let defaultClass = ['fa', 'fa-sort-up', 'table-header-sortchange']; if (!sorting || column !== sorting[0]) return defaultClass; return ['fa', sorting[1] === 'asc' ? 'fa-sort-up' : 'fa-sort-down']; }; $scope.moveLeft = function (column) { - var index = _.indexOf($scope.columns, column); + let index = _.indexOf($scope.columns, column); if (index === 0) return; _.move($scope.columns, index, --index); }; $scope.moveRight = function (column) { - var index = _.indexOf($scope.columns, column); + let index = _.indexOf($scope.columns, column); if (index === $scope.columns.length - 1) return; _.move($scope.columns, index, ++index); @@ -62,9 +62,9 @@ define(function (require) { $scope.sort = function (column) { if (!column || !sortableField(column)) return; - var sorting = $scope.sorting = $scope.sorting || []; + let sorting = $scope.sorting = $scope.sorting || []; - var direction = sorting[1] || 'asc'; + let direction = sorting[1] || 'asc'; if (sorting[0] !== column) { direction = 'asc'; } else { diff --git a/src/ui/public/doc_table/components/table_row.js b/src/ui/public/doc_table/components/table_row.js index f81fb902bcc5..4b50b4270555 100644 --- a/src/ui/public/doc_table/components/table_row.js +++ b/src/ui/public/doc_table/components/table_row.js @@ -1,8 +1,8 @@ define(function (require) { - var _ = require('lodash'); - var $ = require('jquery'); - var addWordBreaks = require('ui/utils/add_word_breaks'); - var module = require('ui/modules').get('app/discover'); + let _ = require('lodash'); + let $ = require('jquery'); + let addWordBreaks = require('ui/utils/add_word_breaks'); + let module = require('ui/modules').get('app/discover'); require('ui/highlight'); require('ui/highlight/highlight_tags'); @@ -12,7 +12,7 @@ define(function (require) { // guesstimate at the minimum number of chars wide cells in the table should be - var MIN_LINE_LENGTH = 20; + let MIN_LINE_LENGTH = 20; /** * kbnTableRow directive @@ -23,11 +23,11 @@ define(function (require) { * ``` */ module.directive('kbnTableRow', function ($compile) { - var noWhiteSpace = require('ui/utils/no_white_space'); - var openRowHtml = require('ui/doc_table/components/table_row/open.html'); - var detailsHtml = require('ui/doc_table/components/table_row/details.html'); - var cellTemplate = _.template(noWhiteSpace(require('ui/doc_table/components/table_row/cell.html'))); - var truncateByHeightTemplate = _.template(noWhiteSpace(require('ui/partials/truncate_by_height.html'))); + let noWhiteSpace = require('ui/utils/no_white_space'); + let openRowHtml = require('ui/doc_table/components/table_row/open.html'); + let detailsHtml = require('ui/doc_table/components/table_row/details.html'); + let cellTemplate = _.template(noWhiteSpace(require('ui/doc_table/components/table_row/cell.html'))); + let truncateByHeightTemplate = _.template(noWhiteSpace(require('ui/partials/truncate_by_height.html'))); return { restrict: 'A', @@ -41,7 +41,7 @@ define(function (require) { $el.after(''); $el.empty(); - var init = function () { + let init = function () { createSummaryRow($scope.row, $scope.row._id); }; @@ -53,7 +53,7 @@ define(function (require) { // toggle display of the rows details, a full list of the fields from each row $scope.toggleRow = function () { - var $detailsTr = $el.next(); + let $detailsTr = $el.next(); $scope.open = !$scope.open; @@ -90,10 +90,10 @@ define(function (require) { // create a tr element that lists the value for each *column* function createSummaryRow(row) { - var indexPattern = $scope.indexPattern; + let indexPattern = $scope.indexPattern; // We just create a string here because its faster. - var newHtmls = [ + let newHtmls = [ openRowHtml ]; @@ -112,18 +112,18 @@ define(function (require) { })); }); - var $cells = $el.children(); + let $cells = $el.children(); newHtmls.forEach(function (html, i) { - var $cell = $cells.eq(i); + let $cell = $cells.eq(i); if ($cell.data('discover:html') === html) return; - var reuse = _.find($cells.slice(i + 1), function (cell) { + let reuse = _.find($cells.slice(i + 1), function (cell) { return $.data(cell, 'discover:html') === html; }); - var $target = reuse ? $(reuse).detach() : $(html); + let $target = reuse ? $(reuse).detach() : $(html); $target.data('discover:html', html); - var $before = $cells.eq(i - 1); + let $before = $cells.eq(i - 1); if ($before.size()) { $before.after($target); } else { @@ -151,8 +151,8 @@ define(function (require) { * Fill an element with the value of a field */ function _displayField(row, fieldName, breakWords) { - var indexPattern = $scope.indexPattern; - var text = indexPattern.formatField(row, fieldName); + let indexPattern = $scope.indexPattern; + let text = indexPattern.formatField(row, fieldName); if (breakWords) { text = addWordBreaks(text, MIN_LINE_LENGTH); diff --git a/src/ui/public/doc_table/doc_table.js b/src/ui/public/doc_table/doc_table.js index 4bebced3c974..cba9b87d0939 100644 --- a/src/ui/public/doc_table/doc_table.js +++ b/src/ui/public/doc_table/doc_table.js @@ -1,8 +1,8 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); - var html = require('ui/doc_table/doc_table.html'); - var getSort = require('ui/doc_table/lib/get_sort'); + let html = require('ui/doc_table/doc_table.html'); + let getSort = require('ui/doc_table/lib/get_sort'); require('ui/doc_table/doc_table.less'); require('ui/directives/truncated'); @@ -25,15 +25,15 @@ define(function (require) { filter: '=?', }, link: function ($scope) { - var notify = new Notifier(); + let notify = new Notifier(); $scope.limit = 50; $scope.persist = { sorting: $scope.sorting, columns: $scope.columns }; - var prereq = (function () { - var fns = []; + let prereq = (function () { + let fns = []; return function register(fn) { fns.push(fn); @@ -59,7 +59,7 @@ define(function (require) { $scope.$watch('columns', function (columns) { if (columns.length !== 0) return; - var $state = getAppState(); + let $state = getAppState(); $scope.columns.push('_source'); if ($state) $state.replace(); }); diff --git a/src/ui/public/doc_table/lib/get_sort.js b/src/ui/public/doc_table/lib/get_sort.js index 6fa8870bf79c..1d8a7fea158a 100644 --- a/src/ui/public/doc_table/lib/get_sort.js +++ b/src/ui/public/doc_table/lib/get_sort.js @@ -1,5 +1,5 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); /** * Take a sorting array and make it into an object @@ -8,7 +8,7 @@ define(function (require) { * @returns {object} a sort object suitable for returning to elasticsearch */ function getSort(sort, indexPattern) { - var sortObj = {}; + let sortObj = {}; let field; let direction; diff --git a/src/ui/public/doc_title/doc_title.js b/src/ui/public/doc_title/doc_title.js index bc7898dc692e..b5f5e6c8a2c7 100644 --- a/src/ui/public/doc_title/doc_title.js +++ b/src/ui/public/doc_title/doc_title.js @@ -1,6 +1,6 @@ define(function (require) { - var _ = require('lodash'); - var chrome = require('ui/chrome'); + let _ = require('lodash'); + let chrome = require('ui/chrome'); require('ui/modules').get('kibana') .run(function ($rootScope, docTitle) { @@ -11,16 +11,16 @@ define(function (require) { $rootScope.$watch(_.bindKey(chrome, 'getActiveTabTitle'), docTitle.update); }) .service('docTitle', function ($rootScope) { - var baseTitle = document.title; - var self = this; + let baseTitle = document.title; + let self = this; let lastChange; function render() { lastChange = lastChange || []; - var parts = [lastChange[0]]; - var activeTabTitle = chrome.getActiveTabTitle(); + let parts = [lastChange[0]]; + let activeTabTitle = chrome.getActiveTabTitle(); if (activeTabTitle) parts.push(activeTabTitle); diff --git a/src/ui/public/doc_viewer/doc_viewer.js b/src/ui/public/doc_viewer/doc_viewer.js index d1359605c846..2378127b35bf 100644 --- a/src/ui/public/doc_viewer/doc_viewer.js +++ b/src/ui/public/doc_viewer/doc_viewer.js @@ -1,9 +1,9 @@ define(function (require) { - var _ = require('lodash'); - var angular = require('angular'); + let _ = require('lodash'); + let angular = require('angular'); require('ace'); - var html = require('ui/doc_viewer/doc_viewer.html'); + let html = require('ui/doc_viewer/doc_viewer.html'); require('ui/doc_viewer/doc_viewer.less'); require('ui/modules').get('kibana') @@ -38,7 +38,7 @@ define(function (require) { }; $scope.showArrayInObjectsWarning = function (row, field) { - var value = $scope.flattened[field]; + let value = $scope.flattened[field]; return _.isArray(value) && typeof value[0] === 'object'; }; }