Files
grafana/public/app/features/panel/panel.ts

93 lines
2.0 KiB
TypeScript
Raw Normal View History

2016-01-22 19:59:36 +01:00
///<reference path="../../headers/common.d.ts" />
2016-01-24 17:30:29 -05:00
import config from 'app/core/config';
function generalOptionsTabEditorTab() {
return {templateUrl: 'public/app/partials/panelgeneral.html'};
}
2016-01-22 19:59:36 +01:00
export class PanelCtrl {
panel: any;
row: any;
dashboard: any;
2016-01-24 17:30:29 -05:00
editorTabIndex: number;
name: string;
icon: string;
editorTabs: any;
2016-01-22 19:59:36 +01:00
2016-01-23 01:44:38 +01:00
constructor(private scope) {
2016-01-24 17:30:29 -05:00
var plugin = config.panels[this.panel.type];
this.name = plugin.name;
this.icon = plugin.info.icon;
this.editorTabIndex = 0;
2016-01-23 01:44:38 +01:00
this.publishAppEvent('panel-instantiated', {scope: scope});
}
publishAppEvent(evtName, evt) {
this.scope.$root.appEvent(evtName, evt);
}
2016-01-23 15:40:30 -05:00
changeView(fullscreen, edit) {
2016-01-23 01:44:38 +01:00
this.publishAppEvent('panel-change-view', {
2016-01-23 15:40:30 -05:00
fullscreen: fullscreen, edit: edit, panelId: this.panel.id
2016-01-23 01:44:38 +01:00
});
2016-01-22 19:59:36 +01:00
}
2016-01-23 15:40:30 -05:00
viewPanel() {
this.changeView(true, false);
}
editPanel() {
2016-01-24 17:30:29 -05:00
if (!this.editorTabs) {
this.initEditorTabs();
}
2016-01-23 15:40:30 -05:00
this.changeView(true, true);
}
exitFullscreen() {
this.changeView(false, false);
}
2016-01-24 17:30:29 -05:00
initEditorTabs() {
this.editorTabs = [];
this.editorTabs.push({title: 'General', directiveFn: generalOptionsTabEditorTab});
}
getMenu() {
let menu = [];
menu.push({text: 'View', click: 'ctrl.viewPanel(); dismiss();'});
menu.push({text: 'Edit', click: 'ctrl.editPanel(); dismiss();', role: 'Editor'});
menu.push({text: 'Duplicate', click: 'ctrl.duplicate()', role: 'Editor' });
menu.push({text: 'Share', click: 'ctrl.share(); dismiss();'});
return menu;
}
2016-01-22 19:59:36 +01:00
}
export class PanelDirective {
template: string;
templateUrl: string;
bindToController: boolean;
scope: any;
controller: any;
controllerAs: string;
getDirective() {
return {
template: this.template,
templateUrl: this.templateUrl,
controller: this.controller,
controllerAs: 'ctrl',
bindToController: true,
scope: {dashboard: "=", panel: "=", row: "="},
link: this.link
};
}
link(scope) {
return null;
}
}
2016-01-22 19:59:36 +01:00