mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
changed var to const 2 (#13068)
* changed var to const * fixed typo created in last commit * added or empty object to options in prometheus/datasource
This commit is contained in:
committed by
Torkel Ödegaard
parent
5e0d0c5816
commit
a702603e7b
@@ -49,7 +49,7 @@ export class GrafanaCtrl {
|
||||
};
|
||||
|
||||
$rootScope.onAppEvent = function(name, callback, localScope) {
|
||||
var unbind = $rootScope.$on(name, callback);
|
||||
const unbind = $rootScope.$on(name, callback);
|
||||
var callerScope = this;
|
||||
if (callerScope.$id === 1 && !localScope) {
|
||||
console.log('warning rootScope onAppEvent called without localscope');
|
||||
@@ -76,7 +76,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
controller: GrafanaCtrl,
|
||||
link: (scope, elem) => {
|
||||
var sidemenuOpen;
|
||||
var body = $('body');
|
||||
const body = $('body');
|
||||
|
||||
// see https://github.com/zenorocha/clipboard.js/issues/155
|
||||
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
|
||||
@@ -153,7 +153,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
// handle in active view state class
|
||||
var lastActivity = new Date().getTime();
|
||||
var activeUser = true;
|
||||
var inActiveTimeLimit = 60 * 1000;
|
||||
const inActiveTimeLimit = 60 * 1000;
|
||||
var sidemenuHidden = false;
|
||||
|
||||
function checkForInActiveUser() {
|
||||
@@ -215,16 +215,16 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
|
||||
// handle document clicks that should hide things
|
||||
body.click(function(evt) {
|
||||
var target = $(evt.target);
|
||||
const target = $(evt.target);
|
||||
if (target.parents().length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// for stuff that animates, slides out etc, clicking it needs to
|
||||
// hide it right away
|
||||
var clickAutoHide = target.closest('[data-click-hide]');
|
||||
const clickAutoHide = target.closest('[data-click-hide]');
|
||||
if (clickAutoHide.length) {
|
||||
var clickAutoHideParent = clickAutoHide.parent();
|
||||
const clickAutoHideParent = clickAutoHide.parent();
|
||||
clickAutoHide.detach();
|
||||
setTimeout(function() {
|
||||
clickAutoHideParent.append(clickAutoHide);
|
||||
@@ -245,7 +245,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
||||
}
|
||||
|
||||
// hide popovers
|
||||
var popover = elem.find('.popover');
|
||||
const popover = elem.find('.popover');
|
||||
if (popover.length > 0 && target.parents('.graph-legend').length === 0) {
|
||||
popover.hide();
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ export class BackendSrv {
|
||||
|
||||
request(options) {
|
||||
options.retry = options.retry || 0;
|
||||
var requestIsLocal = !options.url.match(/^http/);
|
||||
var firstAttempt = options.retry === 0;
|
||||
const requestIsLocal = !options.url.match(/^http/);
|
||||
const firstAttempt = options.retry === 0;
|
||||
|
||||
if (requestIsLocal) {
|
||||
if (this.contextSrv.user && this.contextSrv.user.orgId) {
|
||||
@@ -123,30 +123,31 @@ export class BackendSrv {
|
||||
}
|
||||
|
||||
resolveCancelerIfExists(requestId) {
|
||||
var cancelers = this.inFlightRequests[requestId];
|
||||
const cancelers = this.inFlightRequests[requestId];
|
||||
if (!_.isUndefined(cancelers) && cancelers.length) {
|
||||
cancelers[0].resolve();
|
||||
}
|
||||
}
|
||||
|
||||
datasourceRequest(options) {
|
||||
let canceler = null;
|
||||
options.retry = options.retry || 0;
|
||||
|
||||
// A requestID is provided by the datasource as a unique identifier for a
|
||||
// particular query. If the requestID exists, the promise it is keyed to
|
||||
// is canceled, canceling the previous datasource request if it is still
|
||||
// in-flight.
|
||||
var requestId = options.requestId;
|
||||
const requestId = options.requestId;
|
||||
if (requestId) {
|
||||
this.resolveCancelerIfExists(requestId);
|
||||
// create new canceler
|
||||
var canceler = this.$q.defer();
|
||||
canceler = this.$q.defer();
|
||||
options.timeout = canceler.promise;
|
||||
this.addCanceler(requestId, canceler);
|
||||
}
|
||||
|
||||
var requestIsLocal = !options.url.match(/^http/);
|
||||
var firstAttempt = options.retry === 0;
|
||||
const requestIsLocal = !options.url.match(/^http/);
|
||||
const firstAttempt = options.retry === 0;
|
||||
|
||||
if (requestIsLocal) {
|
||||
if (this.contextSrv.user && this.contextSrv.user.orgId) {
|
||||
|
||||
@@ -8,7 +8,7 @@ function matchSeriesOverride(aliasOrRegex, seriesAlias) {
|
||||
}
|
||||
|
||||
if (aliasOrRegex[0] === '/') {
|
||||
var regex = kbn.stringToJsRegex(aliasOrRegex);
|
||||
const regex = kbn.stringToJsRegex(aliasOrRegex);
|
||||
return seriesAlias.match(regex) != null;
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ export function updateLegendValues(data: TimeSeries[], panel, height) {
|
||||
// legend and tooltip gets one more decimal precision
|
||||
// than graph legend ticks
|
||||
const { datamin, datamax } = getDataMinMax(data);
|
||||
let { tickDecimals, scaledDecimals } = getFlotTickDecimals(datamin, datamax, axis, height);
|
||||
tickDecimals = (tickDecimals || -1) + 1;
|
||||
series.updateLegendValues(formater, tickDecimals, scaledDecimals + 2);
|
||||
const { tickDecimals, scaledDecimals } = getFlotTickDecimals(datamin, datamax, axis, height);
|
||||
const tickDecimalsPlusOne = (tickDecimals || -1) + 1;
|
||||
series.updateLegendValues(formater, tickDecimalsPlusOne, scaledDecimals + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ export default class TimeSeries {
|
||||
delete this.bars.show;
|
||||
|
||||
for (var i = 0; i < overrides.length; i++) {
|
||||
var override = overrides[i];
|
||||
const override = overrides[i];
|
||||
if (!matchSeriesOverride(override.alias, this.alias)) {
|
||||
continue;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ export default class TimeSeries {
|
||||
}
|
||||
|
||||
getFlotPairs(fillStyle) {
|
||||
var result = [];
|
||||
const result = [];
|
||||
|
||||
this.stats.total = 0;
|
||||
this.stats.max = -Number.MAX_VALUE;
|
||||
@@ -209,8 +209,8 @@ export default class TimeSeries {
|
||||
this.allIsNull = true;
|
||||
this.allIsZero = true;
|
||||
|
||||
var ignoreNulls = fillStyle === 'connected';
|
||||
var nullAsZero = fillStyle === 'null as zero';
|
||||
const ignoreNulls = fillStyle === 'connected';
|
||||
const nullAsZero = fillStyle === 'null as zero';
|
||||
var currentTime;
|
||||
var currentValue;
|
||||
var nonNulls = 0;
|
||||
@@ -330,7 +330,7 @@ export default class TimeSeries {
|
||||
isMsResolutionNeeded() {
|
||||
for (var i = 0; i < this.datapoints.length; i++) {
|
||||
if (this.datapoints[i][1] !== null) {
|
||||
var timestamp = this.datapoints[i][1].toString();
|
||||
const timestamp = this.datapoints[i][1].toString();
|
||||
if (timestamp.length === 13 && timestamp % 1000 !== 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user