2022-04-22 08:33:13 -05:00
|
|
|
import { DataSourcePlugin } from '@grafana/data';
|
|
|
|
|
|
|
|
import { MssqlConfigCtrl } from './config_ctrl';
|
2018-03-13 10:03:02 -05:00
|
|
|
import { MssqlDatasource } from './datasource';
|
|
|
|
import { MssqlQueryCtrl } from './query_ctrl';
|
2021-05-05 09:46:07 -05:00
|
|
|
import { MssqlQuery } from './types';
|
2017-12-02 05:40:12 -06:00
|
|
|
|
2018-03-19 07:06:46 -05:00
|
|
|
const defaultQuery = `SELECT
|
|
|
|
<time_column> as time,
|
2017-12-02 05:40:12 -06:00
|
|
|
<text_column> as text,
|
|
|
|
<tags_column> as tags
|
2018-03-19 07:06:46 -05:00
|
|
|
FROM
|
|
|
|
<table name>
|
|
|
|
WHERE
|
|
|
|
$__timeFilter(time_column)
|
|
|
|
ORDER BY
|
|
|
|
<time_column> ASC`;
|
2017-12-02 05:40:12 -06:00
|
|
|
|
|
|
|
class MssqlAnnotationsQueryCtrl {
|
|
|
|
static templateUrl = 'partials/annotations.editor.html';
|
|
|
|
|
2021-05-05 09:46:07 -05:00
|
|
|
declare annotation: any;
|
2017-12-02 05:40:12 -06:00
|
|
|
|
2018-08-31 09:40:43 -05:00
|
|
|
/** @ngInject */
|
2021-05-05 09:46:07 -05:00
|
|
|
constructor($scope: any) {
|
|
|
|
this.annotation = $scope.ctrl.annotation;
|
2017-12-02 05:40:12 -06:00
|
|
|
this.annotation.rawQuery = this.annotation.rawQuery || defaultQuery;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-05 09:46:07 -05:00
|
|
|
export const plugin = new DataSourcePlugin<MssqlDatasource, MssqlQuery>(MssqlDatasource)
|
|
|
|
.setQueryCtrl(MssqlQueryCtrl)
|
|
|
|
.setConfigCtrl(MssqlConfigCtrl)
|
|
|
|
.setAnnotationQueryCtrl(MssqlAnnotationsQueryCtrl);
|