2022-04-22 08:33:13 -05:00
|
|
|
import { DataSourcePlugin } from '@grafana/data';
|
|
|
|
|
2022-07-14 06:29:08 -05:00
|
|
|
import { PostgresConfigEditor } from './configuration/ConfigurationEditor';
|
2017-12-20 05:33:33 -06:00
|
|
|
import { PostgresDatasource } from './datasource';
|
|
|
|
import { PostgresQueryCtrl } from './query_ctrl';
|
2022-07-14 06:29:08 -05:00
|
|
|
import { PostgresOptions, PostgresQuery, SecureJsonData } from './types';
|
2017-10-10 08:19:14 -05:00
|
|
|
|
|
|
|
const defaultQuery = `SELECT
|
|
|
|
extract(epoch from time_column) AS time,
|
2017-10-18 11:10:01 -05:00
|
|
|
text_column as text,
|
|
|
|
tags_column as tags
|
2017-10-10 08:19:14 -05:00
|
|
|
FROM
|
|
|
|
metric_table
|
|
|
|
WHERE
|
|
|
|
$__timeFilter(time_column)
|
|
|
|
`;
|
|
|
|
|
|
|
|
class PostgresAnnotationsQueryCtrl {
|
2017-12-20 05:33:33 -06:00
|
|
|
static templateUrl = 'partials/annotations.editor.html';
|
2017-10-10 08:19:14 -05:00
|
|
|
|
2021-04-23 07:06:30 -05:00
|
|
|
declare annotation: any;
|
2017-10-10 08:19:14 -05:00
|
|
|
|
2018-08-31 09:40:43 -05:00
|
|
|
/** @ngInject */
|
2021-04-23 07:06:30 -05:00
|
|
|
constructor($scope: any) {
|
|
|
|
this.annotation = $scope.ctrl.annotation;
|
2017-10-10 08:19:14 -05:00
|
|
|
this.annotation.rawQuery = this.annotation.rawQuery || defaultQuery;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-14 06:29:08 -05:00
|
|
|
export const plugin = new DataSourcePlugin<PostgresDatasource, PostgresQuery, PostgresOptions, SecureJsonData>(
|
|
|
|
PostgresDatasource
|
|
|
|
)
|
2021-05-05 09:46:07 -05:00
|
|
|
.setQueryCtrl(PostgresQueryCtrl)
|
2022-07-14 06:29:08 -05:00
|
|
|
.setConfigEditor(PostgresConfigEditor)
|
2021-05-05 09:46:07 -05:00
|
|
|
.setAnnotationQueryCtrl(PostgresAnnotationsQueryCtrl);
|