query_ctrl.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import _ from 'lodash';
  2. import { QueryCtrl } from 'app/plugins/sdk';
  3. import './query_aggregation_ctrl';
  4. import './query_filter_ctrl';
  5. import { StackdriverPicker } from './components/StackdriverPicker';
  6. import { react2AngularDirective } from 'app/core/utils/react2angular';
  7. import { registerAngularDirectives } from './angular_wrappers';
  8. import { Target } from './types';
  9. export class StackdriverQueryCtrl extends QueryCtrl {
  10. static templateUrl = 'partials/query.editor.html';
  11. templateSrv: any;
  12. uiSegmentSrv: any;
  13. /** @ngInject */
  14. constructor($scope, $injector, templateSrv, uiSegmentSrv) {
  15. super($scope, $injector);
  16. this.templateSrv = templateSrv;
  17. this.uiSegmentSrv = uiSegmentSrv;
  18. react2AngularDirective('stackdriverPicker', StackdriverPicker, [
  19. 'options',
  20. 'onChange',
  21. 'selected',
  22. 'searchable',
  23. 'className',
  24. 'placeholder',
  25. 'groupName',
  26. ['templateVariables', { watchDepth: 'reference' }],
  27. ]);
  28. registerAngularDirectives();
  29. this.handleQueryChange = this.handleQueryChange.bind(this);
  30. this.handleExecuteQuery = this.handleExecuteQuery.bind(this);
  31. }
  32. handleQueryChange(target: Target) {
  33. Object.assign(this.target, target);
  34. }
  35. handleExecuteQuery() {
  36. this.$scope.ctrl.refresh();
  37. }
  38. }