|
@@ -44,6 +44,11 @@ System.register(['lodash'], function (_export, _context) {
|
|
|
this.q = $q;
|
|
|
this.backendSrv = backendSrv;
|
|
|
this.templateSrv = templateSrv;
|
|
|
+ this.withCredentials = instanceSettings.withCredentials;
|
|
|
+ this.headers = { 'Content-Type': 'application/json' };
|
|
|
+ if (typeof instanceSettings.basicAuth === 'string' && instanceSettings.basicAuth.length > 0) {
|
|
|
+ this.headers['Authorization'] = instanceSettings.basicAuth;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
_createClass(GenericDatasource, [{
|
|
@@ -58,17 +63,16 @@ System.register(['lodash'], function (_export, _context) {
|
|
|
return this.q.when({ data: [] });
|
|
|
}
|
|
|
|
|
|
- return this.backendSrv.datasourceRequest({
|
|
|
+ return this.doRequest({
|
|
|
url: this.url + '/query',
|
|
|
data: query,
|
|
|
- method: 'POST',
|
|
|
- headers: { 'Content-Type': 'application/json' }
|
|
|
+ method: 'POST'
|
|
|
});
|
|
|
}
|
|
|
}, {
|
|
|
key: 'testDatasource',
|
|
|
value: function testDatasource() {
|
|
|
- return this.backendSrv.datasourceRequest({
|
|
|
+ return this.doRequest({
|
|
|
url: this.url + '/',
|
|
|
method: 'GET'
|
|
|
}).then(function (response) {
|
|
@@ -93,7 +97,7 @@ System.register(['lodash'], function (_export, _context) {
|
|
|
rangeRaw: options.rangeRaw
|
|
|
};
|
|
|
|
|
|
- return this.backendSrv.datasourceRequest({
|
|
|
+ return this.doRequest({
|
|
|
url: this.url + '/annotations',
|
|
|
method: 'POST',
|
|
|
data: annotationQuery
|
|
@@ -103,17 +107,15 @@ System.register(['lodash'], function (_export, _context) {
|
|
|
}
|
|
|
}, {
|
|
|
key: 'metricFindQuery',
|
|
|
- value: function metricFindQuery(options) {
|
|
|
- var target = typeof options === "string" ? options : options.target;
|
|
|
+ value: function metricFindQuery(query) {
|
|
|
var interpolated = {
|
|
|
- target: this.templateSrv.replace(target, null, 'regex')
|
|
|
+ target: this.templateSrv.replace(query, null, 'regex')
|
|
|
};
|
|
|
|
|
|
- return this.backendSrv.datasourceRequest({
|
|
|
+ return this.doRequest({
|
|
|
url: this.url + '/search',
|
|
|
data: interpolated,
|
|
|
- method: 'POST',
|
|
|
- headers: { 'Content-Type': 'application/json' }
|
|
|
+ method: 'POST'
|
|
|
}).then(this.mapToTextValue);
|
|
|
}
|
|
|
}, {
|
|
@@ -128,6 +130,14 @@ System.register(['lodash'], function (_export, _context) {
|
|
|
return { text: d, value: d };
|
|
|
});
|
|
|
}
|
|
|
+ }, {
|
|
|
+ key: 'doRequest',
|
|
|
+ value: function doRequest(options) {
|
|
|
+ options.withCredentials = this.withCredentials;
|
|
|
+ options.headers = this.headers;
|
|
|
+
|
|
|
+ return this.backendSrv.datasourceRequest(options);
|
|
|
+ }
|
|
|
}, {
|
|
|
key: 'buildQueryParameters',
|
|
|
value: function buildQueryParameters(options) {
|
|
@@ -140,7 +150,7 @@ System.register(['lodash'], function (_export, _context) {
|
|
|
|
|
|
var targets = _.map(options.targets, function (target) {
|
|
|
return {
|
|
|
- target: _this.templateSrv.replace(target.target),
|
|
|
+ target: _this.templateSrv.replace(target.target, options.scopedVars, 'regex'),
|
|
|
refId: target.refId,
|
|
|
hide: target.hide,
|
|
|
type: target.type || 'timeserie'
|