mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(panel): more panel base infrastructure
This commit is contained in:
@@ -14,18 +14,20 @@ export class PanelCtrl {
|
||||
name: string;
|
||||
icon: string;
|
||||
editorTabs: any;
|
||||
$scope: any;
|
||||
|
||||
constructor(private scope) {
|
||||
constructor($scope) {
|
||||
var plugin = config.panels[this.panel.type];
|
||||
|
||||
this.$scope = $scope;
|
||||
this.name = plugin.name;
|
||||
this.icon = plugin.info.icon;
|
||||
this.editorTabIndex = 0;
|
||||
this.publishAppEvent('panel-instantiated', {scope: scope});
|
||||
this.publishAppEvent('panel-instantiated', {scope: $scope});
|
||||
}
|
||||
|
||||
publishAppEvent(evtName, evt) {
|
||||
this.scope.$root.appEvent(evtName, evt);
|
||||
this.$scope.$root.appEvent(evtName, evt);
|
||||
}
|
||||
|
||||
changeView(fullscreen, edit) {
|
||||
@@ -53,8 +55,11 @@ export class PanelCtrl {
|
||||
initEditorTabs() {
|
||||
this.editorTabs = [];
|
||||
this.editorTabs.push({title: 'General', directiveFn: generalOptionsTabEditorTab});
|
||||
this.editorTabs = this.editorTabs.concat(this.getEditorTabs());
|
||||
}
|
||||
|
||||
getEditorTabs() { return [];}
|
||||
|
||||
getMenu() {
|
||||
let menu = [];
|
||||
menu.push({text: 'View', click: 'ctrl.viewPanel(); dismiss();'});
|
||||
@@ -74,6 +79,10 @@ export class PanelDirective {
|
||||
controllerAs: string;
|
||||
|
||||
getDirective() {
|
||||
if (!this.controller) {
|
||||
this.controller = PanelCtrl;
|
||||
}
|
||||
|
||||
return {
|
||||
template: this.template,
|
||||
templateUrl: this.templateUrl,
|
||||
|
||||
@@ -2,20 +2,25 @@
|
||||
|
||||
import {PanelDirective, PanelCtrl} from '../../../features/panel/panel';
|
||||
|
||||
class TestPanelCtrl extends PanelCtrl {
|
||||
function optionsTab() {
|
||||
return {
|
||||
template: '<h2>options!</h2>'
|
||||
};
|
||||
}
|
||||
|
||||
export class TestPanelCtrl extends PanelCtrl {
|
||||
constructor($scope) {
|
||||
super($scope);
|
||||
}
|
||||
}
|
||||
|
||||
getEditorTabs() {
|
||||
return [{title: 'Options', directiveFn: optionsTab}];
|
||||
}
|
||||
}
|
||||
|
||||
class TestPanel extends PanelDirective {
|
||||
templateUrl = `app/plugins/panel/test/module.html`;
|
||||
controller = TestPanelCtrl;
|
||||
}
|
||||
|
||||
export {
|
||||
TestPanelCtrl,
|
||||
// testPanelDirective as panel,
|
||||
TestPanel as Panel,
|
||||
}
|
||||
export {TestPanel as Panel}
|
||||
|
||||
Reference in New Issue
Block a user