Commit 56c76f38 by Torkel Ödegaard

feat(panels): fixes

parent a00231a1
...@@ -5,7 +5,7 @@ import store from 'app/core/store'; ...@@ -5,7 +5,7 @@ import store from 'app/core/store';
import _ from 'lodash'; import _ from 'lodash';
import angular from 'angular'; import angular from 'angular';
import $ from 'jquery'; import $ from 'jquery';
import coreModule from '../core_module'; import coreModule from 'app/core/core_module';
export class GrafanaCtrl { export class GrafanaCtrl {
......
...@@ -49,6 +49,7 @@ class MetricsPanelCtrl extends PanelCtrl { ...@@ -49,6 +49,7 @@ class MetricsPanelCtrl extends PanelCtrl {
initEditMode() { initEditMode() {
this.addEditorTab('Metrics', 'public/app/partials/metrics.html'); this.addEditorTab('Metrics', 'public/app/partials/metrics.html');
this.addEditorTab('Time range', 'app/features/panel/partials/panelTime.html');
this.datasources = this.datasourceSrv.getMetricSources(); this.datasources = this.datasourceSrv.getMetricSources();
} }
......
...@@ -80,7 +80,7 @@ export class PanelCtrl { ...@@ -80,7 +80,7 @@ export class PanelCtrl {
return; return;
} }
addEditorTab(title, directiveFn) { addEditorTab(title, directiveFn, index?) {
var editorTab = {title, directiveFn}; var editorTab = {title, directiveFn};
if (_.isString(directiveFn)) { if (_.isString(directiveFn)) {
...@@ -88,8 +88,11 @@ export class PanelCtrl { ...@@ -88,8 +88,11 @@ export class PanelCtrl {
return {templateUrl: directiveFn}; return {templateUrl: directiveFn};
}; };
} }
if (index) {
this.editorTabs.push(editorTab); this.editorTabs.splice(index, 0, editorTab);
} else {
this.editorTabs.push(editorTab);
}
} }
getMenu() { getMenu() {
......
...@@ -16,7 +16,6 @@ function panelEditorTab(dynamicDirectiveSrv) { ...@@ -16,7 +16,6 @@ function panelEditorTab(dynamicDirectiveSrv) {
directive: scope => { directive: scope => {
var pluginId = scope.ctrl.pluginId; var pluginId = scope.ctrl.pluginId;
var tabIndex = scope.index; var tabIndex = scope.index;
console.log('tab plugnId:', pluginId);
return Promise.resolve({ return Promise.resolve({
name: `panel-editor-tab-${pluginId}${tabIndex}`, name: `panel-editor-tab-${pluginId}${tabIndex}`,
......
...@@ -104,13 +104,9 @@ class GraphCtrl extends MetricsPanelCtrl { ...@@ -104,13 +104,9 @@ class GraphCtrl extends MetricsPanelCtrl {
super.initEditMode(); super.initEditMode();
this.icon = "fa fa-bar-chart"; this.icon = "fa fa-bar-chart";
this.addEditorTab('Axes & Grid', 'public/app/plugins/panel/graph/axisEditor.html'); this.addEditorTab('Axes & Grid', 'public/app/plugins/panel/graph/axisEditor.html', 2);
this.addEditorTab('Display Styles', 'public/app/plugins/panel/graph/styleEditor.html'); this.addEditorTab('Display Styles', 'public/app/plugins/panel/graph/styleEditor.html', 3);
// $scope.panelMeta.addEditorTab('Time range', 'app/features/panel/partials/panelTime.html');
// $scope.panelMeta.addExtendedMenuItem('Export CSV', '', 'exportCsv()');
// $scope.panelMeta.addExtendedMenuItem('Toggle legend', '', 'toggleLegend()');
//
this.logScales = { this.logScales = {
'linear': 1, 'linear': 1,
'log (base 2)': 2, 'log (base 2)': 2,
...@@ -121,6 +117,13 @@ class GraphCtrl extends MetricsPanelCtrl { ...@@ -121,6 +117,13 @@ class GraphCtrl extends MetricsPanelCtrl {
this.unitFormats = kbn.getUnitFormats(); this.unitFormats = kbn.getUnitFormats();
} }
getExtendedMenu() {
var menu = super.getExtendedMenu();
menu.push({text: 'Export CSV', click: 'ctrl.exportCsv()'});
menu.push({text: 'Toggle legend', click: 'ctrl.toggleLegend()'});
return menu;
}
setUnitFormat(axis, subItem) { setUnitFormat(axis, subItem) {
this.panel.y_formats[axis] = subItem.value; this.panel.y_formats[axis] = subItem.value;
this.render(); this.render();
......
...@@ -52,12 +52,10 @@ export class SingleStatCtrl extends MetricsPanelCtrl { ...@@ -52,12 +52,10 @@ export class SingleStatCtrl extends MetricsPanelCtrl {
initEditMode() { initEditMode() {
super.initEditMode();
this.icon = "fa fa-dashboard"; this.icon = "fa fa-dashboard";
this.fontSizes = ['20%', '30%','50%','70%','80%','100%', '110%', '120%', '150%', '170%', '200%']; this.fontSizes = ['20%', '30%','50%','70%','80%','100%', '110%', '120%', '150%', '170%', '200%'];
this.addEditorTab('Options', 'app/plugins/panel/singlestat/editor.html', 2);
this.addEditorTab('Options', 'app/plugins/panel/singlestat/editor.html');
this.addEditorTab('Time range', 'app/features/panel/partials/panelTime.html');
this.unitFormats = kbn.getUnitFormats(); this.unitFormats = kbn.getUnitFormats();
} }
......
...@@ -57,13 +57,12 @@ export class TablePanelCtrl extends MetricsPanelCtrl { ...@@ -57,13 +57,12 @@ export class TablePanelCtrl extends MetricsPanelCtrl {
initEditMode() { initEditMode() {
super.initEditMode(); super.initEditMode();
this.addEditorTab('Options', tablePanelEditor); this.addEditorTab('Options', tablePanelEditor, 1);
this.addEditorTab('Time range', 'app/features/panel/partials/panelTime.html');
} }
getExtendedMenu() { getExtendedMenu() {
var menu = super.getExtendedMenu(); var menu = super.getExtendedMenu();
menu.push({text: 'Export CSV', click: 'exportCsv()'}); menu.push({text: 'Export CSV', click: 'ctrl.exportCsv()'});
return menu; return menu;
} }
......
...@@ -89,7 +89,9 @@ class TablePanel extends PanelDirective { ...@@ -89,7 +89,9 @@ class TablePanel extends PanelDirective {
scope.$on('render', function(event, renderData) { scope.$on('render', function(event, renderData) {
data = renderData || data; data = renderData || data;
renderPanel(); if (data) {
renderPanel();
}
}); });
} }
} }
......
...@@ -59,7 +59,6 @@ export class TextPanelCtrl extends PanelCtrl { ...@@ -59,7 +59,6 @@ export class TextPanelCtrl extends PanelCtrl {
this.updateContent(this.converter.makeHtml(text)); this.updateContent(this.converter.makeHtml(text));
} else { } else {
System.import('vendor/showdown').then(Showdown => { System.import('vendor/showdown').then(Showdown => {
console.log(this);
this.converter = new Showdown.converter(); this.converter = new Showdown.converter();
this.$scope.$apply(() => { this.$scope.$apply(() => {
this.updateContent(this.converter.makeHtml(text)); this.updateContent(this.converter.makeHtml(text));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment