ソースを参照

feat(panels): fixes

Torkel Ödegaard 10 年 前
コミット
56c76f380b

+ 1 - 1
public/app/core/components/grafana_app.ts

@@ -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 {
 
 

+ 1 - 0
public/app/features/panel/metrics_panel_ctrl.ts

@@ -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();
   }
   }
 
 

+ 6 - 3
public/app/features/panel/panel_ctrl.ts

@@ -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 {
         return {templateUrl: directiveFn};
         return {templateUrl: directiveFn};
       };
       };
     }
     }
-
-    this.editorTabs.push(editorTab);
+    if (index) {
+      this.editorTabs.splice(index, 0, editorTab);
+    } else {
+      this.editorTabs.push(editorTab);
+    }
   }
   }
 
 
   getMenu() {
   getMenu() {

+ 0 - 1
public/app/features/panel/panel_editor_tab.ts

@@ -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}`,

+ 9 - 6
public/app/plugins/panel/graph/graph_ctrl.ts

@@ -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('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 = {
     this.logScales = {
       'linear': 1,
       'linear': 1,
       'log (base 2)': 2,
       'log (base 2)': 2,
@@ -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();

+ 2 - 4
public/app/plugins/panel/singlestat/controller.ts

@@ -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');
-    this.addEditorTab('Time range', 'app/features/panel/partials/panelTime.html');
-
+    this.addEditorTab('Options', 'app/plugins/panel/singlestat/editor.html', 2);
     this.unitFormats = kbn.getUnitFormats();
     this.unitFormats = kbn.getUnitFormats();
   }
   }
 
 

+ 2 - 3
public/app/plugins/panel/table/controller.ts

@@ -57,13 +57,12 @@ export class TablePanelCtrl extends MetricsPanelCtrl {
 
 
   initEditMode() {
   initEditMode() {
     super.initEditMode();
     super.initEditMode();
-    this.addEditorTab('Options', tablePanelEditor);
-    this.addEditorTab('Time range', 'app/features/panel/partials/panelTime.html');
+    this.addEditorTab('Options', tablePanelEditor, 1);
   }
   }
 
 
   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;
   }
   }
 
 

+ 3 - 1
public/app/plugins/panel/table/module.ts

@@ -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();
+      }
     });
     });
   }
   }
 }
 }

+ 0 - 1
public/app/plugins/panel/text/module.ts

@@ -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));