mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataSourceApi: convert interface to abstract class (#16979)
* DataSourceApi as class * add diff signature * Prometheus: moved directUrl to jsonData
This commit is contained in:
committed by
Torkel Ödegaard
parent
5573d28582
commit
1d7bb2a763
@@ -9,8 +9,16 @@ import { logStreamToSeriesData } from './result_transformer';
|
||||
import { formatQuery, parseQuery } from './query_utils';
|
||||
|
||||
// Types
|
||||
import { PluginMeta, DataQueryRequest, SeriesData } from '@grafana/ui/src/types';
|
||||
import { LokiQuery } from './types';
|
||||
import {
|
||||
PluginMeta,
|
||||
DataQueryRequest,
|
||||
SeriesData,
|
||||
DataSourceApi,
|
||||
DataSourceInstanceSettings,
|
||||
} from '@grafana/ui/src/types';
|
||||
import { LokiQuery, LokiOptions } from './types';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
|
||||
export const DEFAULT_MAX_LINES = 1000;
|
||||
|
||||
@@ -30,12 +38,17 @@ function serializeParams(data: any) {
|
||||
.join('&');
|
||||
}
|
||||
|
||||
export class LokiDatasource {
|
||||
export class LokiDatasource extends DataSourceApi<LokiQuery, LokiOptions> {
|
||||
languageProvider: LanguageProvider;
|
||||
maxLines: number;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private instanceSettings, private backendSrv, private templateSrv) {
|
||||
constructor(
|
||||
private instanceSettings: DataSourceInstanceSettings<LokiOptions>,
|
||||
private backendSrv: BackendSrv,
|
||||
private templateSrv: TemplateSrv
|
||||
) {
|
||||
super(instanceSettings);
|
||||
this.languageProvider = new LanguageProvider(this);
|
||||
const settingsData = instanceSettings.jsonData || {};
|
||||
this.maxLines = parseInt(settingsData.maxLines, 10) || DEFAULT_MAX_LINES;
|
||||
|
||||
Reference in New Issue
Block a user