grafana/public/app/plugins/datasource/stackdriver/query_ctrl.ts

40 lines
1.2 KiB
TypeScript
Raw Normal View History

import _ from 'lodash';
2018-09-04 19:21:02 +08:00
import { QueryCtrl } from 'app/plugins/sdk';
import './query_filter_ctrl';
2018-12-18 18:25:13 +08:00
import { StackdriverPicker } from './components/StackdriverPicker';
import { react2AngularDirective } from 'app/core/utils/react2angular';
import { registerAngularDirectives } from './angular_wrappers';
2018-12-22 06:07:46 +08:00
import { Target } from './types';
2018-09-04 19:21:02 +08:00
export class StackdriverQueryCtrl extends QueryCtrl {
static templateUrl = 'partials/query.editor.html';
uiSegmentSrv: any;
2018-09-04 19:21:02 +08:00
/** @ngInject */
2018-12-22 06:21:55 +08:00
constructor($scope, $injector, uiSegmentSrv) {
2018-09-04 19:21:02 +08:00
super($scope, $injector);
this.uiSegmentSrv = uiSegmentSrv;
2018-12-18 18:31:11 +08:00
react2AngularDirective('stackdriverPicker', StackdriverPicker, [
'options',
'onChange',
'selected',
2018-12-12 03:12:33 +08:00
'searchable',
'className',
'placeholder',
'groupName',
['templateVariables', { watchDepth: 'reference' }],
2018-12-12 03:12:33 +08:00
]);
registerAngularDirectives();
2018-12-22 06:07:46 +08:00
this.handleQueryChange = this.handleQueryChange.bind(this);
this.handleExecuteQuery = this.handleExecuteQuery.bind(this);
2018-12-13 07:16:48 +08:00
}
2018-12-19 21:19:27 +08:00
handleQueryChange(target: Target) {
Object.assign(this.target, target);
2018-12-13 07:16:48 +08:00
}
2018-12-19 21:19:27 +08:00
handleExecuteQuery() {
this.$scope.ctrl.refresh();
2018-09-13 17:02:31 +08:00
}
2018-09-04 19:21:02 +08:00
}