Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] PR #6907 to 4.x #6927

Merged
merged 1 commit into from
Apr 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/ui/public/Binder/Binder.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var $ = require('jquery');
var d3 = require('d3');
var callEach = require('lodash').callEach;
var bindKey = require('lodash').bindKey;
var rest = require('lodash').rest;
let $ = require('jquery');
let d3 = require('d3');
let callEach = require('lodash').callEach;
let bindKey = require('lodash').bindKey;
let rest = require('lodash').rest;

function Binder($scope) {
this.disposal = [];
Expand All @@ -23,14 +23,14 @@ Binder.prototype.on = function (emitter/*, ...args */) {
};

Binder.prototype.jqOn = function (el/*, ...args */) {
var $el = $(el);
let $el = $(el);
this._bind($el.on, $el.off, $el, rest(arguments));
};

Binder.prototype.fakeD3Bind = function (el, event, handler) {
this.jqOn(el, event, function (e) {
// mimick https://github.com/mbostock/d3/blob/3abb00113662463e5c19eb87cd33f6d0ddc23bc0/src/selection/on.js#L87-L94
var o = d3.event; // Events can be reentrant (e.g., focus).
let o = d3.event; // Events can be reentrant (e.g., focus).
d3.event = e;
try {
handler.apply(this, [this.__data__]);
Expand All @@ -41,7 +41,7 @@ Binder.prototype.fakeD3Bind = function (el, event, handler) {
};

Binder.prototype.destroy = function () {
var destroyers = this.disposal;
let destroyers = this.disposal;
this.disposal = [];
callEach(destroyers);
};
Expand Down
20 changes: 10 additions & 10 deletions src/ui/public/agg_response/geo_json/_tooltip_formatter.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
define(function (require) {
return function TileMapTooltipFormatter($compile, $rootScope, Private) {
var $ = require('jquery');
var _ = require('lodash');
let $ = require('jquery');
let _ = require('lodash');

var fieldFormats = Private(require('ui/registry/field_formats'));
var $tooltipScope = $rootScope.$new();
var $el = $('<div>').html(require('ui/agg_response/geo_json/_tooltip.html'));
let fieldFormats = Private(require('ui/registry/field_formats'));
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
18 changes: 9 additions & 9 deletions src/ui/public/agg_response/geo_json/geo_json.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
define(function (require) {
return function TileMapConverterFn(Private, timefilter, $compile, $rootScope) {
var _ = require('lodash');
let _ = require('lodash');

var rowsToFeatures = require('ui/agg_response/geo_json/rowsToFeatures');
var tooltipFormatter = Private(require('ui/agg_response/geo_json/_tooltip_formatter'));
let rowsToFeatures = require('ui/agg_response/geo_json/rowsToFeatures');
let tooltipFormatter = Private(require('ui/agg_response/geo_json/_tooltip_formatter'));

return function (vis, table) {

Expand All @@ -13,13 +13,13 @@ define(function (require) {
});
}

var geoI = columnIndex('segment');
var metricI = columnIndex('metric');
var geoAgg = _.get(table.columns, [geoI, 'aggConfig']);
var metricAgg = _.get(table.columns, [metricI, 'aggConfig']);
let geoI = columnIndex('segment');
let metricI = columnIndex('metric');
let geoAgg = _.get(table.columns, [geoI, 'aggConfig']);
let metricAgg = _.get(table.columns, [metricI, 'aggConfig']);

var features = rowsToFeatures(table, geoI, metricI);
var values = features.map(function (feature) {
let features = rowsToFeatures(table, geoI, metricI);
let values = features.map(function (feature) {
return feature.properties.value;
});

Expand Down
14 changes: 7 additions & 7 deletions src/ui/public/agg_response/geo_json/rowsToFeatures.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function (require) {
var decodeGeoHash = require('ui/utils/decode_geo_hash');
var AggConfigResult = require('ui/Vis/AggConfigResult');
var _ = require('lodash');
let decodeGeoHash = require('ui/utils/decode_geo_hash');
let AggConfigResult = require('ui/Vis/AggConfigResult');
let _ = require('lodash');

function getAcr(val) {
return val instanceof AggConfigResult ? val : null;
Expand All @@ -13,19 +13,19 @@ define(function (require) {

function convertRowsToFeatures(table, geoI, metricI) {
return _.transform(table.rows, function (features, row) {
var geohash = unwrap(row[geoI]);
let geohash = unwrap(row[geoI]);
if (!geohash) return;

// fetch latLn of northwest and southeast corners, and center point
var location = decodeGeoHash(geohash);
let location = decodeGeoHash(geohash);

var centerLatLng = [
let centerLatLng = [
location.latitude[2],
location.longitude[2]
];

// order is nw, ne, se, sw
var rectangle = [
let rectangle = [
[location.latitude[0], location.longitude[0]],
[location.latitude[0], location.longitude[1]],
[location.latitude[1], location.longitude[1]],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
var _ = require('lodash');
let _ = require('lodash');
return function (buckets) {
let previous;
_.each(buckets, function (bucket) {
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/agg_response/hierarchical/_build_split.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
define(function (require) {
return function biuldSplitProvider(Private) {
var transformer = Private(require('ui/agg_response/hierarchical/_transform_aggregation'));
var collectKeys = require('ui/agg_response/hierarchical/_collect_keys');
let transformer = Private(require('ui/agg_response/hierarchical/_transform_aggregation'));
let collectKeys = require('ui/agg_response/hierarchical/_collect_keys');
return function (agg, metric, aggData) {
// Ceate the split structure
var split = { label: '', slices: { children: [] } };
let split = { label: '', slices: { children: [] } };

// Transform the aggData into splits
split.slices.children = transformer(agg, metric, aggData);
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
6 changes: 3 additions & 3 deletions src/ui/public/agg_response/hierarchical/_collect_keys.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
define(function (require) {
var _ = require('lodash');
let _ = require('lodash');
return function collectKeys(children) {
var nextChildren = _.pluck(children, 'children');
var keys = _.pluck(children, 'name');
let nextChildren = _.pluck(children, 'children');
let keys = _.pluck(children, 'name');
return _(nextChildren)
.map(collectKeys)
.flattenDeep()
Expand Down
20 changes: 10 additions & 10 deletions src/ui/public/agg_response/hierarchical/_create_raw_data.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
define(function (require) {
var _ = require('lodash');
var extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets');
let _ = require('lodash');
let extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets');
return function (vis, resp) {

// Create the initial results structure
var results = { rows: [] };
let results = { rows: [] };

// Create a reference to the buckets and metrics
var metrics = vis.aggs.bySchemaGroup.metrics;
var buckets = vis.aggs.bySchemaGroup.buckets;
var aggs = [];
let metrics = vis.aggs.bySchemaGroup.metrics;
let buckets = vis.aggs.bySchemaGroup.buckets;
let aggs = [];

if (buckets) {
_.each(buckets, function (bucket) {
Expand Down Expand Up @@ -38,7 +38,7 @@ define(function (require) {

// if there are no buckets then we need to just set the value and return
if (!buckets) {
var value = resp.aggregations
let value = resp.aggregations
&& resp.aggregations[metrics[0].id]
&& resp.aggregations[metrics[0].id].value
|| resp.hits.total;
Expand All @@ -61,9 +61,9 @@ define(function (require) {
// iterate through all the buckets
_.each(extractBuckets(data[agg.id], agg), function (bucket) {

var _record = _.flattenDeep([record, bucket.key]);
let _record = _.flattenDeep([record, bucket.key]);
_.each(metrics, function (metric) {
var value = bucket.doc_count;
let value = bucket.doc_count;
if (bucket[metric.id] && !_.isUndefined(bucket[metric.id].value)) {
value = bucket[metric.id].value;
}
Expand All @@ -74,7 +74,7 @@ define(function (require) {
// buckets. If it does then we need to keep on walking the tree.
// This is where the recursion happens.
if (agg._next) {
var nextBucket = bucket[agg._next.id];
let nextBucket = bucket[agg._next.id];
if (nextBucket && nextBucket.buckets) {
walkBuckets(agg._next, bucket, _record);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_response/hierarchical/_extract_buckets.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
define(function (require) {
var _ = require('lodash');
let _ = require('lodash');
return function (bucket, agg) {
if (bucket && _.isPlainObject(bucket.buckets)) {
return _.map(bucket.buckets, function (value, key) {
var item = _.cloneDeep(value);
let item = _.cloneDeep(value);
item.key = agg ? agg.getKey(value, key) : key;
return item;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
define(function (require) {
return function HierarchicalTooltipFormaterProvider($rootScope, $compile, $sce) {
var _ = require('lodash');
var $ = require('jquery');
var $tooltip = $(require('ui/agg_response/hierarchical/_tooltip.html'));
var collectBranch = require('ui/agg_response/hierarchical/_collect_branch');
var $tooltipScope = $rootScope.$new();
var numeral = require('numeral');
let _ = require('lodash');
let $ = require('jquery');
let $tooltip = $(require('ui/agg_response/hierarchical/_tooltip.html'));
let collectBranch = require('ui/agg_response/hierarchical/_collect_branch');
let $tooltipScope = $rootScope.$new();
let numeral = require('numeral');

$compile($tooltip)($tooltipScope);

return function (columns) {
return function (event) {
var datum = event.datum;
let datum = event.datum;

// Collect the current leaf and parents into an array of values
$tooltipScope.rows = collectBranch(datum);

var metricCol = $tooltipScope.metricCol = _.find(columns, { categoryName: 'metric' });
let metricCol = $tooltipScope.metricCol = _.find(columns, { categoryName: 'metric' });

// Map those values to what the tooltipSource.rows format.
_.forEachRight($tooltipScope.rows, function (row, i, rows) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
define(function (require) {
var _ = require('lodash');
var extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets');
let _ = require('lodash');
let extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets');
return function transformAggregationProvider(Private) {
var AggConfigResult = require('ui/Vis/AggConfigResult');
let AggConfigResult = require('ui/Vis/AggConfigResult');
return function transformAggregation(agg, metric, aggData, parent) {
return _.map(extractBuckets(aggData, agg), function (bucket) {
var aggConfigResult = new AggConfigResult(
let aggConfigResult = new AggConfigResult(
agg,
parent && parent.aggConfigResult,
metric.getValue(bucket),
agg.getKey(bucket)
);

var branch = {
let branch = {
name: agg.fieldFormatter()(bucket.key),
size: aggConfigResult.value,
aggConfig: agg,
Expand All @@ -28,7 +28,7 @@ define(function (require) {
// If the next bucket exists and it has children the we need to
// transform it as well. This is where the recursion happens.
if (agg._next) {
var nextBucket = bucket[agg._next.id];
let nextBucket = bucket[agg._next.id];
if (nextBucket && nextBucket.buckets) {
branch.children = transformAggregation(agg._next, metric, nextBucket, branch);
}
Expand Down
Loading