prettier: change to single quoting

This commit is contained in:
Torkel Ödegaard
2017-12-20 12:33:33 +01:00
parent 2a360c45a2
commit 85879a7014
304 changed files with 10558 additions and 10519 deletions

View File

@@ -1,14 +1,14 @@
import moment from "moment";
import _ from "lodash";
import moment from 'moment';
import _ from 'lodash';
import { GRID_COLUMN_COUNT, REPEAT_DIR_VERTICAL } from "app/core/constants";
import { DEFAULT_ANNOTATION_COLOR } from "app/core/utils/colors";
import { Emitter } from "app/core/utils/emitter";
import { contextSrv } from "app/core/services/context_srv";
import sortByKeys from "app/core/utils/sort_by_keys";
import { GRID_COLUMN_COUNT, REPEAT_DIR_VERTICAL } from 'app/core/constants';
import { DEFAULT_ANNOTATION_COLOR } from 'app/core/utils/colors';
import { Emitter } from 'app/core/utils/emitter';
import { contextSrv } from 'app/core/services/context_srv';
import sortByKeys from 'app/core/utils/sort_by_keys';
import { PanelModel } from "./panel_model";
import { DashboardMigrator } from "./dashboard_migration";
import { PanelModel } from './panel_model';
import { DashboardMigrator } from './dashboard_migration';
export class DashboardModel {
id: any;
@@ -47,7 +47,7 @@ export class DashboardModel {
events: true,
meta: true,
panels: true, // needs special handling
templating: true // needs special handling
templating: true, // needs special handling
};
constructor(data, meta?) {
@@ -58,15 +58,15 @@ export class DashboardModel {
this.events = new Emitter();
this.id = data.id || null;
this.revision = data.revision;
this.title = data.title || "No Title";
this.title = data.title || 'No Title';
this.autoUpdate = data.autoUpdate;
this.description = data.description;
this.tags = data.tags || [];
this.style = data.style || "dark";
this.timezone = data.timezone || "";
this.style = data.style || 'dark';
this.timezone = data.timezone || '';
this.editable = data.editable !== false;
this.graphTooltip = data.graphTooltip || 0;
this.time = data.time || { from: "now-6h", to: "now" };
this.time = data.time || { from: 'now-6h', to: 'now' };
this.timepicker = data.timepicker || {};
this.templating = this.ensureListExist(data.templating);
this.annotations = this.ensureListExist(data.annotations);
@@ -103,13 +103,13 @@ export class DashboardModel {
}
this.annotations.list.unshift({
datasource: "-- Grafana --",
name: "Annotations & Alerts",
type: "dashboard",
datasource: '-- Grafana --',
name: 'Annotations & Alerts',
type: 'dashboard',
iconColor: DEFAULT_ANNOTATION_COLOR,
enable: true,
hide: true,
builtIn: 1
builtIn: 1,
});
}
@@ -152,7 +152,7 @@ export class DashboardModel {
list: _.map(
this.templating.list,
variable => (variable.getSaveModel ? variable.getSaveModel() : variable)
)
),
};
// get panel save models
@@ -170,7 +170,7 @@ export class DashboardModel {
panel.setViewMode(fullscreen, this.meta.isEditing);
this.events.emit("view-mode-changed", panel);
this.events.emit('view-mode-changed', panel);
}
private ensureListExist(data) {
@@ -227,7 +227,7 @@ export class DashboardModel {
this.sortPanelsByGridPos();
this.events.emit("panel-added", panel);
this.events.emit('panel-added', panel);
}
sortPanelsByGridPos() {
@@ -275,7 +275,7 @@ export class DashboardModel {
_.pull(this.panels, ...panelsToRemove);
this.sortPanelsByGridPos();
this.events.emit("repeats-processed");
this.events.emit('repeats-processed');
}
getPanelRepeatClone(sourcePanel, valueIndex, sourcePanelIndex) {
@@ -332,7 +332,7 @@ export class DashboardModel {
return;
}
if (panel.type === "row") {
if (panel.type === 'row') {
this.repeatRow(panel, panelIndex, variable);
return;
}
@@ -444,7 +444,7 @@ export class DashboardModel {
getSelectedVariableOptions(variable) {
let selectedOptions;
if (variable.current.text === "All") {
if (variable.current.text === 'All') {
selectedOptions = variable.options.slice(1, variable.options.length);
} else {
selectedOptions = _.filter(variable.options, { selected: true });
@@ -456,7 +456,7 @@ export class DashboardModel {
if (!rowPanel.panels || rowPanel.panels.length === 0) {
return 0;
}
const positions = _.map(rowPanel.panels, "gridPos");
const positions = _.map(rowPanel.panels, 'gridPos');
const maxPos = _.maxBy(positions, pos => {
return pos.y + pos.h;
});
@@ -466,11 +466,12 @@ export class DashboardModel {
removePanel(panel: PanelModel) {
var index = _.indexOf(this.panels, panel);
this.panels.splice(index, 1);
this.events.emit("panel-removed", panel);
this.events.emit('panel-removed', panel);
}
removeRow(row: PanelModel, removePanels: boolean) {
const needToogle = (!removePanels && row.collapsed) || (removePanels && !row.collapsed);
const needToogle =
(!removePanels && row.collapsed) || (removePanels && !row.collapsed);
if (needToogle) {
this.toggleRow(row);
@@ -514,7 +515,7 @@ export class DashboardModel {
if (this.panels[i].id === panelId) {
return {
panel: this.panels[i],
index: i
index: i,
};
}
}
@@ -549,10 +550,10 @@ export class DashboardModel {
formatDate(date, format?) {
date = moment.isMoment(date) ? date : moment(date);
format = format || "YYYY-MM-DD HH:mm:ss";
format = format || 'YYYY-MM-DD HH:mm:ss';
let timezone = this.getTimezone();
return timezone === "browser"
return timezone === 'browser'
? moment(date).format(format)
: moment.utc(date).format(format);
}
@@ -609,7 +610,7 @@ export class DashboardModel {
this.sortPanelsByGridPos();
// emit change event
this.events.emit("row-expanded");
this.events.emit('row-expanded');
return;
}
@@ -622,7 +623,7 @@ export class DashboardModel {
row.collapsed = true;
// emit change event
this.events.emit("row-collapsed");
this.events.emit('row-collapsed');
}
/**
@@ -635,7 +636,7 @@ export class DashboardModel {
let panel = this.panels[index];
// break when encountering another row
if (panel.type === "row") {
if (panel.type === 'row') {
break;
}
@@ -669,13 +670,13 @@ export class DashboardModel {
getRelativeTime(date) {
date = moment.isMoment(date) ? date : moment(date);
return this.timezone === "browser"
return this.timezone === 'browser'
? moment(date).fromNow()
: moment.utc(date).fromNow();
}
getNextQueryLetter(panel) {
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
return _.find(letters, function(refId) {
return _.every(panel.targets, function(other) {
@@ -685,7 +686,7 @@ export class DashboardModel {
}
isTimezoneUtc() {
return this.getTimezone() === "utc";
return this.getTimezone() === 'utc';
}
getTimezone() {