query_ctrl.ts 1.2 KB

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