Commit ae4bcdd5 by Mitsuhiro Tanda

fix query inspector for cloudwatch

parent 5e11f1a2
......@@ -113,7 +113,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
};
this.performTimeSeriesQuery = function(request) {
return backendSrv.post('/api/tsdb/query', request).then(function (res) {
return this.awsRequest('/api/tsdb/query', request).then(function (res) {
var data = [];
if (res.results) {
......@@ -139,7 +139,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
this.doMetricQueryRequest = function (subtype, parameters) {
var range = timeSrv.timeRange();
return backendSrv.post('/api/tsdb/query', {
return this.awsRequest('/api/tsdb/query', {
from: range.from.valueOf().toString(),
to: range.to.valueOf().toString(),
queries: [
......@@ -277,7 +277,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
alarmNamePrefix: annotation.alarmNamePrefix || ''
};
return backendSrv.post('/api/tsdb/query', {
return this.awsRequest('/api/tsdb/query', {
from: options.range.from.valueOf().toString(),
to: options.range.to.valueOf().toString(),
queries: [
......@@ -325,15 +325,15 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
});
};
this.awsRequest = function(data) {
this.awsRequest = function(url, data) {
var options = {
method: 'POST',
url: this.proxyUrl,
url: url,
data: data
};
return backendSrv.datasourceRequest(options).then(function(result) {
return result.data;
return result;
});
};
......
......@@ -66,8 +66,8 @@ describe('CloudWatchDatasource', function() {
};
beforeEach(function() {
ctx.backendSrv.post = function(path, params) {
requestParams = params;
ctx.backendSrv.datasourceRequest = function(params) {
requestParams = params.data;
return ctx.$q.when(response);
};
});
......@@ -211,8 +211,8 @@ describe('CloudWatchDatasource', function() {
};
beforeEach(function() {
ctx.backendSrv.post = function(path, params) {
requestParams = params;
ctx.backendSrv.datasourceRequest = function(params) {
requestParams = params.data;
return ctx.$q.when(response);
};
});
......@@ -234,11 +234,7 @@ describe('CloudWatchDatasource', function() {
beforeEach(() => {
setupCallback();
ctx.backendSrv.datasourceRequest = args => {
scenario.request = args;
return ctx.$q.when({ data: scenario.requestResponse });
};
ctx.backendSrv.post = (path, args) => {
scenario.request = args;
scenario.request = args.data;
return ctx.$q.when(scenario.requestResponse);
};
ctx.ds.metricFindQuery(query).then(args => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment