module.ts 947 B

12345678910111213141516171819202122232425262728293031323334
  1. import { DataSourcePlugin } from '@grafana/data';
  2. import { MssqlConfigCtrl } from './config_ctrl';
  3. import { MssqlDatasource } from './datasource';
  4. import { MssqlQueryCtrl } from './query_ctrl';
  5. import { MssqlQuery } from './types';
  6. const defaultQuery = `SELECT
  7. <time_column> as time,
  8. <text_column> as text,
  9. <tags_column> as tags
  10. FROM
  11. <table name>
  12. WHERE
  13. $__timeFilter(time_column)
  14. ORDER BY
  15. <time_column> ASC`;
  16. class MssqlAnnotationsQueryCtrl {
  17. static templateUrl = 'partials/annotations.editor.html';
  18. declare annotation: any;
  19. /** @ngInject */
  20. constructor($scope: any) {
  21. this.annotation = $scope.ctrl.annotation;
  22. this.annotation.rawQuery = this.annotation.rawQuery || defaultQuery;
  23. }
  24. }
  25. export const plugin = new DataSourcePlugin<MssqlDatasource, MssqlQuery>(MssqlDatasource)
  26. .setQueryCtrl(MssqlQueryCtrl)
  27. .setConfigCtrl(MssqlConfigCtrl)
  28. .setAnnotationQueryCtrl(MssqlAnnotationsQueryCtrl);