query_editor_row.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import angular from 'angular';
  2. const module = angular.module('grafana.directives');
  3. export class QueryRowCtrl {
  4. target: any;
  5. queryCtrl: any;
  6. panelCtrl: any;
  7. panel: any;
  8. hasTextEditMode: boolean;
  9. constructor() {
  10. this.panelCtrl = this.queryCtrl.panelCtrl;
  11. this.target = this.queryCtrl.target;
  12. this.panel = this.panelCtrl.panel;
  13. if (this.hasTextEditMode && this.queryCtrl.toggleEditorMode) {
  14. // expose this function to react parent component
  15. this.panelCtrl.toggleEditorMode = this.queryCtrl.toggleEditorMode.bind(this.queryCtrl);
  16. }
  17. if (this.queryCtrl.getCollapsedText) {
  18. // expose this function to react parent component
  19. this.panelCtrl.getCollapsedText = this.queryCtrl.getCollapsedText.bind(this.queryCtrl);
  20. }
  21. }
  22. }
  23. /** @ngInject */
  24. function queryEditorRowDirective() {
  25. return {
  26. restrict: 'E',
  27. controller: QueryRowCtrl,
  28. bindToController: true,
  29. controllerAs: 'ctrl',
  30. templateUrl: 'public/app/features/panel/partials/query_editor_row.html',
  31. transclude: true,
  32. scope: {
  33. queryCtrl: '=',
  34. canCollapse: '=',
  35. hasTextEditMode: '=',
  36. },
  37. };
  38. }
  39. module.directive('queryEditorRow', queryEditorRowDirective);