2017-12-20 05:33:33 -06:00
|
|
|
import angular from 'angular';
|
2016-02-02 09:32:36 -06:00
|
|
|
|
2018-08-26 13:19:23 -05:00
|
|
|
const module = angular.module('grafana.directives');
|
2016-02-02 09:32:36 -06:00
|
|
|
|
2016-04-17 15:43:13 -05:00
|
|
|
export class QueryRowCtrl {
|
|
|
|
target: any;
|
|
|
|
queryCtrl: any;
|
|
|
|
panelCtrl: any;
|
|
|
|
panel: any;
|
2019-01-16 10:53:40 -06:00
|
|
|
hasTextEditMode: boolean;
|
2016-04-17 15:43:13 -05:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.panelCtrl = this.queryCtrl.panelCtrl;
|
|
|
|
this.target = this.queryCtrl.target;
|
|
|
|
this.panel = this.panelCtrl.panel;
|
|
|
|
|
2019-02-21 06:34:10 -06:00
|
|
|
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
|
|
|
}
|
2016-04-17 15:43:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-31 09:40:43 -05:00
|
|
|
/** @ngInject */
|
2016-02-02 09:32:36 -06:00
|
|
|
function queryEditorRowDirective() {
|
|
|
|
return {
|
2017-12-20 05:33:33 -06:00
|
|
|
restrict: 'E',
|
2016-04-17 15:43:13 -05:00
|
|
|
controller: QueryRowCtrl,
|
|
|
|
bindToController: true,
|
2017-12-20 05:33:33 -06:00
|
|
|
controllerAs: 'ctrl',
|
|
|
|
templateUrl: 'public/app/features/panel/partials/query_editor_row.html',
|
2016-02-02 09:32:36 -06:00
|
|
|
transclude: true,
|
2016-04-17 15:43:13 -05:00
|
|
|
scope: {
|
2017-12-20 05:33:33 -06:00
|
|
|
queryCtrl: '=',
|
|
|
|
canCollapse: '=',
|
|
|
|
hasTextEditMode: '=',
|
|
|
|
},
|
2016-02-02 09:32:36 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-12-20 05:33:33 -06:00
|
|
|
module.directive('queryEditorRow', queryEditorRowDirective);
|