tslint: more const fixes (#13035)

This commit is contained in:
Torkel Ödegaard 2018-08-26 20:19:23 +02:00 committed by GitHub
parent 314b645857
commit 35c00891e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 120 additions and 123 deletions

View File

@ -31,7 +31,7 @@ export class Settings {
loginError: any; loginError: any;
constructor(options) { constructor(options) {
var defaults = { const defaults = {
datasources: {}, datasources: {},
window_title_prefix: 'Grafana - ', window_title_prefix: 'Grafana - ',
panels: {}, panels: {},
@ -51,8 +51,8 @@ export class Settings {
} }
} }
var bootData = (<any>window).grafanaBootData || { settings: {} }; const bootData = (<any>window).grafanaBootData || { settings: {} };
var options = bootData.settings; const options = bootData.settings;
options.bootData = bootData; options.bootData = bootData;
const config = new Settings(options); const config = new Settings(options);

View File

@ -29,14 +29,14 @@ export class AdminEditUserCtrl {
return; return;
} }
var payload = { password: $scope.password }; const payload = { password: $scope.password };
backendSrv.put('/api/admin/users/' + $scope.user_id + '/password', payload).then(function() { backendSrv.put('/api/admin/users/' + $scope.user_id + '/password', payload).then(function() {
$location.path('/admin/users'); $location.path('/admin/users');
}); });
}; };
$scope.updatePermissions = function() { $scope.updatePermissions = function() {
var payload = $scope.permissions; const payload = $scope.permissions;
backendSrv.put('/api/admin/users/' + $scope.user_id + '/permissions', payload).then(function() { backendSrv.put('/api/admin/users/' + $scope.user_id + '/permissions', payload).then(function() {
$location.path('/admin/users'); $location.path('/admin/users');
@ -99,7 +99,7 @@ export class AdminEditUserCtrl {
return; return;
} }
var orgInfo = _.find($scope.orgsSearchCache, { const orgInfo = _.find($scope.orgsSearchCache, {
name: $scope.newOrg.name, name: $scope.newOrg.name,
}); });
if (!orgInfo) { if (!orgInfo) {

View File

@ -99,7 +99,7 @@ export class AlertNotificationEditCtrl {
return; return;
} }
var payload = { const payload = {
name: this.model.name, name: this.model.name,
type: this.model.type, type: this.model.type,
settings: this.model.settings, settings: this.model.settings,

View File

@ -6,12 +6,8 @@ describe('AnnotationsSrv', function() {
const $rootScope = { const $rootScope = {
onAppEvent: jest.fn(), onAppEvent: jest.fn(),
}; };
let $q;
let datasourceSrv;
let backendSrv;
let timeSrv;
const annotationsSrv = new AnnotationsSrv($rootScope, $q, datasourceSrv, backendSrv, timeSrv); const annotationsSrv = new AnnotationsSrv($rootScope, null, null, null, null);
describe('When translating the query result', () => { describe('When translating the query result', () => {
const annotationSource = { const annotationSource = {

View File

@ -55,8 +55,8 @@ export class AdHocFiltersCtrl {
} }
return this.datasourceSrv.get(this.variable.datasource).then(ds => { return this.datasourceSrv.get(this.variable.datasource).then(ds => {
var options: any = {}; const options: any = {};
var promise = null; let promise = null;
if (segment.type !== 'value') { if (segment.type !== 'value') {
promise = ds.getTagKeys(); promise = ds.getTagKeys();
@ -113,9 +113,9 @@ export class AdHocFiltersCtrl {
} }
updateVariableModel() { updateVariableModel() {
var filters = []; const filters = [];
var filterIndex = -1; let filterIndex = -1;
var hasFakes = false; let hasFakes = false;
this.segments.forEach(segment => { this.segments.forEach(segment => {
if (segment.type === 'value' && segment.fake) { if (segment.type === 'value' && segment.fake) {
@ -153,7 +153,7 @@ export class AdHocFiltersCtrl {
} }
} }
var template = ` const template = `
<div class="gf-form-inline"> <div class="gf-form-inline">
<div class="gf-form" ng-repeat="segment in ctrl.segments"> <div class="gf-form" ng-repeat="segment in ctrl.segments">
<metric-segment segment="segment" get-options="ctrl.getOptions(segment, $index)" <metric-segment segment="segment" get-options="ctrl.getOptions(segment, $index)"

View File

@ -87,7 +87,7 @@ export class ChangeTracker {
return true; return true;
} }
var meta = this.current.meta; const meta = this.current.meta;
return !meta.canSave || meta.fromScript || meta.fromFile; return !meta.canSave || meta.fromScript || meta.fromFile;
} }
@ -141,15 +141,15 @@ export class ChangeTracker {
const current = this.cleanDashboardFromIgnoredChanges(this.current.getSaveModelClone()); const current = this.cleanDashboardFromIgnoredChanges(this.current.getSaveModelClone());
const original = this.cleanDashboardFromIgnoredChanges(this.original); const original = this.cleanDashboardFromIgnoredChanges(this.original);
var currentTimepicker = _.find(current.nav, { type: 'timepicker' }); const currentTimepicker = _.find(current.nav, { type: 'timepicker' });
var originalTimepicker = _.find(original.nav, { type: 'timepicker' }); const originalTimepicker = _.find(original.nav, { type: 'timepicker' });
if (currentTimepicker && originalTimepicker) { if (currentTimepicker && originalTimepicker) {
currentTimepicker.now = originalTimepicker.now; currentTimepicker.now = originalTimepicker.now;
} }
var currentJson = angular.toJson(current, true); const currentJson = angular.toJson(current, true);
var originalJson = angular.toJson(original, true); const originalJson = angular.toJson(original, true);
return currentJson !== originalJson; return currentJson !== originalJson;
} }
@ -167,8 +167,8 @@ export class ChangeTracker {
} }
saveChanges() { saveChanges() {
var self = this; const self = this;
var cancel = this.$rootScope.$on('dashboard-saved', () => { const cancel = this.$rootScope.$on('dashboard-saved', () => {
cancel(); cancel();
this.$timeout(() => { this.$timeout(() => {
self.gotoNext(); self.gotoNext();
@ -179,8 +179,8 @@ export class ChangeTracker {
} }
gotoNext() { gotoNext() {
var baseLen = this.$location.absUrl().length - this.$location.url().length; const baseLen = this.$location.absUrl().length - this.$location.url().length;
var nextUrl = this.next.substring(baseLen); const nextUrl = this.next.substring(baseLen);
this.$location.url(nextUrl); this.$location.url(nextUrl);
} }
} }

View File

@ -52,7 +52,7 @@ export class DashboardImportCtrl {
if (this.dash.__inputs) { if (this.dash.__inputs) {
for (const input of this.dash.__inputs) { for (const input of this.dash.__inputs) {
var inputModel = { const inputModel = {
name: input.name, name: input.name,
label: input.label, label: input.label,
info: input.description, info: input.description,
@ -78,7 +78,7 @@ export class DashboardImportCtrl {
} }
setDatasourceOptions(input, inputModel) { setDatasourceOptions(input, inputModel) {
var sources = _.filter(config.datasources, val => { const sources = _.filter(config.datasources, val => {
return val.type === input.pluginId; return val.type === input.pluginId;
}); });
@ -162,7 +162,7 @@ export class DashboardImportCtrl {
} }
saveDashboard() { saveDashboard() {
var inputs = this.inputs.map(input => { const inputs = this.inputs.map(input => {
return { return {
name: input.name, name: input.name,
type: input.type, type: input.type,
@ -186,7 +186,7 @@ export class DashboardImportCtrl {
loadJsonText() { loadJsonText() {
try { try {
this.parseError = ''; this.parseError = '';
var dash = JSON.parse(this.jsonText); const dash = JSON.parse(this.jsonText);
this.onUpload(dash); this.onUpload(dash);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
@ -198,8 +198,8 @@ export class DashboardImportCtrl {
checkGnetDashboard() { checkGnetDashboard() {
this.gnetError = ''; this.gnetError = '';
var match = /(^\d+$)|dashboards\/(\d+)/.exec(this.gnetUrl); const match = /(^\d+$)|dashboards\/(\d+)/.exec(this.gnetUrl);
var dashboardId; let dashboardId;
if (match && match[1]) { if (match && match[1]) {
dashboardId = match[1]; dashboardId = match[1];

View File

@ -97,7 +97,7 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
const dashboard = panelContainer.getDashboard(); const dashboard = panelContainer.getDashboard();
const { gridPos } = this.props.panel; const { gridPos } = this.props.panel;
var newPanel: any = { const newPanel: any = {
type: panelPluginInfo.id, type: panelPluginInfo.id,
title: 'Panel Title', title: 'Panel Title',
gridPos: { x: gridPos.x, y: gridPos.y, w: gridPos.w, h: gridPos.h }, gridPos: { x: gridPos.x, y: gridPos.y, w: gridPos.w, h: gridPos.h },

View File

@ -21,14 +21,14 @@ export class DashExportCtrl {
} }
save() { save() {
var blob = new Blob([angular.toJson(this.dash, true)], { const blob = new Blob([angular.toJson(this.dash, true)], {
type: 'application/json;charset=utf-8', type: 'application/json;charset=utf-8',
}); });
saveAs(blob, this.dash.title + '-' + new Date().getTime() + '.json'); saveAs(blob, this.dash.title + '-' + new Date().getTime() + '.json');
} }
saveJson() { saveJson() {
var clone = this.dash; const clone = this.dash;
const editScope = this.$rootScope.$new(); const editScope = this.$rootScope.$new();
editScope.object = clone; editScope.object = clone;
editScope.enableCopy = true; editScope.enableCopy = true;

View File

@ -12,23 +12,23 @@ export class DashboardExporter {
// this is pretty hacky and needs to be changed // this is pretty hacky and needs to be changed
dashboard.cleanUpRepeats(); dashboard.cleanUpRepeats();
var saveModel = dashboard.getSaveModelClone(); const saveModel = dashboard.getSaveModelClone();
saveModel.id = null; saveModel.id = null;
// undo repeat cleanup // undo repeat cleanup
dashboard.processRepeats(); dashboard.processRepeats();
var inputs = []; const inputs = [];
var requires = {}; const requires = {};
var datasources = {}; const datasources = {};
var promises = []; const promises = [];
var variableLookup: any = {}; const variableLookup: any = {};
for (const variable of saveModel.templating.list) { for (const variable of saveModel.templating.list) {
variableLookup[variable.name] = variable; variableLookup[variable.name] = variable;
} }
var templateizeDatasourceUsage = obj => { const templateizeDatasourceUsage = obj => {
// ignore data source properties that contain a variable // ignore data source properties that contain a variable
if (obj.datasource && obj.datasource.indexOf('$') === 0) { if (obj.datasource && obj.datasource.indexOf('$') === 0) {
if (variableLookup[obj.datasource.substring(1)]) { if (variableLookup[obj.datasource.substring(1)]) {
@ -42,7 +42,7 @@ export class DashboardExporter {
return; return;
} }
var refName = 'DS_' + ds.name.replace(' ', '_').toUpperCase(); const refName = 'DS_' + ds.name.replace(' ', '_').toUpperCase();
datasources[refName] = { datasources[refName] = {
name: refName, name: refName,
label: ds.name, label: ds.name,
@ -76,7 +76,7 @@ export class DashboardExporter {
} }
} }
var panelDef = config.panels[panel.type]; const panelDef = config.panels[panel.type];
if (panelDef) { if (panelDef) {
requires['panel' + panelDef.id] = { requires['panel' + panelDef.id] = {
type: 'panel', type: 'panel',
@ -131,7 +131,7 @@ export class DashboardExporter {
// templatize constants // templatize constants
for (const variable of saveModel.templating.list) { for (const variable of saveModel.templating.list) {
if (variable.type === 'constant') { if (variable.type === 'constant') {
var refName = 'VAR_' + variable.name.replace(' ', '_').toUpperCase(); const refName = 'VAR_' + variable.name.replace(' ', '_').toUpperCase();
inputs.push({ inputs.push({
name: refName, name: refName,
type: 'constant', type: 'constant',
@ -149,7 +149,7 @@ export class DashboardExporter {
} }
// make inputs and requires a top thing // make inputs and requires a top thing
var newObj = {}; const newObj = {};
newObj['__inputs'] = inputs; newObj['__inputs'] = inputs;
newObj['__requires'] = _.sortBy(requires, ['id']); newObj['__requires'] = _.sortBy(requires, ['id']);

View File

@ -1,6 +1,6 @@
import { coreModule } from 'app/core/core'; import { coreModule } from 'app/core/core';
var template = ` const template = `
<div class="gf-form-select-wrapper max-width-18"> <div class="gf-form-select-wrapper max-width-18">
<select class="gf-form-input" ng-model="panel.repeat" ng-options="f.value as f.text for f in variables" ng-change="optionChanged()"> <select class="gf-form-input" ng-model="panel.repeat" ng-options="f.value as f.text for f in variables" ng-change="optionChanged()">
<option value=""></option> <option value=""></option>

View File

@ -156,7 +156,7 @@ export class SettingsCtrl {
} }
hideSettings() { hideSettings() {
var urlParams = this.$location.search(); const urlParams = this.$location.search();
delete urlParams.editview; delete urlParams.editview;
setTimeout(() => { setTimeout(() => {
this.$rootScope.$apply(() => { this.$rootScope.$apply(() => {

View File

@ -12,7 +12,7 @@ jest.mock('app/core/services/context_srv', () => ({
describe('ChangeTracker', () => { describe('ChangeTracker', () => {
let rootScope; let rootScope;
let location; let location;
let timeout; const timeout = () => {};
let tracker: ChangeTracker; let tracker: ChangeTracker;
let dash; let dash;
let scope; let scope;

View File

@ -2,7 +2,7 @@ import { DashboardImportCtrl } from '../dashboard_import_ctrl';
import config from '../../../core/config'; import config from '../../../core/config';
describe('DashboardImportCtrl', function() { describe('DashboardImportCtrl', function() {
var ctx: any = {}; const ctx: any = {};
let navModelSrv; let navModelSrv;
let backendSrv; let backendSrv;

View File

@ -8,10 +8,10 @@ jest.mock('app/core/services/context_srv', () => ({}));
describe('DashboardModel', function() { describe('DashboardModel', function() {
describe('when creating dashboard with old schema', function() { describe('when creating dashboard with old schema', function() {
var model; let model;
var graph; let graph;
var singlestat; let singlestat;
var table; let table;
beforeEach(function() { beforeEach(function() {
model = new DashboardModel({ model = new DashboardModel({
@ -384,7 +384,8 @@ describe('DashboardModel', function() {
function createRow(options, panelDescriptions: any[]) { function createRow(options, panelDescriptions: any[]) {
const PANEL_HEIGHT_STEP = GRID_CELL_HEIGHT + GRID_CELL_VMARGIN; const PANEL_HEIGHT_STEP = GRID_CELL_HEIGHT + GRID_CELL_VMARGIN;
let { collapse, height, showTitle, title, repeat, repeatIteration } = options; const { collapse, showTitle, title, repeat, repeatIteration } = options;
let { height } = options;
height = height * PANEL_HEIGHT_STEP; height = height * PANEL_HEIGHT_STEP;
const panels = []; const panels = [];
_.each(panelDescriptions, panelDesc => { _.each(panelDescriptions, panelDesc => {

View File

@ -70,7 +70,7 @@ export class TimeSrv {
} }
if (!isNaN(value)) { if (!isNaN(value)) {
var epoch = parseInt(value); const epoch = parseInt(value);
return moment.utc(epoch); return moment.utc(epoch);
} }
@ -78,7 +78,7 @@ export class TimeSrv {
} }
private initTimeFromUrl() { private initTimeFromUrl() {
var params = this.$location.search(); const params = this.$location.search();
if (params.from) { if (params.from) {
this.time.from = this.parseUrlParam(params.from) || this.time.from; this.time.from = this.parseUrlParam(params.from) || this.time.from;
} }
@ -91,8 +91,8 @@ export class TimeSrv {
} }
private routeUpdated() { private routeUpdated() {
var params = this.$location.search(); const params = this.$location.search();
var urlRange = this.timeRangeForUrl(); const urlRange = this.timeRangeForUrl();
// check if url has time range // check if url has time range
if (params.from && params.to) { if (params.from && params.to) {
// is it different from what our current time range? // is it different from what our current time range?
@ -114,7 +114,7 @@ export class TimeSrv {
this.dashboard.refresh = interval; this.dashboard.refresh = interval;
this.cancelNextRefresh(); this.cancelNextRefresh();
if (interval) { if (interval) {
var intervalMs = kbn.interval_to_ms(interval); const intervalMs = kbn.interval_to_ms(interval);
this.refreshTimer = this.timer.register( this.refreshTimer = this.timer.register(
this.$timeout(() => { this.$timeout(() => {
@ -125,7 +125,7 @@ export class TimeSrv {
} }
// update url // update url
var params = this.$location.search(); const params = this.$location.search();
if (interval) { if (interval) {
params.refresh = interval; params.refresh = interval;
this.$location.search(params); this.$location.search(params);
@ -171,8 +171,8 @@ export class TimeSrv {
// update url // update url
if (fromRouteUpdate !== true) { if (fromRouteUpdate !== true) {
var urlRange = this.timeRangeForUrl(); const urlRange = this.timeRangeForUrl();
var urlParams = this.$location.search(); const urlParams = this.$location.search();
urlParams.from = urlRange.from; urlParams.from = urlRange.from;
urlParams.to = urlRange.to; urlParams.to = urlRange.to;
this.$location.search(urlParams); this.$location.search(urlParams);
@ -183,7 +183,7 @@ export class TimeSrv {
} }
timeRangeForUrl() { timeRangeForUrl() {
var range = this.timeRange().raw; const range = this.timeRange().raw;
if (moment.isMoment(range.from)) { if (moment.isMoment(range.from)) {
range.from = range.from.valueOf().toString(); range.from = range.from.valueOf().toString();
@ -197,12 +197,12 @@ export class TimeSrv {
timeRange() { timeRange() {
// make copies if they are moment (do not want to return out internal moment, because they are mutable!) // make copies if they are moment (do not want to return out internal moment, because they are mutable!)
var raw = { const raw = {
from: moment.isMoment(this.time.from) ? moment(this.time.from) : this.time.from, from: moment.isMoment(this.time.from) ? moment(this.time.from) : this.time.from,
to: moment.isMoment(this.time.to) ? moment(this.time.to) : this.time.to, to: moment.isMoment(this.time.to) ? moment(this.time.to) : this.time.to,
}; };
var timezone = this.dashboard && this.dashboard.getTimezone(); const timezone = this.dashboard && this.dashboard.getTimezone();
return { return {
from: dateMath.parse(raw.from, false, timezone), from: dateMath.parse(raw.from, false, timezone),
@ -212,16 +212,16 @@ export class TimeSrv {
} }
zoomOut(e, factor) { zoomOut(e, factor) {
var range = this.timeRange(); const range = this.timeRange();
var timespan = range.to.valueOf() - range.from.valueOf(); const timespan = range.to.valueOf() - range.from.valueOf();
var center = range.to.valueOf() - timespan / 2; const center = range.to.valueOf() - timespan / 2;
var to = center + timespan * factor / 2; let to = center + timespan * factor / 2;
var from = center - timespan * factor / 2; let from = center - timespan * factor / 2;
if (to > Date.now() && range.to <= Date.now()) { if (to > Date.now() && range.to <= Date.now()) {
var offset = to - Date.now(); const offset = to - Date.now();
from = from - offset; from = from - offset;
to = Date.now(); to = Date.now();
} }

View File

@ -6,9 +6,9 @@ export function inputDateDirective() {
restrict: 'A', restrict: 'A',
require: 'ngModel', require: 'ngModel',
link: function($scope, $elem, attrs, ngModel) { link: function($scope, $elem, attrs, ngModel) {
var format = 'YYYY-MM-DD HH:mm:ss'; const format = 'YYYY-MM-DD HH:mm:ss';
var fromUser = function(text) { const fromUser = function(text) {
if (text.indexOf('now') !== -1) { if (text.indexOf('now') !== -1) {
if (!dateMath.isValid(text)) { if (!dateMath.isValid(text)) {
ngModel.$setValidity('error', false); ngModel.$setValidity('error', false);
@ -34,7 +34,7 @@ export function inputDateDirective() {
return parsed; return parsed;
}; };
var toUser = function(currentValue) { const toUser = function(currentValue) {
if (moment.isMoment(currentValue)) { if (moment.isMoment(currentValue)) {
return currentValue.format(format); return currentValue.format(format);
} else { } else {

View File

@ -43,8 +43,8 @@ export class TimePickerCtrl {
} }
onRefresh() { onRefresh() {
var time = angular.copy(this.timeSrv.timeRange()); const time = angular.copy(this.timeSrv.timeRange());
var timeRaw = angular.copy(time.raw); const timeRaw = angular.copy(time.raw);
if (!this.dashboard.isTimezoneUtc()) { if (!this.dashboard.isTimezoneUtc()) {
time.from.local(); time.from.local();
@ -72,9 +72,9 @@ export class TimePickerCtrl {
} }
move(direction) { move(direction) {
var range = this.timeSrv.timeRange(); const range = this.timeSrv.timeRange();
var timespan = (range.to.valueOf() - range.from.valueOf()) / 2; const timespan = (range.to.valueOf() - range.from.valueOf()) / 2;
var to, from; var to, from;
if (direction === -1) { if (direction === -1) {
to = range.to.valueOf() - timespan; to = range.to.valueOf() - timespan;
@ -142,7 +142,7 @@ export class TimePickerCtrl {
} }
setRelativeFilter(timespan) { setRelativeFilter(timespan) {
var range = { from: timespan.from, to: timespan.to }; const range = { from: timespan.from, to: timespan.to };
if (this.panel.nowDelay && range.to === 'now') { if (this.panel.nowDelay && range.to === 'now') {
range.to = 'now-' + this.panel.nowDelay; range.to = 'now-' + this.panel.nowDelay;

View File

@ -1,6 +1,6 @@
import coreModule from 'app/core/core_module'; import coreModule from 'app/core/core_module';
var template = ` const template = `
<input type="file" id="dashupload" name="dashupload" class="hide"/> <input type="file" id="dashupload" name="dashupload" class="hide"/>
<label class="btn btn-success" for="dashupload"> <label class="btn btn-success" for="dashupload">
<i class="fa fa-upload"></i> <i class="fa fa-upload"></i>
@ -18,8 +18,8 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
}, },
link: function(scope) { link: function(scope) {
function file_selected(evt) { function file_selected(evt) {
var files = evt.target.files; // FileList object const files = evt.target.files; // FileList object
var readerOnload = function() { const readerOnload = function() {
return function(e) { return function(e) {
var dash; var dash;
try { try {
@ -37,13 +37,13 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
}; };
for (var i = 0, f; (f = files[i]); i++) { for (var i = 0, f; (f = files[i]); i++) {
var reader = new FileReader(); const reader = new FileReader();
reader.onload = readerOnload(); reader.onload = readerOnload();
reader.readAsText(f); reader.readAsText(f);
} }
} }
var wnd: any = window; const wnd: any = window;
// Check for the various File API support. // Check for the various File API support.
if (wnd.File && wnd.FileReader && wnd.FileList && wnd.Blob) { if (wnd.File && wnd.FileReader && wnd.FileList && wnd.Blob) {
// Something // Something

View File

@ -24,7 +24,7 @@ export class OrgApiKeysCtrl {
$scope.addToken = function() { $scope.addToken = function() {
backendSrv.post('/api/auth/keys', $scope.token).then(function(result) { backendSrv.post('/api/auth/keys', $scope.token).then(function(result) {
var modalScope = $scope.$new(true); const modalScope = $scope.$new(true);
modalScope.key = result.key; modalScope.key = result.key;
modalScope.rootPath = window.location.origin + $scope.$root.appSubUrl; modalScope.rootPath = window.location.origin + $scope.$root.appSubUrl;

View File

@ -20,7 +20,7 @@ export class OrgDetailsCtrl {
if (!$scope.orgForm.$valid) { if (!$scope.orgForm.$valid) {
return; return;
} }
var data = { name: $scope.org.name }; const data = { name: $scope.org.name };
backendSrv.put('/api/org', data).then($scope.getOrgInfo); backendSrv.put('/api/org', data).then($scope.getOrgInfo);
}; };

View File

@ -29,7 +29,7 @@ export class PrefsControlCtrl {
return; return;
} }
var cmd = { const cmd = {
theme: this.prefs.theme, theme: this.prefs.theme,
timezone: this.prefs.timezone, timezone: this.prefs.timezone,
homeDashboardId: this.prefs.homeDashboardId, homeDashboardId: this.prefs.homeDashboardId,
@ -41,7 +41,7 @@ export class PrefsControlCtrl {
} }
} }
var template = ` const template = `
<form name="ctrl.prefsForm" class="section gf-form-group"> <form name="ctrl.prefsForm" class="section gf-form-group">
<h3 class="page-heading">Preferences</h3> <h3 class="page-heading">Preferences</h3>

View File

@ -3,9 +3,9 @@ import $ from 'jquery';
import Drop from 'tether-drop'; import Drop from 'tether-drop';
import baron from 'baron'; import baron from 'baron';
var module = angular.module('grafana.directives'); const module = angular.module('grafana.directives');
var panelTemplate = ` const panelTemplate = `
<div class="panel-container"> <div class="panel-container">
<div class="panel-header" ng-class="{'grid-drag-handle': !ctrl.fullscreen}"> <div class="panel-header" ng-class="{'grid-drag-handle': !ctrl.fullscreen}">
<span class="panel-info-corner"> <span class="panel-info-corner">
@ -61,19 +61,19 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
transclude: true, transclude: true,
scope: { ctrl: '=' }, scope: { ctrl: '=' },
link: function(scope, elem) { link: function(scope, elem) {
var panelContainer = elem.find('.panel-container'); const panelContainer = elem.find('.panel-container');
var panelContent = elem.find('.panel-content'); const panelContent = elem.find('.panel-content');
var cornerInfoElem = elem.find('.panel-info-corner'); const cornerInfoElem = elem.find('.panel-info-corner');
var ctrl = scope.ctrl; const ctrl = scope.ctrl;
var infoDrop; let infoDrop;
var panelScrollbar; let panelScrollbar;
// the reason for handling these classes this way is for performance // the reason for handling these classes this way is for performance
// limit the watchers on panels etc // limit the watchers on panels etc
var transparentLastState = false; let transparentLastState = false;
var lastHasAlertRule = false; let lastHasAlertRule = false;
var lastAlertState; let lastAlertState;
var hasAlertRule; let hasAlertRule;
function mouseEnter() { function mouseEnter() {
panelContainer.toggleClass('panel-hover-highlight', true); panelContainer.toggleClass('panel-hover-highlight', true);
@ -174,7 +174,7 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
}); });
function updatePanelCornerInfo() { function updatePanelCornerInfo() {
var cornerMode = ctrl.getInfoMode(); const cornerMode = ctrl.getInfoMode();
cornerInfoElem[0].className = 'panel-info-corner panel-info-corner--' + cornerMode; cornerInfoElem[0].className = 'panel-info-corner panel-info-corner--' + cornerMode;
if (cornerMode) { if (cornerMode) {

View File

@ -1,6 +1,6 @@
import angular from 'angular'; import angular from 'angular';
var directiveModule = angular.module('grafana.directives'); const directiveModule = angular.module('grafana.directives');
/** @ngInject */ /** @ngInject */
function panelEditorTab(dynamicDirectiveSrv) { function panelEditorTab(dynamicDirectiveSrv) {
@ -11,13 +11,13 @@ function panelEditorTab(dynamicDirectiveSrv) {
index: '=', index: '=',
}, },
directive: scope => { directive: scope => {
var pluginId = scope.ctrl.pluginId; const pluginId = scope.ctrl.pluginId;
var tabIndex = scope.index; const tabIndex = scope.index;
// create a wrapper for directiveFn // create a wrapper for directiveFn
// required for metrics tab directive // required for metrics tab directive
// that is the same for many panels but // that is the same for many panels but
// given different names in this function // given different names in this function
var fn = () => scope.editorTab.directiveFn(); const fn = () => scope.editorTab.directiveFn();
return Promise.resolve({ return Promise.resolve({
name: `panel-editor-tab-${pluginId}${tabIndex}`, name: `panel-editor-tab-${pluginId}${tabIndex}`,

View File

@ -1,7 +1,7 @@
import $ from 'jquery'; import $ from 'jquery';
import { coreModule } from 'app/core/core'; import { coreModule } from 'app/core/core';
var template = ` const template = `
<span class="panel-title"> <span class="panel-title">
<span class="icon-gf panel-alert-icon"></span> <span class="icon-gf panel-alert-icon"></span>
<span class="panel-title-text">{{ctrl.panel.title | interpolateTemplateVars:this}}</span> <span class="panel-title-text">{{ctrl.panel.title | interpolateTemplateVars:this}}</span>

View File

@ -1,6 +1,6 @@
import angular from 'angular'; import angular from 'angular';
var module = angular.module('grafana.directives'); const module = angular.module('grafana.directives');
export class QueryRowCtrl { export class QueryRowCtrl {
collapsedText: string; collapsedText: string;
@ -56,7 +56,7 @@ export class QueryRowCtrl {
try { try {
this.collapsedText = this.queryCtrl.getCollapsedText(); this.collapsedText = this.queryCtrl.getCollapsedText();
} catch (e) { } catch (e) {
var err = e.message || e.toString(); const err = e.message || e.toString();
this.collapsedText = 'Error: ' + err; this.collapsedText = 'Error: ' + err;
} }
} }
@ -78,7 +78,7 @@ export class QueryRowCtrl {
} }
duplicateQuery() { duplicateQuery() {
var clone = angular.copy(this.target); const clone = angular.copy(this.target);
this.panelCtrl.addQuery(clone); this.panelCtrl.addQuery(clone);
} }

View File

@ -172,7 +172,7 @@ export function queryTroubleshooter() {
}, },
link: function(scope, elem, attrs, ctrl) { link: function(scope, elem, attrs, ctrl) {
ctrl.renderJsonExplorer = function(data) { ctrl.renderJsonExplorer = function(data) {
var jsonElem = elem.find('.query-troubleshooter-json'); const jsonElem = elem.find('.query-troubleshooter-json');
ctrl.jsonExplorer = new JsonExplorer(data, 3, { ctrl.jsonExplorer = new JsonExplorer(data, 3, {
animateOpen: true, animateOpen: true,

View File

@ -5,13 +5,13 @@ import appEvents from 'app/core/app_events';
export class SoloPanelCtrl { export class SoloPanelCtrl {
/** @ngInject */ /** @ngInject */
constructor($scope, $routeParams, $location, dashboardLoaderSrv, contextSrv, backendSrv) { constructor($scope, $routeParams, $location, dashboardLoaderSrv, contextSrv, backendSrv) {
var panelId; let panelId;
$scope.init = function() { $scope.init = function() {
contextSrv.sidemenu = false; contextSrv.sidemenu = false;
appEvents.emit('toggle-sidemenu-hidden'); appEvents.emit('toggle-sidemenu-hidden');
var params = $location.search(); const params = $location.search();
panelId = parseInt(params.panelId); panelId = parseInt(params.panelId);
$scope.onAppEvent('dashboard-initialized', $scope.initPanelScope); $scope.onAppEvent('dashboard-initialized', $scope.initPanelScope);

View File

@ -22,7 +22,7 @@ export class PlaylistEditCtrl {
this.isNew = $route.current.params.id; this.isNew = $route.current.params.id;
if ($route.current.params.id) { if ($route.current.params.id) {
var playlistId = $route.current.params.id; const playlistId = $route.current.params.id;
backendSrv.get('/api/playlists/' + playlistId).then(result => { backendSrv.get('/api/playlists/' + playlistId).then(result => {
this.playlist = result; this.playlist = result;
@ -69,7 +69,7 @@ export class PlaylistEditCtrl {
} }
addTagPlaylistItem(tag) { addTagPlaylistItem(tag) {
var playlistItem: any = { const playlistItem: any = {
value: tag.term, value: tag.term,
type: 'dashboard_by_tag', type: 'dashboard_by_tag',
order: this.playlistItems.length + 1, order: this.playlistItems.length + 1,
@ -124,8 +124,8 @@ export class PlaylistEditCtrl {
} }
movePlaylistItem(playlistItem, offset) { movePlaylistItem(playlistItem, offset) {
var currentPosition = this.playlistItems.indexOf(playlistItem); const currentPosition = this.playlistItems.indexOf(playlistItem);
var newPosition = currentPosition + offset; const newPosition = currentPosition + offset;
if (newPosition >= 0 && newPosition < this.playlistItems.length) { if (newPosition >= 0 && newPosition < this.playlistItems.length) {
this.playlistItems.splice(currentPosition, 1); this.playlistItems.splice(currentPosition, 1);

View File

@ -19,7 +19,7 @@ export class PlaylistSearchCtrl {
searchDashboards() { searchDashboards() {
this.tagsMode = false; this.tagsMode = false;
var prom: any = {}; const prom: any = {};
prom.promise = this.backendSrv.search(this.query).then(result => { prom.promise = this.backendSrv.search(this.query).then(result => {
return { return {
@ -50,7 +50,7 @@ export class PlaylistSearchCtrl {
} }
getTags() { getTags() {
var prom: any = {}; const prom: any = {};
prom.promise = this.backendSrv.get('/api/dashboards/tags').then(result => { prom.promise = this.backendSrv.get('/api/dashboards/tags').then(result => {
return { return {
dashboardResult: [], dashboardResult: [],

View File

@ -16,14 +16,14 @@ class PlaylistSrv {
next() { next() {
this.$timeout.cancel(this.cancelPromise); this.$timeout.cancel(this.cancelPromise);
var playedAllDashboards = this.index > this.dashboards.length - 1; const playedAllDashboards = this.index > this.dashboards.length - 1;
if (playedAllDashboards) { if (playedAllDashboards) {
window.location.href = this.getUrlWithKioskMode(); window.location.href = this.getUrlWithKioskMode();
return; return;
} }
var dash = this.dashboards[this.index]; const dash = this.dashboards[this.index];
this.$location.url('dashboard/' + dash.uri); this.$location.url('dashboard/' + dash.uri);
this.index++; this.index++;

View File

@ -17,7 +17,7 @@ class StyleGuideCtrl {
switchTheme() { switchTheme() {
this.$routeParams.theme = this.theme === 'dark' ? 'light' : 'dark'; this.$routeParams.theme = this.theme === 'dark' ? 'light' : 'dark';
var cmd = { const cmd = {
theme: this.$routeParams.theme, theme: this.$routeParams.theme,
}; };