diff --git a/src/ui/public/Vis/AggConfig.js b/src/ui/public/Vis/AggConfig.js index 12d9f05450880..8c8cbf89db224 100644 --- a/src/ui/public/Vis/AggConfig.js +++ b/src/ui/public/Vis/AggConfig.js @@ -1,10 +1,10 @@ define(function (require) { return function AggConfigFactory(Private, fieldTypeFilter) { - var _ = require('lodash'); - var fieldFormats = Private(require('ui/registry/field_formats')); + let _ = require('lodash'); + let fieldFormats = Private(require('ui/registry/field_formats')); function AggConfig(vis, opts) { - var self = this; + let self = this; self.id = String(opts.id || AggConfig.nextId(vis.aggs)); self.vis = vis; @@ -26,13 +26,13 @@ define(function (require) { * @return {array} - the list that was passed in */ AggConfig.ensureIds = function (list) { - var have = []; - var haveNot = []; + let have = []; + let haveNot = []; list.forEach(function (obj) { (obj.id ? have : haveNot).push(obj); }); - var nextId = AggConfig.nextId(have); + let nextId = AggConfig.nextId(have); haveNot.forEach(function (obj) { obj.id = String(nextId++); }); @@ -97,12 +97,12 @@ define(function (require) { * @return {undefined} */ AggConfig.prototype.fillDefaults = function (from) { - var self = this; + let self = this; from = from || self.params || {}; - var to = self.params = {}; + let to = self.params = {}; self.getAggParams().forEach(function (aggParam) { - var val = from[aggParam.name]; + let val = from[aggParam.name]; if (val == null) { if (aggParam.default == null) return; @@ -116,11 +116,11 @@ define(function (require) { } if (aggParam.deserialize) { - var isTyped = _.isFunction(aggParam.type); + let isTyped = _.isFunction(aggParam.type); - var isType = isTyped && (val instanceof aggParam.type); - var isObject = !isTyped && _.isObject(val); - var isDeserialized = (isType || isObject); + let isType = isTyped && (val instanceof aggParam.type); + let isObject = !isTyped && _.isObject(val); + let isDeserialized = (isType || isObject); if (!isDeserialized) { val = aggParam.deserialize(val, self); @@ -140,12 +140,12 @@ define(function (require) { * @return {object} the new params object */ AggConfig.prototype.resetParams = function () { - var fieldParam = this.type && this.type.params.byName.field; + let fieldParam = this.type && this.type.params.byName.field; let field; if (fieldParam) { - var prevField = this.params.field; - var fieldOpts = fieldTypeFilter(this.vis.indexPattern.fields, fieldParam.filterFieldTypes); + let prevField = this.params.field; + let fieldOpts = fieldTypeFilter(this.vis.indexPattern.fields, fieldParam.filterFieldTypes); field = _.contains(fieldOpts, prevField) ? prevField : null; } @@ -161,10 +161,10 @@ define(function (require) { throw new TypeError('The "' + this.type.title + '" aggregation does not support filtering.'); } - var field = this.field(); - var label = this.fieldDisplayName(); + let field = this.field(); + let label = this.fieldDisplayName(); if (field && !field.filterable) { - var message = 'The "' + label + '" field can not be used for filtering.'; + let message = 'The "' + label + '" field can not be used for filtering.'; if (field.scripted) { message = 'The "' + label + '" field is scripted and can not be used for filtering.'; } @@ -181,7 +181,7 @@ define(function (require) { * @return {[type]} [description] */ AggConfig.prototype.requesting = function () { - var self = this; + let self = this; self.type && self.type.params.forEach(function (param) { if (param.onRequest) param.onRequest(self); }); @@ -198,14 +198,14 @@ define(function (require) { */ AggConfig.prototype.toDsl = function () { if (this.type.hasNoDsl) return; - var output = this.write(); + let output = this.write(); - var configDsl = {}; + let configDsl = {}; configDsl[this.type.dslName || this.type.name] = output.params; // if the config requires subAggs, write them to the dsl as well if (output.subAggs) { - var subDslLvl = configDsl.aggs || (configDsl.aggs = {}); + let subDslLvl = configDsl.aggs || (configDsl.aggs = {}); output.subAggs.forEach(function nestAdhocSubAggs(subAggConfig) { subDslLvl[subAggConfig.id] = subAggConfig.toDsl(); }); @@ -215,11 +215,11 @@ define(function (require) { }; AggConfig.prototype.toJSON = function () { - var self = this; - var params = self.params; + let self = this; + let params = self.params; - var outParams = _.transform(self.getAggParams(), function (out, aggParam) { - var val = params[aggParam.name]; + let outParams = _.transform(self.getAggParams(), function (out, aggParam) { + let val = params[aggParam.name]; // don't serialize undefined/null values if (val == null) return; @@ -264,7 +264,7 @@ define(function (require) { } if (!this.type) return ''; - var pre = (_.get(this.vis, 'params.mode') === 'percentage') ? 'Percentage of ' : ''; + let pre = (_.get(this.vis, 'params.mode') === 'percentage') ? 'Percentage of ' : ''; return pre += this.type.makeLabel(this); }; @@ -273,31 +273,31 @@ define(function (require) { }; AggConfig.prototype.fieldFormatter = function (contentType, defaultFormat) { - var format = this.type && this.type.getFormat(this); + let format = this.type && this.type.getFormat(this); if (format) return format.getConverterFor(contentType); return this.fieldOwnFormatter(contentType, defaultFormat); }; AggConfig.prototype.fieldOwnFormatter = function (contentType, defaultFormat) { - var field = this.field(); - var format = field && field.format; + let field = this.field(); + let format = field && field.format; if (!format) format = defaultFormat; if (!format) format = fieldFormats.getDefaultInstance('string'); return format.getConverterFor(contentType); }; AggConfig.prototype.fieldName = function () { - var field = this.field(); + let field = this.field(); return field ? field.name : ''; }; AggConfig.prototype.fieldDisplayName = function () { - var field = this.field(); + let field = this.field(); return field ? (field.displayName || this.fieldName()) : ''; }; AggConfig.prototype.fieldIsTimeField = function () { - var timeFieldName = this.vis.indexPattern.timeFieldName; + let timeFieldName = this.vis.indexPattern.timeFieldName; return timeFieldName && this.fieldName() === timeFieldName; }; diff --git a/src/ui/public/Vis/AggConfigResult.js b/src/ui/public/Vis/AggConfigResult.js index b7dac72820efa..4df97b55477c6 100644 --- a/src/ui/public/Vis/AggConfigResult.js +++ b/src/ui/public/Vis/AggConfigResult.js @@ -1,5 +1,5 @@ define(function () { - var i = 0; + let i = 0; function AggConfigResult(aggConfig, parent, value, key) { this.key = key; diff --git a/src/ui/public/Vis/AggConfigs.js b/src/ui/public/Vis/AggConfigs.js index 910c0d5400793..7a9938f942aee 100644 --- a/src/ui/public/Vis/AggConfigs.js +++ b/src/ui/public/Vis/AggConfigs.js @@ -1,14 +1,14 @@ define(function (require) { return function AggConfigsFactory(Private) { - var _ = require('lodash'); - var AggConfig = Private(require('ui/Vis/AggConfig')); - var IndexedArray = require('ui/IndexedArray'); + let _ = require('lodash'); + let AggConfig = Private(require('ui/Vis/AggConfig')); + let IndexedArray = require('ui/IndexedArray'); AggConfig.aggTypes = Private(require('ui/agg_types/index')); _.class(AggConfigs).inherits(IndexedArray); function AggConfigs(vis, configStates) { - var self = this; + let self = this; self.vis = vis; configStates = AggConfig.ensureIds(configStates || []); @@ -35,9 +35,9 @@ define(function (require) { }) .each(function (schema) { if (!self.bySchemaName[schema.name]) { - var defaults = schema.defaults.slice(0, schema.max); + let defaults = schema.defaults.slice(0, schema.max); _.each(defaults, function (defaultState) { - var state = _.defaults({ id: AggConfig.nextId(self) }, defaultState); + let state = _.defaults({ id: AggConfig.nextId(self) }, defaultState); self.push(new AggConfig(vis, state)); }); } @@ -47,7 +47,7 @@ define(function (require) { } AggConfigs.prototype.toDsl = function () { - var dslTopLvl = {}; + let dslTopLvl = {}; let dslLvlCursor; let nestedMetrics; @@ -75,8 +75,8 @@ define(function (require) { // start at the top level dslLvlCursor = dslTopLvl; } else { - var prevConfig = list[i - 1]; - var prevDsl = dslLvlCursor[prevConfig.id]; + let prevConfig = list[i - 1]; + let prevDsl = dslLvlCursor[prevConfig.id]; // advance the cursor and nest under the previous agg, or // put it on the same level if the previous agg doesn't accept @@ -84,7 +84,7 @@ define(function (require) { dslLvlCursor = prevDsl.aggs || dslLvlCursor; } - var dsl = dslLvlCursor[config.id] = config.toDsl(); + let dsl = dslLvlCursor[config.id] = config.toDsl(); let subAggs; if (config.schema.group === 'buckets' && i < list.length - 1) { @@ -121,7 +121,7 @@ define(function (require) { */ AggConfigs.prototype.getResponseAggs = function () { return this.getRequestAggs().reduce(function (responseValuesAggs, agg) { - var aggs = agg.getResponseAggs(); + let aggs = agg.getResponseAggs(); return aggs ? responseValuesAggs.concat(aggs) : responseValuesAggs; }, []); }; @@ -136,7 +136,7 @@ define(function (require) { */ AggConfigs.prototype.getResponseAggById = function (id) { id = String(id); - var reqAgg = _.find(this.getRequestAggs(), function (agg) { + let reqAgg = _.find(this.getRequestAggs(), function (agg) { return id.substr(0, String(agg.id).length) === agg.id; }); if (!reqAgg) return; diff --git a/src/ui/public/Vis/Renderbot.js b/src/ui/public/Vis/Renderbot.js index a491065889fb2..34533e3ef29c3 100644 --- a/src/ui/public/Vis/Renderbot.js +++ b/src/ui/public/Vis/Renderbot.js @@ -1,5 +1,5 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); return function RenderbotFactory(Private) { diff --git a/src/ui/public/Vis/Schemas.js b/src/ui/public/Vis/Schemas.js index d3b4159f985ee..2b53115059b4e 100644 --- a/src/ui/public/Vis/Schemas.js +++ b/src/ui/public/Vis/Schemas.js @@ -1,11 +1,11 @@ define(function (require) { return function VisTypeSchemasFactory(Private) { - var _ = require('lodash'); - var IndexedArray = require('ui/IndexedArray'); - var AggParams = Private(require('ui/agg_types/AggParams')); + let _ = require('lodash'); + let IndexedArray = require('ui/IndexedArray'); + let AggParams = Private(require('ui/agg_types/AggParams')); function Schemas(schemas) { - var self = this; + let self = this; _(schemas || []) .map(function (schema) { diff --git a/src/ui/public/Vis/Vis.js b/src/ui/public/Vis/Vis.js index e0e1d268d4b06..d7c72aaafe3d1 100644 --- a/src/ui/public/Vis/Vis.js +++ b/src/ui/public/Vis/Vis.js @@ -1,11 +1,11 @@ define(function (require) { return function VisFactory(Notifier, Private) { - var _ = require('lodash'); - var aggTypes = Private(require('ui/agg_types/index')); - var visTypes = Private(require('ui/registry/vis_types')); - var AggConfigs = Private(require('ui/Vis/AggConfigs')); + let _ = require('lodash'); + let aggTypes = Private(require('ui/agg_types/index')); + let visTypes = Private(require('ui/registry/vis_types')); + let AggConfigs = Private(require('ui/Vis/AggConfigs')); - var notify = new Notifier({ + let notify = new Notifier({ location: 'Vis' }); @@ -29,10 +29,10 @@ define(function (require) { type = visTypes.byName[type || 'histogram']; } - var schemas = type.schemas; + let schemas = type.schemas; - var aggs = _.transform(oldState, function (newConfigs, oldConfigs, oldGroupName) { - var schema = schemas.all.byName[oldGroupName]; + let aggs = _.transform(oldState, function (newConfigs, oldConfigs, oldGroupName) { + let schema = schemas.all.byName[oldGroupName]; if (!schema) { notify.log('unable to match old schema', oldGroupName, 'to a new schema'); @@ -40,12 +40,12 @@ define(function (require) { } oldConfigs.forEach(function (oldConfig) { - var agg = { + let agg = { schema: schema.name, type: oldConfig.agg, }; - var aggType = aggTypes.byName[agg.type]; + let aggType = aggTypes.byName[agg.type]; if (!aggType) { notify.log('unable to find an agg type for old confg', oldConfig); return; @@ -116,7 +116,7 @@ define(function (require) { }; Vis.prototype.hasSchemaAgg = function (schemaName, aggTypeName) { - var aggs = this.aggs.bySchemaName[schemaName] || []; + let aggs = this.aggs.bySchemaName[schemaName] || []; return aggs.some(function (agg) { if (!agg.type || !agg.type.name) return false; return agg.type.name === aggTypeName; diff --git a/src/ui/public/Vis/VisType.js b/src/ui/public/Vis/VisType.js index 0c995bd108b14..5ba1214ee6ade 100644 --- a/src/ui/public/Vis/VisType.js +++ b/src/ui/public/Vis/VisType.js @@ -1,6 +1,6 @@ define(function (require) { return function VisTypeFactory(Private) { - var VisTypeSchemas = Private(require('ui/Vis/Schemas')); + let VisTypeSchemas = Private(require('ui/Vis/Schemas')); function VisType(opts) { opts = opts || {}; diff --git a/src/ui/public/url/url.js b/src/ui/public/url/url.js index bede54413b9f7..bff12c1758f65 100644 --- a/src/ui/public/url/url.js +++ b/src/ui/public/url/url.js @@ -1,5 +1,5 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); require('ui/filters/uriescape'); require('ui/filters/rison'); @@ -8,7 +8,7 @@ define(function (require) { .service('kbnUrl', function (Private) { return Private(KbnUrlProvider); }); function KbnUrlProvider($route, $location, $rootScope, globalState, $parse, getAppState) { - var self = this; + let self = this; /** * Navigate to a url @@ -70,10 +70,10 @@ define(function (require) { return template.replace(/\{\{([^\}]+)\}\}/g, function (match, expr) { // remove filters - var key = expr.split('|')[0].trim(); + let key = expr.split('|')[0].trim(); // verify that the expression can be evaluated - var p = $parse(key)(paramObj); + let p = $parse(key)(paramObj); // if evaluation can't be made, throw if (_.isUndefined(p)) { @@ -109,7 +109,7 @@ define(function (require) { * @return {string} - the computed url */ self.getRouteUrl = function (obj, route) { - var template = obj && obj.routes && obj.routes[route]; + let template = obj && obj.routes && obj.routes[route]; if (template) return self.eval(template, obj); }; @@ -143,7 +143,7 @@ define(function (require) { let reloading; self._changeLocation = function (type, url, paramObj, replace) { - var prev = { + let prev = { path: $location.path(), search: $location.search() }; @@ -152,13 +152,13 @@ define(function (require) { $location[type](url); if (replace) $location.replace(); - var next = { + let next = { path: $location.path(), search: $location.search() }; if (self._shouldAutoReload(next, prev)) { - var appState = getAppState(); + let appState = getAppState(); if (appState) appState.destroy(); reloading = $rootScope.$on('$locationChangeSuccess', function () { @@ -174,13 +174,13 @@ define(function (require) { self._shouldAutoReload = function (next, prev) { if (reloading) return false; - var route = $route.current && $route.current.$$route; + let route = $route.current && $route.current.$$route; if (!route) return false; if (next.path !== prev.path) return false; - var reloadOnSearch = route.reloadOnSearch; - var searchSame = _.isEqual(next.search, prev.search); + let reloadOnSearch = route.reloadOnSearch; + let searchSame = _.isEqual(next.search, prev.search); return (reloadOnSearch && searchSame) || !reloadOnSearch; }; diff --git a/src/ui/public/vislib_vis_type/VislibRenderbot.js b/src/ui/public/vislib_vis_type/VislibRenderbot.js index 18ccadd614515..9133c79aef273 100644 --- a/src/ui/public/vislib_vis_type/VislibRenderbot.js +++ b/src/ui/public/vislib_vis_type/VislibRenderbot.js @@ -1,8 +1,8 @@ module.exports = function VislibRenderbotFactory(Private) { - var _ = require('lodash'); - var vislib = Private(require('ui/vislib')); - var Renderbot = Private(require('ui/Vis/Renderbot')); - var buildChartData = Private(require('ui/vislib_vis_type/buildChartData')); + let _ = require('lodash'); + let vislib = Private(require('ui/vislib')); + let Renderbot = Private(require('ui/Vis/Renderbot')); + let buildChartData = Private(require('ui/vislib_vis_type/buildChartData')); _.class(VislibRenderbot).inherits(Renderbot); function VislibRenderbot(vis, $el, uiState) { @@ -11,7 +11,7 @@ module.exports = function VislibRenderbotFactory(Private) { } VislibRenderbot.prototype._createVis = function () { - var self = this; + let self = this; if (self.vislibVis) self.destroy(); @@ -26,7 +26,7 @@ module.exports = function VislibRenderbotFactory(Private) { }; VislibRenderbot.prototype._getVislibParams = function () { - var self = this; + let self = this; return _.assign( {}, @@ -47,9 +47,9 @@ module.exports = function VislibRenderbotFactory(Private) { }; VislibRenderbot.prototype.destroy = function () { - var self = this; + let self = this; - var vislibVis = self.vislibVis; + let vislibVis = self.vislibVis; _.forOwn(self.vis.listeners, function (listener, event) { vislibVis.off(event, listener); @@ -59,10 +59,10 @@ module.exports = function VislibRenderbotFactory(Private) { }; VislibRenderbot.prototype.updateParams = function () { - var self = this; + let self = this; // get full vislib params object - var newParams = self._getVislibParams(); + let newParams = self._getVislibParams(); // if there's been a change, replace the vis if (!_.isEqual(newParams, self.vislibParams)) self._createVis(); diff --git a/src/ui/public/vislib_vis_type/VislibVisType.js b/src/ui/public/vislib_vis_type/VislibVisType.js index 91890c1591cd5..2957deddbb60d 100644 --- a/src/ui/public/vislib_vis_type/VislibVisType.js +++ b/src/ui/public/vislib_vis_type/VislibVisType.js @@ -1,12 +1,12 @@ define(function (require) { return function VislibVisTypeFactory(Private) { - var _ = require('lodash'); + let _ = require('lodash'); require('ui/vislib'); - var VisTypeSchemas = Private(require('ui/Vis/Schemas')); - var VisType = Private(require('ui/Vis/VisType')); - var pointSeries = Private(require('ui/agg_response/point_series/point_series')); - var VislibRenderbot = Private(require('ui/vislib_vis_type/VislibRenderbot')); + let VisTypeSchemas = Private(require('ui/Vis/Schemas')); + let VisType = Private(require('ui/Vis/VisType')); + let pointSeries = Private(require('ui/agg_response/point_series/point_series')); + let VislibRenderbot = Private(require('ui/vislib_vis_type/VislibRenderbot')); require('plugins/kbn_vislib_vis_types/controls/vislib_basic_options'); require('plugins/kbn_vislib_vis_types/controls/point_series_options'); diff --git a/src/ui/public/vislib_vis_type/buildChartData.js b/src/ui/public/vislib_vis_type/buildChartData.js index acc1042ff095e..22373c8632648 100644 --- a/src/ui/public/vislib_vis_type/buildChartData.js +++ b/src/ui/public/vislib_vis_type/buildChartData.js @@ -1,22 +1,22 @@ define(function (require) { return function VislibVisBuildChartData(Private) { - var aggResponse = Private(require('ui/agg_response/index')); - var Table = Private(require('ui/agg_response/tabify/_table')); + let aggResponse = Private(require('ui/agg_response/index')); + let Table = Private(require('ui/agg_response/tabify/_table')); return function (esResponse) { - var vis = this.vis; + let vis = this.vis; if (vis.isHierarchical()) { // the hierarchical converter is very self-contained (woot!) return aggResponse.hierarchical(vis, esResponse); } - var tableGroup = aggResponse.tabify(vis, esResponse, { + let tableGroup = aggResponse.tabify(vis, esResponse, { canSplit: true, asAggConfigResults: true }); - var converted = convertTableGroup(vis, tableGroup); + let converted = convertTableGroup(vis, tableGroup); if (!converted) { // mimic a row of tables that doesn't have any tables // https://github.com/elastic/kibana/blob/7bfb68cd24ed42b1b257682f93c50cd8d73e2520/src/kibana/components/vislib/components/zero_injection/inject_zeros.js#L32 @@ -29,11 +29,11 @@ define(function (require) { }; function convertTableGroup(vis, tableGroup) { - var tables = tableGroup.tables; - var firstChild = tables[0]; + let tables = tableGroup.tables; + let firstChild = tables[0]; if (firstChild instanceof Table) { - var chart = convertTable(vis, firstChild); + let chart = convertTable(vis, firstChild); // if chart is within a split, assign group title to its label if (tableGroup.$parent) { chart.label = tableGroup.title; @@ -42,13 +42,13 @@ define(function (require) { } if (!tables.length) return; - var out = {}; + let out = {}; let outList; tables.forEach(function (table) { if (!outList) { - var aggConfig = table.aggConfig; - var direction = aggConfig.params.row ? 'rows' : 'columns'; + let aggConfig = table.aggConfig; + let direction = aggConfig.params.row ? 'rows' : 'columns'; outList = out[direction] = []; } diff --git a/src/ui/public/visualize/spy.js b/src/ui/public/visualize/spy.js index 3abbebfc1bad7..fd4db67aa085e 100644 --- a/src/ui/public/visualize/spy.js +++ b/src/ui/public/visualize/spy.js @@ -2,19 +2,19 @@ define(function (require) { require('ui/modules') .get('app/visualize') .directive('visualizeSpy', function (Private, $compile) { - var $ = require('jquery'); - var _ = require('lodash'); + let $ = require('jquery'); + let _ = require('lodash'); - var spyModes = Private(require('ui/registry/spy_modes')); - var defaultMode = spyModes.inOrder[0].name; + let spyModes = Private(require('ui/registry/spy_modes')); + let defaultMode = spyModes.inOrder[0].name; return { restrict: 'E', template: require('ui/visualize/spy.html'), link: function ($scope, $el) { let currentSpy; - var $container = $el.find('.visualize-spy-container'); - var fullPageSpy = _.get($scope.spy, 'mode.fill', false); + let $container = $el.find('.visualize-spy-container'); + let fullPageSpy = _.get($scope.spy, 'mode.fill', false); $scope.modes = spyModes; $scope.spy.params = $scope.spy.params || {}; @@ -28,8 +28,8 @@ define(function (require) { }; } - var renderSpy = function (spyName) { - var newMode = $scope.modes.byName[spyName]; + let renderSpy = function (spyName) { + let newMode = $scope.modes.byName[spyName]; // clear the current value if (currentSpy) { @@ -55,7 +55,7 @@ define(function (require) { }; $scope.toggleDisplay = function () { - var modeName = _.get($scope.spy, 'mode.name'); + let modeName = _.get($scope.spy, 'mode.name'); $scope.setSpyMode(modeName ? null : defaultMode); }; @@ -72,7 +72,7 @@ define(function (require) { if ($scope.uiState) { // sync external uiState changes - var syncUIState = () => $scope.spy.mode = $scope.uiState.get('spy.mode'); + let syncUIState = () => $scope.spy.mode = $scope.uiState.get('spy.mode'); $scope.uiState.on('change', syncUIState); $scope.$on('$destroy', () => $scope.uiState.off('change', syncUIState)); } @@ -83,7 +83,7 @@ define(function (require) { 'spy.mode.fill' ], function (newVals, oldVals) { // update the ui state, but only if it really changes - var changedVals = newVals.filter((val) => !_.isUndefined(val)).length > 0; + let changedVals = newVals.filter((val) => !_.isUndefined(val)).length > 0; if (changedVals && !_.isEqual(newVals, oldVals)) { if ($scope.uiState) $scope.uiState.set('spy.mode', $scope.spy.mode); } diff --git a/src/ui/public/visualize/visualize.js b/src/ui/public/visualize/visualize.js index 1fd1dd7b527ed..522764dd21ac2 100644 --- a/src/ui/public/visualize/visualize.js +++ b/src/ui/public/visualize/visualize.js @@ -7,11 +7,11 @@ define(function (require) { require('ui/visualize/visualize.less'); require('ui/visualize/visualize_legend'); - var $ = require('jquery'); - var _ = require('lodash'); - var visTypes = Private(require('ui/registry/vis_types')); + let $ = require('jquery'); + let _ = require('lodash'); + let visTypes = Private(require('ui/registry/vis_types')); - var notify = new Notifier({ + let notify = new Notifier({ location: 'Visualize' }); @@ -28,7 +28,7 @@ define(function (require) { template: require('ui/visualize/visualize.html'), link: function ($scope, $el, attr) { let chart; // set in "vis" watcher - var minVisChartHeight = 180; + let minVisChartHeight = 180; if (_.isUndefined($scope.showSpyPanel)) { $scope.showSpyPanel = true; @@ -36,19 +36,19 @@ define(function (require) { function getter(selector) { return function () { - var $sel = $el.find(selector); + let $sel = $el.find(selector); if ($sel.size()) return $sel; }; } - var getVisEl = getter('.visualize-chart'); - var getVisContainer = getter('.vis-container'); + let getVisEl = getter('.visualize-chart'); + let getVisContainer = getter('.vis-container'); // Show no results message when isZeroHits is true and it requires search $scope.showNoResultsMessage = function () { - var requiresSearch = _.get($scope, 'vis.type.requiresSearch'); - var isZeroHits = _.get($scope,'esResp.hits.total') === 0; - var shouldShowMessage = !_.get($scope, 'vis.params.handleNoResults'); + let requiresSearch = _.get($scope, 'vis.type.requiresSearch'); + let isZeroHits = _.get($scope,'esResp.hits.total') === 0; + let shouldShowMessage = !_.get($scope, 'vis.params.handleNoResults'); return Boolean(requiresSearch && isZeroHits && shouldShowMessage); }; @@ -57,9 +57,9 @@ define(function (require) { $scope.spy = {}; $scope.spy.mode = ($scope.uiState) ? $scope.uiState.get('spy.mode', {}) : {}; - var applyClassNames = function () { - var $visEl = getVisContainer(); - var fullSpy = ($scope.spy.mode && ($scope.spy.mode.fill || $scope.fullScreenSpy)); + let applyClassNames = function () { + let $visEl = getVisContainer(); + let fullSpy = ($scope.spy.mode && ($scope.spy.mode.fill || $scope.fullScreenSpy)); $visEl.toggleClass('spy-only', Boolean(fullSpy)); @@ -72,8 +72,8 @@ define(function (require) { // we need to wait for some watchers to fire at least once // before we are "ready", this manages that - var prereq = (function () { - var fns = []; + let prereq = (function () { + let fns = []; return function register(fn) { fns.push(fn); @@ -91,14 +91,14 @@ define(function (require) { }; }()); - var loadingDelay = config.get('visualization:loadingDelay'); + let loadingDelay = config.get('visualization:loadingDelay'); $scope.loadingStyle = { '-webkit-transition-delay': loadingDelay, 'transition-delay': loadingDelay }; function shouldHaveFullSpy() { - var $visEl = getVisEl(); + let $visEl = getVisEl(); if (!$visEl) return; return ($visEl.height() < minVisChartHeight) @@ -115,7 +115,7 @@ define(function (require) { }); $scope.$watch('vis', prereq(function (vis, oldVis) { - var $visEl = getVisEl(); + let $visEl = getVisEl(); if (!$visEl) return; if (!attr.editableVis) { diff --git a/src/ui/public/visualize/visualize_legend.js b/src/ui/public/visualize/visualize_legend.js index 6ef1fd30c3168..2e9a8f3a7e068 100644 --- a/src/ui/public/visualize/visualize_legend.js +++ b/src/ui/public/visualize/visualize_legend.js @@ -1,23 +1,23 @@ define(function (require) { - var _ = require('lodash'); - var html = require('ui/visualize/visualize_legend.html'); + let _ = require('lodash'); + let html = require('ui/visualize/visualize_legend.html'); - var $ = require('jquery'); - var d3 = require('d3'); - var findByParam = require('ui/utils/find_by_param'); + let $ = require('jquery'); + let d3 = require('d3'); + let findByParam = require('ui/utils/find_by_param'); require('ui/modules').get('kibana') .directive('visualizeLegend', function (Private, getAppState) { - var Data = Private(require('ui/vislib/lib/data')); - var colorPalette = Private(require('ui/vislib/components/color/color')); - var filterBarClickHandler = Private(require('ui/filter_bar/filter_bar_click_handler')); + let Data = Private(require('ui/vislib/lib/data')); + let colorPalette = Private(require('ui/vislib/components/color/color')); + let filterBarClickHandler = Private(require('ui/filter_bar/filter_bar_click_handler')); return { restrict: 'E', template: html, link: function ($scope, $elem) { - var $state = getAppState(); - var clickHandler = filterBarClickHandler($state); + let $state = getAppState(); + let clickHandler = filterBarClickHandler($state); $scope.open = $scope.uiState.get('vis.legendOpen', true); $scope.$watch('renderbot.chartData', function (data) { @@ -27,29 +27,29 @@ define(function (require) { }); $scope.highlight = function (event) { - var el = event.currentTarget; - var handler = $scope.renderbot.vislibVis.handler; + let el = event.currentTarget; + let handler = $scope.renderbot.vislibVis.handler; if (!handler) return; handler.highlight.call(el, handler.el); }; $scope.unhighlight = function (event) { - var el = event.currentTarget; - var handler = $scope.renderbot.vislibVis.handler; + let el = event.currentTarget; + let handler = $scope.renderbot.vislibVis.handler; if (!handler) return; handler.unHighlight.call(el, handler.el); }; $scope.setColor = function (label, color) { - var colors = $scope.uiState.get('vis.colors') || {}; + let colors = $scope.uiState.get('vis.colors') || {}; colors[label] = color; $scope.uiState.set('vis.colors', colors); refresh(); }; $scope.toggleLegend = function () { - var bwcAddLegend = $scope.renderbot.vislibVis._attr.addLegend; - var bwcLegendStateDefault = bwcAddLegend == null ? true : bwcAddLegend; + let bwcAddLegend = $scope.renderbot.vislibVis._attr.addLegend; + let bwcLegendStateDefault = bwcAddLegend == null ? true : bwcAddLegend; $scope.open = !$scope.uiState.get('vis.legendOpen', bwcLegendStateDefault); $scope.uiState.set('vis.legendOpen', $scope.open); }; @@ -59,7 +59,7 @@ define(function (require) { }; $scope.canFilter = function (legendData) { - var filters = clickHandler({point: legendData}, true) || []; + let filters = clickHandler({point: legendData}, true) || []; return filters.length; }; @@ -74,7 +74,7 @@ define(function (require) { ]; function refresh() { - var vislibVis = $scope.renderbot.vislibVis; + let vislibVis = $scope.renderbot.vislibVis; if ($scope.uiState.get('vis.legendOpen') == null && vislibVis._attr.addLegend != null) { $scope.open = vislibVis._attr.addLegend; @@ -87,13 +87,13 @@ define(function (require) { // Most of these functions were moved directly from the old Legend class. Not a fan of this. function getLabels(data, type) { if (!data) return []; - var data = data.columns || data.rows || [data]; + data = data.columns || data.rows || [data]; if (type === 'pie') return Data.prototype.pieNames(data); return getSeriesLabels(data); }; function getSeriesLabels(data) { - var values = data.map(function (chart) { + let values = data.map(function (chart) { return chart.series; }) .reduce(function (a, b) { diff --git a/src/ui/public/watch_multi/watch_multi.js b/src/ui/public/watch_multi/watch_multi.js index 4bfcadfacf29e..9544597b7223e 100644 --- a/src/ui/public/watch_multi/watch_multi.js +++ b/src/ui/public/watch_multi/watch_multi.js @@ -1,5 +1,5 @@ define(function (require) { - var _ = require('lodash'); + let _ = require('lodash'); require('ui/modules').get('kibana') .config(function ($provide) { @@ -37,15 +37,15 @@ define(function (require) { if (!_.isArray(expressions)) throw new TypeError('expected an array of expressions to watch'); if (!_.isFunction(fn)) throw new TypeError('expected a function that is triggered on each watch'); - var $scope = this; - var vals = new Array(expressions.length); - var prev = new Array(expressions.length); - var fire = false; - var init = 0; - var neededInits = expressions.length; + let $scope = this; + let vals = new Array(expressions.length); + let prev = new Array(expressions.length); + let fire = false; + let init = 0; + let neededInits = expressions.length; // first, register all of the multi-watchers - var unwatchers = expressions.map(function (expr, i) { + let unwatchers = expressions.map(function (expr, i) { expr = normalizeExpression($scope, expr); if (!expr) return; @@ -62,7 +62,7 @@ define(function (require) { // then, the watcher that checks to see if any of // the other watchers triggered this cycle - var flip = false; + let flip = false; unwatchers.push($scope.$watch(function () { if (init < neededInits) return init; @@ -85,7 +85,7 @@ define(function (require) { function normalizeExpression($scope, expr) { if (!expr) return; - var norm = { + let norm = { fn: $scope.$watch, deep: false };