diff --git a/public/app/core/components/form_dropdown/form_dropdown.ts b/public/app/core/components/form_dropdown/form_dropdown.ts index 4604e1d7838..134d47e3e53 100644 --- a/public/app/core/components/form_dropdown/form_dropdown.ts +++ b/public/app/core/components/form_dropdown/form_dropdown.ts @@ -2,7 +2,7 @@ import _ from 'lodash'; import coreModule from '../../core_module'; function typeaheadMatcher(item) { - var str = this.query; + let str = this.query; if (str === '') { return true; } diff --git a/public/app/core/components/grafana_app.ts b/public/app/core/components/grafana_app.ts index b715a20e28f..16666dea1b2 100644 --- a/public/app/core/components/grafana_app.ts +++ b/public/app/core/components/grafana_app.ts @@ -50,7 +50,7 @@ export class GrafanaCtrl { $rootScope.onAppEvent = function(name, callback, localScope) { const unbind = $rootScope.$on(name, callback); - var callerScope = this; + let callerScope = this; if (callerScope.$id === 1 && !localScope) { console.log('warning rootScope onAppEvent called without localscope'); } @@ -75,7 +75,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop restrict: 'E', controller: GrafanaCtrl, link: (scope, elem) => { - var sidemenuOpen; + let sidemenuOpen; const body = $('body'); // see https://github.com/zenorocha/clipboard.js/issues/155 @@ -108,7 +108,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop // tooltip removal fix // manage page classes - var pageClass; + let pageClass; scope.$on('$routeChangeSuccess', function(evt, data) { if (pageClass) { body.removeClass(pageClass); @@ -151,10 +151,10 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop }); // handle in active view state class - var lastActivity = new Date().getTime(); - var activeUser = true; + let lastActivity = new Date().getTime(); + let activeUser = true; const inActiveTimeLimit = 60 * 1000; - var sidemenuHidden = false; + let sidemenuHidden = false; function checkForInActiveUser() { if (!activeUser) { diff --git a/public/app/core/components/layout_selector/layout_selector.ts b/public/app/core/components/layout_selector/layout_selector.ts index a28abe19251..07f1c8628e9 100644 --- a/public/app/core/components/layout_selector/layout_selector.ts +++ b/public/app/core/components/layout_selector/layout_selector.ts @@ -52,7 +52,7 @@ export function layoutMode($rootScope) { scope: {}, link: function(scope, elem) { const layout = store.get('grafana.list.layout.mode') || 'grid'; - var className = 'card-list-layout-' + layout; + let className = 'card-list-layout-' + layout; elem.addClass(className); $rootScope.onAppEvent( diff --git a/public/app/core/components/query_part/query_part_editor.ts b/public/app/core/components/query_part/query_part_editor.ts index cab7907a9a2..ef6423b8812 100644 --- a/public/app/core/components/query_part/query_part_editor.ts +++ b/public/app/core/components/query_part/query_part_editor.ts @@ -91,7 +91,7 @@ export function queryPartEditorDirective($compile, templateSrv) { const typeaheadSource = function(query, callback) { if (param.options) { - var options = param.options; + let options = param.options; if (param.type === 'int') { options = _.map(options, function(val) { return val.toString(); diff --git a/public/app/core/filters/filters.ts b/public/app/core/filters/filters.ts index 098bda58de9..745873369c0 100644 --- a/public/app/core/filters/filters.ts +++ b/public/app/core/filters/filters.ts @@ -56,7 +56,7 @@ coreModule.filter('noXml', function() { /** @ngInject */ function interpolateTemplateVars(templateSrv) { const filterFunc: any = function(text, scope) { - var scopedVars; + let scopedVars; if (scope.ctrl) { scopedVars = (scope.ctrl.panel || scope.ctrl.row).scopedVars; } else { diff --git a/public/app/core/nav_model_srv.ts b/public/app/core/nav_model_srv.ts index 8985b2c489c..300a7f0e208 100644 --- a/public/app/core/nav_model_srv.ts +++ b/public/app/core/nav_model_srv.ts @@ -38,7 +38,7 @@ export class NavModelSrv { } getNav(...args) { - var children = this.navItems; + let children = this.navItems; const nav = new NavModel(); for (const id of args) { diff --git a/public/app/core/specs/datemath.test.ts b/public/app/core/specs/datemath.test.ts index cca6eb31593..8197f01c872 100644 --- a/public/app/core/specs/datemath.test.ts +++ b/public/app/core/specs/datemath.test.ts @@ -55,8 +55,8 @@ describe('DateMath', () => { }); describe('subtraction', () => { - var now; - var anchored; + let now; + let anchored; beforeEach(() => { clock = sinon.useFakeTimers(unix); @@ -83,7 +83,7 @@ describe('DateMath', () => { }); describe('rounding', () => { - var now; + let now; beforeEach(() => { clock = sinon.useFakeTimers(unix); diff --git a/public/app/core/specs/table_model.test.ts b/public/app/core/specs/table_model.test.ts index b88bad12227..990daaaa2da 100644 --- a/public/app/core/specs/table_model.test.ts +++ b/public/app/core/specs/table_model.test.ts @@ -26,7 +26,7 @@ describe('when sorting table desc', () => { }); describe('when sorting table asc', () => { - var table; + let table; const panel = { sort: { col: 1, desc: false }, }; @@ -46,8 +46,8 @@ describe('when sorting table asc', () => { }); describe('when sorting with nulls', () => { - var table; - var values; + let table; + let values; beforeEach(() => { table = new TableModel(); diff --git a/public/app/core/specs/time_series.test.ts b/public/app/core/specs/time_series.test.ts index 605c8fd0a2e..3c0fc42be65 100644 --- a/public/app/core/specs/time_series.test.ts +++ b/public/app/core/specs/time_series.test.ts @@ -174,7 +174,7 @@ describe('TimeSeries', function() { }); describe('can detect if series contains ms precision', function() { - var fakedata; + let fakedata; beforeEach(function() { fakedata = testData; @@ -194,7 +194,7 @@ describe('TimeSeries', function() { }); describe('series overrides', function() { - var series; + let series; beforeEach(function() { series = new TimeSeries(testData); }); @@ -313,7 +313,7 @@ describe('TimeSeries', function() { }); describe('value formatter', function() { - var series; + let series; beforeEach(function() { series = new TimeSeries(testData); }); diff --git a/public/app/core/utils/css_loader.ts b/public/app/core/utils/css_loader.ts index b8aaef47085..19dd84a6087 100644 --- a/public/app/core/utils/css_loader.ts +++ b/public/app/core/utils/css_loader.ts @@ -11,7 +11,7 @@ for (let i = 0; i < links.length; i++) { const isWebkit = !!window.navigator.userAgent.match(/AppleWebKit\/([^ ;]*)/); const webkitLoadCheck = function(link, callback) { setTimeout(function() { - for (var i = 0; i < document.styleSheets.length; i++) { + for (let i = 0; i < document.styleSheets.length; i++) { const sheet = document.styleSheets[i]; if (sheet.href === link.href) { return callback(); @@ -68,7 +68,7 @@ export function fetch(load): any { } // don't reload styles loaded in the head - for (var i = 0; i < linkHrefs.length; i++) { + for (let i = 0; i < linkHrefs.length; i++) { if (load.address === linkHrefs[i]) { return ''; } diff --git a/public/app/features/admin/admin_list_users_ctrl.ts b/public/app/features/admin/admin_list_users_ctrl.ts index 083340a43eb..1b5b27a4d66 100644 --- a/public/app/features/admin/admin_list_users_ctrl.ts +++ b/public/app/features/admin/admin_list_users_ctrl.ts @@ -26,7 +26,7 @@ export default class AdminListUsersCtrl { this.showPaging = this.totalPages > 1; this.pages = []; - for (var i = 1; i < this.totalPages + 1; i++) { + for (let i = 1; i < this.totalPages + 1; i++) { this.pages.push({ page: i, current: i === this.page }); } }); diff --git a/public/app/features/annotations/annotation_tooltip.ts b/public/app/features/annotations/annotation_tooltip.ts index cadbac1bd89..9d1147aba60 100644 --- a/public/app/features/annotations/annotation_tooltip.ts +++ b/public/app/features/annotations/annotation_tooltip.ts @@ -22,12 +22,12 @@ export function annotationTooltipDirective($sanitize, dashboardSrv, contextSrv, }, link: function(scope, element) { const event = scope.event; - var title = event.title; - var text = event.text; + let title = event.title; + let text = event.text; const dashboard = dashboardSrv.getCurrent(); - var tooltip = '
'; - var titleStateClass = ''; + let tooltip = '
'; + let titleStateClass = ''; if (event.alertId) { const stateModel = alertDef.getStateDisplayModel(event.newState); @@ -42,7 +42,7 @@ export function annotationTooltipDirective($sanitize, dashboardSrv, contextSrv, title = ''; } - var header = `
`; + let header = `
`; if (event.login) { header += `
' + ' { - var ctx: any; + let ctx: any; beforeEach(() => { const navModelSrv = { getNav: () => { diff --git a/public/app/features/plugins/datasource_srv.ts b/public/app/features/plugins/datasource_srv.ts index 2b8b9476b94..b73c91ddb2b 100644 --- a/public/app/features/plugins/datasource_srv.ts +++ b/public/app/features/plugins/datasource_srv.ts @@ -136,13 +136,13 @@ export class DatasourceSrv { addDataSourceVariables(list) { // look for data source variables - for (var i = 0; i < this.templateSrv.variables.length; i++) { + for (let i = 0; i < this.templateSrv.variables.length; i++) { const variable = this.templateSrv.variables[i]; if (variable.type !== 'datasource') { continue; } - var first = variable.current.value; + let first = variable.current.value; if (first === 'default') { first = config.defaultDatasource; } diff --git a/public/app/features/plugins/ds_edit_ctrl.ts b/public/app/features/plugins/ds_edit_ctrl.ts index 280622cb29a..3c1a1860ac3 100644 --- a/public/app/features/plugins/ds_edit_ctrl.ts +++ b/public/app/features/plugins/ds_edit_ctrl.ts @@ -4,7 +4,7 @@ import config from 'app/core/config'; import { coreModule, appEvents } from 'app/core/core'; import { store } from 'app/stores/store'; -var datasourceTypes = []; +let datasourceTypes = []; const defaults = { name: '', @@ -16,7 +16,7 @@ const defaults = { secureJsonData: {}, }; -var datasourceCreated = false; +let datasourceCreated = false; export class DataSourceEditCtrl { isNew: boolean; diff --git a/public/app/features/plugins/plugin_component.ts b/public/app/features/plugins/plugin_component.ts index fe895693032..8ef20eb54d5 100644 --- a/public/app/features/plugins/plugin_component.ts +++ b/public/app/features/plugins/plugin_component.ts @@ -69,7 +69,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $ }; const panelInfo = config.panels[scope.panel.type]; - var panelCtrlPromise = Promise.resolve(UnknownPanelCtrl); + let panelCtrlPromise = Promise.resolve(UnknownPanelCtrl); if (panelInfo) { panelCtrlPromise = importPluginModule(panelInfo.module).then(function(panelModule) { return panelModule.PanelCtrl; diff --git a/public/app/features/templating/datasource_variable.ts b/public/app/features/templating/datasource_variable.ts index 366d2f89b68..258fa043e1d 100644 --- a/public/app/features/templating/datasource_variable.ts +++ b/public/app/features/templating/datasource_variable.ts @@ -43,14 +43,14 @@ export class DatasourceVariable implements Variable { updateOptions() { const options = []; const sources = this.datasourceSrv.getMetricSources({ skipVariables: true }); - var regex; + let regex; if (this.regex) { regex = this.templateSrv.replace(this.regex, null, 'regex'); regex = kbn.stringToJsRegex(regex); } - for (var i = 0; i < sources.length; i++) { + for (let i = 0; i < sources.length; i++) { const source = sources[i]; // must match on type if (source.meta.id !== this.query) { diff --git a/public/app/features/templating/query_variable.ts b/public/app/features/templating/query_variable.ts index fc51b44ca04..1b8c3697fe9 100644 --- a/public/app/features/templating/query_variable.ts +++ b/public/app/features/templating/query_variable.ts @@ -91,7 +91,7 @@ export class QueryVariable implements Variable { if (this.useTags) { return this.metricFindQuery(datasource, this.tagsQuery).then(results => { this.tags = []; - for (var i = 0; i < results.length; i++) { + for (let i = 0; i < results.length; i++) { this.tags.push(results[i].text); } return datasource; @@ -142,7 +142,7 @@ export class QueryVariable implements Variable { } metricNamesToVariableValues(metricNames) { - var regex, options, i, matches; + let regex, options, i, matches; options = []; if (this.regex) { @@ -150,9 +150,9 @@ export class QueryVariable implements Variable { } for (i = 0; i < metricNames.length; i++) { const item = metricNames[i]; - var text = item.text === undefined || item.text === null ? item.value : item.text; + let text = item.text === undefined || item.text === null ? item.value : item.text; - var value = item.value === undefined || item.value === null ? item.text : item.value; + let value = item.value === undefined || item.value === null ? item.text : item.value; if (_.isNumber(value)) { value = value.toString(); diff --git a/public/app/features/templating/template_srv.ts b/public/app/features/templating/template_srv.ts index 8e716a9f5d9..3510c729cdb 100644 --- a/public/app/features/templating/template_srv.ts +++ b/public/app/features/templating/template_srv.ts @@ -32,7 +32,7 @@ export class TemplateSrv { updateTemplateData() { this.index = {}; - for (var i = 0; i < this.variables.length; i++) { + for (let i = 0; i < this.variables.length; i++) { const variable = this.variables[i]; if (!variable.current || (!variable.current.isNone && !variable.current.value)) { @@ -48,9 +48,9 @@ export class TemplateSrv { } getAdhocFilters(datasourceName) { - var filters = []; + let filters = []; - for (var i = 0; i < this.variables.length; i++) { + for (let i = 0; i < this.variables.length; i++) { const variable = this.variables[i]; if (variable.type !== 'adhoc') { continue; @@ -171,7 +171,7 @@ export class TemplateSrv { return variable.allValue; } const values = []; - for (var i = 1; i < variable.options.length; i++) { + for (let i = 1; i < variable.options.length; i++) { values.push(variable.options[i].value); } return values; @@ -182,7 +182,7 @@ export class TemplateSrv { return target; } - var variable, systemValue, value, fmt; + let variable, systemValue, value, fmt; this.regex.lastIndex = 0; return target.replace(this.regex, (match, var1, var2, fmt2, var3, fmt3) => { @@ -227,7 +227,7 @@ export class TemplateSrv { return target; } - var variable; + let variable; this.regex.lastIndex = 0; return target.replace(this.regex, (match, var1, var2, fmt2, var3) => { diff --git a/public/app/features/templating/variable_srv.ts b/public/app/features/templating/variable_srv.ts index 55294d6fea2..22f8a909440 100644 --- a/public/app/features/templating/variable_srv.ts +++ b/public/app/features/templating/variable_srv.ts @@ -138,7 +138,7 @@ export class VariableSrv { } selectOptionsForCurrentValue(variable) { - var i, y, value, option; + let i, y, value, option; const selected: any = []; for (i = 0; i < variable.options.length; i++) { @@ -167,7 +167,7 @@ export class VariableSrv { } if (_.isArray(variable.current.value)) { - var selected = this.selectOptionsForCurrentValue(variable); + let selected = this.selectOptionsForCurrentValue(variable); // if none pick first if (selected.length === 0) { @@ -200,14 +200,14 @@ export class VariableSrv { } setOptionFromUrl(variable, urlValue) { - var promise = this.$q.when(); + let promise = this.$q.when(); if (variable.refresh) { promise = variable.updateOptions(); } return promise.then(() => { - var option = _.find(variable.options, op => { + let option = _.find(variable.options, op => { return op.text === urlValue || op.value === urlValue; }); @@ -262,7 +262,7 @@ export class VariableSrv { } setAdhocFilter(options) { - var variable = _.find(this.variables, { + let variable = _.find(this.variables, { type: 'adhoc', datasource: options.datasource, }); diff --git a/public/app/plugins/datasource/elasticsearch/specs/elastic_response.test.ts b/public/app/plugins/datasource/elasticsearch/specs/elastic_response.test.ts index ea9d10f989f..8b41e71145a 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/elastic_response.test.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/elastic_response.test.ts @@ -1,9 +1,9 @@ import { ElasticResponse } from '../elastic_response'; describe('ElasticResponse', () => { - var targets; - var response; - var result; + let targets; + let response; + let result; describe('simple query and count', () => { beforeEach(() => { @@ -48,7 +48,7 @@ describe('ElasticResponse', () => { }); describe('simple query count & avg aggregation', () => { - var result; + let result; beforeEach(() => { targets = [ @@ -97,7 +97,7 @@ describe('ElasticResponse', () => { }); describe('single group by query one metric', () => { - var result; + let result; beforeEach(() => { targets = [ @@ -149,7 +149,7 @@ describe('ElasticResponse', () => { }); describe('single group by query two metrics', () => { - var result; + let result; beforeEach(() => { targets = [ @@ -209,7 +209,7 @@ describe('ElasticResponse', () => { }); describe('with percentiles ', () => { - var result; + let result; beforeEach(() => { targets = [ @@ -257,7 +257,7 @@ describe('ElasticResponse', () => { }); describe('with extended_stats', () => { - var result; + let result; beforeEach(() => { targets = [ @@ -333,7 +333,7 @@ describe('ElasticResponse', () => { }); describe('single group by with alias pattern', () => { - var result; + let result; beforeEach(() => { targets = [ @@ -394,7 +394,7 @@ describe('ElasticResponse', () => { }); describe('histogram response', () => { - var result; + let result; beforeEach(() => { targets = [ @@ -426,7 +426,7 @@ describe('ElasticResponse', () => { }); describe('with two filters agg', () => { - var result; + let result; beforeEach(() => { targets = [ diff --git a/public/app/plugins/panel/graph/align_yaxes.ts b/public/app/plugins/panel/graph/align_yaxes.ts index ac176e7b956..f52138ea40e 100644 --- a/public/app/plugins/panel/graph/align_yaxes.ts +++ b/public/app/plugins/panel/graph/align_yaxes.ts @@ -120,7 +120,7 @@ function checkOppositeSides(yLeft, yRight) { } function getRate(yLeft, yRight) { - var rateLeft, rateRight, rate; + let rateLeft, rateRight, rate; if (checkTwoCross(yLeft, yRight)) { rateLeft = yRight.min ? yLeft.min / yRight.min : 0; rateRight = yRight.max ? yLeft.max / yRight.max : 0; diff --git a/public/app/plugins/panel/graph/data_processor.ts b/public/app/plugins/panel/graph/data_processor.ts index 2fd21459125..4ea1efe1502 100644 --- a/public/app/plugins/panel/graph/data_processor.ts +++ b/public/app/plugins/panel/graph/data_processor.ts @@ -11,7 +11,7 @@ export class DataProcessor { } // auto detect xaxis mode - var firstItem; + let firstItem; if (options.dataList && options.dataList.length > 0) { firstItem = options.dataList[0]; const autoDetectMode = this.getAutoDetectXAxisMode(firstItem); diff --git a/public/app/plugins/panel/graph/graph.ts b/public/app/plugins/panel/graph/graph.ts index 3aada709484..7dec2df1130 100755 --- a/public/app/plugins/panel/graph/graph.ts +++ b/public/app/plugins/panel/graph/graph.ts @@ -209,7 +209,7 @@ class GraphElement { // apply y-axis min/max options const yaxis = plot.getYAxes(); - for (var i = 0; i < yaxis.length; i++) { + for (let i = 0; i < yaxis.length; i++) { const axis = yaxis[i]; const panelOptions = this.panel.yaxes[i]; axis.options.max = axis.options.max !== null ? axis.options.max : panelOptions.max; @@ -231,7 +231,7 @@ class GraphElement { // let's find the smallest one so that bars are correctly rendered. // In addition, only take series which are rendered as bars for this. getMinTimeStepOfSeries(data) { - var min = Number.MAX_VALUE; + let min = Number.MAX_VALUE; for (let i = 0; i < data.length; i++) { if (!data[i].stats.timeStep) { @@ -533,7 +533,7 @@ class GraphElement { } addXTableAxis(options) { - var ticks = _.map(this.data, function(series, seriesIndex) { + let ticks = _.map(this.data, function(series, seriesIndex) { return _.map(series.datapoints, function(point, pointIndex) { const tickIndex = seriesIndex * series.datapoints.length + pointIndex; return [tickIndex + 1, point[1]]; @@ -611,8 +611,8 @@ class GraphElement { axis.max = null; } - var series, i; - var max = axis.max, + let series, i; + let max = axis.max, min = axis.min; for (i = 0; i < data.length; i++) { @@ -681,7 +681,7 @@ class GraphElement { generateTicksForLogScaleYAxis(min, max, logBase) { let ticks = []; - var nextTick; + let nextTick; for (nextTick = min; nextTick <= max; nextTick *= logBase) { ticks.push(nextTick); } diff --git a/public/app/plugins/panel/graph/legend.ts b/public/app/plugins/panel/graph/legend.ts index 48acdcb9793..ef5da3e296a 100644 --- a/public/app/plugins/panel/graph/legend.ts +++ b/public/app/plugins/panel/graph/legend.ts @@ -8,13 +8,13 @@ const module = angular.module('grafana.directives'); module.directive('graphLegend', function(popoverSrv, $timeout) { return { link: function(scope, elem) { - var firstRender = true; + let firstRender = true; const ctrl = scope.ctrl; const panel = ctrl.panel; - var data; - var seriesList; - var i; - var legendScrollbar; + let data; + let seriesList; + let i; + let legendScrollbar; const legendRightDefaultWidth = 10; const legendElem = elem.parent(); @@ -100,7 +100,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) { if (!panel.legend[statName]) { return ''; } - var html = '' + statName; + let html = '' + statName; if (panel.legend.sort === statName) { const cssClass = panel.legend.sortDesc ? 'fa fa-caret-down' : 'fa fa-caret-up'; @@ -138,9 +138,9 @@ module.directive('graphLegend', function(popoverSrv, $timeout) { elem.toggleClass('graph-legend-table', panel.legend.alignAsTable === true); - var tableHeaderElem; + let tableHeaderElem; if (panel.legend.alignAsTable) { - var header = ''; + let header = ''; header += ''; if (panel.legend.values) { header += getTableHeaderHtml('min'); @@ -184,7 +184,7 @@ module.directive('graphLegend', function(popoverSrv, $timeout) { continue; } - var html = '
3) { count = parseInt(point[2]); diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index fcbb39f8417..5146df7b513 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -100,7 +100,7 @@ export class HeatmapRenderer { setElementHeight() { try { - var height = this.ctrl.height || this.panel.height || this.ctrl.row.height; + let height = this.ctrl.height || this.panel.height || this.ctrl.row.height; if (_.isString(height)) { height = parseInt(height.replace('px', ''), 10); } diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index ba2f81c1541..6b244cd577f 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -243,7 +243,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { } const delta = value / 2; - var dec = -Math.floor(Math.log(delta) / Math.LN10); + let dec = -Math.floor(Math.log(delta) / Math.LN10); const magn = Math.pow(10, -dec); const norm = delta / magn; // norm is between 1.0 and 10.0 @@ -400,7 +400,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { const $timeout = this.$timeout; const panel = ctrl.panel; const templateSrv = this.templateSrv; - var data, linkInfo; + let data, linkInfo; const $panelContainer = elem.find('.panel-container'); elem = elem.find('.singlestat-panel'); @@ -419,24 +419,24 @@ class SingleStatCtrl extends MetricsPanelCtrl { } function getBigValueHtml() { - var body = '
'; + let body = '
'; if (panel.prefix) { - var prefix = panel.prefix; + let prefix = panel.prefix; if (panel.colorPrefix) { prefix = applyColoringThresholds(data.value, panel.prefix); } body += getSpan('singlestat-panel-prefix', panel.prefixFontSize, prefix); } - var value = data.valueFormatted; + let value = data.valueFormatted; if (panel.colorValue) { value = applyColoringThresholds(data.value, value); } body += getSpan('singlestat-panel-value', panel.valueFontSize, value); if (panel.postfix) { - var postfix = panel.postfix; + let postfix = panel.postfix; if (panel.colorPostfix) { postfix = applyColoringThresholds(data.value, panel.postfix); } @@ -449,7 +449,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { } function getValueText() { - var result = panel.prefix ? templateSrv.replace(panel.prefix, data.scopedVars) : ''; + let result = panel.prefix ? templateSrv.replace(panel.prefix, data.scopedVars) : ''; result += data.valueFormatted; result += panel.postfix ? templateSrv.replace(panel.postfix, data.scopedVars) : ''; @@ -480,7 +480,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { plotCanvas.css(plotCss); const thresholds = []; - for (var i = 0; i < data.thresholds.length; i++) { + for (let i = 0; i < data.thresholds.length; i++) { thresholds.push({ value: data.thresholds[i], color: data.colorMap[i], @@ -720,7 +720,7 @@ function getColorForValue(data, value) { return null; } - for (var i = data.thresholds.length; i > 0; i--) { + for (let i = data.thresholds.length; i > 0; i--) { if (value >= data.thresholds[i - 1]) { return data.colorMap[i]; } diff --git a/public/app/plugins/panel/table/column_options.ts b/public/app/plugins/panel/table/column_options.ts index 7c62ade2d1c..205b988f557 100644 --- a/public/app/plugins/panel/table/column_options.ts +++ b/public/app/plugins/panel/table/column_options.ts @@ -81,7 +81,7 @@ export class ColumnOptionsCtrl { const styles = this.panel.styles; const stylesCount = styles.length; - var indexToInsert = stylesCount; + let indexToInsert = stylesCount; // check if last is a catch all rule, then add it before that one if (stylesCount > 0) { diff --git a/public/app/plugins/panel/table/module.ts b/public/app/plugins/panel/table/module.ts index 79d38ef0489..68080c0558d 100644 --- a/public/app/plugins/panel/table/module.ts +++ b/public/app/plugins/panel/table/module.ts @@ -171,12 +171,12 @@ class TablePanelCtrl extends MetricsPanelCtrl { } link(scope, elem, attrs, ctrl: TablePanelCtrl) { - var data; + let data; const panel = ctrl.panel; - var pageCount = 0; + let pageCount = 0; function getTableHeight() { - var panelHeight = ctrl.height; + let panelHeight = ctrl.height; if (pageCount > 1) { panelHeight -= 26; @@ -211,7 +211,7 @@ class TablePanelCtrl extends MetricsPanelCtrl { const paginationList = $('
    '); - for (var i = startPage; i < endPage; i++) { + for (let i = startPage; i < endPage; i++) { const activeClass = i === ctrl.pageIndex ? 'active' : ''; const pageLinkElem = $( '
  • ' + (i + 1) + '
  • ' diff --git a/public/app/plugins/panel/table/renderer.ts b/public/app/plugins/panel/table/renderer.ts index 37e69ecf993..d2eb310dddd 100644 --- a/public/app/plugins/panel/table/renderer.ts +++ b/public/app/plugins/panel/table/renderer.ts @@ -47,7 +47,7 @@ export class TableRenderer { if (!style.thresholds) { return null; } - for (var i = style.thresholds.length; i > 0; i--) { + for (let i = style.thresholds.length; i > 0; i--) { if (value >= style.thresholds[i - 1]) { return style.colors[i]; } @@ -91,7 +91,7 @@ export class TableRenderer { if (_.isArray(v)) { v = v[0]; } - var date = moment(v); + let date = moment(v); if (this.isUtc) { date = date.utc(); } @@ -211,9 +211,9 @@ export class TableRenderer { value = this.formatColumnValue(columnIndex, value); const column = this.table.columns[columnIndex]; - var style = ''; + let style = ''; const cellClasses = []; - var cellClass = ''; + let cellClass = ''; if (this.colorState.cell) { style = ' style="background-color:' + this.colorState.cell + '"'; @@ -226,7 +226,7 @@ export class TableRenderer { // because of the fixed table headers css only solution // there is an issue if header cell is wider the cell // this hack adds header content to cell (not visible) - var columnHtml = ''; + let columnHtml = ''; if (addWidthHack) { columnHtml = '
    ' + this.table.columns[columnIndex].title + '
    '; } @@ -291,15 +291,15 @@ export class TableRenderer { const pageSize = this.panel.pageSize || 100; const startPos = page * pageSize; const endPos = Math.min(startPos + pageSize, this.table.rows.length); - var html = ''; + let html = ''; const rowClasses = []; let rowClass = ''; - for (var y = startPos; y < endPos; y++) { + for (let y = startPos; y < endPos; y++) { const row = this.table.rows[y]; let cellHtml = ''; let rowStyle = ''; - for (var i = 0; i < this.table.columns.length; i++) { + for (let i = 0; i < this.table.columns.length; i++) { cellHtml += this.renderCell(i, y, row[i], y === startPos); } @@ -322,10 +322,10 @@ export class TableRenderer { render_values() { const rows = []; - for (var y = 0; y < this.table.rows.length; y++) { + for (let y = 0; y < this.table.rows.length; y++) { const row = this.table.rows[y]; const new_row = []; - for (var i = 0; i < this.table.columns.length; i++) { + for (let i = 0; i < this.table.columns.length; i++) { new_row.push(this.formatColumnValue(i, row[i])); } rows.push(new_row); diff --git a/public/app/plugins/panel/table/transformers.ts b/public/app/plugins/panel/table/transformers.ts index 1b8212ce1af..428fbff05cf 100644 --- a/public/app/plugins/panel/table/transformers.ts +++ b/public/app/plugins/panel/table/transformers.ts @@ -13,9 +13,9 @@ transformers['timeseries_to_rows'] = { transform: function(data, panel, model) { model.columns = [{ text: 'Time', type: 'date' }, { text: 'Metric' }, { text: 'Value' }]; - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { const series = data[i]; - for (var y = 0; y < series.datapoints.length; y++) { + for (let y = 0; y < series.datapoints.length; y++) { const dp = series.datapoints[y]; model.rows.push([dp[1], series.target, dp[0]]); } @@ -38,7 +38,7 @@ transformers['timeseries_to_columns'] = { const series = data[i]; model.columns.push({ text: series.target }); - for (var y = 0; y < series.datapoints.length; y++) { + for (let y = 0; y < series.datapoints.length; y++) { const dp = series.datapoints[y]; const timeKey = dp[1].toString(); @@ -78,7 +78,7 @@ transformers['timeseries_aggregations'] = { ]; }, transform: function(data, panel, model) { - var i, y; + let i, y; model.columns.push({ text: 'Metric' }); for (i = 0; i < panel.columns.length; i++) { @@ -118,7 +118,7 @@ transformers['annotations'] = { return; } - for (var i = 0; i < data.annotations.length; i++) { + for (let i = 0; i < data.annotations.length; i++) { const evt = data.annotations[i]; model.rows.push([evt.time, evt.title, evt.text, evt.tags]); } @@ -270,7 +270,7 @@ transformers['json'] = { } const names: any = {}; - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { const series = data[i]; if (series.type !== 'docs') { continue; @@ -278,7 +278,7 @@ transformers['json'] = { // only look at 100 docs const maxDocs = Math.min(series.datapoints.length, 100); - for (var y = 0; y < maxDocs; y++) { + for (let y = 0; y < maxDocs; y++) { const doc = series.datapoints[y]; const flattened = flatten(doc, null); for (const propName in flattened) { @@ -292,7 +292,7 @@ transformers['json'] = { }); }, transform: function(data, panel, model) { - var i, y, z; + let i, y, z; for (const column of panel.columns) { const tableCol: any = { text: column.text };