Skip to content

Commit

Permalink
Removed @grafana/data import to enabeld backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudioWaldvogel committed Jan 14, 2021
1 parent 2d05543 commit 7c89902
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
.vscode/
.vscode/
.idea/
6 changes: 2 additions & 4 deletions dist/datasource.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
var data_1 = require("@grafana/data");
// @ts-ignore
var kbn = require("app/core/utils/kbn");
var ApmDatasource = /** @class */ (function () {
function ApmDatasource(instanceSettings, $q, backendSrv, templateSrv) {
Expand All @@ -16,11 +14,11 @@ var ApmDatasource = /** @class */ (function () {
if (window.DOMParser) {
this.parser = new DOMParser();
}
if (!data_1.rangeUtil.intervalToSeconds) {
if (kbn.interval_to_seconds) {
this.intervalToSeconds = kbn.interval_to_seconds;
}
else {
this.intervalToSeconds = data_1.rangeUtil.intervalToSeconds;
this.intervalToSeconds = kbn.intervalToSeconds;
}
}
ApmDatasource.prototype.query = function (options) {
Expand Down
9 changes: 4 additions & 5 deletions src/datasource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// @ts-ignore
import { rangeUtil } from '@grafana/data';
// @ts-ignore
import * as kbn from 'app/core/utils/kbn';
import ApmRawQuery from './apmrawquery'

Expand All @@ -12,6 +10,7 @@ export class ApmDatasource {
soapHead: string = '<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:met=\"http://metricslist.webservicesimpl.server.introscope.wily.com\"><soapenv:Header/><soapenv:Body>';
soapTail: string= '</soapenv:Body></soapenv:Envelope>';

// Wrapper function for kbn.interval_to_seconds since this was renamed in Grafana 7.x to kbn.intervalToSeconds...
private intervalToSeconds: (interval: string) => any;

constructor(instanceSettings, private $q, private backendSrv, private templateSrv) {
Expand All @@ -23,10 +22,10 @@ export class ApmDatasource {
this.parser = new DOMParser();
}

if (!rangeUtil.intervalToSeconds) {
if (kbn.interval_to_seconds) {
this.intervalToSeconds = kbn.interval_to_seconds;
} else {
this.intervalToSeconds = rangeUtil.intervalToSeconds;
this.intervalToSeconds = kbn.intervalToSeconds
}
}

Expand Down Expand Up @@ -444,4 +443,4 @@ interface Target {
interface MetricPoint {
metricKey: string;
metricValue: number;
}
}

0 comments on commit 7c89902

Please sign in to comment.