diff --git a/public/app/core/directives/give_focus.ts b/public/app/core/directives/give_focus.ts
index 32e7205f84b..9b2cf01750e 100644
--- a/public/app/core/directives/give_focus.ts
+++ b/public/app/core/directives/give_focus.ts
@@ -14,9 +14,9 @@ coreModule.directive('giveFocus', function() {
}
setTimeout(function() {
element.focus();
- var domEl = element[0];
+ const domEl = element[0];
if (domEl.setSelectionRange) {
- var pos = element.val().length * 2;
+ const pos = element.val().length * 2;
domEl.setSelectionRange(pos, pos);
}
}, 200);
diff --git a/public/app/core/directives/misc.ts b/public/app/core/directives/misc.ts
index 034b312aa0e..07796245f2b 100644
--- a/public/app/core/directives/misc.ts
+++ b/public/app/core/directives/misc.ts
@@ -82,11 +82,11 @@ function editorOptBool($compile) {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
- var ngchange = attrs.change ? ' ng-change="' + attrs.change + '"' : '';
- var tip = attrs.tip ? ' ' + attrs.tip + '' : '';
- var showIf = attrs.showIf ? ' ng-show="' + attrs.showIf + '" ' : '';
+ const ngchange = attrs.change ? ' ng-change="' + attrs.change + '"' : '';
+ const tip = attrs.tip ? ' ' + attrs.tip + '' : '';
+ const showIf = attrs.showIf ? ' ng-show="' + attrs.showIf + '" ' : '';
- var template =
+ const template =
'' +
@@ -119,11 +119,11 @@ function editorCheckbox($compile, $interpolate) {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
- var text = $interpolate(attrs.text)(scope);
- var model = $interpolate(attrs.model)(scope);
- var ngchange = attrs.change ? ' ng-change="' + attrs.change + '"' : '';
- var tip = attrs.tip ? ' ' + attrs.tip + '' : '';
- var label = '';
+ const text = $interpolate(attrs.text)(scope);
+ const model = $interpolate(attrs.model)(scope);
+ const ngchange = attrs.change ? ' ng-change="' + attrs.change + '"' : '';
+ const tip = attrs.tip ? ' ' + attrs.tip + '' : '';
+ const label = '';
var template =
'', ''];
+ const upclass = placement === 'top' ? 'dropup' : '';
+ const ul = [''];
for (let index = 0; index < items.length; index++) {
const item = items[index];
@@ -192,11 +192,11 @@ function gfDropdown($parse, $compile, $timeout) {
restrict: 'EA',
scope: true,
link: function postLink(scope, iElement, iAttrs) {
- var getter = $parse(iAttrs.gfDropdown),
+ const getter = $parse(iAttrs.gfDropdown),
items = getter(scope);
$timeout(function() {
- var placement = iElement.data('placement');
- var dropdown = angular.element(buildTemplate(items, placement).join(''));
+ const placement = iElement.data('placement');
+ const dropdown = angular.element(buildTemplate(items, placement).join(''));
dropdown.insertAfter(iElement);
$compile(iElement.next('ul.dropdown-menu'))(scope);
});
diff --git a/public/app/core/directives/ng_model_on_blur.ts b/public/app/core/directives/ng_model_on_blur.ts
index 4385c72f1b0..2818f620dde 100644
--- a/public/app/core/directives/ng_model_on_blur.ts
+++ b/public/app/core/directives/ng_model_on_blur.ts
@@ -47,7 +47,7 @@ function validTimeSpan() {
if (viewValue.indexOf('$') === 0 || viewValue.indexOf('+$') === 0) {
return true; // allow template variable
}
- var info = rangeUtil.describeTextRange(viewValue);
+ const info = rangeUtil.describeTextRange(viewValue);
return info.invalid !== true;
};
},
diff --git a/public/app/core/directives/rebuild_on_change.ts b/public/app/core/directives/rebuild_on_change.ts
index 15907dc6c19..3a2d33dd771 100644
--- a/public/app/core/directives/rebuild_on_change.ts
+++ b/public/app/core/directives/rebuild_on_change.ts
@@ -3,7 +3,7 @@ import coreModule from '../core_module';
function getBlockNodes(nodes) {
var node = nodes[0];
- var endNode = nodes[nodes.length - 1];
+ const endNode = nodes[nodes.length - 1];
var blockNodes;
for (var i = 1; node !== endNode && (node = node.nextSibling); i++) {
diff --git a/public/app/core/directives/tags.ts b/public/app/core/directives/tags.ts
index 6b36ee7d503..7cee3ac338d 100644
--- a/public/app/core/directives/tags.ts
+++ b/public/app/core/directives/tags.ts
@@ -47,7 +47,7 @@ function bootstrapTagsinput() {
scope.model = [];
}
- var select = $('select', element);
+ const select = $('select', element);
if (attrs.placeholder) {
select.attr('placeholder', attrs.placeholder);
@@ -76,7 +76,7 @@ function bootstrapTagsinput() {
scope.onTagsUpdated();
}
}
- var tagElement = select
+ const tagElement = select
.next()
.children('span')
.filter(function() {
@@ -86,7 +86,7 @@ function bootstrapTagsinput() {
});
select.on('itemRemoved', function(event) {
- var idx = scope.model.indexOf(event.item);
+ const idx = scope.model.indexOf(event.item);
if (idx !== -1) {
scope.model.splice(idx, 1);
if (scope.onTagsUpdated) {
diff --git a/public/app/core/jquery_extended.ts b/public/app/core/jquery_extended.ts
index 7932d495ab0..f6c28c69f35 100644
--- a/public/app/core/jquery_extended.ts
+++ b/public/app/core/jquery_extended.ts
@@ -2,10 +2,10 @@ import $ from 'jquery';
import angular from 'angular';
import _ from 'lodash';
-var $win = $(window);
+const $win = $(window);
$.fn.place_tt = (function() {
- var defaults = {
+ const defaults = {
offset: 5,
};
@@ -13,9 +13,8 @@ $.fn.place_tt = (function() {
opts = $.extend(true, {}, defaults, opts);
return this.each(function() {
- var $tooltip = $(this),
- width,
- height;
+ const $tooltip = $(this);
+ let width, height;
$tooltip.addClass('grafana-tooltip');
@@ -30,7 +29,7 @@ $.fn.place_tt = (function() {
'$compile',
'$rootScope',
function($compile, $rootScope) {
- var tmpScope = $rootScope.$new(true);
+ const tmpScope = $rootScope.$new(true);
_.extend(tmpScope, opts.scopeData);
$compile($tooltip)(tmpScope);
diff --git a/public/app/core/live/live_srv.ts b/public/app/core/live/live_srv.ts
index e03e8296794..b49c38b9007 100644
--- a/public/app/core/live/live_srv.ts
+++ b/public/app/core/live/live_srv.ts
@@ -13,7 +13,7 @@ export class LiveSrv {
}
getWebSocketUrl() {
- var l = window.location;
+ const l = window.location;
return (l.protocol === 'https:' ? 'wss://' : 'ws://') + l.host + config.appSubUrl + '/ws';
}
@@ -66,7 +66,7 @@ export class LiveSrv {
return;
}
- var observer = this.observers[message.stream];
+ const observer = this.observers[message.stream];
if (!observer) {
this.removeObserver(message.stream, null);
return;
@@ -128,5 +128,5 @@ export class LiveSrv {
}
}
-var instance = new LiveSrv();
+const instance = new LiveSrv();
export { instance as liveSrv };
diff --git a/public/app/core/nav_model_srv.ts b/public/app/core/nav_model_srv.ts
index 2bed33e70da..8985b2c489c 100644
--- a/public/app/core/nav_model_srv.ts
+++ b/public/app/core/nav_model_srv.ts
@@ -39,7 +39,7 @@ export class NavModelSrv {
getNav(...args) {
var children = this.navItems;
- var nav = new NavModel();
+ const nav = new NavModel();
for (const id of args) {
// if its a number then it's the index to use for main
@@ -69,7 +69,7 @@ export class NavModelSrv {
}
getNotFoundNav() {
- var node = {
+ const node = {
text: 'Page not found',
icon: 'fa fa-fw fa-warning',
subTitle: '404 Error',
diff --git a/public/app/core/profiler.ts b/public/app/core/profiler.ts
index adf2fe67cb8..09c0d6843a8 100644
--- a/public/app/core/profiler.ts
+++ b/public/app/core/profiler.ts
@@ -64,11 +64,11 @@ export class Profiler {
console.log('Dashboard::Performance Total Watchers: ' + this.getTotalWatcherCount());
console.log('Dashboard::Performance Total ScopeCount: ' + this.scopeCount);
- var timeTaken = this.timings.lastPanelInitializedAt - this.timings.dashboardLoadStart;
+ const timeTaken = this.timings.lastPanelInitializedAt - this.timings.dashboardLoadStart;
console.log('Dashboard::Performance All panels initialized in ' + timeTaken + ' ms');
// measure digest performance
- var rootDigestStart = window.performance.now();
+ const rootDigestStart = window.performance.now();
for (var i = 0; i < 30; i++) {
this.$rootScope.$apply();
}
@@ -80,9 +80,9 @@ export class Profiler {
getTotalWatcherCount() {
var count = 0;
var scopes = 0;
- var root = $(document.getElementsByTagName('body'));
+ const root = $(document.getElementsByTagName('body'));
- var f = function(element) {
+ const f = function(element) {
if (element.data().hasOwnProperty('$scope')) {
scopes++;
angular.forEach(element.data().$scope.$$watchers, function() {
@@ -126,5 +126,5 @@ export class Profiler {
}
}
-var profiler = new Profiler();
+const profiler = new Profiler();
export { profiler };
diff --git a/public/app/core/services/context_srv.ts b/public/app/core/services/context_srv.ts
index 8959573e731..c2742c82958 100644
--- a/public/app/core/services/context_srv.ts
+++ b/public/app/core/services/context_srv.ts
@@ -59,7 +59,7 @@ export class ContextSrv {
}
}
-var contextSrv = new ContextSrv();
+const contextSrv = new ContextSrv();
export { contextSrv };
coreModule.factory('contextSrv', function() {
diff --git a/public/app/core/services/impression_srv.ts b/public/app/core/services/impression_srv.ts
index 3945c048876..bbebf37c149 100644
--- a/public/app/core/services/impression_srv.ts
+++ b/public/app/core/services/impression_srv.ts
@@ -6,7 +6,7 @@ export class ImpressionSrv {
constructor() {}
addDashboardImpression(dashboardId) {
- var impressionsKey = this.impressionKey(config);
+ const impressionsKey = this.impressionKey(config);
var impressions = [];
if (store.exists(impressionsKey)) {
impressions = JSON.parse(store.get(impressionsKey));
diff --git a/public/app/core/services/ng_react.ts b/public/app/core/services/ng_react.ts
index aeffaaa9b3b..8c262275ffa 100644
--- a/public/app/core/services/ng_react.ts
+++ b/public/app/core/services/ng_react.ts
@@ -52,9 +52,9 @@ function applied(fn, scope) {
if (fn.wrappedInApply) {
return fn;
}
- var wrapped: any = function() {
- var args = arguments;
- var phase = scope.$root.$$phase;
+ const wrapped: any = function() {
+ const args = arguments;
+ const phase = scope.$root.$$phase;
if (phase === '$apply' || phase === '$digest') {
return fn.apply(null, args);
} else {
@@ -81,8 +81,8 @@ function applied(fn, scope) {
*/
function applyFunctions(obj, scope, propsConfig?) {
return Object.keys(obj || {}).reduce(function(prev, key) {
- var value = obj[key];
- var config = (propsConfig || {})[key] || {};
+ const value = obj[key];
+ const config = (propsConfig || {})[key] || {};
/**
* wrap functions in a function that ensures they are scope.$applied
* ensures that when function is called from a React component
@@ -103,14 +103,14 @@ function applyFunctions(obj, scope, propsConfig?) {
* If watchDepth attribute is NOT reference or collection, watchDepth defaults to deep watching by value
*/
function watchProps(watchDepth, scope, watchExpressions, listener) {
- var supportsWatchCollection = angular.isFunction(scope.$watchCollection);
- var supportsWatchGroup = angular.isFunction(scope.$watchGroup);
+ const supportsWatchCollection = angular.isFunction(scope.$watchCollection);
+ const supportsWatchGroup = angular.isFunction(scope.$watchGroup);
- var watchGroupExpressions = [];
+ const watchGroupExpressions = [];
watchExpressions.forEach(function(expr) {
- var actualExpr = getPropExpression(expr);
- var exprWatchDepth = getPropWatchDepth(watchDepth, expr);
+ const actualExpr = getPropExpression(expr);
+ const exprWatchDepth = getPropWatchDepth(watchDepth, expr);
if (exprWatchDepth === 'collection' && supportsWatchCollection) {
scope.$watchCollection(actualExpr, listener);
@@ -156,7 +156,7 @@ function getPropExpression(prop) {
// find the normalized attribute knowing that React props accept any type of capitalization
function findAttribute(attrs, propName) {
- var index = Object.keys(attrs).filter(function(attr) {
+ const index = Object.keys(attrs).filter(function(attr) {
return attr.toLowerCase() === propName.toLowerCase();
})[0];
return attrs[index];
@@ -164,7 +164,7 @@ function findAttribute(attrs, propName) {
// get watch depth of prop (string or array)
function getPropWatchDepth(defaultWatch, prop) {
- var customWatchDepth = Array.isArray(prop) && angular.isObject(prop[1]) && prop[1].watchDepth;
+ const customWatchDepth = Array.isArray(prop) && angular.isObject(prop[1]) && prop[1].watchDepth;
return customWatchDepth || defaultWatch;
}
@@ -186,16 +186,16 @@ function getPropWatchDepth(defaultWatch, prop) {
// }
// }));
//
-var reactComponent = function($injector) {
+const reactComponent = function($injector) {
return {
restrict: 'E',
replace: true,
link: function(scope, elem, attrs) {
- var reactComponent = getReactComponent(attrs.name, $injector);
+ const reactComponent = getReactComponent(attrs.name, $injector);
- var renderMyComponent = function() {
- var scopeProps = scope.$eval(attrs.props);
- var props = applyFunctions(scopeProps, scope);
+ const renderMyComponent = function() {
+ const scopeProps = scope.$eval(attrs.props);
+ const props = applyFunctions(scopeProps, scope);
renderComponent(reactComponent, props, scope, elem);
};
@@ -243,24 +243,24 @@ var reactComponent = function($injector) {
//
//
//
-var reactDirective = function($injector) {
+const reactDirective = function($injector) {
return function(reactComponentName, props, conf, injectableProps) {
- var directive = {
+ const directive = {
restrict: 'E',
replace: true,
link: function(scope, elem, attrs) {
- var reactComponent = getReactComponent(reactComponentName, $injector);
+ const reactComponent = getReactComponent(reactComponentName, $injector);
// if props is not defined, fall back to use the React component's propTypes if present
props = props || Object.keys(reactComponent.propTypes || {});
// for each of the properties, get their scope value and set it to scope.props
- var renderMyComponent = function() {
- var scopeProps = {},
- config = {};
+ const renderMyComponent = function() {
+ var scopeProps = {};
+ const config = {};
props.forEach(function(prop) {
- var propName = getPropName(prop);
+ const propName = getPropName(prop);
scopeProps[propName] = scope.$eval(findAttribute(attrs, propName));
config[propName] = getPropConfig(prop);
});
@@ -272,7 +272,7 @@ var reactDirective = function($injector) {
// watch each property name and trigger an update whenever something changes,
// to update scope.props with new values
- var propExpressions = props.map(function(prop) {
+ const propExpressions = props.map(function(prop) {
return Array.isArray(prop) ? [attrs[getPropName(prop)], getPropConfig(prop)] : attrs[prop];
});
diff --git a/public/app/core/services/search_srv.ts b/public/app/core/services/search_srv.ts
index 017b2c15efc..aa5e146530b 100644
--- a/public/app/core/services/search_srv.ts
+++ b/public/app/core/services/search_srv.ts
@@ -31,7 +31,7 @@ export class SearchSrv {
}
private queryForRecentDashboards() {
- var dashIds = _.take(impressionSrv.getDashboardOpened(), 5);
+ const dashIds = _.take(impressionSrv.getDashboardOpened(), 5);
if (dashIds.length === 0) {
return Promise.resolve([]);
}
diff --git a/public/app/core/utils/datemath.ts b/public/app/core/utils/datemath.ts
index 340591e5d9c..045b5711beb 100644
--- a/public/app/core/utils/datemath.ts
+++ b/public/app/core/utils/datemath.ts
@@ -1,7 +1,7 @@
import _ from 'lodash';
import moment from 'moment';
-var units = ['y', 'M', 'w', 'd', 'h', 'm', 's'];
+const units = ['y', 'M', 'w', 'd', 'h', 'm', 's'];
export function parse(text, roundUp?, timezone?) {
if (!text) {
@@ -47,7 +47,7 @@ export function parse(text, roundUp?, timezone?) {
}
export function isValid(text) {
- var date = parse(text);
+ const date = parse(text);
if (!date) {
return false;
}
@@ -60,12 +60,12 @@ export function isValid(text) {
}
export function parseDateMath(mathString, time, roundUp?) {
- var dateTime = time;
+ const dateTime = time;
var i = 0;
- var len = mathString.length;
+ const len = mathString.length;
while (i < len) {
- var c = mathString.charAt(i++);
+ const c = mathString.charAt(i++);
var type;
var num;
var unit;
@@ -85,7 +85,7 @@ export function parseDateMath(mathString, time, roundUp?) {
} else if (mathString.length === 2) {
num = mathString.charAt(i);
} else {
- var numFrom = i;
+ const numFrom = i;
while (!isNaN(mathString.charAt(i))) {
i++;
if (i > 10) {
diff --git a/public/app/core/utils/emitter.ts b/public/app/core/utils/emitter.ts
index ae2489810a1..9a5c671f574 100644
--- a/public/app/core/utils/emitter.ts
+++ b/public/app/core/utils/emitter.ts
@@ -15,7 +15,7 @@ export class Emitter {
this.emitter.on(name, handler);
if (scope) {
- var unbind = scope.$on('$destroy', () => {
+ const unbind = scope.$on('$destroy', () => {
this.emitter.off(name, handler);
unbind();
});
diff --git a/public/app/core/utils/model_utils.ts b/public/app/core/utils/model_utils.ts
index e595ada6e13..4b319a9731e 100644
--- a/public/app/core/utils/model_utils.ts
+++ b/public/app/core/utils/model_utils.ts
@@ -1,5 +1,5 @@
export function assignModelProperties(target, source, defaults, removeDefaults?) {
- for (var key in defaults) {
+ for (const key in defaults) {
if (!defaults.hasOwnProperty(key)) {
continue;
}
diff --git a/public/app/core/utils/outline.ts b/public/app/core/utils/outline.ts
index cc06102bfdc..ebd4258c66b 100644
--- a/public/app/core/utils/outline.ts
+++ b/public/app/core/utils/outline.ts
@@ -2,10 +2,10 @@
function outlineFixer() {
const d: any = document;
- var style_element = d.createElement('STYLE');
- var dom_events = 'addEventListener' in d;
+ const style_element = d.createElement('STYLE');
+ const dom_events = 'addEventListener' in d;
- var add_event_listener = function(type, callback) {
+ const add_event_listener = function(type, callback) {
// Basic cross-browser event handling
if (dom_events) {
d.addEventListener(type, callback);
@@ -14,7 +14,7 @@ function outlineFixer() {
}
};
- var set_css = function(css_text) {
+ const set_css = function(css_text) {
// Handle setting of