import { DataSourcePlugin } from '@grafana/data'; import { createChangeHandler, createResetHandler, PasswordFieldEnum, } from '../../../features/datasources/utils/passwordHandlers'; import { MysqlDatasource } from './datasource'; import { MysqlQueryCtrl } from './query_ctrl'; import { MySQLQuery } from './types'; class MysqlConfigCtrl { static templateUrl = 'partials/config.html'; current: any; onPasswordReset: ReturnType; onPasswordChange: ReturnType; constructor() { this.onPasswordReset = createResetHandler(this, PasswordFieldEnum.Password); this.onPasswordChange = createChangeHandler(this, PasswordFieldEnum.Password); } } const defaultQuery = `SELECT UNIX_TIMESTAMP() as time_sec, as text, as tags FROM WHERE $__timeFilter(time_column) ORDER BY ASC LIMIT 100 `; class MysqlAnnotationsQueryCtrl { static templateUrl = 'partials/annotations.editor.html'; declare annotation: any; /** @ngInject */ constructor($scope: any) { this.annotation = $scope.ctrl.annotation; this.annotation.rawQuery = this.annotation.rawQuery || defaultQuery; } } export { MysqlDatasource, MysqlDatasource as Datasource, MysqlQueryCtrl as QueryCtrl, MysqlConfigCtrl as ConfigCtrl, MysqlAnnotationsQueryCtrl as AnnotationsQueryCtrl, }; export const plugin = new DataSourcePlugin(MysqlDatasource) .setQueryCtrl(MysqlQueryCtrl) .setConfigCtrl(MysqlConfigCtrl) .setAnnotationQueryCtrl(MysqlAnnotationsQueryCtrl);