query_ctrl.ts 932 B

123456789101112131415161718192021222324252627282930313233
  1. import _ from 'lodash';
  2. import { QueryCtrl } from 'app/plugins/sdk';
  3. import { react2AngularDirective } from 'app/core/utils/react2angular';
  4. import { QueryEditor } from './components/QueryEditor';
  5. import { Target } from './types';
  6. export class StackdriverQueryCtrl extends QueryCtrl {
  7. static templateUrl = 'partials/query.editor.html';
  8. /** @ngInject */
  9. constructor($scope, $injector) {
  10. super($scope, $injector);
  11. this.handleQueryChange = this.handleQueryChange.bind(this);
  12. this.handleExecuteQuery = this.handleExecuteQuery.bind(this);
  13. react2AngularDirective('queryEditor', QueryEditor, [
  14. 'target',
  15. 'onQueryChange',
  16. 'onExecuteQuery',
  17. ['events', { watchDepth: 'reference' }],
  18. ['datasource', { watchDepth: 'reference' }],
  19. ]);
  20. }
  21. handleQueryChange(target: Target) {
  22. Object.assign(this.target, target);
  23. }
  24. handleExecuteQuery() {
  25. this.$scope.ctrl.refresh();
  26. }
  27. }