module.ts 948 B

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