annotations_query_ctrl.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import _ from 'lodash';
  2. import './query_filter_ctrl';
  3. import { react2AngularDirective } from 'app/core/utils/react2angular';
  4. import { AnnotationQueryEditor } from './components/AnnotationQueryEditor';
  5. export class StackdriverAnnotationsQueryCtrl {
  6. static templateUrl = 'partials/annotations.editor.html';
  7. annotation: any;
  8. datasource: any;
  9. defaultDropdownValue = 'Select Metric';
  10. defaultServiceValue = 'All Services';
  11. defaults = {
  12. project: {
  13. id: 'default',
  14. name: 'loading project...',
  15. },
  16. metricType: this.defaultDropdownValue,
  17. service: this.defaultServiceValue,
  18. metric: '',
  19. filters: [],
  20. metricKind: '',
  21. valueType: '',
  22. };
  23. /** @ngInject */
  24. constructor() {
  25. this.annotation.target = this.annotation.target || {};
  26. this.annotation.target.refId = 'annotationQuery';
  27. _.defaultsDeep(this.annotation.target, this.defaults);
  28. this.handleQueryChange = this.handleQueryChange.bind(this);
  29. react2AngularDirective('annotationQueryEditor', AnnotationQueryEditor, [
  30. 'target',
  31. 'onQueryChange',
  32. 'onExecuteQuery',
  33. ['datasource', { watchDepth: 'reference' }],
  34. ]);
  35. }
  36. handleQueryChange(target) {
  37. Object.assign(this.annotation.target, target);
  38. }
  39. }