Chore: Remove angular dependency from data sources (#27735)

* Chore: Remove angular dependency from data sources

* Removes default export for time and template srvs
Also uses @grafana/runtime versions of the interfaces where possible

* Replace usage of internal templateSrv where possible

* Use runtime templateSrv in a couple more places
This commit is contained in:
kay delaney
2020-10-01 18:51:23 +01:00
committed by GitHub
parent 8a5fc00330
commit 185442115c
60 changed files with 302 additions and 334 deletions

View File

@@ -3,12 +3,11 @@ import { Observable, of } from 'rxjs';
import { catchError, map, mapTo } from 'rxjs/operators';
import { getBackendSrv } from '@grafana/runtime';
import { ScopedVars } from '@grafana/data';
import { TemplateSrv } from 'app/features/templating/template_srv';
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import MysqlQuery from 'app/plugins/datasource/mysql/mysql_query';
import ResponseParser, { MysqlResponse } from './response_parser';
import { MysqlMetricFindValue, MysqlQueryForInterpolation } from './types';
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { getSearchFilterScopedVar } from '../../../features/variables/utils';
export class MysqlDatasource {
@@ -18,8 +17,11 @@ export class MysqlDatasource {
queryModel: MysqlQuery;
interval: string;
/** @ngInject */
constructor(instanceSettings: any, private templateSrv: TemplateSrv, private timeSrv: TimeSrv) {
constructor(
instanceSettings: any,
private readonly templateSrv: TemplateSrv = getTemplateSrv(),
private readonly timeSrv: TimeSrv = getTimeSrv()
) {
this.name = instanceSettings.name;
this.id = instanceSettings.id;
this.responseParser = new ResponseParser();

View File

@@ -1,5 +1,5 @@
import _ from 'lodash';
import { TemplateSrv } from 'app/features/templating/template_srv';
import { TemplateSrv } from '@grafana/runtime';
import { ScopedVars } from '@grafana/data';
export default class MysqlQuery {

View File

@@ -6,11 +6,10 @@ import { SqlPart } from 'app/core/components/sql_part/sql_part';
import MysqlQuery from './mysql_query';
import sqlPart from './sql_part';
import { auto } from 'angular';
import { TemplateSrv } from 'app/features/templating/template_srv';
import { CoreEvents } from 'app/types';
import { PanelEvents } from '@grafana/data';
import { VariableWithMultiSupport } from 'app/features/variables/types';
import { getLocationSrv } from '@grafana/runtime';
import { getLocationSrv, TemplateSrv } from '@grafana/runtime';
export interface QueryMeta {
sql: string;