query_ctrl.js 758 B

1234567891011121314151617181920212223242526
  1. import {QueryCtrl} from 'app/plugins/sdk';
  2. import './css/query-editor.css!'
  3. export class GenericDatasourceQueryCtrl extends QueryCtrl {
  4. constructor($scope, $injector, uiSegmentSrv) {
  5. super($scope, $injector);
  6. this.scope = $scope;
  7. this.uiSegmentSrv = uiSegmentSrv;
  8. this.target.target = this.target.target || 'select metric';
  9. }
  10. getOptions() {
  11. return this.datasource.metricFindQuery(this.target)
  12. .then(this.uiSegmentSrv.transformToSegments(false));
  13. // Options have to be transformed by uiSegmentSrv to be usable by metric-segment-model directive
  14. }
  15. onChangeInternal() {
  16. this.panelCtrl.refresh(); // Asks the panel to refresh data.
  17. }
  18. }
  19. GenericDatasourceQueryCtrl.templateUrl = 'partials/query.editor.html';