Commit 56c76f38 by Torkel Ödegaard

feat(panels): fixes

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