tslint: autofix of let -> const (#13033)

pull/13034/head
Torkel Ödegaard 7 years ago committed by GitHub
parent 8a99fa269d
commit 9b978b7203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      public/app/containers/AlertRuleList/AlertRuleList.test.tsx
  2. 4
      public/app/containers/AlertRuleList/AlertRuleList.tsx
  3. 2
      public/app/containers/Explore/Table.tsx
  4. 2
      public/app/containers/Explore/utils/prometheus.ts
  5. 2
      public/app/containers/Teams/TeamList.tsx
  6. 2
      public/app/core/components/Permissions/AddPermissions.test.tsx
  7. 2
      public/app/core/components/TagFilter/TagFilter.tsx
  8. 30
      public/app/core/components/code_editor/code_editor.ts
  9. 4
      public/app/core/components/colorpicker/ColorPicker.tsx
  10. 14
      public/app/core/components/colorpicker/ColorPickerPopover.tsx
  11. 2
      public/app/core/components/colorpicker/SpectrumPicker.tsx
  12. 2
      public/app/core/components/form_dropdown/form_dropdown.ts
  13. 2
      public/app/core/components/grafana_app.ts
  14. 14
      public/app/core/components/info_popover.ts
  15. 14
      public/app/core/components/manage_dashboards/manage_dashboards.ts
  16. 6
      public/app/core/components/scroll/scroll.ts
  17. 2
      public/app/core/components/search/SearchResult.tsx
  18. 4
      public/app/core/components/sidemenu/sidemenu.ts
  19. 4
      public/app/core/controllers/login_ctrl.ts
  20. 32
      public/app/core/directives/dropdown_typeahead.ts
  21. 28
      public/app/core/directives/metric_segment.ts
  22. 2
      public/app/core/directives/misc.ts
  23. 18
      public/app/core/directives/value_select_dropdown.ts
  24. 6
      public/app/core/nav_model_srv.ts
  25. 10
      public/app/core/services/backend_srv.ts
  26. 4
      public/app/core/services/bridge_srv.ts
  27. 2
      public/app/core/services/dynamic_directive_srv.ts
  28. 2
      public/app/core/services/keybindingSrv.ts
  29. 2
      public/app/core/services/ng_react.ts
  30. 14
      public/app/core/services/search_srv.ts
  31. 4
      public/app/core/services/segment_srv.ts
  32. 4
      public/app/core/specs/backend_srv.test.ts
  33. 6
      public/app/core/specs/file_export.test.ts
  34. 2
      public/app/core/specs/search.test.ts
  35. 8
      public/app/core/specs/search_results.test.ts
  36. 2
      public/app/core/specs/ticks.test.ts
  37. 10
      public/app/core/specs/time_series.test.ts
  38. 2
      public/app/core/specs/value_select_dropdown.test.ts
  39. 8
      public/app/core/time_series2.ts
  40. 4
      public/app/core/utils/colors.ts
  41. 20
      public/app/core/utils/dag.test.ts
  42. 18
      public/app/core/utils/dag.ts
  43. 16
      public/app/core/utils/file_export.ts
  44. 2
      public/app/core/utils/outline.ts
  45. 10
      public/app/core/utils/rangeutil.ts
  46. 2
      public/app/core/utils/sort_by_keys.ts
  47. 6
      public/app/core/utils/tags.ts
  48. 22
      public/app/core/utils/ticks.ts
  49. 10
      public/app/core/utils/url.ts
  50. 6
      public/app/core/utils/version.ts
  51. 4
      public/app/features/alerting/alert_tab_ctrl.ts
  52. 2
      public/app/features/alerting/notification_edit_ctrl.ts
  53. 14
      public/app/features/alerting/threshold_mapper.ts
  54. 2
      public/app/features/annotations/annotations_srv.ts
  55. 4
      public/app/features/annotations/event_editor.ts
  56. 12
      public/app/features/annotations/event_manager.ts
  57. 12
      public/app/features/annotations/events_processing.ts
  58. 4
      public/app/features/annotations/specs/annotations_srv.test.ts
  59. 8
      public/app/features/annotations/specs/annotations_srv_specs.test.ts
  60. 2
      public/app/features/dashboard/ad_hoc_filters.ts
  61. 8
      public/app/features/dashboard/change_tracker.ts
  62. 4
      public/app/features/dashboard/dashboard_import_ctrl.ts
  63. 14
      public/app/features/dashboard/dashboard_migration.ts
  64. 88
      public/app/features/dashboard/dashboard_model.ts
  65. 20
      public/app/features/dashboard/dashgrid/AddPanelPanel.tsx
  66. 8
      public/app/features/dashboard/dashgrid/DashboardGrid.tsx
  67. 4
      public/app/features/dashboard/dashnav/dashnav.ts
  68. 2
      public/app/features/dashboard/export/export_modal.ts
  69. 14
      public/app/features/dashboard/export/exporter.ts
  70. 4
      public/app/features/dashboard/history/history.ts
  71. 2
      public/app/features/dashboard/settings/settings.ts
  72. 2
      public/app/features/dashboard/shareModalCtrl.ts
  73. 84
      public/app/features/dashboard/specs/dashboard_migration.test.ts
  74. 32
      public/app/features/dashboard/specs/dashboard_model.test.ts
  75. 4
      public/app/features/dashboard/specs/history_ctrl.test.ts
  76. 6
      public/app/features/dashboard/specs/history_srv.test.ts
  77. 2
      public/app/features/dashboard/specs/repeat.test.ts
  78. 6
      public/app/features/dashboard/specs/viewstate_srv.test.ts
  79. 4
      public/app/features/dashboard/validation_srv.ts
  80. 4
      public/app/features/dashboard/view_state_srv.ts
  81. 2
      public/app/features/org/org_users_ctrl.ts
  82. 2
      public/app/features/panel/metrics_tab.ts
  83. 16
      public/app/features/panel/panel_ctrl.ts
  84. 4
      public/app/features/panel/panel_directive.ts
  85. 12
      public/app/features/panel/panel_header.ts
  86. 2
      public/app/features/panel/solo_panel_ctrl.ts
  87. 2
      public/app/features/panellinks/specs/link_srv.test.ts
  88. 2
      public/app/features/playlist/playlist_routes.ts
  89. 2
      public/app/features/playlist/specs/playlist_edit_ctrl.test.ts
  90. 2
      public/app/features/plugins/ds_list_ctrl.ts
  91. 8
      public/app/features/plugins/plugin_component.ts
  92. 6
      public/app/features/plugins/plugin_edit_ctrl.ts
  93. 2
      public/app/features/plugins/plugin_list_ctrl.ts
  94. 4
      public/app/features/plugins/plugin_loader.ts
  95. 2
      public/app/features/plugins/plugin_page_ctrl.ts
  96. 4
      public/app/features/plugins/specs/datasource_srv.test.ts
  97. 2
      public/app/features/templating/specs/editor_ctrl.test.ts
  98. 6
      public/app/features/templating/specs/variable_srv_init.test.ts
  99. 12
      public/app/features/templating/variable_srv.ts
  100. 4
      public/app/plugins/datasource/cloudwatch/datasource.ts
  101. Some files were not shown because too many files have changed in this diff Show More

@ -46,7 +46,7 @@ describe('AlertRuleList', () => {
it('should render 1 rule', () => {
page.update();
let ruleNode = page.find('.alert-rule-item');
const ruleNode = page.find('.alert-rule-item');
expect(toJson(ruleNode)).toMatchSnapshot();
});

@ -132,13 +132,13 @@ export class AlertRuleItem extends React.Component<AlertRuleItemProps, any> {
render() {
const { rule } = this.props;
let stateClass = classNames({
const stateClass = classNames({
fa: true,
'fa-play': rule.isPaused,
'fa-pause': !rule.isPaused,
});
let ruleUrl = `${rule.url}?panelId=${rule.panelId}&fullscreen=true&edit=true&tab=alert`;
const ruleUrl = `${rule.url}?panelId=${rule.panelId}&fullscreen=true&edit=true&tab=alert`;
return (
<li className="alert-rule-item">

@ -40,7 +40,7 @@ function Cell(props: SFCCellProps) {
export default class Table extends PureComponent<TableProps, {}> {
render() {
const { className = '', data, loading, onClickCell } = this.props;
let tableModel = data || EMPTY_TABLE;
const tableModel = data || EMPTY_TABLE;
if (!loading && data && data.rows.length === 0) {
return (
<table className={`${className} filter-table`}>

@ -65,7 +65,7 @@ export function parseSelector(query: string, cursorOffset = 1): { labelKeys: any
// Extract clean labels to form clean selector, incomplete labels are dropped
const selector = query.slice(prefixOpen, suffixClose);
let labels = {};
const labels = {};
selector.replace(labelRegexp, match => {
const delimiterIndex = match.indexOf('=');
const key = match.slice(0, delimiterIndex);

@ -36,7 +36,7 @@ export class TeamList extends React.Component<Props, any> {
};
renderTeamMember(team: Team): JSX.Element {
let teamUrl = `org/teams/edit/${team.id}`;
const teamUrl = `org/teams/edit/${team.id}`;
return (
<tr key={team.id}>

@ -22,7 +22,7 @@ describe('AddPermissions', () => {
let wrapper;
let store;
let instance;
let backendSrv: any = getBackendSrv();
const backendSrv: any = getBackendSrv();
beforeAll(() => {
store = RootStore.create({}, { backendSrv: backendSrv });

@ -43,7 +43,7 @@ export class TagFilter extends React.Component<Props, any> {
}
render() {
let selectOptions = {
const selectOptions = {
loadOptions: this.searchTags,
onChange: this.onChange,
value: this.props.tags,

@ -53,23 +53,23 @@ const DEFAULT_TAB_SIZE = 2;
const DEFAULT_BEHAVIOURS = true;
const DEFAULT_SNIPPETS = true;
let editorTemplate = `<div></div>`;
const editorTemplate = `<div></div>`;
function link(scope, elem, attrs) {
// Options
let langMode = attrs.mode || DEFAULT_MODE;
let maxLines = attrs.maxLines || DEFAULT_MAX_LINES;
let showGutter = attrs.showGutter !== undefined;
let tabSize = attrs.tabSize || DEFAULT_TAB_SIZE;
let behavioursEnabled = attrs.behavioursEnabled ? attrs.behavioursEnabled === 'true' : DEFAULT_BEHAVIOURS;
let snippetsEnabled = attrs.snippetsEnabled ? attrs.snippetsEnabled === 'true' : DEFAULT_SNIPPETS;
const langMode = attrs.mode || DEFAULT_MODE;
const maxLines = attrs.maxLines || DEFAULT_MAX_LINES;
const showGutter = attrs.showGutter !== undefined;
const tabSize = attrs.tabSize || DEFAULT_TAB_SIZE;
const behavioursEnabled = attrs.behavioursEnabled ? attrs.behavioursEnabled === 'true' : DEFAULT_BEHAVIOURS;
const snippetsEnabled = attrs.snippetsEnabled ? attrs.snippetsEnabled === 'true' : DEFAULT_SNIPPETS;
// Initialize editor
let aceElem = elem.get(0);
let codeEditor = ace.edit(aceElem);
let editorSession = codeEditor.getSession();
const aceElem = elem.get(0);
const codeEditor = ace.edit(aceElem);
const editorSession = codeEditor.getSession();
let editorOptions = {
const editorOptions = {
maxLines: maxLines,
showGutter: showGutter,
tabSize: tabSize,
@ -93,7 +93,7 @@ function link(scope, elem, attrs) {
// Add classes
elem.addClass('gf-code-editor');
let textarea = elem.find('textarea');
const textarea = elem.find('textarea');
textarea.addClass('gf-form-input');
if (scope.codeEditorFocus) {
@ -110,14 +110,14 @@ function link(scope, elem, attrs) {
// Event handlers
editorSession.on('change', e => {
scope.$apply(() => {
let newValue = codeEditor.getValue();
const newValue = codeEditor.getValue();
scope.content = newValue;
});
});
// Sync with outer scope - update editor content if model has been changed from outside of directive.
scope.$watch('content', (newValue, oldValue) => {
let editorValue = codeEditor.getValue();
const editorValue = codeEditor.getValue();
if (newValue !== editorValue && newValue !== oldValue) {
scope.$$postDigest(function() {
setEditorContent(newValue);
@ -157,7 +157,7 @@ function link(scope, elem, attrs) {
anyEditor.completers.push(scope.getCompleter());
}
let aceModeName = `ace/mode/${lang}`;
const aceModeName = `ace/mode/${lang}`;
editorSession.setMode(aceModeName);
}

@ -29,10 +29,10 @@ export class ColorPicker extends React.Component<Props, any> {
openColorPicker() {
const dropContent = <ColorPickerPopover color={this.props.color} onColorSelect={this.onColorSelect} />;
let dropContentElem = document.createElement('div');
const dropContentElem = document.createElement('div');
ReactDOM.render(dropContent, dropContentElem);
let drop = new Drop({
const drop = new Drop({
target: this.pickerElem[0],
content: dropContentElem,
position: 'top center',

@ -28,7 +28,7 @@ export class ColorPickerPopover extends React.Component<Props, any> {
}
setColor(color) {
let newColor = tinycolor(color);
const newColor = tinycolor(color);
if (newColor.isValid()) {
this.setState({
color: newColor.toString(),
@ -43,20 +43,20 @@ export class ColorPickerPopover extends React.Component<Props, any> {
}
spectrumColorSelected(color) {
let rgbColor = color.toRgbString();
const rgbColor = color.toRgbString();
this.setColor(rgbColor);
}
onColorStringChange(e) {
let colorString = e.target.value;
const colorString = e.target.value;
this.setState({
colorString: colorString,
});
let newColor = tinycolor(colorString);
const newColor = tinycolor(colorString);
if (newColor.isValid()) {
// Update only color state
let newColorString = newColor.toString();
const newColorString = newColor.toString();
this.setState({
color: newColorString,
});
@ -65,7 +65,7 @@ export class ColorPickerPopover extends React.Component<Props, any> {
}
onColorStringBlur(e) {
let colorString = e.target.value;
const colorString = e.target.value;
this.setColor(colorString);
}
@ -73,7 +73,7 @@ export class ColorPickerPopover extends React.Component<Props, any> {
this.pickerNavElem.find('li:first').addClass('active');
this.pickerNavElem.on('show', e => {
// use href attr (#name => name)
let tab = e.target.hash.slice(1);
const tab = e.target.hash.slice(1);
this.setState({
tab: tab,
});

@ -29,7 +29,7 @@ export class SpectrumPicker extends React.Component<Props, any> {
}
componentDidMount() {
let spectrumOptions = _.assignIn(
const spectrumOptions = _.assignIn(
{
flat: true,
showAlpha: true,

@ -132,7 +132,7 @@ export class FormDropdownCtrl {
this.optionCache = options;
// extract texts
let optionTexts = _.map(options, op => {
const optionTexts = _.map(options, op => {
return _.escape(op.text);
});

@ -140,7 +140,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
}
// close all drops
for (let drop of Drop.drops) {
for (const drop of Drop.drops) {
drop.destroy();
}
});

@ -8,10 +8,10 @@ export function infoPopover() {
template: '<i class="fa fa-info-circle"></i>',
transclude: true,
link: function(scope, elem, attrs, ctrl, transclude) {
let offset = attrs.offset || '0 -10px';
let position = attrs.position || 'right middle';
const offset = attrs.offset || '0 -10px';
const position = attrs.position || 'right middle';
let classes = 'drop-help drop-hide-out-of-bounds';
let openOn = 'hover';
const openOn = 'hover';
elem.addClass('gf-form-help-icon');
@ -24,14 +24,14 @@ export function infoPopover() {
}
transclude(function(clone, newScope) {
let content = document.createElement('div');
const content = document.createElement('div');
content.className = 'markdown-html';
_.each(clone, node => {
content.appendChild(node);
});
let dropOptions = {
const dropOptions = {
target: elem[0],
content: content,
position: position,
@ -52,9 +52,9 @@ export function infoPopover() {
// Create drop in next digest after directive content is rendered.
scope.$applyAsync(() => {
let drop = new Drop(dropOptions);
const drop = new Drop(dropOptions);
let unbind = scope.$on('$destroy', function() {
const unbind = scope.$on('$destroy', function() {
drop.destroy();
unbind();
});

@ -103,10 +103,10 @@ export class ManageDashboardsCtrl {
this.sections = result;
for (let section of this.sections) {
for (const section of this.sections) {
section.checked = false;
for (let dashboard of section.items) {
for (const dashboard of section.items) {
dashboard.checked = false;
}
}
@ -119,7 +119,7 @@ export class ManageDashboardsCtrl {
selectionChanged() {
let selectedDashboards = 0;
for (let section of this.sections) {
for (const section of this.sections) {
selectedDashboards += _.filter(section.items, { checked: true }).length;
}
@ -129,7 +129,7 @@ export class ManageDashboardsCtrl {
}
getFoldersAndDashboardsToDelete() {
let selectedDashboards = {
const selectedDashboards = {
folders: [],
dashboards: [],
};
@ -148,7 +148,7 @@ export class ManageDashboardsCtrl {
getFolderIds(sections) {
const ids = [];
for (let s of sections) {
for (const s of sections) {
if (s.checked) {
ids.push(s.id);
}
@ -191,7 +191,7 @@ export class ManageDashboardsCtrl {
}
getDashboardsToMove() {
let selectedDashboards = [];
const selectedDashboards = [];
for (const section of this.sections) {
const selected = _.filter(section.items, { checked: true });
@ -264,7 +264,7 @@ export class ManageDashboardsCtrl {
}
onSelectAllChanged() {
for (let section of this.sections) {
for (const section of this.sections) {
if (!section.hideHeader) {
section.checked = this.selectAllChecked;
}

@ -17,7 +17,7 @@ export function geminiScrollbar() {
restrict: 'A',
link: function(scope, elem, attrs) {
let scrollRoot = elem.parent();
let scroller = elem;
const scroller = elem;
if (attrs.grafanaScrollbar && attrs.grafanaScrollbar === 'scrollonroot') {
scrollRoot = scroller;
@ -27,7 +27,7 @@ export function geminiScrollbar() {
$(scrollBarHTML).appendTo(scrollRoot);
elem.addClass(scrollerClass);
let scrollParams = {
const scrollParams = {
root: scrollRoot[0],
scroller: scroller[0],
bar: '.baron__bar',
@ -37,7 +37,7 @@ export function geminiScrollbar() {
direction: 'v',
};
let scrollbar = baron(scrollParams);
const scrollbar = baron(scrollParams);
let lastPos = 0;

@ -54,7 +54,7 @@ export class SearchResultSection extends React.Component<SectionProps, any> {
};
render() {
let collapseClassNames = classNames({
const collapseClassNames = classNames({
fa: true,
'fa-plus': !this.props.section.expanded,
'fa-minus': this.props.section.expanded,

@ -17,13 +17,13 @@ export class SideMenuCtrl {
this.isSignedIn = contextSrv.isSignedIn;
this.user = contextSrv.user;
let navTree = _.cloneDeep(config.bootData.navTree);
const navTree = _.cloneDeep(config.bootData.navTree);
this.mainLinks = _.filter(navTree, item => !item.hideFromMenu);
this.bottomNav = _.filter(navTree, item => item.hideFromMenu);
this.loginUrl = 'login?redirect=' + encodeURIComponent(this.$location.path());
if (contextSrv.user.orgCount > 1) {
let profileNode = _.find(this.bottomNav, { id: 'profile' });
const profileNode = _.find(this.bottomNav, { id: 'profile' });
if (profileNode) {
profileNode.showOrgSwitcher = true;
}

@ -45,8 +45,8 @@ export class LoginCtrl {
};
$scope.changeView = function() {
let loginView = document.querySelector('#login-view');
let changePasswordView = document.querySelector('#change-password-view');
const loginView = document.querySelector('#login-view');
const changePasswordView = document.querySelector('#change-password-view');
loginView.className += ' add';
setTimeout(() => {

@ -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();
});

@ -41,14 +41,14 @@ export class NavModelSrv {
var children = this.navItems;
var nav = new NavModel();
for (let id of args) {
for (const id of args) {
// if its a number then it's the index to use for main
if (_.isNumber(id)) {
nav.main = nav.breadcrumbs[id];
break;
}
let node = _.find(children, { id: id });
const node = _.find(children, { id: id });
nav.breadcrumbs.push(node);
nav.node = node;
nav.main = node;
@ -56,7 +56,7 @@ export class NavModelSrv {
}
if (nav.main.children) {
for (let item of nav.main.children) {
for (const item of nav.main.children) {
item.active = false;
if (item.url === nav.node.url) {

@ -276,11 +276,11 @@ export class BackendSrv {
deleteFoldersAndDashboards(folderUids, dashboardUids) {
const tasks = [];
for (let folderUid of folderUids) {
for (const folderUid of folderUids) {
tasks.push(this.createTask(this.deleteFolder.bind(this), true, folderUid, true));
}
for (let dashboardUid of dashboardUids) {
for (const dashboardUid of dashboardUids) {
tasks.push(this.createTask(this.deleteDashboard.bind(this), true, dashboardUid, true));
}
@ -290,7 +290,7 @@ export class BackendSrv {
moveDashboards(dashboardUids, toFolder) {
const tasks = [];
for (let uid of dashboardUids) {
for (const uid of dashboardUids) {
tasks.push(this.createTask(this.moveDashboard.bind(this), true, uid, toFolder));
}
@ -304,7 +304,7 @@ export class BackendSrv {
}
private moveDashboard(uid, toFolder) {
let deferred = this.$q.defer();
const deferred = this.$q.defer();
this.getDashboardByUid(uid).then(fullDash => {
const model = new DashboardModel(fullDash.dashboard, fullDash.meta);
@ -315,7 +315,7 @@ export class BackendSrv {
}
const clone = model.getSaveModelClone();
let options = {
const options = {
folderId: toFolder.id,
overwrite: false,
};

@ -15,7 +15,7 @@ export class BridgeSrv {
init() {
this.$rootScope.$on('$routeUpdate', (evt, data) => {
let angularUrl = this.$location.url();
const angularUrl = this.$location.url();
if (store.view.currentUrl !== angularUrl) {
store.view.updatePathAndQuery(this.$location.path(), this.$location.search(), this.$route.current.params);
}
@ -28,7 +28,7 @@ export class BridgeSrv {
reaction(
() => store.view.currentUrl,
currentUrl => {
let angularUrl = this.$location.url();
const angularUrl = this.$location.url();
const url = locationUtil.stripBaseFromUrl(currentUrl);
if (angularUrl !== url) {
this.$timeout(() => {

@ -36,7 +36,7 @@ class DynamicDirectiveSrv {
}
create(options) {
let directiveDef = {
const directiveDef = {
restrict: 'E',
scope: options.scope,
link: (scope, elem, attrs) => {

@ -210,7 +210,7 @@ export class KeybindingSrv {
// duplicate panel
this.bind('p d', () => {
if (dashboard.meta.focusPanelId && dashboard.meta.canEdit) {
let panelIndex = dashboard.getPanelInfoById(dashboard.meta.focusPanelId).index;
const panelIndex = dashboard.getPanelInfoById(dashboard.meta.focusPanelId).index;
dashboard.duplicatePanel(dashboard.panels[panelIndex]);
}
});

@ -295,6 +295,6 @@ var reactDirective = function($injector) {
};
};
let ngModule = angular.module('react', []);
const ngModule = angular.module('react', []);
ngModule.directive('reactComponent', ['$injector', reactComponent]);
ngModule.factory('reactDirective', ['$injector', reactDirective]);

@ -85,10 +85,10 @@ export class SearchSrv {
}
search(options) {
let sections: any = {};
let promises = [];
let query = _.clone(options);
let hasFilters =
const sections: any = {};
const promises = [];
const query = _.clone(options);
const hasFilters =
options.query ||
(options.tag && options.tag.length > 0) ||
options.starred ||
@ -124,7 +124,7 @@ export class SearchSrv {
}
// create folder index
for (let hit of results) {
for (const hit of results) {
if (hit.type === 'dash-folder') {
sections[hit.id] = {
id: hit.id,
@ -140,7 +140,7 @@ export class SearchSrv {
}
}
for (let hit of results) {
for (const hit of results) {
if (hit.type === 'dash-folder') {
continue;
}
@ -185,7 +185,7 @@ export class SearchSrv {
return Promise.resolve(section);
}
let query = {
const query = {
folderIds: [section.id],
};

@ -3,7 +3,7 @@ import coreModule from '../core_module';
/** @ngInject */
export function uiSegmentSrv($sce, templateSrv) {
let self = this;
const self = this;
function MetricSegment(options) {
if (options === '*' || options.value === '*') {
@ -78,7 +78,7 @@ export function uiSegmentSrv($sce, templateSrv) {
this.transformToSegments = function(addTemplateVars, variableTypeFilter) {
return function(results) {
let segments = _.map(results, function(segment) {
const segments = _.map(results, function(segment) {
return self.newSegment({ value: segment.text, expandable: segment.expandable });
});

@ -2,14 +2,14 @@ import { BackendSrv } from 'app/core/services/backend_srv';
jest.mock('app/core/store');
describe('backend_srv', function() {
let _httpBackend = options => {
const _httpBackend = options => {
if (options.url === 'gateway-error') {
return Promise.reject({ status: 502 });
}
return Promise.resolve({});
};
let _backendSrv = new BackendSrv(_httpBackend, {}, {}, {}, {});
const _backendSrv = new BackendSrv(_httpBackend, {}, {}, {}, {});
describe('when handling errors', () => {
it('should return the http status code', async () => {

@ -2,7 +2,7 @@ import * as fileExport from '../utils/file_export';
import { beforeEach, expect } from 'test/lib/common';
describe('file_export', () => {
let ctx: any = {};
const ctx: any = {};
beforeEach(() => {
ctx.seriesList = [
@ -28,7 +28,7 @@ describe('file_export', () => {
describe('when exporting series as rows', () => {
it('should export points in proper order', () => {
let text = fileExport.convertSeriesListToCsv(ctx.seriesList, ctx.timeFormat);
const text = fileExport.convertSeriesListToCsv(ctx.seriesList, ctx.timeFormat);
const expectedText =
'"Series";"Time";"Value"\r\n' +
'"series_1";"1500026100";1\r\n' +
@ -48,7 +48,7 @@ describe('file_export', () => {
describe('when exporting series as columns', () => {
it('should export points in proper order', () => {
let text = fileExport.convertSeriesListToCsvColumns(ctx.seriesList, ctx.timeFormat);
const text = fileExport.convertSeriesListToCsvColumns(ctx.seriesList, ctx.timeFormat);
const expectedText =
'"Time";"series_1";"series_2"\r\n' +
'"1500026100";1;11\r\n' +

@ -12,7 +12,7 @@ describe('SearchCtrl', () => {
search: (options: any) => {},
getDashboardTags: () => {},
};
let ctrl = new SearchCtrl({ $on: () => {} }, {}, {}, <SearchSrv>searchSrvStub);
const ctrl = new SearchCtrl({ $on: () => {} }, {}, {}, <SearchSrv>searchSrvStub);
describe('Given an empty result', () => {
beforeEach(() => {

@ -12,7 +12,7 @@ describe('SearchResultsCtrl', () => {
let ctrl;
describe('when checking an item that is not checked', () => {
let item = { checked: false };
const item = { checked: false };
let selectionChanged = false;
beforeEach(() => {
@ -31,7 +31,7 @@ describe('SearchResultsCtrl', () => {
});
describe('when checking an item that is checked', () => {
let item = { checked: true };
const item = { checked: true };
let selectionChanged = false;
beforeEach(() => {
@ -72,7 +72,7 @@ describe('SearchResultsCtrl', () => {
folderExpanded = true;
};
let folder = {
const folder = {
expanded: false,
toggle: () => Promise.resolve(folder),
};
@ -94,7 +94,7 @@ describe('SearchResultsCtrl', () => {
folderExpanded = true;
};
let folder = {
const folder = {
expanded: true,
toggle: () => Promise.resolve(folder),
};

@ -2,7 +2,7 @@ import * as ticks from '../utils/ticks';
describe('ticks', () => {
describe('getFlotTickDecimals()', () => {
let ctx: any = {};
const ctx: any = {};
beforeEach(() => {
ctx.axis = {};

@ -329,7 +329,7 @@ describe('TimeSeries', function() {
describe('legend decimals', function() {
let series, panel;
let height = 200;
const height = 200;
beforeEach(function() {
testData = {
alias: 'test',
@ -348,7 +348,7 @@ describe('TimeSeries', function() {
});
it('should set decimals based on Y axis (expect calculated decimals = 1)', function() {
let data = [series];
const data = [series];
// Expect ticks with this data will have decimals = 1
updateLegendValues(data, panel, height);
expect(data[0].decimals).toBe(2);
@ -358,21 +358,21 @@ describe('TimeSeries', function() {
testData.datapoints = [[10, 2], [0, 3], [100, 4], [80, 5]];
series = new TimeSeries(testData);
series.getFlotPairs();
let data = [series];
const data = [series];
updateLegendValues(data, panel, height);
expect(data[0].decimals).toBe(0);
});
it('should set decimals to Y axis decimals + 1', function() {
panel.yaxes[0].decimals = 2;
let data = [series];
const data = [series];
updateLegendValues(data, panel, height);
expect(data[0].decimals).toBe(3);
});
it('should set decimals to legend decimals value if it was set explicitly', function() {
panel.decimals = 3;
let data = [series];
const data = [series];
updateLegendValues(data, panel, height);
expect(data[0].decimals).toBe(3);
});

@ -3,7 +3,7 @@ import { ValueSelectDropdownCtrl } from '../directives/value_select_dropdown';
import q from 'q';
describe('SelectDropdownCtrl', () => {
let tagValuesMap: any = {};
const tagValuesMap: any = {};
ValueSelectDropdownCtrl.prototype.onUpdated = jest.fn();
let ctrl;

@ -27,11 +27,11 @@ function translateFillOption(fill) {
*/
export function updateLegendValues(data: TimeSeries[], panel, height) {
for (let i = 0; i < data.length; i++) {
let series = data[i];
const series = data[i];
const yaxes = panel.yaxes;
const seriesYAxis = series.yaxis || 1;
const axis = yaxes[seriesYAxis - 1];
let formater = kbn.valueFormats[axis.format];
const formater = kbn.valueFormats[axis.format];
// decimal override
if (_.isNumber(panel.decimals)) {
@ -54,7 +54,7 @@ export function getDataMinMax(data: TimeSeries[]) {
let datamin = null;
let datamax = null;
for (let series of data) {
for (const series of data) {
if (datamax === null || datamax < series.stats.max) {
datamax = series.stats.max;
}
@ -225,7 +225,7 @@ export default class TimeSeries {
// Due to missing values we could have different timeStep all along the series
// so we have to find the minimum one (could occur with aggregators such as ZimSum)
if (previousTime !== undefined) {
let timeStep = currentTime - previousTime;
const timeStep = currentTime - previousTime;
if (timeStep < this.stats.timeStep) {
this.stats.timeStep = timeStep;
}

@ -9,7 +9,7 @@ export const ALERTING_COLOR = 'rgba(237, 46, 24, 1)';
export const NO_DATA_COLOR = 'rgba(150, 150, 150, 1)';
export const REGION_FILL_ALPHA = 0.09;
let colors = [
const colors = [
'#7EB26D',
'#EAB839',
'#6ED0E0',
@ -69,7 +69,7 @@ let colors = [
];
export function sortColorsByHue(hexColors) {
let hslColors = _.map(hexColors, hexToHsl);
const hslColors = _.map(hexColors, hexToHsl);
let sortedHSLColors = _.sortBy(hslColors, ['h']);
sortedHSLColors = _.chunk(sortedHSLColors, PALETTE_ROWS);

@ -2,16 +2,16 @@ import { Graph } from './dag';
describe('Directed acyclic graph', () => {
describe('Given a graph with nodes with different links in between them', () => {
let dag = new Graph();
let nodeA = dag.createNode('A');
let nodeB = dag.createNode('B');
let nodeC = dag.createNode('C');
let nodeD = dag.createNode('D');
let nodeE = dag.createNode('E');
let nodeF = dag.createNode('F');
let nodeG = dag.createNode('G');
let nodeH = dag.createNode('H');
let nodeI = dag.createNode('I');
const dag = new Graph();
const nodeA = dag.createNode('A');
const nodeB = dag.createNode('B');
const nodeC = dag.createNode('C');
const nodeD = dag.createNode('D');
const nodeE = dag.createNode('E');
const nodeF = dag.createNode('F');
const nodeG = dag.createNode('G');
const nodeH = dag.createNode('H');
const nodeI = dag.createNode('I');
dag.link([nodeB, nodeC, nodeD, nodeE, nodeF, nodeG, nodeH], nodeA);
dag.link([nodeC, nodeD, nodeE, nodeF, nodeI], nodeB);
dag.link([nodeD, nodeE, nodeF, nodeG], nodeC);

@ -26,8 +26,8 @@ export class Edge {
unlink() {
let pos;
let inode = this.inputNode;
let onode = this.outputNode;
const inode = this.inputNode;
const onode = this.outputNode;
if (!(inode && onode)) {
return;
@ -96,12 +96,12 @@ export class Node {
}
getOptimizedInputEdges(): Edge[] {
let toBeRemoved = [];
const toBeRemoved = [];
this.inputEdges.forEach(e => {
let inputEdgesNodes = e.inputNode.inputEdges.map(e => e.inputNode);
const inputEdgesNodes = e.inputNode.inputEdges.map(e => e.inputNode);
inputEdgesNodes.forEach(n => {
let edgeToRemove = n.getEdgeTo(this.name);
const edgeToRemove = n.getEdgeTo(this.name);
if (edgeToRemove) {
toBeRemoved.push(edgeToRemove);
}
@ -124,7 +124,7 @@ export class Graph {
}
createNodes(names: string[]): Node[] {
let nodes = [];
const nodes = [];
names.forEach(name => {
nodes.push(this.createNode(name));
});
@ -134,8 +134,8 @@ export class Graph {
link(input: string | string[] | Node | Node[], output: string | string[] | Node | Node[]): Edge[] {
let inputArr = [];
let outputArr = [];
let inputNodes = [];
let outputNodes = [];
const inputNodes = [];
const outputNodes = [];
if (input instanceof Array) {
inputArr = input;
@ -167,7 +167,7 @@ export class Graph {
}
}
let edges = [];
const edges = [];
inputNodes.forEach(input => {
outputNodes.forEach(output => {
edges.push(this.createEdge().link(input, output));

@ -74,7 +74,7 @@ export function convertSeriesListToCsv(seriesList, dateTimeFormat = DEFAULT_DATE
}
export function exportSeriesListToCsv(seriesList, dateTimeFormat = DEFAULT_DATETIME_FORMAT, excel = false) {
let text = convertSeriesListToCsv(seriesList, dateTimeFormat, excel);
const text = convertSeriesListToCsv(seriesList, dateTimeFormat, excel);
saveSaveBlob(text, EXPORT_FILENAME);
}
@ -115,7 +115,7 @@ export function convertSeriesListToCsvColumns(seriesList, dateTimeFormat = DEFAU
function mergeSeriesByTime(seriesList) {
let timestamps = [];
for (let i = 0; i < seriesList.length; i++) {
let seriesPoints = seriesList[i].datapoints;
const seriesPoints = seriesList[i].datapoints;
for (let j = 0; j < seriesPoints.length; j++) {
timestamps.push(seriesPoints[j][POINT_TIME_INDEX]);
}
@ -123,9 +123,9 @@ function mergeSeriesByTime(seriesList) {
timestamps = sortedUniq(timestamps.sort());
for (let i = 0; i < seriesList.length; i++) {
let seriesPoints = seriesList[i].datapoints;
let seriesTimestamps = seriesPoints.map(p => p[POINT_TIME_INDEX]);
let extendedSeries = [];
const seriesPoints = seriesList[i].datapoints;
const seriesTimestamps = seriesPoints.map(p => p[POINT_TIME_INDEX]);
const extendedSeries = [];
let pointIndex;
for (let j = 0; j < timestamps.length; j++) {
pointIndex = sortedIndexOf(seriesTimestamps, timestamps[j]);
@ -141,7 +141,7 @@ function mergeSeriesByTime(seriesList) {
}
export function exportSeriesListToCsvColumns(seriesList, dateTimeFormat = DEFAULT_DATETIME_FORMAT, excel = false) {
let text = convertSeriesListToCsvColumns(seriesList, dateTimeFormat, excel);
const text = convertSeriesListToCsvColumns(seriesList, dateTimeFormat, excel);
saveSaveBlob(text, EXPORT_FILENAME);
}
@ -157,11 +157,11 @@ export function convertTableDataToCsv(table, excel = false) {
}
export function exportTableDataToCsv(table, excel = false) {
let text = convertTableDataToCsv(table, excel);
const text = convertTableDataToCsv(table, excel);
saveSaveBlob(text, EXPORT_FILENAME);
}
export function saveSaveBlob(payload, fname) {
let blob = new Blob([payload], { type: 'text/csv;charset=utf-8;header=present;' });
const blob = new Blob([payload], { type: 'text/csv;charset=utf-8;header=present;' });
saveAs(blob, fname);
}

@ -1,6 +1,6 @@
// based on http://www.paciellogroup.com/blog/2012/04/how-to-remove-css-outlines-in-an-accessible-manner/
function outlineFixer() {
let d: any = document;
const d: any = document;
var style_element = d.createElement('STYLE');
var dom_events = 'addEventListener' in d;

@ -92,7 +92,7 @@ function formatDate(date) {
// now/d
// if no to <expr> then to now is assumed
export function describeTextRange(expr: any) {
let isLast = expr.indexOf('+') !== 0;
const isLast = expr.indexOf('+') !== 0;
if (expr.indexOf('now') === -1) {
expr = (isLast ? 'now-' : 'now') + expr;
}
@ -108,11 +108,11 @@ export function describeTextRange(expr: any) {
opt = { from: 'now', to: expr };
}
let parts = /^now([-+])(\d+)(\w)/.exec(expr);
const parts = /^now([-+])(\d+)(\w)/.exec(expr);
if (parts) {
let unit = parts[3];
let amount = parseInt(parts[2]);
let span = spans[unit];
const unit = parts[3];
const amount = parseInt(parts[2]);
const span = spans[unit];
if (span) {
opt.display = isLast ? 'Last ' : 'Next ';
opt.display += amount + ' ' + span.display;

@ -7,7 +7,7 @@ export default function sortByKeys(input) {
if (_.isPlainObject(input)) {
var sortedObject = {};
for (let key of _.keys(input).sort()) {
for (const key of _.keys(input).sort()) {
sortedObject[key] = sortByKeys(input[key]);
}
return sortedObject;

@ -67,9 +67,9 @@ const TAG_BORDER_COLORS = [
* @param name tag name
*/
export function getTagColorsFromName(name: string): { color: string; borderColor: string } {
let hash = djb2(name.toLowerCase());
let color = TAG_COLORS[Math.abs(hash % TAG_COLORS.length)];
let borderColor = TAG_BORDER_COLORS[Math.abs(hash % TAG_BORDER_COLORS.length)];
const hash = djb2(name.toLowerCase());
const color = TAG_COLORS[Math.abs(hash % TAG_COLORS.length)];
const borderColor = TAG_BORDER_COLORS[Math.abs(hash % TAG_BORDER_COLORS.length)];
return { color, borderColor };
}

@ -7,7 +7,7 @@
* @param count Ticks count
*/
export function tickStep(start: number, stop: number, count: number): number {
let e10 = Math.sqrt(50),
const e10 = Math.sqrt(50),
e5 = Math.sqrt(10),
e2 = Math.sqrt(2);
@ -76,7 +76,7 @@ export function getFlotRange(panelMin, panelMax, datamin, datamax) {
let min = +(panelMin != null ? panelMin : datamin);
let max = +(panelMax != null ? panelMax : datamax);
let delta = max - min;
const delta = max - min;
if (delta === 0.0) {
// Grafana fix: wide Y min and max using increased wideFactor
@ -123,11 +123,11 @@ export function getFlotTickDecimals(datamin, datamax, axis, height) {
const { min, max } = getFlotRange(axis.min, axis.max, datamin, datamax);
const noTicks = 0.3 * Math.sqrt(height);
const delta = (max - min) / noTicks;
let dec = -Math.floor(Math.log(delta) / Math.LN10);
const dec = -Math.floor(Math.log(delta) / Math.LN10);
let magn = Math.pow(10, -dec);
const magn = Math.pow(10, -dec);
// norm is between 1.0 and 10.0
let norm = delta / magn;
const norm = delta / magn;
let size;
if (norm < 1.5) {
@ -159,10 +159,10 @@ export function getFlotTickDecimals(datamin, datamax, axis, height) {
*/
export function grafanaTimeFormat(ticks, min, max) {
if (min && max && ticks) {
let range = max - min;
let secPerTick = range / ticks / 1000;
let oneDay = 86400000;
let oneYear = 31536000000;
const range = max - min;
const secPerTick = range / ticks / 1000;
const oneDay = 86400000;
const oneYear = 31536000000;
if (secPerTick <= 45) {
return '%H:%M:%S';
@ -193,7 +193,7 @@ export function logp(value, base) {
* Get decimal precision of number (3.14 => 2)
*/
export function getPrecision(num: number): number {
let str = num.toString();
const str = num.toString();
return getStringPrecision(str);
}
@ -201,7 +201,7 @@ export function getPrecision(num: number): number {
* Get decimal precision of number stored as a string ("3.14" => 2)
*/
export function getStringPrecision(num: string): number {
let dot_index = num.indexOf('.');
const dot_index = num.indexOf('.');
if (dot_index === -1) {
return 0;
} else {

@ -3,14 +3,14 @@
*/
export function toUrlParams(a) {
let s = [];
let rbracket = /\[\]$/;
const s = [];
const rbracket = /\[\]$/;
let isArray = function(obj) {
const isArray = function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
let add = function(k, v) {
const add = function(k, v) {
v = typeof v === 'function' ? v() : v === null ? '' : v === undefined ? '' : v;
if (typeof v !== 'boolean') {
s[s.length] = encodeURIComponent(k) + '=' + encodeURIComponent(v);
@ -19,7 +19,7 @@ export function toUrlParams(a) {
}
};
let buildParams = function(prefix, obj) {
const buildParams = function(prefix, obj) {
var i, len, key;
if (prefix) {

@ -9,7 +9,7 @@ export class SemVersion {
meta: string;
constructor(version: string) {
let match = versionPattern.exec(version);
const match = versionPattern.exec(version);
if (match) {
this.major = Number(match[1]);
this.minor = Number(match[2] || 0);
@ -19,7 +19,7 @@ export class SemVersion {
}
isGtOrEq(version: string): boolean {
let compared = new SemVersion(version);
const compared = new SemVersion(version);
return !(this.major < compared.major || this.minor < compared.minor || this.patch < compared.patch);
}
@ -29,6 +29,6 @@ export class SemVersion {
}
export function isVersionGtOrEq(a: string, b: string): boolean {
let a_semver = new SemVersion(a);
const a_semver = new SemVersion(a);
return a_semver.isGtOrEq(b);
}

@ -184,7 +184,7 @@ export class AlertTabCtrl {
ThresholdMapper.alertToGraphThresholds(this.panel);
for (let addedNotification of alert.notifications) {
for (const addedNotification of alert.notifications) {
var model = _.find(this.notifications, { id: addedNotification.id });
if (model && model.isDefault === false) {
model.iconClass = this.getNotificationIcon(model.type);
@ -192,7 +192,7 @@ export class AlertTabCtrl {
}
}
for (let notification of this.notifications) {
for (const notification of this.notifications) {
if (notification.isDefault) {
notification.iconClass = this.getNotificationIcon(notification.type);
notification.bgColor = '#00678b';

@ -30,7 +30,7 @@ export class AlertNotificationEditCtrl {
this.notifiers = notifiers;
// add option templates
for (let notifier of this.notifiers) {
for (const notifier of this.notifiers) {
this.$templateCache.put(this.getNotifierTemplateId(notifier.type), notifier.optionsTemplate);
}

@ -1,7 +1,7 @@
export class ThresholdMapper {
static alertToGraphThresholds(panel) {
for (var i = 0; i < panel.alert.conditions.length; i++) {
let condition = panel.alert.conditions[i];
const condition = panel.alert.conditions[i];
if (condition.type !== 'query') {
continue;
}
@ -11,18 +11,18 @@ export class ThresholdMapper {
switch (evaluator.type) {
case 'gt': {
let value = evaluator.params[0];
const value = evaluator.params[0];
thresholds.push({ value: value, op: 'gt' });
break;
}
case 'lt': {
let value = evaluator.params[0];
const value = evaluator.params[0];
thresholds.push({ value: value, op: 'lt' });
break;
}
case 'outside_range': {
let value1 = evaluator.params[0];
let value2 = evaluator.params[1];
const value1 = evaluator.params[0];
const value2 = evaluator.params[1];
if (value1 > value2) {
thresholds.push({ value: value1, op: 'gt' });
@ -35,8 +35,8 @@ export class ThresholdMapper {
break;
}
case 'within_range': {
let value1 = evaluator.params[0];
let value2 = evaluator.params[1];
const value1 = evaluator.params[0];
const value2 = evaluator.params[1];
if (value1 > value2) {
thresholds.push({ value: value1, op: 'lt' });

@ -91,7 +91,7 @@ export class AnnotationsSrv {
var range = this.timeSrv.timeRange();
var promises = [];
for (let annotation of dashboard.annotations.list) {
for (const annotation of dashboard.annotations.list) {
if (!annotation.enable) {
continue;
}

@ -31,7 +31,7 @@ export class EventEditorCtrl {
return;
}
let saveModel = _.cloneDeep(this.event);
const saveModel = _.cloneDeep(this.event);
saveModel.time = saveModel.time.valueOf();
saveModel.timeEnd = 0;
@ -85,7 +85,7 @@ export class EventEditorCtrl {
function tryEpochToMoment(timestamp) {
if (timestamp && _.isNumber(timestamp)) {
let epoch = Number(timestamp);
const epoch = Number(timestamp);
return moment(epoch);
} else {
return timestamp;

@ -125,11 +125,11 @@ export class EventManager {
}
}
let regions = getRegions(annotations);
const regions = getRegions(annotations);
addRegionMarking(regions, flotOptions);
let eventSectionHeight = 20;
let eventSectionMargin = 7;
const eventSectionHeight = 20;
const eventSectionMargin = 7;
flotOptions.grid.eventSectionHeight = eventSectionMargin;
flotOptions.xaxis.eventSectionHeight = eventSectionHeight;
@ -147,8 +147,8 @@ function getRegions(events) {
}
function addRegionMarking(regions, flotOptions) {
let markings = flotOptions.grid.markings;
let defaultColor = DEFAULT_ANNOTATION_COLOR;
const markings = flotOptions.grid.markings;
const defaultColor = DEFAULT_ANNOTATION_COLOR;
let fillColor;
_.each(regions, region => {
@ -167,7 +167,7 @@ function addRegionMarking(regions, flotOptions) {
}
function addAlphaToRGB(colorString: string, alpha: number): string {
let color = tinycolor(colorString);
const color = tinycolor(colorString);
if (color.isValid()) {
color.setAlpha(alpha);
return color.toRgbString();

@ -7,20 +7,20 @@ import _ from 'lodash';
* @param options
*/
export function makeRegions(annotations, options) {
let [regionEvents, singleEvents] = _.partition(annotations, 'regionId');
let regions = getRegions(regionEvents, options.range);
const [regionEvents, singleEvents] = _.partition(annotations, 'regionId');
const regions = getRegions(regionEvents, options.range);
annotations = _.concat(regions, singleEvents);
return annotations;
}
function getRegions(events, range) {
let region_events = _.filter(events, event => {
const region_events = _.filter(events, event => {
return event.regionId;
});
let regions = _.groupBy(region_events, 'regionId');
regions = _.compact(
_.map(regions, region_events => {
let region_obj = _.head(region_events);
const region_obj = _.head(region_events);
if (region_events && region_events.length > 1) {
region_obj.timeEnd = region_events[1].time;
region_obj.isRegion = true;
@ -57,9 +57,9 @@ export function dedupAnnotations(annotations) {
let dedup = [];
// Split events by annotationId property existence
let events = _.partition(annotations, 'id');
const events = _.partition(annotations, 'id');
let eventsById = _.groupBy(events[0], 'id');
const eventsById = _.groupBy(events[0], 'id');
dedup = _.map(eventsById, eventGroup => {
if (eventGroup.length > 1 && !_.every(eventGroup, isPanelAlert)) {
// Get first non-panel alert

@ -3,7 +3,7 @@ import 'app/features/dashboard/time_srv';
import { AnnotationsSrv } from '../annotations_srv';
describe('AnnotationsSrv', function() {
let $rootScope = {
const $rootScope = {
onAppEvent: jest.fn(),
};
let $q;
@ -11,7 +11,7 @@ describe('AnnotationsSrv', function() {
let backendSrv;
let timeSrv;
let annotationsSrv = new AnnotationsSrv($rootScope, $q, datasourceSrv, backendSrv, timeSrv);
const annotationsSrv = new AnnotationsSrv($rootScope, $q, datasourceSrv, backendSrv, timeSrv);
describe('When translating the query result', () => {
const annotationSource = {

@ -24,7 +24,7 @@ describe('Annotations', () => {
{ id: 2, time: 2 },
];
let regions = makeRegions(testAnnotations, { range: range });
const regions = makeRegions(testAnnotations, { range: range });
expect(regions).toEqual(expectedAnnotations);
});
@ -33,7 +33,7 @@ describe('Annotations', () => {
testAnnotations = [{ id: 5, time: 4, regionId: 5 }];
const expectedAnnotations = [{ id: 5, regionId: 5, isRegion: true, time: 4, timeEnd: 7 }];
let regions = makeRegions(testAnnotations, { range: range });
const regions = makeRegions(testAnnotations, { range: range });
expect(regions).toEqual(expectedAnnotations);
});
});
@ -49,7 +49,7 @@ describe('Annotations', () => {
];
const expectedAnnotations = [{ id: 1, time: 1 }, { id: 2, time: 2 }, { id: 5, time: 5 }];
let deduplicated = dedupAnnotations(testAnnotations);
const deduplicated = dedupAnnotations(testAnnotations);
expect(deduplicated).toEqual(expectedAnnotations);
});
@ -63,7 +63,7 @@ describe('Annotations', () => {
];
const expectedAnnotations = [{ id: 1, time: 1 }, { id: 2, time: 2 }, { id: 5, time: 5 }];
let deduplicated = dedupAnnotations(testAnnotations);
const deduplicated = dedupAnnotations(testAnnotations);
expect(deduplicated).toEqual(expectedAnnotations);
});
});

@ -30,7 +30,7 @@ export class AdHocFiltersCtrl {
if (this.variable.value && !_.isArray(this.variable.value)) {
}
for (let tag of this.variable.filters) {
for (const tag of this.variable.filters) {
if (this.segments.length > 0) {
this.segments.push(this.uiSegmentSrv.newCondition('AND'));
}

@ -94,13 +94,13 @@ export class ChangeTracker {
// remove stuff that should not count in diff
cleanDashboardFromIgnoredChanges(dashData) {
// need to new up the domain model class to get access to expand / collapse row logic
let model = new DashboardModel(dashData);
const model = new DashboardModel(dashData);
// Expand all rows before making comparison. This is required because row expand / collapse
// change order of panel array and panel positions.
model.expandRows();
let dash = model.getSaveModelClone();
const dash = model.getSaveModelClone();
// ignore time and refresh
dash.time = 0;
@ -138,8 +138,8 @@ export class ChangeTracker {
}
hasChanges() {
let current = this.cleanDashboardFromIgnoredChanges(this.current.getSaveModelClone());
let original = this.cleanDashboardFromIgnoredChanges(this.original);
const current = this.cleanDashboardFromIgnoredChanges(this.current.getSaveModelClone());
const original = this.cleanDashboardFromIgnoredChanges(this.original);
var currentTimepicker = _.find(current.nav, { type: 'timepicker' });
var originalTimepicker = _.find(original.nav, { type: 'timepicker' });

@ -51,7 +51,7 @@ export class DashboardImportCtrl {
this.inputs = [];
if (this.dash.__inputs) {
for (let input of this.dash.__inputs) {
for (const input of this.dash.__inputs) {
var inputModel = {
name: input.name,
label: input.label,
@ -95,7 +95,7 @@ export class DashboardImportCtrl {
inputValueChanged() {
this.inputsValid = true;
for (let input of this.inputs) {
for (const input of this.inputs) {
if (!input.value) {
this.inputsValid = false;
}

@ -389,7 +389,7 @@ export class DashboardMigrator {
upgradeToGridLayout(old) {
let yPos = 0;
let widthFactor = GRID_COLUMN_COUNT / 12;
const widthFactor = GRID_COLUMN_COUNT / 12;
const maxPanelId = _.max(
_.flattenDeep(
@ -407,15 +407,15 @@ export class DashboardMigrator {
// Add special "row" panels if even one row is collapsed, repeated or has visible title
const showRows = _.some(old.rows, row => row.collapse || row.showTitle || row.repeat);
for (let row of old.rows) {
for (const row of old.rows) {
if (row.repeatIteration) {
continue;
}
let height: any = row.height || DEFAULT_ROW_HEIGHT;
const height: any = row.height || DEFAULT_ROW_HEIGHT;
const rowGridHeight = getGridHeight(height);
let rowPanel: any = {};
const rowPanel: any = {};
let rowPanelModel: PanelModel;
if (showRows) {
// add special row panel
@ -436,9 +436,9 @@ export class DashboardMigrator {
yPos++;
}
let rowArea = new RowArea(rowGridHeight, GRID_COLUMN_COUNT, yPos);
const rowArea = new RowArea(rowGridHeight, GRID_COLUMN_COUNT, yPos);
for (let panel of row.panels) {
for (const panel of row.panels) {
panel.span = panel.span || DEFAULT_PANEL_SPAN;
if (panel.minSpan) {
panel.minSpan = Math.min(GRID_COLUMN_COUNT, GRID_COLUMN_COUNT / 12 * panel.minSpan);
@ -446,7 +446,7 @@ export class DashboardMigrator {
const panelWidth = Math.floor(panel.span) * widthFactor;
const panelHeight = panel.height ? getGridHeight(panel.height) : rowGridHeight;
let panelPos = rowArea.getPanelPosition(panelHeight, panelWidth);
const panelPos = rowArea.getPanelPosition(panelHeight, panelWidth);
yPos = rowArea.yPos;
panel.gridPos = {
x: panelPos.x,

@ -95,7 +95,7 @@ export class DashboardModel {
addBuiltInAnnotationQuery() {
let found = false;
for (let item of this.annotations.list) {
for (const item of this.annotations.list) {
if (item.builtIn === 1) {
found = true;
break;
@ -138,7 +138,7 @@ export class DashboardModel {
// cleans meta data and other non persistent state
getSaveModelClone(options?) {
let defaults = _.defaults(options || {}, {
const defaults = _.defaults(options || {}, {
saveVariables: true,
saveTimerange: true,
});
@ -160,8 +160,8 @@ export class DashboardModel {
if (!defaults.saveVariables) {
for (let i = 0; i < copy.templating.list.length; i++) {
let current = copy.templating.list[i];
let original = _.find(this.originalTemplating, { name: current.name, type: current.type });
const current = copy.templating.list[i];
const original = _.find(this.originalTemplating, { name: current.name, type: current.type });
if (!original) {
continue;
@ -213,13 +213,13 @@ export class DashboardModel {
getNextPanelId() {
let max = 0;
for (let panel of this.panels) {
for (const panel of this.panels) {
if (panel.id > max) {
max = panel.id;
}
if (panel.collapsed) {
for (let rowPanel of panel.panels) {
for (const rowPanel of panel.panels) {
if (rowPanel.id > max) {
max = rowPanel.id;
}
@ -237,7 +237,7 @@ export class DashboardModel {
}
getPanelById(id) {
for (let panel of this.panels) {
for (const panel of this.panels) {
if (panel.id === id) {
return panel;
}
@ -248,7 +248,7 @@ export class DashboardModel {
addPanel(panelData) {
panelData.id = this.getNextPanelId();
let panel = new PanelModel(panelData);
const panel = new PanelModel(panelData);
this.panels.unshift(panel);
@ -273,15 +273,15 @@ export class DashboardModel {
}
this.iteration = (this.iteration || new Date().getTime()) + 1;
let panelsToRemove = [];
const panelsToRemove = [];
// cleanup scopedVars
for (let panel of this.panels) {
for (const panel of this.panels) {
delete panel.scopedVars;
}
for (let i = 0; i < this.panels.length; i++) {
let panel = this.panels[i];
const panel = this.panels[i];
if ((!panel.repeat || panel.repeatedByRow) && panel.repeatPanelId && panel.repeatIteration !== this.iteration) {
panelsToRemove.push(panel);
}
@ -304,7 +304,7 @@ export class DashboardModel {
this.iteration = (this.iteration || new Date().getTime()) + 1;
for (let i = 0; i < this.panels.length; i++) {
let panel = this.panels[i];
const panel = this.panels[i];
if (panel.repeat) {
this.repeatPanel(panel, i);
}
@ -315,9 +315,9 @@ export class DashboardModel {
}
cleanUpRowRepeats(rowPanels) {
let panelsToRemove = [];
const panelsToRemove = [];
for (let i = 0; i < rowPanels.length; i++) {
let panel = rowPanels[i];
const panel = rowPanels[i];
if (!panel.repeat && panel.repeatPanelId) {
panelsToRemove.push(panel);
}
@ -333,16 +333,16 @@ export class DashboardModel {
let rowPanels = row.panels;
if (!row.collapsed) {
let rowPanelIndex = _.findIndex(this.panels, p => p.id === row.id);
const rowPanelIndex = _.findIndex(this.panels, p => p.id === row.id);
rowPanels = this.getRowPanels(rowPanelIndex);
}
this.cleanUpRowRepeats(rowPanels);
for (let i = 0; i < rowPanels.length; i++) {
let panel = rowPanels[i];
const panel = rowPanels[i];
if (panel.repeat) {
let panelIndex = _.findIndex(this.panels, p => p.id === panel.id);
const panelIndex = _.findIndex(this.panels, p => p.id === panel.id);
this.repeatPanel(panel, panelIndex);
}
}
@ -354,7 +354,7 @@ export class DashboardModel {
return sourcePanel;
}
let clone = new PanelModel(sourcePanel.getSaveModel());
const clone = new PanelModel(sourcePanel.getSaveModel());
clone.id = this.getNextPanelId();
// insert after source panel + value index
@ -370,13 +370,13 @@ export class DashboardModel {
// if first clone return source
if (valueIndex === 0) {
if (!sourceRowPanel.collapsed) {
let rowPanels = this.getRowPanels(sourcePanelIndex);
const rowPanels = this.getRowPanels(sourcePanelIndex);
sourceRowPanel.panels = rowPanels;
}
return sourceRowPanel;
}
let clone = new PanelModel(sourceRowPanel.getSaveModel());
const clone = new PanelModel(sourceRowPanel.getSaveModel());
// for row clones we need to figure out panels under row to clone and where to insert clone
let rowPanels, insertPos;
if (sourceRowPanel.collapsed) {
@ -397,7 +397,7 @@ export class DashboardModel {
}
repeatPanel(panel: PanelModel, panelIndex: number) {
let variable = _.find(this.templating.list, { name: panel.repeat });
const variable = _.find(this.templating.list, { name: panel.repeat });
if (!variable) {
return;
}
@ -407,13 +407,13 @@ export class DashboardModel {
return;
}
let selectedOptions = this.getSelectedVariableOptions(variable);
let minWidth = panel.minSpan || 6;
const selectedOptions = this.getSelectedVariableOptions(variable);
const minWidth = panel.minSpan || 6;
let xPos = 0;
let yPos = panel.gridPos.y;
for (let index = 0; index < selectedOptions.length; index++) {
let option = selectedOptions[index];
const option = selectedOptions[index];
let copy;
copy = this.getPanelRepeatClone(panel, index, panelIndex);
@ -443,9 +443,9 @@ export class DashboardModel {
}
// Update gridPos for panels below
let yOffset = yPos - panel.gridPos.y;
const yOffset = yPos - panel.gridPos.y;
if (yOffset > 0) {
let panelBelowIndex = panelIndex + selectedOptions.length;
const panelBelowIndex = panelIndex + selectedOptions.length;
for (let i = panelBelowIndex; i < this.panels.length; i++) {
this.panels[i].gridPos.y += yOffset;
}
@ -453,7 +453,7 @@ export class DashboardModel {
}
repeatRow(panel: PanelModel, panelIndex: number, variable) {
let selectedOptions = this.getSelectedVariableOptions(variable);
const selectedOptions = this.getSelectedVariableOptions(variable);
let yPos = panel.gridPos.y;
function setScopedVars(panel, variableOption) {
@ -462,12 +462,12 @@ export class DashboardModel {
}
for (let optionIndex = 0; optionIndex < selectedOptions.length; optionIndex++) {
let option = selectedOptions[optionIndex];
let rowCopy = this.getRowRepeatClone(panel, optionIndex, panelIndex);
const option = selectedOptions[optionIndex];
const rowCopy = this.getRowRepeatClone(panel, optionIndex, panelIndex);
setScopedVars(rowCopy, option);
let rowHeight = this.getRowHeight(rowCopy);
let rowPanels = rowCopy.panels || [];
const rowHeight = this.getRowHeight(rowCopy);
const rowPanels = rowCopy.panels || [];
let panelBelowIndex;
if (panel.collapsed) {
@ -483,11 +483,11 @@ export class DashboardModel {
panelBelowIndex = panelIndex + optionIndex + 1;
} else {
// insert after 'row' panel
let insertPos = panelIndex + (rowPanels.length + 1) * optionIndex + 1;
const insertPos = panelIndex + (rowPanels.length + 1) * optionIndex + 1;
_.each(rowPanels, (rowPanel, i) => {
setScopedVars(rowPanel, option);
if (optionIndex > 0) {
let cloneRowPanel = new PanelModel(rowPanel);
const cloneRowPanel = new PanelModel(rowPanel);
this.updateRepeatedPanelIds(cloneRowPanel, true);
// For exposed row additionally set proper Y grid position and add it to dashboard panels
cloneRowPanel.gridPos.y += rowHeight * optionIndex;
@ -650,29 +650,29 @@ export class DashboardModel {
formatDate(date, format?) {
date = moment.isMoment(date) ? date : moment(date);
format = format || 'YYYY-MM-DD HH:mm:ss';
let timezone = this.getTimezone();
const timezone = this.getTimezone();
return timezone === 'browser' ? moment(date).format(format) : moment.utc(date).format(format);
}
destroy() {
this.events.removeAllListeners();
for (let panel of this.panels) {
for (const panel of this.panels) {
panel.destroy();
}
}
toggleRow(row: PanelModel) {
let rowIndex = _.indexOf(this.panels, row);
const rowIndex = _.indexOf(this.panels, row);
if (row.collapsed) {
row.collapsed = false;
let hasRepeat = _.some(row.panels, p => p.repeat);
const hasRepeat = _.some(row.panels, p => p.repeat);
if (row.panels.length > 0) {
// Use first panel to figure out if it was moved or pushed
let firstPanel = row.panels[0];
let yDiff = firstPanel.gridPos.y - (row.gridPos.y + row.gridPos.h);
const firstPanel = row.panels[0];
const yDiff = firstPanel.gridPos.y - (row.gridPos.y + row.gridPos.h);
// start inserting after row
let insertPos = rowIndex + 1;
@ -680,7 +680,7 @@ export class DashboardModel {
// needed to know home much panels below should be pushed down
let yMax = row.gridPos.y;
for (let panel of row.panels) {
for (const panel of row.panels) {
// make sure y is adjusted (in case row moved while collapsed)
// console.log('yDiff', yDiff);
panel.gridPos.y -= yDiff;
@ -713,7 +713,7 @@ export class DashboardModel {
return;
}
let rowPanels = this.getRowPanels(rowIndex);
const rowPanels = this.getRowPanels(rowIndex);
// remove panels
_.pull(this.panels, ...rowPanels);
@ -729,10 +729,10 @@ export class DashboardModel {
* Will return all panels after rowIndex until it encounters another row
*/
getRowPanels(rowIndex: number): PanelModel[] {
let rowPanels = [];
const rowPanels = [];
for (let index = rowIndex + 1; index < this.panels.length; index++) {
let panel = this.panels[index];
const panel = this.panels[index];
// break when encountering another row
if (panel.type === 'row') {
@ -791,7 +791,7 @@ export class DashboardModel {
}
private updateSchema(old) {
let migrator = new DashboardMigrator(this);
const migrator = new DashboardMigrator(this);
migrator.updateSchema(old);
}

@ -68,18 +68,18 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
}
getCopiedPanelPlugins(filter) {
let panels = _.chain(config.panels)
const panels = _.chain(config.panels)
.filter({ hideFromList: false })
.map(item => item)
.value();
let copiedPanels = [];
let copiedPanelJson = store.get(LS_PANEL_COPY_KEY);
const copiedPanelJson = store.get(LS_PANEL_COPY_KEY);
if (copiedPanelJson) {
let copiedPanel = JSON.parse(copiedPanelJson);
let pluginInfo = _.find(panels, { id: copiedPanel.type });
const copiedPanel = JSON.parse(copiedPanelJson);
const pluginInfo = _.find(panels, { id: copiedPanel.type });
if (pluginInfo) {
let pluginCopy = _.cloneDeep(pluginInfo);
const pluginCopy = _.cloneDeep(pluginInfo);
pluginCopy.name = copiedPanel.title;
pluginCopy.sort = -1;
pluginCopy.defaults = copiedPanel;
@ -129,7 +129,7 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
}
renderText(text: string) {
let searchWords = this.state.filter.split('');
const searchWords = this.state.filter.split('');
return <Highlighter highlightClassName="highlight-search-match" textToHighlight={text} searchWords={searchWords} />;
}
@ -156,7 +156,7 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
filterKeyPress(evt) {
if (evt.key === 'Enter') {
let panel = _.head(this.state.panelPlugins);
const panel = _.head(this.state.panelPlugins);
if (panel) {
this.onAddPanel(panel);
}
@ -164,7 +164,7 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
}
filterPanels(panels, filter) {
let regex = new RegExp(filter, 'i');
const regex = new RegExp(filter, 'i');
return panels.filter(panel => {
return regex.test(panel.name);
});
@ -189,12 +189,12 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
}
render() {
let addClass = classNames({
const addClass = classNames({
'active active--panel': this.state.tab === 'Add',
'': this.state.tab === 'Copy',
});
let copyClass = classNames({
const copyClass = classNames({
'': this.state.tab === 'Add',
'active active--panel': this.state.tab === 'Copy',
});

@ -94,8 +94,8 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
const layout = [];
this.panelMap = {};
for (let panel of this.dashboard.panels) {
let stringId = panel.id.toString();
for (const panel of this.dashboard.panels) {
const stringId = panel.id.toString();
this.panelMap[stringId] = panel;
if (!panel.gridPos) {
@ -103,7 +103,7 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
continue;
}
let panelPos: any = {
const panelPos: any = {
i: stringId,
x: panel.gridPos.x,
y: panel.gridPos.y,
@ -174,7 +174,7 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
renderPanels() {
const panelElements = [];
for (let panel of this.dashboard.panels) {
for (const panel of this.dashboard.panels) {
const panelClasses = classNames({ panel: true, 'panel--fullscreen': panel.fullscreen });
panelElements.push(
<div key={panel.id.toString()} className={panelClasses}>

@ -22,7 +22,7 @@ export class DashNavCtrl {
}
toggleSettings() {
let search = this.$location.search();
const search = this.$location.search();
if (search.editview) {
delete search.editview;
} else {
@ -32,7 +32,7 @@ export class DashNavCtrl {
}
close() {
let search = this.$location.search();
const search = this.$location.search();
if (search.editview) {
delete search.editview;
} else if (search.fullscreen) {

@ -29,7 +29,7 @@ export class DashExportCtrl {
saveJson() {
var clone = this.dash;
let editScope = this.$rootScope.$new();
const editScope = this.$rootScope.$new();
editScope.object = clone;
editScope.enableCopy = true;

@ -24,7 +24,7 @@ export class DashboardExporter {
var promises = [];
var variableLookup: any = {};
for (let variable of saveModel.templating.list) {
for (const variable of saveModel.templating.list) {
variableLookup[variable.name] = variable;
}
@ -69,7 +69,7 @@ export class DashboardExporter {
}
if (panel.targets) {
for (let target of panel.targets) {
for (const target of panel.targets) {
if (target.datasource !== undefined) {
templateizeDatasourceUsage(target);
}
@ -88,19 +88,19 @@ export class DashboardExporter {
};
// check up panel data sources
for (let panel of saveModel.panels) {
for (const panel of saveModel.panels) {
processPanel(panel);
// handle collapsed rows
if (panel.collapsed !== undefined && panel.collapsed === true && panel.panels) {
for (let rowPanel of panel.panels) {
for (const rowPanel of panel.panels) {
processPanel(rowPanel);
}
}
}
// templatize template vars
for (let variable of saveModel.templating.list) {
for (const variable of saveModel.templating.list) {
if (variable.type === 'query') {
templateizeDatasourceUsage(variable);
variable.options = [];
@ -110,7 +110,7 @@ export class DashboardExporter {
}
// templatize annotations vars
for (let annotationDef of saveModel.annotations.list) {
for (const annotationDef of saveModel.annotations.list) {
templateizeDatasourceUsage(annotationDef);
}
@ -129,7 +129,7 @@ export class DashboardExporter {
});
// templatize constants
for (let variable of saveModel.templating.list) {
for (const variable of saveModel.templating.list) {
if (variable.type === 'constant') {
var refName = 'VAR_' + variable.name.replace(' ', '_').toUpperCase();
inputs.push({

@ -67,7 +67,7 @@ export class HistoryListCtrl {
}
revisionSelectionChanged() {
let selected = _.filter(this.revisions, { checked: true }).length;
const selected = _.filter(this.revisions, { checked: true }).length;
this.canCompare = selected === 2;
}
@ -134,7 +134,7 @@ export class HistoryListCtrl {
.getHistoryList(this.dashboard, options)
.then(revisions => {
// set formatted dates & default values
for (let rev of revisions) {
for (const rev of revisions) {
rev.createdDateString = this.formatDate(rev.created);
rev.ageString = this.formatBasicDate(rev.created);
rev.checked = false;

@ -109,7 +109,7 @@ export class SettingsCtrl {
const params = this.$location.search();
const url = this.$location.path();
for (let section of this.sections) {
for (const section of this.sections) {
const sectionParams = _.defaults({ editview: section.id }, params);
section.url = config.appSubUrl + url + '?' + $.param(sectionParams);
}

@ -91,7 +91,7 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv,
// This function will try to return the proper full name of the local timezone
// Chrome does not handle the timezone offset (but phantomjs does)
$scope.getLocalTimeZone = function() {
let utcOffset = '&tz=UTC' + encodeURIComponent(moment().format('Z'));
const utcOffset = '&tz=UTC' + encodeURIComponent(moment().format('Z'));
// Older browser does not the internationalization API
if (!(<any>window).Intl) {

@ -151,18 +151,18 @@ describe('DashboardModel', function() {
it('should create proper grid', function() {
model.rows = [createRow({ collapse: false, height: 8 }, [[6], [6]])];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [{ x: 0, y: 0, w: 12, h: 8 }, { x: 12, y: 0, w: 12, h: 8 }];
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [{ x: 0, y: 0, w: 12, h: 8 }, { x: 12, y: 0, w: 12, h: 8 }];
expect(panelGridPos).toEqual(expectedGrid);
});
it('should add special "row" panel if row is collapsed', function() {
model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]]), createRow({ height: 8 }, [[12]])];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 24, h: 8 }, // row
{ x: 0, y: 1, w: 24, h: 8 }, // row
{ x: 0, y: 2, w: 24, h: 8 },
@ -176,9 +176,9 @@ describe('DashboardModel', function() {
createRow({ showTitle: true, title: 'Row', height: 8 }, [[6], [6]]),
createRow({ height: 8 }, [[12]]),
];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 24, h: 8 }, // row
{ x: 0, y: 1, w: 12, h: 8 },
{ x: 12, y: 1, w: 12, h: 8 },
@ -196,9 +196,9 @@ describe('DashboardModel', function() {
createRow({ height: 8 }, [[12], [6], [6]]),
createRow({ collapse: true, height: 8 }, [[12]]),
];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 24, h: 8 }, // row
{ x: 0, y: 1, w: 24, h: 8 }, // row
{ x: 0, y: 2, w: 24, h: 8 },
@ -214,9 +214,9 @@ describe('DashboardModel', function() {
it('should add all rows if even one collapsed or titled row is present', function() {
model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]]), createRow({ height: 8 }, [[12]])];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 24, h: 8 }, // row
{ x: 0, y: 1, w: 24, h: 8 }, // row
{ x: 0, y: 2, w: 24, h: 8 },
@ -230,9 +230,9 @@ describe('DashboardModel', function() {
createRow({ height: 6 }, [[6], [6, 3], [6, 3]]),
createRow({ height: 6 }, [[4], [4], [4, 3], [4, 3]]),
];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 12, h: 6 },
{ x: 12, y: 0, w: 12, h: 3 },
{ x: 12, y: 3, w: 12, h: 3 },
@ -247,9 +247,9 @@ describe('DashboardModel', function() {
it('should place panel to the right side of panel having bigger height', function() {
model.rows = [createRow({ height: 6 }, [[4], [2, 3], [4, 6], [2, 3], [2, 3]])];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 8, h: 6 },
{ x: 8, y: 0, w: 4, h: 3 },
{ x: 12, y: 0, w: 8, h: 6 },
@ -262,9 +262,9 @@ describe('DashboardModel', function() {
it('should fill current row if it possible', function() {
model.rows = [createRow({ height: 9 }, [[4], [2, 3], [4, 6], [2, 3], [2, 3], [8, 3]])];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 8, h: 9 },
{ x: 8, y: 0, w: 4, h: 3 },
{ x: 12, y: 0, w: 8, h: 6 },
@ -278,9 +278,9 @@ describe('DashboardModel', function() {
it('should fill current row if it possible (2)', function() {
model.rows = [createRow({ height: 8 }, [[4], [2, 3], [4, 6], [2, 3], [2, 3], [8, 3]])];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 8, h: 8 },
{ x: 8, y: 0, w: 4, h: 3 },
{ x: 12, y: 0, w: 8, h: 6 },
@ -294,9 +294,9 @@ describe('DashboardModel', function() {
it('should fill current row if panel height more than row height', function() {
model.rows = [createRow({ height: 6 }, [[4], [2, 3], [4, 8], [2, 3], [2, 3]])];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 8, h: 6 },
{ x: 8, y: 0, w: 4, h: 3 },
{ x: 12, y: 0, w: 8, h: 8 },
@ -309,9 +309,9 @@ describe('DashboardModel', function() {
it('should wrap panels to multiple rows', function() {
model.rows = [createRow({ height: 6 }, [[6], [6], [12], [6], [3], [3]])];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 12, h: 6 },
{ x: 12, y: 0, w: 12, h: 6 },
{ x: 0, y: 6, w: 24, h: 6 },
@ -328,9 +328,9 @@ describe('DashboardModel', function() {
createRow({ showTitle: true, title: 'Row', height: 8, repeat: 'server' }, [[6]]),
createRow({ height: 8 }, [[12]]),
];
let dashboard = new DashboardModel(model);
let panelGridPos = getGridPositions(dashboard);
let expectedGrid = [
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [
{ x: 0, y: 0, w: 24, h: 8 },
{ x: 0, y: 1, w: 12, h: 8 },
{ x: 0, y: 9, w: 24, h: 8 },
@ -359,7 +359,7 @@ describe('DashboardModel', function() {
),
];
let dashboard = new DashboardModel(model);
const dashboard = new DashboardModel(model);
expect(dashboard.panels[0].repeat).toBe('server');
expect(dashboard.panels.length).toBe(2);
});
@ -368,7 +368,7 @@ describe('DashboardModel', function() {
model.rows = [createRow({ height: 8 }, [[6]])];
model.rows[0].panels[0] = { minSpan: 12 };
let dashboard = new DashboardModel(model);
const dashboard = new DashboardModel(model);
expect(dashboard.panels[0].minSpan).toBe(24);
});
@ -376,7 +376,7 @@ describe('DashboardModel', function() {
model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]])];
model.rows[0].panels[0] = {};
let dashboard = new DashboardModel(model);
const dashboard = new DashboardModel(model);
expect(dashboard.panels[0].id).toBe(1);
});
});
@ -386,15 +386,15 @@ function createRow(options, panelDescriptions: any[]) {
const PANEL_HEIGHT_STEP = GRID_CELL_HEIGHT + GRID_CELL_VMARGIN;
let { collapse, height, showTitle, title, repeat, repeatIteration } = options;
height = height * PANEL_HEIGHT_STEP;
let panels = [];
const panels = [];
_.each(panelDescriptions, panelDesc => {
let panel = { span: panelDesc[0] };
const panel = { span: panelDesc[0] };
if (panelDesc.length > 1) {
panel['height'] = panelDesc[1] * PANEL_HEIGHT_STEP;
}
panels.push(panel);
});
let row = {
const row = {
collapse,
height,
showTitle,

@ -457,16 +457,16 @@ describe('DashboardModel', function() {
});
it('getSaveModelClone should return original time when saveTimerange=false', () => {
let options = { saveTimerange: false };
let saveModel = model.getSaveModelClone(options);
const options = { saveTimerange: false };
const saveModel = model.getSaveModelClone(options);
expect(saveModel.time.from).toBe('now-6h');
expect(saveModel.time.to).toBe('now');
});
it('getSaveModelClone should return updated time when saveTimerange=true', () => {
let options = { saveTimerange: true };
let saveModel = model.getSaveModelClone(options);
const options = { saveTimerange: true };
const saveModel = model.getSaveModelClone(options);
expect(saveModel.time.from).toBe('now-3h');
expect(saveModel.time.to).toBe('now-1h');
@ -478,16 +478,16 @@ describe('DashboardModel', function() {
});
it('getSaveModelClone should return original time when saveTimerange=false', () => {
let options = { saveTimerange: false };
let saveModel = model.getSaveModelClone(options);
const options = { saveTimerange: false };
const saveModel = model.getSaveModelClone(options);
expect(saveModel.time.from).toBe('now-6h');
expect(saveModel.time.to).toBe('now');
});
it('getSaveModelClone should return updated time when saveTimerange=true', () => {
let options = { saveTimerange: true };
let saveModel = model.getSaveModelClone(options);
const options = { saveTimerange: true };
const saveModel = model.getSaveModelClone(options);
expect(saveModel.time.from).toBe('now-3h');
expect(saveModel.time.to).toBe('now-1h');
@ -542,8 +542,8 @@ describe('DashboardModel', function() {
it('getSaveModelClone should return original variable when saveVariables=false', () => {
model.templating.list[0].current.text = 'server_002';
let options = { saveVariables: false };
let saveModel = model.getSaveModelClone(options);
const options = { saveVariables: false };
const saveModel = model.getSaveModelClone(options);
expect(saveModel.templating.list[0].current.text).toBe('server_001');
});
@ -551,8 +551,8 @@ describe('DashboardModel', function() {
it('getSaveModelClone should return updated variable when saveVariables=true', () => {
model.templating.list[0].current.text = 'server_002';
let options = { saveVariables: true };
let saveModel = model.getSaveModelClone(options);
const options = { saveVariables: true };
const saveModel = model.getSaveModelClone(options);
expect(saveModel.templating.list[0].current.text).toBe('server_002');
});
@ -620,8 +620,8 @@ describe('DashboardModel', function() {
it('getSaveModelClone should return original variable when saveVariables=false', () => {
model.templating.list[0].filters[0].value = 'server 1';
let options = { saveVariables: false };
let saveModel = model.getSaveModelClone(options);
const options = { saveVariables: false };
const saveModel = model.getSaveModelClone(options);
expect(saveModel.templating.list[0].filters[0].value).toBe('server 20');
});
@ -629,8 +629,8 @@ describe('DashboardModel', function() {
it('getSaveModelClone should return updated variable when saveVariables=true', () => {
model.templating.list[0].filters[0].value = 'server 1';
let options = { saveVariables: true };
let saveModel = model.getSaveModelClone(options);
const options = { saveVariables: true };
const saveModel = model.getSaveModelClone(options);
expect(saveModel.templating.list[0].filters[0].value).toBe('server 1');
});

@ -70,7 +70,7 @@ describe('HistoryListCtrl', () => {
});
it('should add a checked property to each revision', () => {
let actual = _.filter(historyListCtrl.revisions, rev => rev.hasOwnProperty('checked'));
const actual = _.filter(historyListCtrl.revisions, rev => rev.hasOwnProperty('checked'));
expect(actual.length).toBe(4);
});
@ -78,7 +78,7 @@ describe('HistoryListCtrl', () => {
historyListCtrl.revisions[0].checked = true;
historyListCtrl.revisions[2].checked = true;
historyListCtrl.reset();
let actual = _.filter(historyListCtrl.revisions, rev => !rev.checked);
const actual = _.filter(historyListCtrl.revisions, rev => !rev.checked);
expect(actual.length).toBe(4);
});
});

@ -8,7 +8,7 @@ describe('historySrv', function() {
const versionsResponse = versions();
const restoreResponse = restore;
let backendSrv = {
const backendSrv = {
get: jest.fn(() => Promise.resolve({})),
post: jest.fn(() => Promise.resolve({})),
};
@ -44,7 +44,7 @@ describe('historySrv', function() {
describe('restoreDashboard', () => {
it('should return a success response given valid parameters', function() {
let version = 6;
const version = 6;
backendSrv.post = jest.fn(() => Promise.resolve(restoreResponse(version)));
historySrv = new HistorySrv(backendSrv);
return historySrv.restoreDashboard(dash, version).then(function(response) {
@ -54,7 +54,7 @@ describe('historySrv', function() {
it('should return an empty object when not given an id', async () => {
historySrv = new HistorySrv(backendSrv);
let rsp = await historySrv.restoreDashboard(emptyDash, 6);
const rsp = await historySrv.restoreDashboard(emptyDash, 6);
expect(rsp).toEqual({});
});
});

@ -8,7 +8,7 @@ describe('given dashboard with panel repeat', function() {
var dashboard;
beforeEach(function() {
let dashboardJSON = {
const dashboardJSON = {
panels: [
{ id: 1, type: 'row', gridPos: { x: 0, y: 0, h: 1, w: 24 } },
{ id: 2, repeat: 'apps', repeatDirection: 'h', gridPos: { x: 0, y: 1, h: 2, w: 8 } },

@ -4,12 +4,12 @@ import config from 'app/core/config';
import { DashboardViewState } from '../view_state_srv';
describe('when updating view state', () => {
let location = {
const location = {
replace: jest.fn(),
search: jest.fn(),
};
let $scope = {
const $scope = {
onAppEvent: jest.fn(() => {}),
dashboard: {
meta: {},
@ -17,7 +17,7 @@ describe('when updating view state', () => {
},
};
let $rootScope = {};
const $rootScope = {};
let viewState;
beforeEach(() => {

@ -37,7 +37,7 @@ export class ValidationSrv {
});
}
let deferred = this.$q.defer();
const deferred = this.$q.defer();
const promises = [];
promises.push(this.backendSrv.search({ type: hitTypes.FOLDER, folderIds: [folderId], query: name }));
@ -54,7 +54,7 @@ export class ValidationSrv {
hits = hits.concat(res[1]);
}
for (let hit of hits) {
for (const hit of hits) {
if (nameLowerCased === hit.title.toLowerCase()) {
deferred.reject({
type: 'EXISTING',

@ -111,9 +111,9 @@ export class DashboardViewState {
}
toggleCollapsedPanelRow(panelId) {
for (let panel of this.dashboard.panels) {
for (const panel of this.dashboard.panels) {
if (panel.collapsed) {
for (let rowPanel of panel.panels) {
for (const rowPanel of panel.panels) {
if (rowPanel.id === panelId) {
this.dashboard.toggleRow(panel);
return;

@ -44,7 +44,7 @@ export class OrgUsersCtrl {
}
onQueryUpdated() {
let regex = new RegExp(this.searchQuery, 'ig');
const regex = new RegExp(this.searchQuery, 'ig');
this.users = _.filter(this.unfiltered, item => {
return regex.test(item.email) || regex.test(item.login);
});

@ -28,7 +28,7 @@ export class MetricsTabCtrl {
this.datasources = datasourceSrv.getMetricSources();
this.panelDsValue = this.panelCtrl.panel.datasource;
for (let ds of this.datasources) {
for (const ds of this.datasources) {
if (ds.value === this.panelDsValue) {
this.datasourceInstance = ds;
}

@ -138,7 +138,7 @@ export class PanelCtrl {
}
getMenu() {
let menu = [];
const menu = [];
menu.push({
text: 'View',
click: 'ctrl.viewPanel();',
@ -166,7 +166,7 @@ export class PanelCtrl {
// Additional items from sub-class
menu.push(...this.getAdditionalMenuItems());
let extendedMenu = this.getExtendedMenu();
const extendedMenu = this.getExtendedMenu();
menu.push({
text: 'More ...',
click: '',
@ -189,7 +189,7 @@ export class PanelCtrl {
}
getExtendedMenu() {
let menu = [];
const menu = [];
if (!this.fullscreen && this.dashboard.meta.canEdit) {
menu.push({
text: 'Duplicate',
@ -259,7 +259,7 @@ export class PanelCtrl {
}
editPanelJson() {
let editScope = this.$scope.$root.$new();
const editScope = this.$scope.$root.$new();
editScope.object = this.panel.getSaveModel();
editScope.updateHandler = this.replacePanel.bind(this);
editScope.enableCopy = true;
@ -276,12 +276,12 @@ export class PanelCtrl {
}
replacePanel(newPanel, oldPanel) {
let dashboard = this.dashboard;
let index = _.findIndex(dashboard.panels, panel => {
const dashboard = this.dashboard;
const index = _.findIndex(dashboard.panels, panel => {
return panel.id === oldPanel.id;
});
let deletedPanel = dashboard.panels.splice(index, 1);
const deletedPanel = dashboard.panels.splice(index, 1);
this.dashboard.events.emit('panel-removed', deletedPanel);
newPanel = new PanelModel(newPanel);
@ -333,7 +333,7 @@ export class PanelCtrl {
if (this.panel.links && this.panel.links.length > 0) {
html += '<ul>';
for (let link of this.panel.links) {
for (const link of this.panel.links) {
var info = linkSrv.getPanelLinkAnchorInfo(link, this.panel.scopedVars);
html +=
'<li><a class="panel-menu-link" href="' +

@ -112,8 +112,8 @@ module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
</div>
`;
let scrollRoot = panelContent;
let scroller = panelContent.find(':first').find(':first');
const scrollRoot = panelContent;
const scroller = panelContent.find(':first').find(':first');
scrollRoot.addClass(scrollRootClass);
$(scrollBarHTML).appendTo(scrollRoot);

@ -60,7 +60,7 @@ function renderMenuItem(item, ctrl) {
if (item.submenu) {
html += '<ul class="dropdown-menu dropdown-menu--menu panel-menu">';
for (let subitem of item.submenu) {
for (const subitem of item.submenu) {
html += renderMenuItem(subitem, ctrl);
}
html += '</ul>';
@ -73,7 +73,7 @@ function renderMenuItem(item, ctrl) {
function createMenuTemplate(ctrl) {
let html = '';
for (let item of ctrl.getMenu()) {
for (const item of ctrl.getMenu()) {
html += renderMenuItem(item, ctrl);
}
@ -86,7 +86,7 @@ function panelHeader($compile) {
restrict: 'E',
template: template,
link: function(scope, elem, attrs) {
let menuElem = elem.find('.panel-menu');
const menuElem = elem.find('.panel-menu');
let menuScope;
let isDragged;
@ -99,7 +99,7 @@ function panelHeader($compile) {
}
menuScope = scope.$new();
let menuHtml = createMenuTemplate(scope.ctrl);
const menuHtml = createMenuTemplate(scope.ctrl);
menuElem.html(menuHtml);
$compile(menuElem)(menuScope);
@ -132,12 +132,12 @@ function panelHeader($compile) {
.find('[data-toggle=dropdown]')
.parentsUntil('.panel')
.parent();
let menuElem = elem.find('[data-toggle=dropdown]').parent();
const menuElem = elem.find('[data-toggle=dropdown]').parent();
panelElem = panelElem && panelElem.length ? panelElem[0] : undefined;
if (panelElem) {
panelElem = $(panelElem);
$(panelGridClass).removeClass(menuOpenClass);
let state = !menuElem.hasClass('open');
const state = !menuElem.hasClass('open');
panelElem.toggleClass(menuOpenClass, state);
}
}

@ -34,7 +34,7 @@ export class SoloPanelCtrl {
};
$scope.initPanelScope = function() {
let panelInfo = $scope.dashboard.getPanelInfoById(panelId);
const panelInfo = $scope.dashboard.getPanelInfoById(panelId);
// fake row ctrl scope
$scope.ctrl = {

@ -2,7 +2,7 @@ import { LinkSrv } from '../link_srv';
import _ from 'lodash';
jest.mock('angular', () => {
let AngularJSMock = require('test/mocks/angular');
const AngularJSMock = require('test/mocks/angular');
return new AngularJSMock();
});

@ -24,7 +24,7 @@ function grafanaRoutes($routeProvider) {
controller: 'PlaylistsCtrl',
resolve: {
init: function(playlistSrv, $route) {
let playlistId = $route.current.params.id;
const playlistId = $route.current.params.id;
playlistSrv.start(playlistId);
},
},

@ -4,7 +4,7 @@ import { PlaylistEditCtrl } from '../playlist_edit_ctrl';
describe('PlaylistEditCtrl', () => {
var ctx: any;
beforeEach(() => {
let navModelSrv = {
const navModelSrv = {
getNav: () => {
return { breadcrumbs: [], node: {} };
},

@ -17,7 +17,7 @@ export class DataSourcesCtrl {
}
onQueryUpdated() {
let regex = new RegExp(this.searchQuery, 'ig');
const regex = new RegExp(this.searchQuery, 'ig');
this.datasources = _.filter(this.unfiltered, item => {
regex.lastIndex = 0;
return regex.test(item.name) || regex.test(item.type);

@ -68,7 +68,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
},
};
let panelInfo = config.panels[scope.panel.type];
const panelInfo = config.panels[scope.panel.type];
var panelCtrlPromise = Promise.resolve(UnknownPanelCtrl);
if (panelInfo) {
panelCtrlPromise = importPluginModule(panelInfo.module).then(function(panelModule) {
@ -107,7 +107,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
switch (attrs.type) {
// QueryCtrl
case 'query-ctrl': {
let datasource = scope.target.datasource || scope.ctrl.panel.datasource;
const datasource = scope.target.datasource || scope.ctrl.panel.datasource;
return datasourceSrv.get(datasource).then(ds => {
scope.datasource = ds;
@ -160,7 +160,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
}
// AppConfigCtrl
case 'app-config-ctrl': {
let model = scope.ctrl.model;
const model = scope.ctrl.model;
return importPluginModule(model.module).then(function(appModule) {
return {
baseUrl: model.baseUrl,
@ -173,7 +173,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
}
// App Page
case 'app-page': {
let appModel = scope.ctrl.appModel;
const appModel = scope.ctrl.appModel;
return importPluginModule(appModel.module).then(function(appModule) {
return {
baseUrl: appModel.baseUrl,

@ -53,7 +53,7 @@ export class PluginEditCtrl {
url: `plugins/${this.model.id}/edit?tab=config`,
});
let hasDashboards = _.find(model.includes, { type: 'dashboard' });
const hasDashboards = _.find(model.includes, { type: 'dashboard' });
if (hasDashboards) {
this.navModel.main.children.push({
@ -69,7 +69,7 @@ export class PluginEditCtrl {
this.tab = this.$routeParams.tab || defaultTab;
for (let tab of this.navModel.main.children) {
for (const tab of this.navModel.main.children) {
if (tab.id === this.tab) {
tab.active = true;
}
@ -98,7 +98,7 @@ export class PluginEditCtrl {
initReadme() {
return this.backendSrv.get(`/api/plugins/${this.pluginId}/markdown/readme`).then(res => {
var md = new Remarkable({
linkify: true
linkify: true,
});
this.readmeHtml = this.$sce.trustAsHtml(md.render(res));
});

@ -20,7 +20,7 @@ export class PluginListCtrl {
}
onQueryUpdated() {
let regex = new RegExp(this.searchQuery, 'ig');
const regex = new RegExp(this.searchQuery, 'ig');
this.plugins = _.filter(this.allPlugins, item => {
return regex.test(item.name) || regex.test(item.type);
});

@ -140,12 +140,12 @@ const flotDeps = [
'jquery.flot.events',
'jquery.flot.gauge',
];
for (let flotDep of flotDeps) {
for (const flotDep of flotDeps) {
exposeToPlugin(flotDep, { fakeDep: 1 });
}
export function importPluginModule(path: string): Promise<any> {
let builtIn = builtInPlugins[path];
const builtIn = builtInPlugins[path];
if (builtIn) {
return Promise.resolve(builtIn);
}

@ -33,7 +33,7 @@ export class AppPageCtrl {
return;
}
let pluginNav = this.navModelSrv.getNav('plugin-page-' + app.id);
const pluginNav = this.navModelSrv.getNav('plugin-page-' + app.id);
this.navModel = {
main: {

@ -16,7 +16,7 @@ const templateSrv = {
};
describe('datasource_srv', function() {
let _datasourceSrv = new DatasourceSrv({}, {}, {}, templateSrv);
const _datasourceSrv = new DatasourceSrv({}, {}, {}, templateSrv);
describe('when loading explore sources', () => {
beforeEach(() => {
@ -46,7 +46,7 @@ describe('datasource_srv', function() {
describe('when loading metric sources', () => {
let metricSources;
let unsortedDatasources = {
const unsortedDatasources = {
mmm: {
type: 'test-db',
meta: { metrics: { m: 1 } },

@ -9,7 +9,7 @@ jest.mock('app/core/app_events', () => {
});
describe('VariableEditorCtrl', () => {
let scope = {
const scope = {
runQuery: () => {
return Promise.resolve({});
},

@ -5,7 +5,7 @@ import { VariableSrv } from '../variable_srv';
import $q from 'q';
describe('VariableSrv init', function() {
let templateSrv = {
const templateSrv = {
init: vars => {
this.variables = vars;
},
@ -17,8 +17,8 @@ describe('VariableSrv init', function() {
}),
};
let $injector = <any>{};
let $rootscope = {
const $injector = <any>{};
const $rootscope = {
$on: () => {},
};

@ -23,7 +23,7 @@ export class VariableSrv {
this.templateSrv.init(this.variables);
// init variables
for (let variable of this.variables) {
for (const variable of this.variables) {
variable.initLock = this.$q.defer();
}
@ -60,7 +60,7 @@ export class VariableSrv {
processVariable(variable, queryParams) {
var dependencies = [];
for (let otherVariable of this.variables) {
for (const otherVariable of this.variables) {
if (variable.dependsOn(otherVariable)) {
dependencies.push(otherVariable.initLock.promise);
}
@ -212,13 +212,13 @@ export class VariableSrv {
});
let defaultText = urlValue;
let defaultValue = urlValue;
const defaultValue = urlValue;
if (!option && _.isArray(urlValue)) {
defaultText = [];
for (let n = 0; n < urlValue.length; n++) {
let t = _.find(variable.options, op => {
const t = _.find(variable.options, op => {
return op.value === urlValue[n];
});
@ -275,7 +275,7 @@ export class VariableSrv {
this.addVariable(variable);
}
let filters = variable.filters;
const filters = variable.filters;
let filter = _.find(filters, { key: options.key, value: options.value });
if (!filter) {
@ -288,7 +288,7 @@ export class VariableSrv {
}
createGraph() {
let g = new Graph();
const g = new Graph();
this.variables.forEach(v1 => {
g.createNode(v1.name);

@ -45,7 +45,7 @@ export default class CloudWatchDatasource {
item.returnData = typeof item.hide === 'undefined' ? true : !item.hide;
// valid ExtendedStatistics is like p90.00, check the pattern
let hasInvalidStatistics = item.statistics.some(s => {
const hasInvalidStatistics = item.statistics.some(s => {
return s.indexOf('p') === 0 && !/p\d{2}\.\d{2}/.test(s);
});
if (hasInvalidStatistics) {
@ -402,7 +402,7 @@ export default class CloudWatchDatasource {
value: v,
};
});
let useSelectedVariables =
const useSelectedVariables =
selectedVariables.some(s => {
return s.value === currentVariables[0].value;
}) || currentVariables[0].value === '$__all';

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save