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 bb32a5e81821..f444d5b27d0d 100644 --- a/src/ui/public/agg_response/geo_json/_tooltip_formatter.js +++ b/src/ui/public/agg_response/geo_json/_tooltip_formatter.js @@ -3,20 +3,20 @@ import _ from 'lodash'; import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; export default function TileMapTooltipFormatter($compile, $rootScope, Private) { - var fieldFormats = Private(RegistryFieldFormatsProvider); - var $tooltipScope = $rootScope.$new(); - var $el = $('
').html(require('ui/agg_response/geo_json/_tooltip.html')); + let fieldFormats = Private(RegistryFieldFormatsProvider); + 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 c0e0b9b52e4b..6c01ac567792 100644 --- a/src/ui/public/agg_response/geo_json/geo_json.js +++ b/src/ui/public/agg_response/geo_json/geo_json.js @@ -3,7 +3,7 @@ import rowsToFeatures from 'ui/agg_response/geo_json/rows_to_features'; import AggResponseGeoJsonTooltipFormatterProvider from 'ui/agg_response/geo_json/_tooltip_formatter'; export default function TileMapConverterFn(Private, timefilter, $compile, $rootScope) { - var tooltipFormatter = Private(AggResponseGeoJsonTooltipFormatterProvider); + let tooltipFormatter = Private(AggResponseGeoJsonTooltipFormatterProvider); return function (vis, table) { @@ -13,13 +13,13 @@ export default function TileMapConverterFn(Private, timefilter, $compile, $rootS }); } - 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/rows_to_features.js b/src/ui/public/agg_response/geo_json/rows_to_features.js index 6c65e09ab35b..634bfd26b533 100644 --- a/src/ui/public/agg_response/geo_json/rows_to_features.js +++ b/src/ui/public/agg_response/geo_json/rows_to_features.js @@ -12,19 +12,19 @@ function unwrap(val) { 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/_build_split.js b/src/ui/public/agg_response/hierarchical/_build_split.js index 8435b3c521bd..f4eb0fdf764a 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 @@ import collectKeys from 'ui/agg_response/hierarchical/_collect_keys'; import AggResponseHierarchicalTransformAggregationProvider from 'ui/agg_response/hierarchical/_transform_aggregation'; export default function biuldSplitProvider(Private) { - var transformer = Private(AggResponseHierarchicalTransformAggregationProvider); + let transformer = Private(AggResponseHierarchicalTransformAggregationProvider); 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 f19a3d8cf3b1..1b9a542462c7 100644 --- a/src/ui/public/agg_response/hierarchical/_collect_keys.js +++ b/src/ui/public/agg_response/hierarchical/_collect_keys.js @@ -1,7 +1,7 @@ import _ from 'lodash'; export default 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 ae79c41665db..93b9c1b519bf 100644 --- a/src/ui/public/agg_response/hierarchical/_create_raw_data.js +++ b/src/ui/public/agg_response/hierarchical/_create_raw_data.js @@ -3,12 +3,12 @@ import extractBuckets from 'ui/agg_response/hierarchical/_extract_buckets'; export default 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) { @@ -37,7 +37,7 @@ export default function (vis, resp) { // 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; @@ -60,9 +60,9 @@ export default function (vis, resp) { // 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; } @@ -73,7 +73,7 @@ export default function (vis, resp) { // 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 f6228c62b579..e80f40866453 100644 --- a/src/ui/public/agg_response/hierarchical/_extract_buckets.js +++ b/src/ui/public/agg_response/hierarchical/_extract_buckets.js @@ -2,7 +2,7 @@ import _ from 'lodash'; export default 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 0d4c88554ae3..f4acab3927a5 100644 --- a/src/ui/public/agg_response/hierarchical/_hierarchical_tooltip_formatter.js +++ b/src/ui/public/agg_response/hierarchical/_hierarchical_tooltip_formatter.js @@ -3,19 +3,19 @@ import $ from 'jquery'; import collectBranch from 'ui/agg_response/hierarchical/_collect_branch'; import numeral from 'numeral'; export default function HierarchicalTooltipFormaterProvider($rootScope, $compile, $sce) { - var $tooltip = $(require('ui/agg_response/hierarchical/_tooltip.html')); - var $tooltipScope = $rootScope.$new(); + let $tooltip = $(require('ui/agg_response/hierarchical/_tooltip.html')); + let $tooltipScope = $rootScope.$new(); $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 6078989cd13b..a176f2d3e015 100644 --- a/src/ui/public/agg_response/hierarchical/_transform_aggregation.js +++ b/src/ui/public/agg_response/hierarchical/_transform_aggregation.js @@ -4,14 +4,14 @@ import AggConfigResult from 'ui/vis/agg_config_result'; export default function transformAggregationProvider(Private) { 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, @@ -27,7 +27,7 @@ export default function transformAggregationProvider(Private) { // 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 7c64f4285c65..32c782bf6622 100644 --- a/src/ui/public/agg_response/hierarchical/build_hierarchical_data.js +++ b/src/ui/public/agg_response/hierarchical/build_hierarchical_data.js @@ -6,34 +6,34 @@ import AggConfigResult from 'ui/vis/agg_config_result'; import AggResponseHierarchicalBuildSplitProvider from 'ui/agg_response/hierarchical/_build_split'; import AggResponseHierarchicalHierarchicalTooltipFormatterProvider from 'ui/agg_response/hierarchical/_hierarchical_tooltip_formatter'; export default function buildHierarchicalDataProvider(Private, Notifier) { - var buildSplit = Private(AggResponseHierarchicalBuildSplitProvider); - var tooltipFormatter = Private(AggResponseHierarchicalHierarchicalTooltipFormatterProvider); + let buildSplit = Private(AggResponseHierarchicalBuildSplitProvider); + let tooltipFormatter = Private(AggResponseHierarchicalHierarchicalTooltipFormatterProvider); - 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; @@ -50,8 +50,8 @@ export default function buildHierarchicalDataProvider(Private, Notifier) { }; } - 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.'); @@ -59,7 +59,7 @@ export default function buildHierarchicalDataProvider(Private, Notifier) { // 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); @@ -67,17 +67,17 @@ export default function buildHierarchicalDataProvider(Private, Notifier) { } // 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; @@ -85,7 +85,7 @@ export default function buildHierarchicalDataProvider(Private, Notifier) { 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 a88978181b08..5f9516a421cc 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 @@ -2,10 +2,10 @@ import VisAggConfigProvider from 'ui/vis/agg_config'; import AggTypesAggTypeProvider from 'ui/agg_types/agg_type'; export default function PointSeriesFakeXAxis(Private) { - var AggConfig = Private(VisAggConfigProvider); - var AggType = Private(AggTypesAggTypeProvider); + let AggConfig = Private(VisAggConfigProvider); + let AggType = Private(AggTypesAggTypeProvider); - var allAgg = new AggType({ + let allAgg = new AggType({ name: 'all', title: 'All docs', ordered: false, @@ -13,7 +13,7 @@ export default function PointSeriesFakeXAxis(Private) { }); 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 db8aaeff5cc8..f4978de29885 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 @@ import _ from 'lodash'; import AggResponsePointSeriesFakeXAspectProvider from 'ui/agg_response/point_series/_fake_x_aspect'; export default function PointSeriesGetAspects(Private) { - var fakeXAspect = Private(AggResponsePointSeriesFakeXAspectProvider); + let fakeXAspect = Private(AggResponsePointSeriesFakeXAspectProvider); - var map = { + let map = { segment: 'x', metric: 'y', radius: 'z', @@ -12,12 +12,12 @@ export default function PointSeriesGetAspects(Private) { }; 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 @@ export default function PointSeriesGetAspects(Private) { * 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 9d52d18bd536..266ba41ce5c8 100644 --- a/src/ui/public/agg_response/point_series/_get_point.js +++ b/src/ui/public/agg_response/point_series/_get_point.js @@ -5,10 +5,10 @@ export default function PointSeriesGetPoint() { } 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 7c05f844a643..817ec2712d96 100644 --- a/src/ui/public/agg_response/point_series/_get_series.js +++ b/src/ui/public/agg_response/point_series/_get_series.js @@ -2,30 +2,30 @@ import _ from 'lodash'; import AggResponsePointSeriesGetPointProvider from 'ui/agg_response/point_series/_get_point'; import AggResponsePointSeriesAddToSiriProvider from 'ui/agg_response/point_series/_add_to_siri'; export default function PointSeriesGetSeries(Private) { - var getPoint = Private(AggResponsePointSeriesGetPointProvider); - var addToSiri = Private(AggResponsePointSeriesAddToSiriProvider); + let getPoint = Private(AggResponsePointSeriesGetPointProvider); + let addToSiri = Private(AggResponsePointSeriesAddToSiriProvider); 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); }); @@ -36,11 +36,11 @@ export default function PointSeriesGetSeries(Private) { 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 3c0e3313dd8b..edd3060fc85c 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 @@ -2,8 +2,8 @@ import _ from 'lodash'; export default function PointSeriesInitYAxis() { 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 @@ -14,7 +14,7 @@ export default function PointSeriesInitYAxis() { 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 ad4acd09b208..08b1d962252f 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 @@ -2,9 +2,9 @@ import moment from 'moment'; export default function PointSeriesOrderedDateAxis(timefilter) { 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); @@ -15,8 +15,8 @@ export default function PointSeriesOrderedDateAxis(timefilter) { 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 60a9627ea55d..715d692127d1 100644 --- a/src/ui/public/agg_response/point_series/_tooltip_formatter.js +++ b/src/ui/public/agg_response/point_series/_tooltip_formatter.js @@ -1,22 +1,22 @@ import $ from 'jquery'; export default function PointSeriesTooltipFormatter($compile, $rootScope) { - 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 f44c7fdc466c..0a2ccd90729c 100644 --- a/src/ui/public/agg_response/point_series/point_series.js +++ b/src/ui/public/agg_response/point_series/point_series.js @@ -7,23 +7,23 @@ import AggResponsePointSeriesOrderedDateAxisProvider from 'ui/agg_response/point import AggResponsePointSeriesTooltipFormatterProvider from 'ui/agg_response/point_series/_tooltip_formatter'; export default function PointSeriesProvider(Private) { - var getSeries = Private(AggResponsePointSeriesGetSeriesProvider); - var getAspects = Private(AggResponsePointSeriesGetAspectsProvider); - var initYAxis = Private(AggResponsePointSeriesInitYAxisProvider); - var initXAxis = Private(AggResponsePointSeriesInitXAxisProvider); - var setupOrderedDateXAxis = Private(AggResponsePointSeriesOrderedDateAxisProvider); - var tooltipFormatter = Private(AggResponsePointSeriesTooltipFormatterProvider); + let getSeries = Private(AggResponsePointSeriesGetSeriesProvider); + let getAspects = Private(AggResponsePointSeriesGetAspectsProvider); + let initYAxis = Private(AggResponsePointSeriesInitYAxisProvider); + let initXAxis = Private(AggResponsePointSeriesInitXAxisProvider); + let setupOrderedDateXAxis = Private(AggResponsePointSeriesOrderedDateAxisProvider); + let tooltipFormatter = Private(AggResponsePointSeriesTooltipFormatterProvider); 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 965597be9bd0..7d05c83a882b 100644 --- a/src/ui/public/agg_response/tabify/_buckets.js +++ b/src/ui/public/agg_response/tabify/_buckets.js @@ -15,7 +15,7 @@ export default function AggResponseBucketsProvider() { } 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 1ddda56b1417..b9268891cadc 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 @@ import _ from 'lodash'; import VisAggConfigProvider from 'ui/vis/agg_config'; export default function GetColumnsProvider(Private) { - var AggConfig = Private(VisAggConfigProvider); + let AggConfig = Private(VisAggConfigProvider); 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 @@ export default function GetColumnsProvider(Private) { } // 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 be27f4518dc9..53f1ee01782a 100644 --- a/src/ui/public/agg_response/tabify/_response_writer.js +++ b/src/ui/public/agg_response/tabify/_response_writer.js @@ -4,9 +4,9 @@ import AggResponseTabifyTableProvider from 'ui/agg_response/tabify/_table'; import AggResponseTabifyTableGroupProvider from 'ui/agg_response/tabify/_table_group'; import AggResponseTabifyGetColumnsProvider from 'ui/agg_response/tabify/_get_columns'; export default function TabbedAggResponseWriterProvider(Private) { - var Table = Private(AggResponseTabifyTableProvider); - var TableGroup = Private(AggResponseTabifyTableGroupProvider); - var getColumns = Private(AggResponseTabifyGetColumnsProvider); + let Table = Private(AggResponseTabifyTableProvider); + let TableGroup = Private(AggResponseTabifyTableGroupProvider); + let getColumns = Private(AggResponseTabifyGetColumnsProvider); _.class(SplitAcr).inherits(AggConfigResult); @@ -25,7 +25,7 @@ export default function TabbedAggResponseWriterProvider(Private) { 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. @@ -67,9 +67,9 @@ export default function TabbedAggResponseWriterProvider(Private) { * @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; @@ -95,7 +95,7 @@ export default function TabbedAggResponseWriterProvider(Private) { * @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'); @@ -105,11 +105,11 @@ export default function TabbedAggResponseWriterProvider(Private) { 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); } @@ -127,7 +127,7 @@ export default function TabbedAggResponseWriterProvider(Private) { }; TabbedAggResponseWriter.prototype._removeAggFromColumns = function (agg) { - var i = _.findIndex(this.columns, function (col) { + let i = _.findIndex(this.columns, function (col) { return col.aggConfig === agg; }); @@ -140,8 +140,8 @@ export default function TabbedAggResponseWriterProvider(Private) { // 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; }); @@ -160,12 +160,12 @@ export default function TabbedAggResponseWriterProvider(Private) { * @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); @@ -175,7 +175,7 @@ export default function TabbedAggResponseWriterProvider(Private) { // 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) { @@ -189,11 +189,11 @@ export default function TabbedAggResponseWriterProvider(Private) { 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; } @@ -215,7 +215,7 @@ export default function TabbedAggResponseWriterProvider(Private) { 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); @@ -237,14 +237,14 @@ export default function TabbedAggResponseWriterProvider(Private) { * @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); @@ -257,7 +257,7 @@ export default function TabbedAggResponseWriterProvider(Private) { * @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) { @@ -272,7 +272,7 @@ export default function TabbedAggResponseWriterProvider(Private) { 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/tabify.js b/src/ui/public/agg_response/tabify/tabify.js index a74a340dc52e..722a1a12b803 100644 --- a/src/ui/public/agg_response/tabify/tabify.js +++ b/src/ui/public/agg_response/tabify/tabify.js @@ -4,15 +4,15 @@ import AggResponseTabifyResponseWriterProvider from 'ui/agg_response/tabify/_res import AggResponseTabifyBucketsProvider from 'ui/agg_response/tabify/_buckets'; export default function tabifyAggResponseProvider(Private, Notifier) { - var AggConfig = Private(VisAggConfigProvider); - var TabbedAggResponseWriter = Private(AggResponseTabifyResponseWriterProvider); - var Buckets = Private(AggResponseTabifyBucketsProvider); - var notify = new Notifier({ location: 'agg_response/tabify'}); + let AggConfig = Private(VisAggConfigProvider); + let TabbedAggResponseWriter = Private(AggResponseTabifyResponseWriterProvider); + let Buckets = Private(AggResponseTabifyBucketsProvider); + 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 }); @@ -31,13 +31,13 @@ export default function tabifyAggResponseProvider(Private, Notifier) { * @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); @@ -63,7 +63,7 @@ export default function tabifyAggResponseProvider(Private, Notifier) { } break; case 'metrics': - var value = agg.getValue(bucket); + let value = agg.getValue(bucket); write.cell(agg, value, function () { if (!write.aggStack.length) { // row complete @@ -82,7 +82,7 @@ export default function tabifyAggResponseProvider(Private, Notifier) { // 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 5c2017325b53..f44961b4e3a3 100644 --- a/src/ui/public/agg_table/agg_table.js +++ b/src/ui/public/agg_table/agg_table.js @@ -24,7 +24,7 @@ uiModules return compileRecursiveDirective.compile($el); }, controller: function ($scope) { - var self = this; + let self = this; self.sort = null; self._saveAs = require('@spalger/filesaver').saveAs; @@ -34,15 +34,15 @@ uiModules }; 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(); @@ -54,7 +54,7 @@ uiModules } // escape each cell in each row - var csvRows = rows.map(function (row) { + let csvRows = rows.map(function (row) { return row.map(escape); }); @@ -69,7 +69,7 @@ uiModules }; $scope.$watch('table', function () { - var table = $scope.table; + let table = $scope.table; if (!table) { $scope.rows = null; @@ -80,14 +80,14 @@ uiModules 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 040f75841d42..1b133f57b36c 100644 --- a/src/ui/public/agg_table/agg_table_group.js +++ b/src/ui/public/agg_table/agg_table_group.js @@ -25,10 +25,10 @@ uiModules 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/agg_params.js b/src/ui/public/agg_types/agg_params.js index 1c5aa3a52e32..d6c435c214b4 100644 --- a/src/ui/public/agg_types/agg_params.js +++ b/src/ui/public/agg_types/agg_params.js @@ -10,7 +10,7 @@ import AggTypesParamTypesBaseProvider from 'ui/agg_types/param_types/base'; export default function AggParamsFactory(Private) { - var paramTypeMap = { + let paramTypeMap = { field: Private(AggTypesParamTypesFieldProvider), optioned: Private(AggTypesParamTypesOptionedProvider), regex: Private(AggTypesParamTypesRegexProvider), @@ -37,8 +37,8 @@ export default function AggParamsFactory(Private) { 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); }) }); @@ -59,7 +59,7 @@ export default function AggParamsFactory(Private) { * 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/agg_type.js b/src/ui/public/agg_types/agg_type.js index d262d5077664..64f9db58e33e 100644 --- a/src/ui/public/agg_types/agg_type.js +++ b/src/ui/public/agg_types/agg_type.js @@ -2,8 +2,8 @@ import _ from 'lodash'; import AggTypesAggParamsProvider from 'ui/agg_types/agg_params'; import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; export default function AggTypeFactory(Private) { - var AggParams = Private(AggTypesAggParamsProvider); - var fieldFormats = Private(RegistryFieldFormatsProvider); + let AggParams = Private(AggTypesAggParamsProvider); + let fieldFormats = Private(RegistryFieldFormatsProvider); /** * Generic AggType Constructor @@ -142,7 +142,7 @@ export default function AggTypeFactory(Private) { * @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 d47006baa55e..4249ec29be71 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 @@ import _ from 'lodash'; import AggTypesAggTypeProvider from 'ui/agg_types/agg_type'; export default function BucketAggTypeProvider(Private) { - var AggType = Private(AggTypesAggTypeProvider); + let AggType = Private(AggTypesAggTypeProvider); _.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 9acc16c66e04..3fbcd3e72334 100644 --- a/src/ui/public/agg_types/buckets/_bucket_count_between.js +++ b/src/ui/public/agg_types/buckets/_bucket_count_between.js @@ -13,19 +13,19 @@ export default function BucketCountBetweenProvider() { * @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 0dcdf7989c20..f1a8f151898d 100644 --- a/src/ui/public/agg_types/buckets/_interval_options.js +++ b/src/ui/public/agg_types/buckets/_interval_options.js @@ -3,7 +3,7 @@ import 'ui/directives/input_whole_number'; export default function IntervalOptionsService(Private) { // 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 da88378324b7..ce3a85c8b909 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 @@ -3,8 +3,8 @@ import buildRangeFilter from 'ui/filter_manager/lib/range'; export default function createDateHistogramFilterProvider(Private) { 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 fba9d3c64d1b..89e8232b6e53 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 @@ -4,9 +4,9 @@ import buildRangeFilter from 'ui/filter_manager/lib/range'; export default function createDateRangeFilterProvider(config) { 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 60409405af00..e9cbde979f2f 100644 --- a/src/ui/public/agg_types/buckets/create_filter/filters.js +++ b/src/ui/public/agg_types/buckets/create_filter/filters.js @@ -3,8 +3,8 @@ import _ from 'lodash'; export default 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 250bebbeae23..0bc21c35010f 100644 --- a/src/ui/public/agg_types/buckets/create_filter/histogram.js +++ b/src/ui/public/agg_types/buckets/create_filter/histogram.js @@ -2,7 +2,7 @@ import buildRangeFilter from 'ui/filter_manager/lib/range'; export default 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 490f67b320e0..ea5efa64adc3 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 @@ -6,7 +6,7 @@ export default function createIpRangeFilterProvider() { 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/date_histogram.js b/src/ui/public/agg_types/buckets/date_histogram.js index 0b252b262fdf..a939b94abe1f 100644 --- a/src/ui/public/agg_types/buckets/date_histogram.js +++ b/src/ui/public/agg_types/buckets/date_histogram.js @@ -10,17 +10,17 @@ import AggTypesBucketsIntervalOptionsProvider from 'ui/agg_types/buckets/_interv import ConfigDefaultsProvider from 'ui/config/defaults'; import intervalTemplate from 'ui/agg_types/controls/interval.html'; export default function DateHistogramAggType(timefilter, config, Private) { - var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); - var TimeBuckets = Private(TimeBucketsProvider); - var createFilter = Private(AggTypesBucketsCreateFilterDateHistogramProvider); - var intervalOptions = Private(AggTypesBucketsIntervalOptionsProvider); - var configDefaults = Private(ConfigDefaultsProvider); + let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); + let TimeBuckets = Private(TimeBucketsProvider); + let createFilter = Private(AggTypesBucketsCreateFilterDateHistogramProvider); + let intervalOptions = Private(AggTypesBucketsIntervalOptionsProvider); + let configDefaults = Private(ConfigDefaultsProvider); - var detectedTimezone = tzDetect.determine().name(); - var tzOffset = moment().format('Z'); + 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; } @@ -39,8 +39,8 @@ export default function DateHistogramAggType(timefilter, config, Private) { 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, @@ -81,7 +81,7 @@ export default function DateHistogramAggType(timefilter, config, Private) { 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 @@ -98,16 +98,16 @@ export default function DateHistogramAggType(timefilter, config, Private) { 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'); @@ -140,7 +140,7 @@ export default function DateHistogramAggType(timefilter, config, Private) { 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 = { diff --git a/src/ui/public/agg_types/buckets/date_range.js b/src/ui/public/agg_types/buckets/date_range.js index e36047cab88c..1101cc72b439 100644 --- a/src/ui/public/agg_types/buckets/date_range.js +++ b/src/ui/public/agg_types/buckets/date_range.js @@ -7,9 +7,9 @@ import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; import dateRangesTemplate from 'ui/agg_types/controls/date_ranges.html'; export default function DateRangeAggDefinition(Private, config) { - var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); - var createFilter = Private(AggTypesBucketsCreateFilterDateRangeProvider); - var fieldFormats = Private(RegistryFieldFormatsProvider); + let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); + let createFilter = Private(AggTypesBucketsCreateFilterDateRangeProvider); + let fieldFormats = Private(RegistryFieldFormatsProvider); return new BucketAggType({ @@ -17,7 +17,7 @@ export default function DateRangeAggDefinition(Private, config) { 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 af54504c8fa3..47ab9c13bd0c 100644 --- a/src/ui/public/agg_types/buckets/filters.js +++ b/src/ui/public/agg_types/buckets/filters.js @@ -5,10 +5,10 @@ import AggTypesBucketsCreateFilterFiltersProvider from 'ui/agg_types/buckets/cre import DecorateQueryProvider from 'ui/courier/data_source/_decorate_query'; import filtersTemplate from 'ui/agg_types/controls/filters.html'; export default function FiltersAggDefinition(Private, Notifier) { - var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); - var createFilter = Private(AggTypesBucketsCreateFilterFiltersProvider); - var decorateQuery = Private(DecorateQueryProvider); - var notif = new Notifier({ location: 'Filters Agg' }); + let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); + let createFilter = Private(AggTypesBucketsCreateFilterFiltersProvider); + let decorateQuery = Private(DecorateQueryProvider); + let notif = new Notifier({ location: 'Filters Agg' }); return new BucketAggType({ name: 'filters', @@ -21,25 +21,25 @@ export default function FiltersAggDefinition(Private, Notifier) { editor: filtersTemplate, 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 dcaaa1d17b79..d27d6bf338d8 100644 --- a/src/ui/public/agg_types/buckets/geo_hash.js +++ b/src/ui/public/agg_types/buckets/geo_hash.js @@ -3,11 +3,11 @@ import moment from 'moment'; import AggTypesBucketsBucketAggTypeProvider from 'ui/agg_types/buckets/_bucket_agg_type'; import precisionTemplate from 'ui/agg_types/controls/precision.html'; export default function GeoHashAggDefinition(Private, config) { - var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); - var defaultPrecision = 2; + let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); + 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 c580625793e8..bbfd761b1522 100644 --- a/src/ui/public/agg_types/buckets/histogram.js +++ b/src/ui/public/agg_types/buckets/histogram.js @@ -7,8 +7,8 @@ import intervalTemplate from 'ui/agg_types/controls/interval.html'; import minDocCountTemplate from 'ui/agg_types/controls/min_doc_count.html'; import extendedBoundsTemplate from 'ui/agg_types/controls/extended_bounds.html'; export default function HistogramAggDefinition(Private) { - var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); - var createFilter = Private(AggTypesBucketsCreateFilterHistogramProvider); + let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); + let createFilter = Private(AggTypesBucketsCreateFilterHistogramProvider); return new BucketAggType({ @@ -49,7 +49,7 @@ export default function HistogramAggDefinition(Private) { default: {}, editor: extendedBoundsTemplate, write: function (aggConfig, output) { - var val = aggConfig.params.extended_bounds; + let val = aggConfig.params.extended_bounds; if (aggConfig.params.min_doc_count && (val.min != null || val.max != null)) { output.params.extended_bounds = { @@ -61,7 +61,7 @@ export default function HistogramAggDefinition(Private) { // 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 ea14437eb39e..ea1a44610162 100644 --- a/src/ui/public/agg_types/buckets/ip_range.js +++ b/src/ui/public/agg_types/buckets/ip_range.js @@ -6,8 +6,8 @@ import AggTypesBucketsCreateFilterIpRangeProvider from 'ui/agg_types/buckets/cre import ipRangesTemplate from 'ui/agg_types/controls/ip_ranges.html'; export default function RangeAggDefinition(Private) { - var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); - var createFilter = Private(AggTypesBucketsCreateFilterIpRangeProvider); + let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); + let createFilter = Private(AggTypesBucketsCreateFilterIpRangeProvider); return new BucketAggType({ name: 'ip_range', @@ -38,7 +38,7 @@ export default function RangeAggDefinition(Private) { }, editor: ipRangesTemplate, 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 bc57b997774d..ec6d33935b7c 100644 --- a/src/ui/public/agg_types/buckets/range.js +++ b/src/ui/public/agg_types/buckets/range.js @@ -5,13 +5,13 @@ import IndexPatternsFieldFormatFieldFormatProvider from 'ui/index_patterns/_fiel import RangeKeyProvider from './range_key'; import rangesTemplate from 'ui/agg_types/controls/ranges.html'; export default function RangeAggDefinition(Private) { - var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); - var createFilter = Private(AggTypesBucketsCreateFilterRangeProvider); - var FieldFormat = Private(IndexPatternsFieldFormatFieldFormatProvider); - var RangeKey = Private(RangeKeyProvider); + let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); + let createFilter = Private(AggTypesBucketsCreateFilterRangeProvider); + let FieldFormat = Private(IndexPatternsFieldFormatFieldFormatProvider); + let RangeKey = Private(RangeKeyProvider); - var keyCaches = new WeakMap(); - var formats = new WeakMap(); + let keyCaches = new WeakMap(); + let formats = new WeakMap(); return new BucketAggType({ name: 'range', @@ -21,14 +21,14 @@ export default function RangeAggDefinition(Private) { 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 ae924e6552b5..36fe87d970d8 100644 --- a/src/ui/public/agg_types/buckets/significant_terms.js +++ b/src/ui/public/agg_types/buckets/significant_terms.js @@ -3,8 +3,8 @@ import AggTypesBucketsBucketAggTypeProvider from 'ui/agg_types/buckets/_bucket_a import AggTypesBucketsCreateFilterTermsProvider from 'ui/agg_types/buckets/create_filter/terms'; import orderAndSizeTemplate from 'ui/agg_types/controls/order_and_size.html'; export default function SignificantTermsAggDefinition(Private) { - var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); - var createFilter = Private(AggTypesBucketsCreateFilterTermsProvider); + let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); + let createFilter = Private(AggTypesBucketsCreateFilterTermsProvider); 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 acc74d7cf2f4..4a81cbbf939f 100644 --- a/src/ui/public/agg_types/buckets/terms.js +++ b/src/ui/public/agg_types/buckets/terms.js @@ -7,13 +7,13 @@ import AggTypesBucketsCreateFilterTermsProvider from 'ui/agg_types/buckets/creat import orderAggTemplate from 'ui/agg_types/controls/order_agg.html'; import orderAndSizeTemplate from 'ui/agg_types/controls/order_and_size.html'; export default function TermsAggDefinition(Private) { - var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); - var bucketCountBetween = Private(AggTypesBucketsBucketCountBetweenProvider); - var AggConfig = Private(VisAggConfigProvider); - var Schemas = Private(VisSchemasProvider); - var createFilter = Private(AggTypesBucketsCreateFilterTermsProvider); + let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); + let bucketCountBetween = Private(AggTypesBucketsBucketCountBetweenProvider); + let AggConfig = Private(VisAggConfigProvider); + let Schemas = Private(VisSchemasProvider); + let createFilter = Private(AggTypesBucketsCreateFilterTermsProvider); - var orderAggSchema = (new Schemas([ + let orderAggSchema = (new Schemas([ { group: 'none', name: 'orderAgg', @@ -24,7 +24,7 @@ export default function TermsAggDefinition(Private) { function isNotType(type) { return function (agg) { - var field = agg.params.field; + let field = agg.params.field; return !field || field.type !== type; }; } @@ -33,7 +33,7 @@ export default function TermsAggDefinition(Private) { name: 'terms', title: 'Terms', makeLabel: function (agg) { - var params = agg.params; + let params = agg.params; return params.field.displayName + ': ' + params.order.display; }, createFilter: createFilter, @@ -73,7 +73,7 @@ export default function TermsAggDefinition(Private) { 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; }, @@ -86,18 +86,18 @@ export default function TermsAggDefinition(Private) { } }; - 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) { @@ -130,11 +130,11 @@ export default function TermsAggDefinition(Private) { } }, 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 @@ -153,7 +153,7 @@ export default function TermsAggDefinition(Private) { 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 dafc04b8245a..762a9dbab4a9 100644 --- a/src/ui/public/agg_types/index.js +++ b/src/ui/public/agg_types/index.js @@ -21,7 +21,7 @@ import AggTypesBucketsSignificantTermsProvider from 'ui/agg_types/buckets/signif import AggTypesBucketsGeoHashProvider from 'ui/agg_types/buckets/geo_hash'; export default function AggTypeService(Private) { - var aggs = { + let aggs = { metrics: [ Private(AggTypesMetricsCountProvider), Private(AggTypesMetricsAvgProvider), diff --git a/src/ui/public/agg_types/metrics/avg.js b/src/ui/public/agg_types/metrics/avg.js index e70c3b775408..f313464433da 100644 --- a/src/ui/public/agg_types/metrics/avg.js +++ b/src/ui/public/agg_types/metrics/avg.js @@ -1,7 +1,7 @@ import AggTypesMetricsMetricAggTypeProvider from 'ui/agg_types/metrics/metric_agg_type'; export default function AggTypeMetricAvgProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); 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 0cce5b7ab1be..8ff6d93f6192 100644 --- a/src/ui/public/agg_types/metrics/cardinality.js +++ b/src/ui/public/agg_types/metrics/cardinality.js @@ -2,8 +2,8 @@ import AggTypesMetricsMetricAggTypeProvider from 'ui/agg_types/metrics/metric_ag import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; export default function AggTypeMetricCardinalityProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); - var fieldFormats = Private(RegistryFieldFormatsProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let fieldFormats = Private(RegistryFieldFormatsProvider); 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 ec9d2d37008f..fcad3d8dffa0 100644 --- a/src/ui/public/agg_types/metrics/count.js +++ b/src/ui/public/agg_types/metrics/count.js @@ -2,8 +2,8 @@ import AggTypesMetricsMetricAggTypeProvider from 'ui/agg_types/metrics/metric_ag import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; export default function AggTypeMetricCountProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); - var fieldFormats = Private(RegistryFieldFormatsProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let fieldFormats = Private(RegistryFieldFormatsProvider); return new MetricAggType({ name: 'count', diff --git a/src/ui/public/agg_types/metrics/get_response_agg_config_class.js b/src/ui/public/agg_types/metrics/get_response_agg_config_class.js index b90a308e8686..b9112f343e81 100644 --- a/src/ui/public/agg_types/metrics/get_response_agg_config_class.js +++ b/src/ui/public/agg_types/metrics/get_response_agg_config_class.js @@ -30,7 +30,7 @@ export default function ResponseAggConfigProvider() { 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 70e893f0b869..938ee8d4a45e 100644 --- a/src/ui/public/agg_types/metrics/max.js +++ b/src/ui/public/agg_types/metrics/max.js @@ -1,7 +1,7 @@ import AggTypesMetricsMetricAggTypeProvider from 'ui/agg_types/metrics/metric_agg_type'; export default function AggTypeMetricMaxProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); 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 1f6273e1def5..dad3c9b9bd30 100644 --- a/src/ui/public/agg_types/metrics/median.js +++ b/src/ui/public/agg_types/metrics/median.js @@ -3,9 +3,9 @@ import AggTypesMetricsMetricAggTypeProvider from 'ui/agg_types/metrics/metric_ag import AggTypesMetricsGetResponseAggConfigClassProvider from 'ui/agg_types/metrics/get_response_agg_config_class'; import AggTypesMetricsPercentilesProvider from 'ui/agg_types/metrics/percentiles'; export default function AggTypeMetricMaxProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); - var getResponseAggConfigClass = Private(AggTypesMetricsGetResponseAggConfigClassProvider); - var percentiles = Private(AggTypesMetricsPercentilesProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let getResponseAggConfigClass = Private(AggTypesMetricsGetResponseAggConfigClassProvider); + let percentiles = Private(AggTypesMetricsPercentilesProvider); return new MetricAggType({ name: 'median', diff --git a/src/ui/public/agg_types/metrics/metric_agg_type.js b/src/ui/public/agg_types/metrics/metric_agg_type.js index 1d435accefe3..e9d03f60f335 100644 --- a/src/ui/public/agg_types/metrics/metric_agg_type.js +++ b/src/ui/public/agg_types/metrics/metric_agg_type.js @@ -2,8 +2,8 @@ import _ from 'lodash'; import AggTypesAggTypeProvider from 'ui/agg_types/agg_type'; import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; export default function MetricAggTypeProvider(Private) { - var AggType = Private(AggTypesAggTypeProvider); - var fieldFormats = Private(RegistryFieldFormatsProvider); + let AggType = Private(AggTypesAggTypeProvider); + let fieldFormats = Private(RegistryFieldFormatsProvider); _.class(MetricAggType).inherits(AggType); function MetricAggType(config) { @@ -24,7 +24,7 @@ export default function MetricAggTypeProvider(Private) { */ 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 @@ -42,7 +42,7 @@ export default function MetricAggTypeProvider(Private) { * @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/min.js b/src/ui/public/agg_types/metrics/min.js index fd31dbd3dff5..a14593af1dd0 100644 --- a/src/ui/public/agg_types/metrics/min.js +++ b/src/ui/public/agg_types/metrics/min.js @@ -1,7 +1,7 @@ import AggTypesMetricsMetricAggTypeProvider from 'ui/agg_types/metrics/metric_agg_type'; export default function AggTypeMetricMinProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); 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 f0e6147a6c70..0ddc449a05ed 100644 --- a/src/ui/public/agg_types/metrics/percentile_ranks.js +++ b/src/ui/public/agg_types/metrics/percentile_ranks.js @@ -7,16 +7,16 @@ import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; import getPercentileValue from './percentiles_get_value'; export default function AggTypeMetricPercentileRanksProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); - var getResponseAggConfigClass = Private(AggTypesMetricsGetResponseAggConfigClassProvider); - var fieldFormats = Private(RegistryFieldFormatsProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let getResponseAggConfigClass = Private(AggTypesMetricsGetResponseAggConfigClassProvider); + let fieldFormats = Private(RegistryFieldFormatsProvider); // required by the values editor - 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() + '"'; } @@ -45,7 +45,7 @@ export default function AggTypeMetricPercentileRanksProvider(Private) { } ], 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 08edbfc193a8..d14401143e7c 100644 --- a/src/ui/public/agg_types/metrics/percentiles.js +++ b/src/ui/public/agg_types/metrics/percentiles.js @@ -8,13 +8,13 @@ import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; import getPercentileValue from './percentiles_get_value'; export default function AggTypeMetricPercentilesProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); - var getResponseAggConfigClass = Private(AggTypesMetricsGetResponseAggConfigClassProvider); - var fieldFormats = Private(RegistryFieldFormatsProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let getResponseAggConfigClass = Private(AggTypesMetricsGetResponseAggConfigClassProvider); + let fieldFormats = Private(RegistryFieldFormatsProvider); // required by the percentiles editor - var valueProps = { + let valueProps = { makeLabel: function () { return ordinalSuffix(this.key) + ' percentile of ' + this.fieldDisplayName(); } @@ -43,7 +43,7 @@ export default function AggTypeMetricPercentilesProvider(Private) { } ], 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/std_deviation.js b/src/ui/public/agg_types/metrics/std_deviation.js index 7114a666fea8..36340ee4fbc6 100644 --- a/src/ui/public/agg_types/metrics/std_deviation.js +++ b/src/ui/public/agg_types/metrics/std_deviation.js @@ -2,16 +2,16 @@ import _ from 'lodash'; import AggTypesMetricsMetricAggTypeProvider from 'ui/agg_types/metrics/metric_agg_type'; import AggTypesMetricsGetResponseAggConfigClassProvider from 'ui/agg_types/metrics/get_response_agg_config_class'; export default function AggTypeMetricStandardDeviationProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); - var getResponseAggConfigClass = Private(AggTypesMetricsGetResponseAggConfigClassProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let getResponseAggConfigClass = Private(AggTypesMetricsGetResponseAggConfigClassProvider); - var responseAggConfigProps = { + let responseAggConfigProps = { valProp: function () { - var details = this.keyedDetails(this.params.customLabel)[this.key]; + let details = this.keyedDetails(this.params.customLabel)[this.key]; return details.valProp; }, makeLabel: function () { - var details = this.keyedDetails(this.params.customLabel)[this.key]; + let details = this.keyedDetails(this.params.customLabel)[this.key]; return details.title + ' of ' + this.fieldDisplayName(); }, keyedDetails: function (customLabel) { @@ -48,7 +48,7 @@ export default function AggTypeMetricStandardDeviationProvider(Private) { ], 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 cbdced241db1..d419edb241e6 100644 --- a/src/ui/public/agg_types/metrics/sum.js +++ b/src/ui/public/agg_types/metrics/sum.js @@ -1,7 +1,7 @@ import AggTypesMetricsMetricAggTypeProvider from 'ui/agg_types/metrics/metric_agg_type'; export default function AggTypeMetricSumProvider(Private) { - var MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); + let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider); return new MetricAggType({ name: 'sum', diff --git a/src/ui/public/agg_types/param_types/field.js b/src/ui/public/agg_types/param_types/field.js index 7cd72f27141c..9a6fc8b36964 100644 --- a/src/ui/public/agg_types/param_types/field.js +++ b/src/ui/public/agg_types/param_types/field.js @@ -4,7 +4,7 @@ import editorHtml from 'ui/agg_types/controls/field.html'; import AggTypesParamTypesBaseProvider from 'ui/agg_types/param_types/base'; export default function FieldAggParamFactory(Private) { - var BaseAggParam = Private(AggTypesParamTypesBaseProvider); + let BaseAggParam = Private(AggTypesParamTypesBaseProvider); _.class(FieldAggParam).inherits(BaseAggParam); function FieldAggParam(config) { @@ -33,7 +33,7 @@ export default function FieldAggParamFactory(Private) { * @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 @@ export default function FieldAggParamFactory(Private) { * @return {undefined} */ FieldAggParam.prototype.write = function (aggConfig, output) { - var field = aggConfig.params.field; + let field = aggConfig.params.field; if (field.scripted) { output.params.script = { diff --git a/src/ui/public/agg_types/param_types/optioned.js b/src/ui/public/agg_types/param_types/optioned.js index 646d7c103b55..2e161a879a6c 100644 --- a/src/ui/public/agg_types/param_types/optioned.js +++ b/src/ui/public/agg_types/param_types/optioned.js @@ -3,7 +3,7 @@ import IndexedArray from 'ui/indexed_array'; import AggTypesParamTypesBaseProvider from 'ui/agg_types/param_types/base'; export default function OptionedAggParamFactory(Private) { - var BaseAggParam = Private(AggTypesParamTypesBaseProvider); + let BaseAggParam = Private(AggTypesParamTypesBaseProvider); _.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 8cc22af5cdce..25f160174230 100644 --- a/src/ui/public/agg_types/param_types/raw_json.js +++ b/src/ui/public/agg_types/param_types/raw_json.js @@ -3,7 +3,7 @@ import editorHtml from 'ui/agg_types/controls/raw_json.html'; import AggTypesParamTypesBaseProvider from 'ui/agg_types/param_types/base'; export default function RawJSONAggParamFactory(Private) { - var BaseAggParam = Private(AggTypesParamTypesBaseProvider); + let BaseAggParam = Private(AggTypesParamTypesBaseProvider); _.class(RawJSONAggParam).inherits(BaseAggParam); function RawJSONAggParam(config) { @@ -26,7 +26,7 @@ export default function RawJSONAggParamFactory(Private) { */ 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 @@ export default function RawJSONAggParamFactory(Private) { .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 6268c0ef3c84..3a38c06f8b9d 100644 --- a/src/ui/public/agg_types/param_types/regex.js +++ b/src/ui/public/agg_types/param_types/regex.js @@ -3,7 +3,7 @@ import editorHtml from 'ui/agg_types/controls/regular_expression.html'; import AggTypesParamTypesBaseProvider from 'ui/agg_types/param_types/base'; export default function RegexAggParamFactory(Private) { - var BaseAggParam = Private(AggTypesParamTypesBaseProvider); + let BaseAggParam = Private(AggTypesParamTypesBaseProvider); _.class(RegexAggParam).inherits(BaseAggParam); function RegexAggParam(config) { @@ -33,15 +33,15 @@ export default function RegexAggParamFactory(Private) { * @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 8c3a1057d6fa..58803171c44a 100644 --- a/src/ui/public/agg_types/param_types/string.js +++ b/src/ui/public/agg_types/param_types/string.js @@ -3,7 +3,7 @@ import editorHtml from 'ui/agg_types/controls/string.html'; import AggTypesParamTypesBaseProvider from 'ui/agg_types/param_types/base'; export default function FieldAggParamFactory(Private) { - var BaseAggParam = Private(AggTypesParamTypesBaseProvider); + let BaseAggParam = Private(AggTypesParamTypesBaseProvider); _.class(ScriptAggParam).inherits(BaseAggParam); function ScriptAggParam(config) { diff --git a/src/ui/public/bind/bind.js b/src/ui/public/bind/bind.js index 000912c559d0..ba16ddc5bfdc 100644 --- a/src/ui/public/bind/bind.js +++ b/src/ui/public/bind/bind.js @@ -27,26 +27,26 @@ uiModules.get('kibana') * @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 @@ uiModules.get('kibana') }; // 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/api/angular.js b/src/ui/public/chrome/api/angular.js index 2561cdfcc92e..587c327758fb 100644 --- a/src/ui/public/chrome/api/angular.js +++ b/src/ui/public/chrome/api/angular.js @@ -7,7 +7,7 @@ module.exports = function (chrome, internals) { chrome.getBreadcrumbs = _.noop; chrome.setupAngular = function () { - var kibana = modules.get('kibana'); + let kibana = modules.get('kibana'); _.forOwn(chrome.getInjected(), function (val, name) { kibana.value(name, val); @@ -21,7 +21,7 @@ module.exports = function (chrome, internals) { .value('sessionId', Date.now()) .value('chrome', chrome) .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 38b1136ea87a..93408b9c682d 100644 --- a/src/ui/public/chrome/api/controls.js +++ b/src/ui/public/chrome/api/controls.js @@ -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 0a3611c47c8d..73a2396510d3 100644 --- a/src/ui/public/chrome/api/nav.js +++ b/src/ui/public/chrome/api/nav.js @@ -11,10 +11,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; @@ -111,7 +111,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; }); diff --git a/src/ui/public/chrome/api/tabs.js b/src/ui/public/chrome/api/tabs.js index c7ac25e14ce2..aba3734cfd1c 100644 --- a/src/ui/public/chrome/api/tabs.js +++ b/src/ui/public/chrome/api/tabs.js @@ -85,7 +85,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/theme.js b/src/ui/public/chrome/api/theme.js index dba1bdbcecbb..192239cd9148 100644 --- a/src/ui/public/chrome/api/theme.js +++ b/src/ui/public/chrome/api/theme.js @@ -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 7b2482b1ff29..c0f980c993b0 100644 --- a/src/ui/public/chrome/chrome.js +++ b/src/ui/public/chrome/chrome.js @@ -12,8 +12,8 @@ import 'ui/promises'; import 'ui/directives/kbn_src'; import 'ui/watch_multi'; -var chrome = {}; -var internals = _.defaults( +let chrome = {}; +let internals = _.defaults( _.cloneDeep(metadata), { basePath: '', diff --git a/src/ui/public/chrome/tab_collection.js b/src/ui/public/chrome/tab_collection.js index d74e0104d33b..67759bb7e0d8 100644 --- a/src/ui/public/chrome/tab_collection.js +++ b/src/ui/public/chrome/tab_collection.js @@ -4,10 +4,10 @@ import { startsWith, get, set, omit, wrap, pick } from 'lodash'; import { parse } from '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/collapsible_sidebar/collapsible_sidebar.js b/src/ui/public/collapsible_sidebar/collapsible_sidebar.js index 4b3fc520e03c..d19a70af9643 100644 --- a/src/ui/public/collapsible_sidebar/collapsible_sidebar.js +++ b/src/ui/public/collapsible_sidebar/collapsible_sidebar.js @@ -8,15 +8,15 @@ uiModules .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 7997120e3373..89f08e4ca628 100644 --- a/src/ui/public/config/_delayed_updater.js +++ b/src/ui/public/config/_delayed_updater.js @@ -4,14 +4,14 @@ import ConfigValsProvider from 'ui/config/_vals'; import Notifier from 'ui/notify/notifier'; export default function DelayedUpdaterFactory(Private, $rootScope, Promise) { - var notify = new Notifier(); + let notify = new Notifier(); - var vals = Private(ConfigValsProvider); + let vals = Private(ConfigValsProvider); return function DelayedUpdater(doc) { - var updater = this; - var queue = []; - var log = {}; + let updater = this; + let queue = []; + let log = {}; let timer; updater.fire = function () { @@ -23,8 +23,8 @@ export default function DelayedUpdaterFactory(Private, $rootScope, Promise) { let method; let body; - var updated = []; - var deleted = []; + let updated = []; + let deleted = []; // seperate the log into lists Object.keys(log).forEach(function (key) { @@ -55,8 +55,8 @@ export default function DelayedUpdaterFactory(Private, $rootScope, Promise) { }; 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(); @@ -72,7 +72,7 @@ export default function DelayedUpdaterFactory(Private, $rootScope, Promise) { 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 9291de9e0fc2..bcf497e80b2b 100644 --- a/src/ui/public/config/config.js +++ b/src/ui/public/config/config.js @@ -8,7 +8,7 @@ import uiRoutes from 'ui/routes'; import uiModules from 'ui/modules'; import Notifier from 'ui/notify/notifier'; -var module = uiModules.get('kibana/config'); +let module = uiModules.get('kibana/config'); uiRoutes.addSetupWork(function (config) { return config.init(); @@ -16,13 +16,13 @@ uiRoutes.addSetupWork(function (config) { // service for delivering config variables to everywhere else module.service('config', function (Private, kbnVersion, kbnIndex, $rootScope, buildNum) { - var config = this; + let config = this; - var defaults = Private(ConfigDefaultsProvider); - var DelayedUpdater = Private(ConfigDelayedUpdaterProvider); - var vals = Private(ConfigValsProvider); + let defaults = Private(ConfigDefaultsProvider); + let DelayedUpdater = Private(ConfigDelayedUpdaterProvider); + let vals = Private(ConfigValsProvider); - var notify = new Notifier({ + let notify = new Notifier({ location: 'Config' }); @@ -30,8 +30,8 @@ module.service('config', function (Private, kbnVersion, kbnIndex, $rootScope, bu // update once it is requested by calling #set() or #clear(). let updater; - var DocSource = Private(DocSourceProvider); - var doc = (new DocSource()) + let DocSource = Private(DocSourceProvider); + let doc = (new DocSource()) .index(kbnIndex) .type('config') .id(kbnVersion); @@ -47,13 +47,13 @@ module.service('config', function (Private, kbnVersion, kbnIndex, $rootScope, bu * @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); }); @@ -132,7 +132,7 @@ module.service('config', function (Private, kbnVersion, kbnIndex, $rootScope, bu 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/courier/_redirect_when_missing.js b/src/ui/public/courier/_redirect_when_missing.js index b6a17ac90d2d..b86c75cba412 100644 --- a/src/ui/public/courier/_redirect_when_missing.js +++ b/src/ui/public/courier/_redirect_when_missing.js @@ -1,9 +1,9 @@ import errors from 'ui/errors'; export default 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 @@ -22,7 +22,7 @@ export default function RedirectWhenMissingFn($location, kbnUrl, Notifier, Promi // 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 a5b940ec7c2b..b6dba26b187f 100644 --- a/src/ui/public/courier/_request_queue.js +++ b/src/ui/public/courier/_request_queue.js @@ -6,7 +6,7 @@ export default function PendingRequestList() { * they are processed by fetch.[sourceType](). * @type {Array} */ - var queue = []; + let queue = []; queue.getInactive = function (/* strategies */) { return queue.get.apply(queue, arguments) @@ -21,7 +21,7 @@ export default function PendingRequestList() { 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 486d5bcb20e8..4e09d24a8ef8 100644 --- a/src/ui/public/courier/courier.js +++ b/src/ui/public/courier/courier.js @@ -24,18 +24,18 @@ import RedirectWhenMissingProvider from './_redirect_when_missing'; uiModules.get('kibana/courier') .service('courier', function ($rootScope, Private, Promise, indexPatterns) { function Courier() { - var self = this; + let self = this; - var DocSource = Private(DocSourceProvider); - var SearchSource = Private(SearchSourceProvider); - var searchStrategy = Private(SearchStrategyProvider); + let DocSource = Private(DocSourceProvider); + let SearchSource = Private(SearchSourceProvider); + let searchStrategy = Private(SearchStrategyProvider); - var requestQueue = Private(RequestQueueProvider); - var errorHandlers = Private(ErrorHandlersProvider); + let requestQueue = Private(RequestQueueProvider); + let errorHandlers = Private(ErrorHandlersProvider); - var fetch = Private(FetchProvider); - var docLooper = self.docLooper = Private(DocLooperProvider); - var searchLooper = self.searchLooper = Private(SearchLooperProvider); + let fetch = Private(FetchProvider); + let docLooper = self.docLooper = Private(DocLooperProvider); + let searchLooper = self.searchLooper = Private(SearchLooperProvider); // expose some internal modules self.setRootSearchSource = Private(RootSearchSourceProvider).set; @@ -47,7 +47,7 @@ uiModules.get('kibana/courier') self.DocSource = DocSource; self.SearchSource = SearchSource; - var HastyRefresh = errors.HastyRefresh; + let HastyRefresh = errors.HastyRefresh; /** * update the time between automatic search requests @@ -135,8 +135,8 @@ uiModules.get('kibana/courier') // 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 { @@ -144,7 +144,7 @@ uiModules.get('kibana/courier') } }); - 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 d666db7ff5c5..07f6d856b52b 100644 --- a/src/ui/public/courier/data_source/_abstract.js +++ b/src/ui/public/courier/data_source/_abstract.js @@ -9,12 +9,12 @@ import FetchProvider from '../fetch'; import DecorateQueryProvider from './_decorate_query'; export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) { - var requestQueue = Private(RequestQueueProvider); - var errorHandlers = Private(ErrorHandlersProvider); - var courierFetch = Private(FetchProvider); + let requestQueue = Private(RequestQueueProvider); + let errorHandlers = Private(ErrorHandlersProvider); + let courierFetch = Private(FetchProvider); function SourceAbstract(initialState, strategy) { - var self = this; + let self = this; self._instanceid = _.uniqueId('data_source'); self._state = (function () { @@ -57,7 +57,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) * @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(); @@ -79,7 +79,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) * 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 @@ -125,7 +125,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) * @return {Promise} */ SourceAbstract.prototype.onResults = function (handler) { - var self = this; + let self = this; return new PromiseEmitter(function (resolve, reject) { const defer = Promise.defer(); @@ -149,7 +149,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) * @return {Promise} */ SourceAbstract.prototype.onError = function (handler) { - var self = this; + let self = this; return new PromiseEmitter(function (resolve, reject) { const defer = Promise.defer(); @@ -172,8 +172,8 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) * @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(); @@ -232,16 +232,16 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) * @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() { @@ -255,12 +255,12 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) }); } - 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; @@ -271,7 +271,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) .then(function () { if (type === 'search') { // This is down here to prevent the circular dependency - var decorateQuery = Private(DecorateQueryProvider); + let decorateQuery = Private(DecorateQueryProvider); flatState.body = flatState.body || {}; @@ -283,7 +283,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) } if (flatState.body.size > 0) { - 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 || []; @@ -301,7 +301,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) * 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; @@ -313,7 +313,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) * @param {Object} filter - The fitler to translate * @return {Object} the query version of that filter */ - var translateToQuery = function (filter) { + let translateToQuery = function (filter) { if (!filter) return; if (filter.query) { @@ -328,7 +328,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) * @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 a97740b0508b..bb6fca29200b 100644 --- a/src/ui/public/courier/data_source/_decorate_query.js +++ b/src/ui/public/courier/data_source/_decorate_query.js @@ -7,7 +7,7 @@ export default function DecorateQuery(config) { * @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 ac2aea1e9c4c..5cc07f9e0425 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 @@ -5,8 +5,8 @@ import RequestQueueProvider from 'ui/courier/_request_queue'; import FetchProvider from 'ui/courier/fetch/fetch'; export default function (Promise, Private, es) { - var requestQueue = Private(RequestQueueProvider); - var courierFetch = Private(FetchProvider); + let requestQueue = Private(RequestQueueProvider); + let courierFetch = Private(FetchProvider); /** * Backend for doUpdate and doIndex @@ -16,9 +16,9 @@ export default function (Promise, Private, es) { * @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]; @@ -51,13 +51,13 @@ export default function (Promise, Private, es) { // 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 1ea2eff0e36d..3798b0abd71d 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 @@ import _ from 'lodash'; export default function normalizeSortRequest(config) { - var defaultSortOptions = config.get('sort:options'); + let defaultSortOptions = config.get('sort:options'); /** * Decorate queries with default parameters @@ -9,7 +9,7 @@ export default function normalizeSortRequest(config) { * @returns {object} */ return function (sortObject, indexPattern) { - var normalizedSort = []; + let normalizedSort = []; // [].concat({}) -> [{}], [].concat([{}]) -> [{}] return [].concat(sortObject).map(function (sortable) { @@ -22,10 +22,10 @@ export default function normalizeSortRequest(config) { { 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 045dc0611c3c..c3cb53ffb33c 100644 --- a/src/ui/public/courier/data_source/_root_search_source.js +++ b/src/ui/public/courier/data_source/_root_search_source.js @@ -1,11 +1,11 @@ import SearchSourceProvider from 'ui/courier/data_source/search_source'; export default function RootSearchSource(Private, $rootScope, timefilter, Notifier) { - var SearchSource = Private(SearchSourceProvider); + let SearchSource = Private(SearchSourceProvider); - 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 @@ -35,7 +35,7 @@ export default function RootSearchSource(Private, $rootScope, timefilter, Notifi // 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 c2725309bfb7..67d6de7e9e6b 100644 --- a/src/ui/public/courier/data_source/doc_source.js +++ b/src/ui/public/courier/data_source/doc_source.js @@ -9,10 +9,10 @@ import DocRequestProvider from '../fetch/request/doc'; import DocStrategyProvider from '../fetch/strategy/doc'; export default function DocSourceFactory(Private, Promise, es, sessionStorage) { - var sendToEs = Private(DocSendToEsProvider); - var SourceAbstract = Private(AbstractDataSourceProvider); - var DocRequest = Private(DocRequestProvider); - var docStrategy = Private(DocStrategyProvider); + let sendToEs = Private(DocSendToEsProvider); + let SourceAbstract = Private(AbstractDataSourceProvider); + let DocRequest = Private(DocRequestProvider); + let docStrategy = Private(DocStrategyProvider); _.class(DocSource).inherits(SourceAbstract); function DocSource(initialState) { @@ -99,7 +99,7 @@ export default function DocSourceFactory(Private, Promise, es, sessionStorage) { * @return {string} */ DocSource.prototype._versionKey = function () { - var state = this._state; + let state = this._state; if (!state.index || !state.type || !state.id) return; return 'DocVersion:' + ( @@ -125,10 +125,10 @@ export default function DocSourceFactory(Private, Promise, es, sessionStorage) { * @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; }; @@ -141,7 +141,7 @@ export default function DocSourceFactory(Private, Promise, es, sessionStorage) { 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); @@ -151,7 +151,7 @@ export default function DocSourceFactory(Private, Promise, es, sessionStorage) { * 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 0cd2a14d749b..ef0fc31ab733 100644 --- a/src/ui/public/courier/data_source/search_source.js +++ b/src/ui/public/courier/data_source/search_source.js @@ -8,11 +8,11 @@ import SegmentedRequestProvider from '../fetch/request/segmented'; import SearchStrategyProvider from '../fetch/strategy/search'; export default function SearchSourceFactory(Promise, Private) { - var SourceAbstract = Private(AbstractDataSourceProvider); - var SearchRequest = Private(SearchRequestProvider); - var SegmentedRequest = Private(SegmentedRequestProvider); - var searchStrategy = Private(SearchStrategyProvider); - var normalizeSortRequest = Private(NormalizeSortRequestProvider); + let SourceAbstract = Private(AbstractDataSourceProvider); + let SearchRequest = Private(SearchRequestProvider); + let SegmentedRequest = Private(SegmentedRequestProvider); + let searchStrategy = Private(SearchStrategyProvider); + let normalizeSortRequest = Private(NormalizeSortRequestProvider); _.class(SearchSource).inherits(SourceAbstract); function SearchSource(initialState) { @@ -71,7 +71,7 @@ export default function SearchSourceFactory(Promise, Private) { * @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(); @@ -92,9 +92,9 @@ export default function SearchSourceFactory(Promise, Private) { }; 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 @@ -139,7 +139,7 @@ export default function SearchSourceFactory(Promise, Private) { */ 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/looper/_looper.js b/src/ui/public/courier/looper/_looper.js index fcb25511e6a1..8ebf2df44d49 100644 --- a/src/ui/public/courier/looper/_looper.js +++ b/src/ui/public/courier/looper/_looper.js @@ -4,7 +4,7 @@ import 'ui/promises'; import Notifier from 'ui/notify/notifier'; export default function LooperFactory($timeout, Promise) { - var notify = new Notifier(); + let notify = new Notifier(); function Looper(ms, fn) { this._fn = fn; @@ -130,7 +130,7 @@ export default function LooperFactory($timeout, Promise) { * @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 a1c6104ce20a..e0f21394777c 100644 --- a/src/ui/public/courier/looper/doc.js +++ b/src/ui/public/courier/looper/doc.js @@ -3,15 +3,15 @@ import LooperProvider from './_looper'; import DocStrategyProvider from '../fetch/strategy/doc'; export default function DocLooperService(Private) { - var fetch = Private(FetchProvider); - var Looper = Private(LooperProvider); - var DocStrategy = Private(DocStrategyProvider); + let fetch = Private(FetchProvider); + let Looper = Private(LooperProvider); + let DocStrategy = Private(DocStrategyProvider); /** * 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 cb3914c601c0..ae6867f77d50 100644 --- a/src/ui/public/courier/looper/search.js +++ b/src/ui/public/courier/looper/search.js @@ -4,18 +4,18 @@ import RequestQueueProvider from '../_request_queue'; import LooperProvider from './_looper'; export default function SearchLooperService(Private, Promise, Notifier, $rootScope) { - var fetch = Private(FetchProvider); - var searchStrategy = Private(SearchStrategyProvider); - var requestQueue = Private(RequestQueueProvider); + let fetch = Private(FetchProvider); + let searchStrategy = Private(SearchStrategyProvider); + let requestQueue = Private(RequestQueueProvider); - var Looper = Private(LooperProvider); - var notif = new Notifier({ location: 'Search Looper' }); + let Looper = Private(LooperProvider); + 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 477c6c76b959..5c32ccac9064 100644 --- a/src/ui/public/courier/saved_object/saved_object.js +++ b/src/ui/public/courier/saved_object/saved_object.js @@ -10,38 +10,38 @@ import SearchSourceProvider from '../data_source/search_source'; export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notifier, safeConfirm, indexPatterns) { - var DocSource = Private(DocSourceProvider); - var SearchSource = Private(SearchSourceProvider); - var mappingSetup = Private(MappingSetupProvider); + let DocSource = Private(DocSourceProvider); + let SearchSource = Private(SearchSourceProvider); + let mappingSetup = Private(MappingSetupProvider); 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(); @@ -113,7 +113,7 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif 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) { @@ -158,8 +158,8 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif 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; }, {}); @@ -176,7 +176,7 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif 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); @@ -200,7 +200,7 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif * @return {Object} */ self.serialize = function () { - var body = {}; + let body = {}; _.forOwn(mapping, function (fieldMapping, fieldName) { if (self[fieldName] != null) { @@ -227,7 +227,7 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif */ self.save = function () { - var body = self.serialize(); + let body = self.serialize(); // Slugify the object id self.id = slugifyId(self.id); @@ -240,7 +240,7 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif }; self.saveSource = function (source) { - var finish = function (id) { + let finish = function (id) { self.id = id; return es.indices.refresh({ index: kbnIndex @@ -255,7 +255,7 @@ export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notif .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 f317ee51b85c..7f8652f39d8f 100644 --- a/src/ui/public/debounce/debounce.js +++ b/src/ui/public/debounce/debounce.js @@ -3,7 +3,7 @@ import uiModules from 'ui/modules'; // Debounce service, angularized version of lodash debounce // borrowed heavily from https://github.com/shahata/angular-debounce -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.service('debounce', ['$timeout', function ($timeout) { return function (func, wait, options) { @@ -20,14 +20,14 @@ module.service('debounce', ['$timeout', function ($timeout) { 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 b5c96abae51b..2fead2be3983 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 @@ import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('autoSelectIfOnlyOne', function ($parse) { return { @@ -7,7 +7,7 @@ module.directive('autoSelectIfOnlyOne', function ($parse) { 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/bread_crumbs.js b/src/ui/public/directives/bread_crumbs.js index f78739f098a5..145c2749f85a 100644 --- a/src/ui/public/directives/bread_crumbs.js +++ b/src/ui/public/directives/bread_crumbs.js @@ -2,7 +2,7 @@ import _ from 'lodash'; import chrome from 'ui/chrome/chrome'; import breadCrumbsTemplate from 'ui/partials/bread_crumbs.html'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('breadCrumbs', function () { return { diff --git a/src/ui/public/directives/click_focus.js b/src/ui/public/directives/click_focus.js index 4f5353514370..5a005676699c 100644 --- a/src/ui/public/directives/click_focus.js +++ b/src/ui/public/directives/click_focus.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import $ from 'jquery'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('clickFocus', function () { return { @@ -11,7 +11,7 @@ module.directive('clickFocus', function () { 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/confirm_click.js b/src/ui/public/directives/confirm_click.js index 027facb56b17..9c83e861ee29 100644 --- a/src/ui/public/directives/confirm_click.js +++ b/src/ui/public/directives/confirm_click.js @@ -6,9 +6,9 @@ uiModules 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 bebff1a1fa92..b9541a814d2d 100644 --- a/src/ui/public/directives/css_truncate.js +++ b/src/ui/public/directives/css_truncate.js @@ -1,7 +1,7 @@ import $ from 'jquery'; import _ from 'lodash'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); 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 d167958f56c2..22944b50019a 100644 --- a/src/ui/public/directives/field_name.js +++ b/src/ui/public/directives/field_name.js @@ -1,6 +1,6 @@ import 'ui/filters/short_dots'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('fieldName', function ($compile, $rootScope, $filter) { return { @@ -12,7 +12,7 @@ module.directive('fieldName', function ($compile, $rootScope, $filter) { }, link: function ($scope, $el) { - var typeIcon = function (fieldType) { + let typeIcon = function (fieldType) { switch (fieldType) { case 'source': return ''; @@ -44,12 +44,12 @@ module.directive('fieldName', function ($compile, $rootScope, $filter) { '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 fe2aaffc7715..2283f34319da 100644 --- a/src/ui/public/directives/file_upload.js +++ b/src/ui/public/directives/file_upload.js @@ -1,25 +1,25 @@ import $ from 'jquery'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); 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 67ed3aeb051d..b6e2ed72b068 100644 --- a/src/ui/public/directives/inequality.js +++ b/src/ui/public/directives/inequality.js @@ -5,8 +5,8 @@ function makeDirectiveDef(id, compare) { 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 @@ function makeDirectiveDef(id, compare) { }); 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 50df93f06136..db1f410f56ed 100644 --- a/src/ui/public/directives/infinite_scroll.js +++ b/src/ui/public/directives/infinite_scroll.js @@ -1,6 +1,6 @@ import $ from 'jquery'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('kbnInfiniteScroll', function () { return { @@ -9,20 +9,20 @@ module.directive('kbnInfiniteScroll', function () { 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/input_datetime.js b/src/ui/public/directives/input_datetime.js index 1e82ae790e87..0559358e8309 100644 --- a/src/ui/public/directives/input_datetime.js +++ b/src/ui/public/directives/input_datetime.js @@ -2,7 +2,7 @@ import $ from 'jquery'; import _ from 'lodash'; import moment from 'moment'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('inputDatetime', function () { return { @@ -10,18 +10,18 @@ module.directive('inputDatetime', function () { 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 f4484717f085..c6adccfd3e7b 100644 --- a/src/ui/public/directives/input_focus.js +++ b/src/ui/public/directives/input_focus.js @@ -1,5 +1,5 @@ import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.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 11d388dfb889..5a4f406ea5a9 100644 --- a/src/ui/public/directives/input_whole_number.js +++ b/src/ui/public/directives/input_whole_number.js @@ -1,5 +1,5 @@ import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.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 1b2e61a8eca1..640b5bd88790 100644 --- a/src/ui/public/directives/json_input.js +++ b/src/ui/public/directives/json_input.js @@ -15,7 +15,7 @@ uiModules 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 444df4b3f4b7..cf11e8ac6fd0 100644 --- a/src/ui/public/directives/paginate.js +++ b/src/ui/public/directives/paginate.js @@ -2,7 +2,7 @@ import _ from 'lodash'; import uiModules from 'ui/modules'; import paginateControlsTemplate from 'ui/partials/paginate_controls.html'; -var PER_PAGE_DEFAULT = 10; +let PER_PAGE_DEFAULT = 10; uiModules.get('kibana') .directive('paginate', function ($parse, $compile) { @@ -22,7 +22,7 @@ uiModules.get('kibana') $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); @@ -42,8 +42,8 @@ uiModules.get('kibana') }, controllerAs: 'paginate', controller: function ($scope) { - var self = this; - var ALL = 0; + let self = this; + let ALL = 0; self.sizeOptions = [ { title: '10', value: 10 }, @@ -62,8 +62,8 @@ uiModules.get('kibana') 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)) { @@ -102,14 +102,14 @@ uiModules.get('kibana') $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); @@ -144,9 +144,9 @@ uiModules.get('kibana') // 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) { @@ -155,14 +155,14 @@ uiModules.get('kibana') } // 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; @@ -173,7 +173,7 @@ uiModules.get('kibana') }; 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 79e5bc25c71d..80262b962605 100644 --- a/src/ui/public/directives/pretty_duration.js +++ b/src/ui/public/directives/pretty_duration.js @@ -4,7 +4,7 @@ import moment from 'moment'; import 'ui/timepicker/quick_ranges'; import 'ui/timepicker/time_units'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('prettyDuration', function (config, quickRanges, timeUnits) { @@ -15,9 +15,9 @@ module.directive('prettyDuration', function (config, quickRanges, timeUnits) { 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 @@ module.directive('prettyDuration', function (config, quickRanges, timeUnits) { 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 @@ module.directive('prettyDuration', function (config, quickRanges, timeUnits) { }; 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 @@ module.directive('prettyDuration', function (config, quickRanges, timeUnits) { 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 436bfb983071..11f3ae3f2e96 100644 --- a/src/ui/public/directives/rows.js +++ b/src/ui/public/directives/rows.js @@ -3,24 +3,24 @@ import _ from 'lodash'; import AggConfigResult from 'ui/vis/agg_config_result'; import FilterBarFilterBarClickHandlerProvider from 'ui/filter_bar/filter_bar_click_handler'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('kbnRows', function ($compile, $rootScope, getAppState, Private) { - var filterBarClickHandler = Private(FilterBarFilterBarClickHandlerProvider); + let filterBarClickHandler = Private(FilterBarFilterBarClickHandlerProvider); 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)'); @@ -71,19 +71,19 @@ module.directive('kbnRows', function ($compile, $rootScope, getAppState, Private 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 @@ -91,7 +91,7 @@ module.directive('kbnRows', function ($compile, $rootScope, getAppState, Private } 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 becf923d5ee0..f6c7f766807e 100644 --- a/src/ui/public/directives/saved_object_finder.js +++ b/src/ui/public/directives/saved_object_finder.js @@ -4,11 +4,11 @@ import keymap from 'ui/utils/key_map'; import SavedObjectsSavedObjectRegistryProvider from 'ui/saved_objects/saved_object_registry'; import uiModules from 'ui/modules'; import savedObjectFinderTemplate from 'ui/partials/saved_object_finder.html'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Private, config) { - var services = Private(SavedObjectsSavedObjectRegistryProvider).byLoaderPropertiesName; + let services = Private(SavedObjectsSavedObjectRegistryProvider).byLoaderPropertiesName; return { restrict: 'E', @@ -23,19 +23,19 @@ module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Pr template: savedObjectFinderTemplate, controllerAs: 'finder', controller: function ($scope, $element, $timeout) { - var self = this; + let self = this; // the text input element - var $input = $element.find('input[ng-model=filter]'); + let $input = $element.find('input[ng-model=filter]'); // The number of items to show in the list $scope.perPage = config.get('savedObjects:perPage'); // 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; @@ -95,7 +95,7 @@ module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Pr $scope.userOnChoose(hit, $event); } - var url = self.makeUrl(hit); + let url = self.makeUrl(hit); if (!url || url === '#' || url.charAt(0) !== '#') return; $event.preventDefault(); @@ -133,7 +133,7 @@ module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Pr case 'enter': if (self.hitCount !== 1) return; - var hit = self.hits[0]; + let hit = self.hits[0]; if (!hit) return; self.onChoose(hit, $event); @@ -206,8 +206,8 @@ module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Pr 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); @@ -249,7 +249,7 @@ module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Pr // 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; @@ -265,7 +265,7 @@ module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Pr } function scrollIntoView($element, snapTop) { - var el = $element[0]; + let el = $element[0]; if (!el) return; diff --git a/src/ui/public/directives/truncated.js b/src/ui/public/directives/truncated.js index 325d7955ef38..a46197a707a8 100644 --- a/src/ui/public/directives/truncated.js +++ b/src/ui/public/directives/truncated.js @@ -1,6 +1,6 @@ import $ from 'jquery'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); module.directive('kbnTruncated', function ($compile) { return { @@ -10,14 +10,14 @@ module.directive('kbnTruncated', function ($compile) { 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_date_math.js b/src/ui/public/directives/validate_date_math.js index bfb4e437d4fc..d9dad2aa5f30 100644 --- a/src/ui/public/directives/validate_date_math.js +++ b/src/ui/public/directives/validate_date_math.js @@ -19,7 +19,7 @@ uiModules.get('kibana').directive('validateDateMath', function () { 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 fe41be26f5bd..1082616ee0e7 100644 --- a/src/ui/public/directives/validate_index_name.js +++ b/src/ui/public/directives/validate_index_name.js @@ -12,11 +12,11 @@ uiModules '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 @@ uiModules // 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_json.js b/src/ui/public/directives/validate_json.js index 973aa7276433..bf4df84f69da 100644 --- a/src/ui/public/directives/validate_json.js +++ b/src/ui/public/directives/validate_json.js @@ -2,7 +2,7 @@ import _ from 'lodash'; import $ from 'jquery'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.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 4fbdd83173bd..b0c0d56644d6 100644 --- a/src/ui/public/doc_table/components/table_header.js +++ b/src/ui/public/doc_table/components/table_header.js @@ -2,7 +2,7 @@ import _ from 'lodash'; import 'ui/filters/short_dots'; import headerHtml from 'ui/doc_table/components/table_header.html'; import uiModules from 'ui/modules'; -var module = uiModules.get('app/discover'); +let module = uiModules.get('app/discover'); module.directive('kbnTableHeader', function (shortDotsFilter) { @@ -16,9 +16,9 @@ module.directive('kbnTableHeader', function (shortDotsFilter) { 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 @@ module.directive('kbnTableHeader', function (shortDotsFilter) { $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 @@ module.directive('kbnTableHeader', function (shortDotsFilter) { $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 168e71a52ea7..7dfdfe24fa69 100644 --- a/src/ui/public/doc_table/components/table_row.js +++ b/src/ui/public/doc_table/components/table_row.js @@ -10,12 +10,12 @@ import noWhiteSpace from 'ui/utils/no_white_space'; import openRowHtml from 'ui/doc_table/components/table_row/open.html'; import detailsHtml from 'ui/doc_table/components/table_row/details.html'; import uiModules from 'ui/modules'; -var module = uiModules.get('app/discover'); +let module = uiModules.get('app/discover'); // 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 @@ -26,8 +26,8 @@ var MIN_LINE_LENGTH = 20; * ``` */ module.directive('kbnTableRow', function ($compile) { - 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 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 @@ module.directive('kbnTableRow', function ($compile) { $el.after(''); $el.empty(); - var init = function () { + let init = function () { createSummaryRow($scope.row, $scope.row._id); }; @@ -53,7 +53,7 @@ module.directive('kbnTableRow', function ($compile) { // 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 @@ module.directive('kbnTableRow', function ($compile) { // 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 @@ module.directive('kbnTableRow', function ($compile) { })); }); - 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 @@ module.directive('kbnTableRow', function ($compile) { * 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/components/table_row/cell.html b/src/ui/public/doc_table/components/table_row/cell.html index 55f1e17f0cde..ca28d024ff7a 100644 --- a/src/ui/public/doc_table/components/table_row/cell.html +++ b/src/ui/public/doc_table/components/table_row/cell.html @@ -1,5 +1,5 @@ <% -var attributes = ''; +let attributes = ''; if (timefield) { attributes='class="discover-table-timefield" width="1%"'; } else if (sourcefield) { diff --git a/src/ui/public/doc_table/doc_table.js b/src/ui/public/doc_table/doc_table.js index f9d0eec99fba..db3148a83152 100644 --- a/src/ui/public/doc_table/doc_table.js +++ b/src/ui/public/doc_table/doc_table.js @@ -25,15 +25,15 @@ uiModules.get('kibana') 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 @@ uiModules.get('kibana') $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 a92572a6eae3..e9f99615b1fc 100644 --- a/src/ui/public/doc_table/lib/get_sort.js +++ b/src/ui/public/doc_table/lib/get_sort.js @@ -7,7 +7,7 @@ import _ from 'lodash'; * @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 5cff0b94fe56..5bd02d6af0f3 100644 --- a/src/ui/public/doc_title/doc_title.js +++ b/src/ui/public/doc_title/doc_title.js @@ -11,16 +11,16 @@ uiModules.get('kibana') $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);