mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
tslint: autofix of let -> const (#13033)
This commit is contained in:
@@ -4,12 +4,12 @@ import coreModule from '../core_module';
|
||||
|
||||
/** @ngInject */
|
||||
export function dropdownTypeahead($compile) {
|
||||
let inputTemplate =
|
||||
const inputTemplate =
|
||||
'<input type="text"' +
|
||||
' class="gf-form-input input-medium tight-form-input"' +
|
||||
' spellcheck="false" style="display:none"></input>';
|
||||
|
||||
let buttonTemplate =
|
||||
const buttonTemplate =
|
||||
'<a class="gf-form-label tight-form-func dropdown-toggle"' +
|
||||
' tabindex="1" gf-dropdown="menuItems" data-toggle="dropdown"' +
|
||||
' data-placement="top"><i class="fa fa-plus"></i></a>';
|
||||
@@ -21,8 +21,8 @@ export function dropdownTypeahead($compile) {
|
||||
model: '=ngModel',
|
||||
},
|
||||
link: function($scope, elem, attrs) {
|
||||
let $input = $(inputTemplate);
|
||||
let $button = $(buttonTemplate);
|
||||
const $input = $(inputTemplate);
|
||||
const $button = $(buttonTemplate);
|
||||
$input.appendTo(elem);
|
||||
$button.appendTo(elem);
|
||||
|
||||
@@ -42,7 +42,7 @@ export function dropdownTypeahead($compile) {
|
||||
});
|
||||
}
|
||||
|
||||
let typeaheadValues = _.reduce(
|
||||
const typeaheadValues = _.reduce(
|
||||
$scope.menuItems,
|
||||
function(memo, value, index) {
|
||||
if (!value.submenu) {
|
||||
@@ -60,8 +60,8 @@ export function dropdownTypeahead($compile) {
|
||||
);
|
||||
|
||||
$scope.menuItemSelected = function(index, subIndex) {
|
||||
let menuItem = $scope.menuItems[index];
|
||||
let payload: any = { $item: menuItem };
|
||||
const menuItem = $scope.menuItems[index];
|
||||
const payload: any = { $item: menuItem };
|
||||
if (menuItem.submenu && subIndex !== void 0) {
|
||||
payload.$subItem = menuItem.submenu[subIndex];
|
||||
}
|
||||
@@ -74,7 +74,7 @@ export function dropdownTypeahead($compile) {
|
||||
minLength: 1,
|
||||
items: 10,
|
||||
updater: function(value) {
|
||||
let result: any = {};
|
||||
const result: any = {};
|
||||
_.each($scope.menuItems, function(menuItem) {
|
||||
_.each(menuItem.submenu, function(submenuItem) {
|
||||
if (value === menuItem.text + ' ' + submenuItem.text) {
|
||||
@@ -124,10 +124,10 @@ export function dropdownTypeahead($compile) {
|
||||
|
||||
/** @ngInject */
|
||||
export function dropdownTypeahead2($compile) {
|
||||
let inputTemplate =
|
||||
const inputTemplate =
|
||||
'<input type="text"' + ' class="gf-form-input"' + ' spellcheck="false" style="display:none"></input>';
|
||||
|
||||
let buttonTemplate =
|
||||
const buttonTemplate =
|
||||
'<a class="gf-form-input dropdown-toggle"' +
|
||||
' tabindex="1" gf-dropdown="menuItems" data-toggle="dropdown"' +
|
||||
' data-placement="top"><i class="fa fa-plus"></i></a>';
|
||||
@@ -139,8 +139,8 @@ export function dropdownTypeahead2($compile) {
|
||||
model: '=ngModel',
|
||||
},
|
||||
link: function($scope, elem, attrs) {
|
||||
let $input = $(inputTemplate);
|
||||
let $button = $(buttonTemplate);
|
||||
const $input = $(inputTemplate);
|
||||
const $button = $(buttonTemplate);
|
||||
$input.appendTo(elem);
|
||||
$button.appendTo(elem);
|
||||
|
||||
@@ -160,7 +160,7 @@ export function dropdownTypeahead2($compile) {
|
||||
});
|
||||
}
|
||||
|
||||
let typeaheadValues = _.reduce(
|
||||
const typeaheadValues = _.reduce(
|
||||
$scope.menuItems,
|
||||
function(memo, value, index) {
|
||||
if (!value.submenu) {
|
||||
@@ -178,8 +178,8 @@ export function dropdownTypeahead2($compile) {
|
||||
);
|
||||
|
||||
$scope.menuItemSelected = function(index, subIndex) {
|
||||
let menuItem = $scope.menuItems[index];
|
||||
let payload: any = { $item: menuItem };
|
||||
const menuItem = $scope.menuItems[index];
|
||||
const payload: any = { $item: menuItem };
|
||||
if (menuItem.submenu && subIndex !== void 0) {
|
||||
payload.$subItem = menuItem.submenu[subIndex];
|
||||
}
|
||||
@@ -192,7 +192,7 @@ export function dropdownTypeahead2($compile) {
|
||||
minLength: 1,
|
||||
items: 10,
|
||||
updater: function(value) {
|
||||
let result: any = {};
|
||||
const result: any = {};
|
||||
_.each($scope.menuItems, function(menuItem) {
|
||||
_.each(menuItem.submenu, function(submenuItem) {
|
||||
if (value === menuItem.text + ' ' + submenuItem.text) {
|
||||
|
||||
@@ -4,16 +4,16 @@ import coreModule from '../core_module';
|
||||
|
||||
/** @ngInject */
|
||||
export function metricSegment($compile, $sce) {
|
||||
let inputTemplate =
|
||||
const inputTemplate =
|
||||
'<input type="text" data-provide="typeahead" ' +
|
||||
' class="gf-form-input input-medium"' +
|
||||
' spellcheck="false" style="display:none"></input>';
|
||||
|
||||
let linkTemplate =
|
||||
const linkTemplate =
|
||||
'<a class="gf-form-label" ng-class="segment.cssClass" ' +
|
||||
'tabindex="1" give-focus="segment.focus" ng-bind-html="segment.html"></a>';
|
||||
|
||||
let selectTemplate =
|
||||
const selectTemplate =
|
||||
'<a class="gf-form-input gf-form-input--dropdown" ng-class="segment.cssClass" ' +
|
||||
'tabindex="1" give-focus="segment.focus" ng-bind-html="segment.html"></a>';
|
||||
|
||||
@@ -25,13 +25,13 @@ export function metricSegment($compile, $sce) {
|
||||
debounce: '@',
|
||||
},
|
||||
link: function($scope, elem) {
|
||||
let $input = $(inputTemplate);
|
||||
let segment = $scope.segment;
|
||||
let $button = $(segment.selectMode ? selectTemplate : linkTemplate);
|
||||
const $input = $(inputTemplate);
|
||||
const segment = $scope.segment;
|
||||
const $button = $(segment.selectMode ? selectTemplate : linkTemplate);
|
||||
let options = null;
|
||||
let cancelBlur = null;
|
||||
let linkMode = true;
|
||||
let debounceLookup = $scope.debounce;
|
||||
const debounceLookup = $scope.debounce;
|
||||
|
||||
$input.appendTo(elem);
|
||||
$button.appendTo(elem);
|
||||
@@ -44,7 +44,7 @@ export function metricSegment($compile, $sce) {
|
||||
value = _.unescape(value);
|
||||
|
||||
$scope.$apply(function() {
|
||||
let selected = _.find($scope.altSegments, { value: value });
|
||||
const selected = _.find($scope.altSegments, { value: value });
|
||||
if (selected) {
|
||||
segment.value = selected.value;
|
||||
segment.html = selected.html || selected.value;
|
||||
@@ -141,10 +141,10 @@ export function metricSegment($compile, $sce) {
|
||||
matcher: $scope.matcher,
|
||||
});
|
||||
|
||||
let typeahead = $input.data('typeahead');
|
||||
const typeahead = $input.data('typeahead');
|
||||
typeahead.lookup = function() {
|
||||
this.query = this.$element.val() || '';
|
||||
let items = this.source(this.query, $.proxy(this.process, this));
|
||||
const items = this.source(this.query, $.proxy(this.process, this));
|
||||
return items ? this.process(items) : items;
|
||||
};
|
||||
|
||||
@@ -169,7 +169,7 @@ export function metricSegment($compile, $sce) {
|
||||
|
||||
linkMode = false;
|
||||
|
||||
let typeahead = $input.data('typeahead');
|
||||
const typeahead = $input.data('typeahead');
|
||||
if (typeahead) {
|
||||
$input.val('');
|
||||
typeahead.lookup();
|
||||
@@ -200,8 +200,8 @@ export function metricSegmentModel(uiSegmentSrv, $q) {
|
||||
let cachedOptions;
|
||||
|
||||
$scope.valueToSegment = function(value) {
|
||||
let option = _.find($scope.options, { value: value });
|
||||
let segment = {
|
||||
const option = _.find($scope.options, { value: value });
|
||||
const segment = {
|
||||
cssClass: attrs.cssClass,
|
||||
custom: attrs.custom,
|
||||
value: option ? option.text : value,
|
||||
@@ -234,7 +234,7 @@ export function metricSegmentModel(uiSegmentSrv, $q) {
|
||||
|
||||
$scope.onSegmentChange = function() {
|
||||
if (cachedOptions) {
|
||||
let option = _.find(cachedOptions, { text: $scope.segment.value });
|
||||
const option = _.find(cachedOptions, { text: $scope.segment.value });
|
||||
if (option && option.value !== $scope.property) {
|
||||
$scope.property = option.value;
|
||||
} else if (attrs.custom !== 'false') {
|
||||
|
||||
@@ -156,7 +156,7 @@ function gfDropdown($parse, $compile, $timeout) {
|
||||
var ul = ['<ul class="dropdown-menu ' + upclass + '" role="menu" aria-labelledby="drop1">', '</ul>'];
|
||||
|
||||
for (let index = 0; index < items.length; index++) {
|
||||
let item = items[index];
|
||||
const item = items[index];
|
||||
|
||||
if (item.divider) {
|
||||
ul.splice(index + 1, 0, '<li class="divider"></li>');
|
||||
|
||||
@@ -46,16 +46,16 @@ export class ValueSelectDropdownCtrl {
|
||||
}
|
||||
|
||||
updateLinkText() {
|
||||
let current = this.variable.current;
|
||||
const current = this.variable.current;
|
||||
|
||||
if (current.tags && current.tags.length) {
|
||||
// filer out values that are in selected tags
|
||||
let selectedAndNotInTag = _.filter(this.variable.options, option => {
|
||||
const selectedAndNotInTag = _.filter(this.variable.options, option => {
|
||||
if (!option.selected) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < current.tags.length; i++) {
|
||||
let tag = current.tags[i];
|
||||
const tag = current.tags[i];
|
||||
if (_.indexOf(tag.values, option.value) !== -1) {
|
||||
return false;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ export class ValueSelectDropdownCtrl {
|
||||
});
|
||||
|
||||
// convert values to text
|
||||
let currentTexts = _.map(selectedAndNotInTag, 'text');
|
||||
const currentTexts = _.map(selectedAndNotInTag, 'text');
|
||||
|
||||
// join texts
|
||||
this.linkText = currentTexts.join(' + ');
|
||||
@@ -142,7 +142,7 @@ export class ValueSelectDropdownCtrl {
|
||||
commitChange = commitChange || false;
|
||||
excludeOthers = excludeOthers || false;
|
||||
|
||||
let setAllExceptCurrentTo = newValue => {
|
||||
const setAllExceptCurrentTo = newValue => {
|
||||
_.each(this.options, other => {
|
||||
if (option !== other) {
|
||||
other.selected = newValue;
|
||||
@@ -246,9 +246,9 @@ export function valueSelectDropdown($compile, $window, $timeout, $rootScope) {
|
||||
controllerAs: 'vm',
|
||||
bindToController: true,
|
||||
link: function(scope, elem) {
|
||||
let bodyEl = angular.element($window.document.body);
|
||||
let linkEl = elem.find('.variable-value-link');
|
||||
let inputEl = elem.find('input');
|
||||
const bodyEl = angular.element($window.document.body);
|
||||
const linkEl = elem.find('.variable-value-link');
|
||||
const inputEl = elem.find('input');
|
||||
|
||||
function openDropdown() {
|
||||
inputEl.css('width', Math.max(linkEl.width(), 80) + 'px');
|
||||
@@ -288,7 +288,7 @@ export function valueSelectDropdown($compile, $window, $timeout, $rootScope) {
|
||||
}
|
||||
});
|
||||
|
||||
let cleanUp = $rootScope.$on('template-variable-value-updated', () => {
|
||||
const cleanUp = $rootScope.$on('template-variable-value-updated', () => {
|
||||
scope.vm.updateLinkText();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user