mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Updated rules for variable name (#13106)
* updated rules for variable name and fixed files that didn't follow new rules * fixed test so it uses new rule * made exceptions to rule in interval_variable
This commit is contained in:
committed by
Torkel Ödegaard
parent
0d25aa08fa
commit
7837ee4466
@@ -14,33 +14,33 @@ export function makeRegions(annotations, options) {
|
||||
}
|
||||
|
||||
function getRegions(events, range) {
|
||||
const region_events = _.filter(events, event => {
|
||||
const regionEvents = _.filter(events, event => {
|
||||
return event.regionId;
|
||||
});
|
||||
let regions = _.groupBy(region_events, 'regionId');
|
||||
let regions = _.groupBy(regionEvents, 'regionId');
|
||||
regions = _.compact(
|
||||
_.map(regions, 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;
|
||||
return region_obj;
|
||||
_.map(regions, regionEvents => {
|
||||
const regionObj = _.head(regionEvents);
|
||||
if (regionEvents && regionEvents.length > 1) {
|
||||
regionObj.timeEnd = regionEvents[1].time;
|
||||
regionObj.isRegion = true;
|
||||
return regionObj;
|
||||
} else {
|
||||
if (region_events && region_events.length) {
|
||||
if (regionEvents && regionEvents.length) {
|
||||
// Don't change proper region object
|
||||
if (!region_obj.time || !region_obj.timeEnd) {
|
||||
if (!regionObj.time || !regionObj.timeEnd) {
|
||||
// This is cut region
|
||||
if (isStartOfRegion(region_obj)) {
|
||||
region_obj.timeEnd = range.to.valueOf() - 1;
|
||||
if (isStartOfRegion(regionObj)) {
|
||||
regionObj.timeEnd = range.to.valueOf() - 1;
|
||||
} else {
|
||||
// Start time = null
|
||||
region_obj.timeEnd = region_obj.time;
|
||||
region_obj.time = range.from.valueOf() + 1;
|
||||
regionObj.timeEnd = regionObj.time;
|
||||
regionObj.time = range.from.valueOf() + 1;
|
||||
}
|
||||
region_obj.isRegion = true;
|
||||
regionObj.isRegion = true;
|
||||
}
|
||||
|
||||
return region_obj;
|
||||
return regionObj;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -102,7 +102,7 @@ export class DashboardCtrl implements PanelContainer {
|
||||
}
|
||||
|
||||
setWindowTitleAndTheme() {
|
||||
window.document.title = config.window_title_prefix + this.dashboard.title;
|
||||
window.document.title = config.windowTitlePrefix + this.dashboard.title;
|
||||
}
|
||||
|
||||
showJsonEditor(evt, options) {
|
||||
|
||||
@@ -106,7 +106,7 @@ export class DashboardLoaderSrv {
|
||||
};
|
||||
|
||||
/*jshint -W054 */
|
||||
const script_func = new Function(
|
||||
const scriptFunc = new Function(
|
||||
'ARGS',
|
||||
'kbn',
|
||||
'dateMath',
|
||||
@@ -119,12 +119,12 @@ export class DashboardLoaderSrv {
|
||||
'services',
|
||||
result.data
|
||||
);
|
||||
const script_result = script_func(this.$routeParams, kbn, dateMath, _, moment, window, document, $, $, services);
|
||||
const scriptResult = scriptFunc(this.$routeParams, kbn, dateMath, _, moment, window, document, $, $, services);
|
||||
|
||||
// Handle async dashboard scripts
|
||||
if (_.isFunction(script_result)) {
|
||||
if (_.isFunction(scriptResult)) {
|
||||
const deferred = this.$q.defer();
|
||||
script_result(dashboard => {
|
||||
scriptResult(dashboard => {
|
||||
this.$timeout(() => {
|
||||
deferred.resolve({ data: dashboard });
|
||||
});
|
||||
@@ -132,7 +132,7 @@ export class DashboardLoaderSrv {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
return { data: script_result };
|
||||
return { data: scriptResult };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -271,8 +271,8 @@ describe('given dashboard with row repeat and panel repeat in horizontal directi
|
||||
});
|
||||
|
||||
it('should panels in self row', () => {
|
||||
const panel_types = _.map(dashboard.panels, 'type');
|
||||
expect(panel_types).toEqual([
|
||||
const panelTypes = _.map(dashboard.panels, 'type');
|
||||
expect(panelTypes).toEqual([
|
||||
'row',
|
||||
'graph',
|
||||
'graph',
|
||||
@@ -350,8 +350,8 @@ describe('given dashboard with row repeat', function() {
|
||||
});
|
||||
|
||||
it('should not repeat only row', function() {
|
||||
const panel_types = _.map(dashboard.panels, 'type');
|
||||
expect(panel_types).toEqual(['row', 'graph', 'graph', 'row', 'graph', 'graph', 'row', 'graph']);
|
||||
const panelTypes = _.map(dashboard.panels, 'type');
|
||||
expect(panelTypes).toEqual(['row', 'graph', 'graph', 'row', 'graph', 'graph', 'row', 'graph']);
|
||||
});
|
||||
|
||||
it('should set scopedVars for each panel', function() {
|
||||
@@ -399,8 +399,8 @@ describe('given dashboard with row repeat', function() {
|
||||
dashboard = new DashboardModel(dashboardJSON);
|
||||
dashboard.processRepeats();
|
||||
|
||||
const panel_types = _.map(dashboard.panels, 'type');
|
||||
expect(panel_types).toEqual(['row', 'row', 'row', 'graph']);
|
||||
const panelTypes = _.map(dashboard.panels, 'type');
|
||||
expect(panelTypes).toEqual(['row', 'row', 'row', 'graph']);
|
||||
expect(dashboard.panels[0].panels).toHaveLength(2);
|
||||
expect(dashboard.panels[1].panels).toHaveLength(2);
|
||||
});
|
||||
@@ -441,8 +441,8 @@ describe('given dashboard with row repeat', function() {
|
||||
dashboard = new DashboardModel(dashboardJSON);
|
||||
dashboard.processRepeats();
|
||||
|
||||
const panel_types = _.map(dashboard.panels, 'type');
|
||||
expect(panel_types).toEqual([
|
||||
const panelTypes = _.map(dashboard.panels, 'type');
|
||||
expect(panelTypes).toEqual([
|
||||
'row',
|
||||
'graph',
|
||||
'graph',
|
||||
@@ -488,7 +488,7 @@ describe('given dashboard with row repeat', function() {
|
||||
dashboard = new DashboardModel(dashboardJSON);
|
||||
dashboard.processRepeats();
|
||||
|
||||
const panel_ids = _.flattenDeep(
|
||||
const panelIds = _.flattenDeep(
|
||||
_.map(dashboard.panels, panel => {
|
||||
let ids = [];
|
||||
if (panel.panels && panel.panels.length) {
|
||||
@@ -498,7 +498,7 @@ describe('given dashboard with row repeat', function() {
|
||||
return ids;
|
||||
})
|
||||
);
|
||||
expect(panel_ids.length).toEqual(_.uniq(panel_ids).length);
|
||||
expect(panelIds.length).toEqual(_.uniq(panelIds).length);
|
||||
});
|
||||
|
||||
it('should place new panels in proper order', function() {
|
||||
@@ -511,10 +511,10 @@ describe('given dashboard with row repeat', function() {
|
||||
dashboard = new DashboardModel(dashboardJSON);
|
||||
dashboard.processRepeats();
|
||||
|
||||
const panel_types = _.map(dashboard.panels, 'type');
|
||||
expect(panel_types).toEqual(['row', 'graph', 'graph', 'graph', 'row', 'graph', 'graph', 'graph']);
|
||||
const panel_y_positions = _.map(dashboard.panels, p => p.gridPos.y);
|
||||
expect(panel_y_positions).toEqual([0, 1, 1, 5, 7, 8, 8, 12]);
|
||||
const panelTypes = _.map(dashboard.panels, 'type');
|
||||
expect(panelTypes).toEqual(['row', 'graph', 'graph', 'graph', 'row', 'graph', 'graph', 'graph']);
|
||||
const panelYPositions = _.map(dashboard.panels, p => p.gridPos.y);
|
||||
expect(panelYPositions).toEqual([0, 1, 1, 5, 7, 8, 8, 12]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -566,8 +566,8 @@ describe('given dashboard with row and panel repeat', () => {
|
||||
});
|
||||
|
||||
it('should repeat row and panels for each row', () => {
|
||||
const panel_types = _.map(dashboard.panels, 'type');
|
||||
expect(panel_types).toEqual(['row', 'graph', 'graph', 'row', 'graph', 'graph']);
|
||||
const panelTypes = _.map(dashboard.panels, 'type');
|
||||
expect(panelTypes).toEqual(['row', 'graph', 'graph', 'row', 'graph', 'graph']);
|
||||
});
|
||||
|
||||
it('should clean up old repeated panels', () => {
|
||||
@@ -592,8 +592,8 @@ describe('given dashboard with row and panel repeat', () => {
|
||||
dashboard = new DashboardModel(dashboardJSON);
|
||||
dashboard.processRepeats();
|
||||
|
||||
const panel_types = _.map(dashboard.panels, 'type');
|
||||
expect(panel_types).toEqual(['row', 'graph', 'graph', 'row', 'graph', 'graph']);
|
||||
const panelTypes = _.map(dashboard.panels, 'type');
|
||||
expect(panelTypes).toEqual(['row', 'graph', 'graph', 'row', 'graph', 'graph']);
|
||||
});
|
||||
|
||||
it('should set scopedVars for each row', () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { coreModule } from 'app/core/core';
|
||||
|
||||
export class ProfileCtrl {
|
||||
user: any;
|
||||
old_theme: any;
|
||||
oldTheme: any;
|
||||
teams: any = [];
|
||||
orgs: any = [];
|
||||
userForm: any;
|
||||
@@ -54,7 +54,7 @@ export class ProfileCtrl {
|
||||
|
||||
this.backendSrv.put('/api/user/', this.user).then(() => {
|
||||
this.contextSrv.user.name = this.user.name || this.user.login;
|
||||
if (this.old_theme !== this.user.theme) {
|
||||
if (this.oldTheme !== this.user.theme) {
|
||||
window.location.href = config.appSubUrl + this.$location.path();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,8 +4,8 @@ import { Variable, assignModelProperties, variableTypes } from './variable';
|
||||
|
||||
export class IntervalVariable implements Variable {
|
||||
name: string;
|
||||
auto_count: number;
|
||||
auto_min: number;
|
||||
auto_count: number; // tslint:disable-line variable-name
|
||||
auto_min: number; // tslint:disable-line variable-name
|
||||
options: any;
|
||||
auto: boolean;
|
||||
query: string;
|
||||
|
||||
Reference in New Issue
Block a user