Skip to content

Commit

Permalink
Merge pull request #6907 from epixa/uiletconst3
Browse files Browse the repository at this point in the history
[internal] Replace var with let in ui/public A-D
  • Loading branch information
epixa committed Apr 14, 2016
2 parents 3b2689d + 4c535f6 commit fa4c6b0
Show file tree
Hide file tree
Showing 116 changed files with 605 additions and 605 deletions.
16 changes: 8 additions & 8 deletions src/ui/public/agg_response/geo_json/_tooltip_formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<div>').html(require('ui/agg_response/geo_json/_tooltip.html'));
let fieldFormats = Private(RegistryFieldFormatsProvider);
let $tooltipScope = $rootScope.$new();
let $el = $('<div>').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 = [
Expand Down
14 changes: 7 additions & 7 deletions src/ui/public/agg_response/geo_json/geo_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -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;
});

Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/agg_response/geo_json/rows_to_features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_response/hierarchical/_build_split.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/agg_response/hierarchical/_collect_branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_response/hierarchical/_collect_keys.js
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
16 changes: 8 additions & 8 deletions src/ui/public/agg_response/hierarchical/_create_raw_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down
34 changes: 17 additions & 17 deletions src/ui/public/agg_response/hierarchical/build_hierarchical_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -50,42 +50,42 @@ 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.');
}

// 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);
return split;
}

// 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;
});
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 {
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/agg_response/point_series/_fake_x_aspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ 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,
hasNoDsl: true
});

return function makeFakeXAxis(vis) {
var fake = new AggConfig(vis, {
let fake = new AggConfig(vis, {
type: allAgg,
schema: vis.type.schemas.all.byName.segment
});
Expand Down
12 changes: 6 additions & 6 deletions src/ui/public/agg_response/point_series/_get_aspects.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/agg_response/point_series/_get_point.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down
Loading

0 comments on commit fa4c6b0

Please sign in to comment.