mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 20:59:35 +08:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import _ from 'lodash';
|
|
import './query_filter_ctrl';
|
|
import { react2AngularDirective } from 'app/core/utils/react2angular';
|
|
import { AnnotationQueryEditor } from './components/AnnotationQueryEditor';
|
|
|
|
export class StackdriverAnnotationsQueryCtrl {
|
|
static templateUrl = 'partials/annotations.editor.html';
|
|
annotation: any;
|
|
datasource: any;
|
|
|
|
defaultDropdownValue = 'Select Metric';
|
|
defaultServiceValue = 'All Services';
|
|
|
|
defaults = {
|
|
project: {
|
|
id: 'default',
|
|
name: 'loading project...',
|
|
},
|
|
metricType: this.defaultDropdownValue,
|
|
service: this.defaultServiceValue,
|
|
metric: '',
|
|
filters: [],
|
|
metricKind: '',
|
|
valueType: '',
|
|
};
|
|
|
|
/** @ngInject */
|
|
constructor() {
|
|
this.annotation.target = this.annotation.target || {};
|
|
this.annotation.target.refId = 'annotationQuery';
|
|
_.defaultsDeep(this.annotation.target, this.defaults);
|
|
this.handleQueryChange = this.handleQueryChange.bind(this);
|
|
|
|
react2AngularDirective('annotationQueryEditor', AnnotationQueryEditor, [
|
|
'target',
|
|
'onQueryChange',
|
|
'onExecuteQuery',
|
|
['datasource', { watchDepth: 'reference' }],
|
|
]);
|
|
}
|
|
|
|
handleQueryChange(target) {
|
|
Object.assign(this.annotation.target, target);
|
|
}
|
|
}
|