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

47 lines
1.2 KiB
TypeScript
Raw Normal View History

2017-12-20 05:33:33 -06:00
import angular from 'angular';
2018-08-26 13:19:23 -05:00
const module = angular.module('grafana.directives');
export class QueryRowCtrl {
target: any;
queryCtrl: any;
panelCtrl: any;
panel: any;
2019-01-16 10:53:40 -06:00
hasTextEditMode: boolean;
constructor() {
this.panelCtrl = this.queryCtrl.panelCtrl;
this.target = this.queryCtrl.target;
this.panel = this.panelCtrl.panel;
if (this.hasTextEditMode && this.queryCtrl.toggleEditorMode) {
2019-01-17 06:08:20 -06:00
// expose this function to react parent component
this.panelCtrl.toggleEditorMode = this.queryCtrl.toggleEditorMode.bind(this.queryCtrl);
2019-01-16 10:53:40 -06:00
}
2019-01-17 06:08:20 -06:00
if (this.queryCtrl.getCollapsedText) {
// expose this function to react parent component
this.panelCtrl.getCollapsedText = this.queryCtrl.getCollapsedText.bind(this.queryCtrl);
2016-04-27 03:16:04 -05:00
}
}
}
/** @ngInject */
function queryEditorRowDirective() {
return {
2017-12-20 05:33:33 -06:00
restrict: 'E',
controller: QueryRowCtrl,
bindToController: true,
2017-12-20 05:33:33 -06:00
controllerAs: 'ctrl',
templateUrl: 'public/app/features/panel/partials/query_editor_row.html',
transclude: true,
scope: {
2017-12-20 05:33:33 -06:00
queryCtrl: '=',
canCollapse: '=',
hasTextEditMode: '=',
},
};
}
2017-12-20 05:33:33 -06:00
module.directive('queryEditorRow', queryEditorRowDirective);