mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
prettier: change to single quoting
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import config from "app/core/config";
|
||||
import _ from "lodash";
|
||||
import $ from "jquery";
|
||||
import { appEvents, profiler } from "app/core/core";
|
||||
import { PanelModel } from "app/features/dashboard/panel_model";
|
||||
import Remarkable from "remarkable";
|
||||
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN } from "app/core/constants";
|
||||
import config from 'app/core/config';
|
||||
import _ from 'lodash';
|
||||
import $ from 'jquery';
|
||||
import { appEvents, profiler } from 'app/core/core';
|
||||
import { PanelModel } from 'app/features/dashboard/panel_model';
|
||||
import Remarkable from 'remarkable';
|
||||
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN } from 'app/core/constants';
|
||||
|
||||
const TITLE_HEIGHT = 27;
|
||||
const PANEL_BORDER = 2;
|
||||
|
||||
import { Emitter } from "app/core/core";
|
||||
import { Emitter } from 'app/core/core';
|
||||
|
||||
export class PanelCtrl {
|
||||
panel: any;
|
||||
@@ -35,7 +35,7 @@ export class PanelCtrl {
|
||||
constructor($scope, $injector) {
|
||||
this.$injector = $injector;
|
||||
this.$scope = $scope;
|
||||
this.$timeout = $injector.get("$timeout");
|
||||
this.$timeout = $injector.get('$timeout');
|
||||
this.editorTabIndex = 0;
|
||||
this.events = this.panel.events;
|
||||
this.timing = {};
|
||||
@@ -46,22 +46,22 @@ export class PanelCtrl {
|
||||
this.pluginName = plugin.name;
|
||||
}
|
||||
|
||||
$scope.$on("refresh", () => this.refresh());
|
||||
$scope.$on("component-did-mount", () => this.panelDidMount());
|
||||
$scope.$on('refresh', () => this.refresh());
|
||||
$scope.$on('component-did-mount', () => this.panelDidMount());
|
||||
|
||||
$scope.$on("$destroy", () => {
|
||||
this.events.emit("panel-teardown");
|
||||
$scope.$on('$destroy', () => {
|
||||
this.events.emit('panel-teardown');
|
||||
this.events.removeAllListeners();
|
||||
});
|
||||
}
|
||||
|
||||
init() {
|
||||
this.events.emit("panel-initialized");
|
||||
this.publishAppEvent("panel-initialized", { scope: this.$scope });
|
||||
this.events.emit('panel-initialized');
|
||||
this.publishAppEvent('panel-initialized', { scope: this.$scope });
|
||||
}
|
||||
|
||||
panelDidMount() {
|
||||
this.events.emit("component-did-mount");
|
||||
this.events.emit('component-did-mount');
|
||||
}
|
||||
|
||||
renderingCompleted() {
|
||||
@@ -69,7 +69,7 @@ export class PanelCtrl {
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.events.emit("refresh", null);
|
||||
this.events.emit('refresh', null);
|
||||
}
|
||||
|
||||
publishAppEvent(evtName, evt) {
|
||||
@@ -77,10 +77,10 @@ export class PanelCtrl {
|
||||
}
|
||||
|
||||
changeView(fullscreen, edit) {
|
||||
this.publishAppEvent("panel-change-view", {
|
||||
this.publishAppEvent('panel-change-view', {
|
||||
fullscreen: fullscreen,
|
||||
edit: edit,
|
||||
panelId: this.panel.id
|
||||
panelId: this.panel.id,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ export class PanelCtrl {
|
||||
|
||||
initEditMode() {
|
||||
this.editorTabs = [];
|
||||
this.addEditorTab("General", "public/app/partials/panelgeneral.html");
|
||||
this.addEditorTab('General', 'public/app/partials/panelgeneral.html');
|
||||
this.editModeInitiated = true;
|
||||
this.events.emit("init-edit-mode", null);
|
||||
this.events.emit('init-edit-mode', null);
|
||||
|
||||
var urlTab = (this.$injector.get("$routeParams").tab || "").toLowerCase();
|
||||
var urlTab = (this.$injector.get('$routeParams').tab || '').toLowerCase();
|
||||
if (urlTab) {
|
||||
this.editorTabs.forEach((tab, i) => {
|
||||
if (tab.title.toLowerCase() === urlTab) {
|
||||
@@ -114,7 +114,7 @@ export class PanelCtrl {
|
||||
|
||||
changeTab(newIndex) {
|
||||
this.editorTabIndex = newIndex;
|
||||
var route = this.$injector.get("$route");
|
||||
var route = this.$injector.get('$route');
|
||||
route.current.params.tab = this.editorTabs[newIndex].title.toLowerCase();
|
||||
route.updateParams();
|
||||
}
|
||||
@@ -137,45 +137,45 @@ export class PanelCtrl {
|
||||
getMenu() {
|
||||
let menu = [];
|
||||
menu.push({
|
||||
text: "View",
|
||||
click: "ctrl.viewPanel();",
|
||||
icon: "fa fa-fw fa-eye",
|
||||
shortcut: "v"
|
||||
text: 'View',
|
||||
click: 'ctrl.viewPanel();',
|
||||
icon: 'fa fa-fw fa-eye',
|
||||
shortcut: 'v',
|
||||
});
|
||||
|
||||
if (this.dashboard.meta.canEdit) {
|
||||
menu.push({
|
||||
text: "Edit",
|
||||
click: "ctrl.editPanel();",
|
||||
role: "Editor",
|
||||
icon: "fa fa-fw fa-edit",
|
||||
shortcut: "e"
|
||||
text: 'Edit',
|
||||
click: 'ctrl.editPanel();',
|
||||
role: 'Editor',
|
||||
icon: 'fa fa-fw fa-edit',
|
||||
shortcut: 'e',
|
||||
});
|
||||
}
|
||||
|
||||
menu.push({
|
||||
text: "Share",
|
||||
click: "ctrl.sharePanel();",
|
||||
icon: "fa fa-fw fa-share",
|
||||
shortcut: "p s"
|
||||
text: 'Share',
|
||||
click: 'ctrl.sharePanel();',
|
||||
icon: 'fa fa-fw fa-share',
|
||||
shortcut: 'p s',
|
||||
});
|
||||
|
||||
let extendedMenu = this.getExtendedMenu();
|
||||
menu.push({
|
||||
text: "More ...",
|
||||
click: "",
|
||||
icon: "fa fa-fw fa-cube",
|
||||
submenu: extendedMenu
|
||||
text: 'More ...',
|
||||
click: '',
|
||||
icon: 'fa fa-fw fa-cube',
|
||||
submenu: extendedMenu,
|
||||
});
|
||||
|
||||
if (this.dashboard.meta.canEdit) {
|
||||
menu.push({ divider: true, role: "Editor" });
|
||||
menu.push({ divider: true, role: 'Editor' });
|
||||
menu.push({
|
||||
text: "Remove",
|
||||
click: "ctrl.removePanel();",
|
||||
role: "Editor",
|
||||
icon: "fa fa-fw fa-trash",
|
||||
shortcut: "p r"
|
||||
text: 'Remove',
|
||||
click: 'ctrl.removePanel();',
|
||||
role: 'Editor',
|
||||
icon: 'fa fa-fw fa-trash',
|
||||
shortcut: 'p r',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -186,16 +186,16 @@ export class PanelCtrl {
|
||||
let menu = [];
|
||||
if (!this.fullscreen && this.dashboard.meta.canEdit) {
|
||||
menu.push({
|
||||
text: "Duplicate",
|
||||
click: "ctrl.duplicate()",
|
||||
role: "Editor"
|
||||
text: 'Duplicate',
|
||||
click: 'ctrl.duplicate()',
|
||||
role: 'Editor',
|
||||
});
|
||||
}
|
||||
menu.push({
|
||||
text: "Panel JSON",
|
||||
click: "ctrl.editPanelJson(); dismiss();"
|
||||
text: 'Panel JSON',
|
||||
click: 'ctrl.editPanelJson(); dismiss();',
|
||||
});
|
||||
this.events.emit("init-panel-actions", menu);
|
||||
this.events.emit('init-panel-actions', menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
@@ -224,13 +224,13 @@ export class PanelCtrl {
|
||||
|
||||
render(payload?) {
|
||||
this.timing.renderStart = new Date().getTime();
|
||||
this.events.emit("render", payload);
|
||||
this.events.emit('render', payload);
|
||||
}
|
||||
|
||||
duplicate() {
|
||||
this.dashboard.duplicatePanel(this.panel);
|
||||
this.$timeout(() => {
|
||||
this.$scope.$root.$broadcast("render");
|
||||
this.$scope.$root.$broadcast('render');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -241,20 +241,20 @@ export class PanelCtrl {
|
||||
|
||||
if (this.panel.alert) {
|
||||
text2 =
|
||||
"Panel includes an alert rule, removing panel will also remove alert rule";
|
||||
confirmText = "YES";
|
||||
'Panel includes an alert rule, removing panel will also remove alert rule';
|
||||
confirmText = 'YES';
|
||||
}
|
||||
|
||||
appEvents.emit("confirm-modal", {
|
||||
title: "Remove Panel",
|
||||
text: "Are you sure you want to remove this panel?",
|
||||
appEvents.emit('confirm-modal', {
|
||||
title: 'Remove Panel',
|
||||
text: 'Are you sure you want to remove this panel?',
|
||||
text2: text2,
|
||||
icon: "fa-trash",
|
||||
icon: 'fa-trash',
|
||||
confirmText: confirmText,
|
||||
yesText: "Remove",
|
||||
yesText: 'Remove',
|
||||
onConfirm: () => {
|
||||
this.removePanel(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -267,9 +267,9 @@ export class PanelCtrl {
|
||||
editScope.object = this.panel.getSaveModel();
|
||||
editScope.updateHandler = this.replacePanel.bind(this);
|
||||
|
||||
this.publishAppEvent("show-modal", {
|
||||
src: "public/app/partials/edit_json.html",
|
||||
scope: editScope
|
||||
this.publishAppEvent('show-modal', {
|
||||
src: 'public/app/partials/edit_json.html',
|
||||
scope: editScope,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -280,14 +280,14 @@ export class PanelCtrl {
|
||||
});
|
||||
|
||||
let deletedPanel = dashboard.panels.splice(index, 1);
|
||||
this.dashboard.events.emit("panel-removed", deletedPanel);
|
||||
this.dashboard.events.emit('panel-removed', deletedPanel);
|
||||
|
||||
newPanel = new PanelModel(newPanel);
|
||||
newPanel.id = oldPanel.id;
|
||||
|
||||
dashboard.panels.splice(index, 0, newPanel);
|
||||
dashboard.sortPanelsByGridPos();
|
||||
dashboard.events.emit("panel-added", newPanel);
|
||||
dashboard.events.emit('panel-added', newPanel);
|
||||
}
|
||||
|
||||
sharePanel() {
|
||||
@@ -295,34 +295,34 @@ export class PanelCtrl {
|
||||
shareScope.panel = this.panel;
|
||||
shareScope.dashboard = this.dashboard;
|
||||
|
||||
this.publishAppEvent("show-modal", {
|
||||
src: "public/app/features/dashboard/partials/shareModal.html",
|
||||
scope: shareScope
|
||||
this.publishAppEvent('show-modal', {
|
||||
src: 'public/app/features/dashboard/partials/shareModal.html',
|
||||
scope: shareScope,
|
||||
});
|
||||
}
|
||||
|
||||
getInfoMode() {
|
||||
if (this.error) {
|
||||
return "error";
|
||||
return 'error';
|
||||
}
|
||||
if (!!this.panel.description) {
|
||||
return "info";
|
||||
return 'info';
|
||||
}
|
||||
if (this.panel.links && this.panel.links.length) {
|
||||
return "links";
|
||||
return 'links';
|
||||
}
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
getInfoContent(options) {
|
||||
var markdown = this.panel.description;
|
||||
|
||||
if (options.mode === "tooltip") {
|
||||
if (options.mode === 'tooltip') {
|
||||
markdown = this.error || this.panel.description;
|
||||
}
|
||||
|
||||
var linkSrv = this.$injector.get("linkSrv");
|
||||
var templateSrv = this.$injector.get("templateSrv");
|
||||
var linkSrv = this.$injector.get('linkSrv');
|
||||
var templateSrv = this.$injector.get('templateSrv');
|
||||
var interpolatedMarkdown = templateSrv.replace(
|
||||
markdown,
|
||||
this.panel.scopedVars
|
||||
@@ -332,7 +332,7 @@ export class PanelCtrl {
|
||||
html += new Remarkable().render(interpolatedMarkdown);
|
||||
|
||||
if (this.panel.links && this.panel.links.length > 0) {
|
||||
html += "<ul>";
|
||||
html += '<ul>';
|
||||
for (let link of this.panel.links) {
|
||||
var info = linkSrv.getPanelLinkAnchorInfo(link, this.panel.scopedVars);
|
||||
html +=
|
||||
@@ -342,24 +342,24 @@ export class PanelCtrl {
|
||||
info.target +
|
||||
'">' +
|
||||
info.title +
|
||||
"</a></li>";
|
||||
'</a></li>';
|
||||
}
|
||||
html += "</ul>";
|
||||
html += '</ul>';
|
||||
}
|
||||
|
||||
return html + "</div>";
|
||||
return html + '</div>';
|
||||
}
|
||||
|
||||
openInspector() {
|
||||
var modalScope = this.$scope.$new();
|
||||
modalScope.panel = this.panel;
|
||||
modalScope.dashboard = this.dashboard;
|
||||
modalScope.panelInfoHtml = this.getInfoContent({ mode: "inspector" });
|
||||
modalScope.panelInfoHtml = this.getInfoContent({ mode: 'inspector' });
|
||||
|
||||
modalScope.inspector = $.extend(true, {}, this.inspector);
|
||||
this.publishAppEvent("show-modal", {
|
||||
src: "public/app/features/dashboard/partials/inspector.html",
|
||||
scope: modalScope
|
||||
this.publishAppEvent('show-modal', {
|
||||
src: 'public/app/features/dashboard/partials/inspector.html',
|
||||
scope: modalScope,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user