Browse Source

Get datasource type from Grafana API (#71)

master
rozetko 6 years ago committed by Alexey Velikiy
parent
commit
039719619c
  1. 6
      src/module.ts
  2. 3
      src/services/analytic_service.ts

6
src/module.ts

@ -187,14 +187,16 @@ class GraphCtrl extends MetricsPanelCtrl {
this.render(this.seriesList);
this.$scope.$digest();
});
appEvents.on('ds-request-response', data => {
let requestConfig = data.config;
this.datasourceRequest = {
url: requestConfig.url,
type: requestConfig.inspect.type,
method: requestConfig.method,
data: requestConfig.data,
params: requestConfig.params
params: requestConfig.params,
type: undefined
};
});

3
src/services/analytic_service.ts

@ -15,6 +15,9 @@ export class AnalyticService {
metric: MetricExpanded, datasourceRequest: DatasourceRequest,
newItem: AnalyticUnit, panelId: number
): Promise<AnalyticUnitId> {
let datasource = await this._backendSrv.get(`/api/datasources/name/${metric.datasource}`);
datasourceRequest.type = datasource.type;
return this._backendSrv.post(
this._backendURL + '/analyticUnits',
{

Loading…
Cancel
Save