Commit ae4bcdd5 by Mitsuhiro Tanda

fix query inspector for cloudwatch

parent 5e11f1a2
...@@ -113,7 +113,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) { ...@@ -113,7 +113,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
}; };
this.performTimeSeriesQuery = function(request) { 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 = []; var data = [];
if (res.results) { if (res.results) {
...@@ -139,7 +139,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) { ...@@ -139,7 +139,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
this.doMetricQueryRequest = function (subtype, parameters) { this.doMetricQueryRequest = function (subtype, parameters) {
var range = timeSrv.timeRange(); var range = timeSrv.timeRange();
return backendSrv.post('/api/tsdb/query', { return this.awsRequest('/api/tsdb/query', {
from: range.from.valueOf().toString(), from: range.from.valueOf().toString(),
to: range.to.valueOf().toString(), to: range.to.valueOf().toString(),
queries: [ queries: [
...@@ -277,7 +277,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) { ...@@ -277,7 +277,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
alarmNamePrefix: annotation.alarmNamePrefix || '' alarmNamePrefix: annotation.alarmNamePrefix || ''
}; };
return backendSrv.post('/api/tsdb/query', { return this.awsRequest('/api/tsdb/query', {
from: options.range.from.valueOf().toString(), from: options.range.from.valueOf().toString(),
to: options.range.to.valueOf().toString(), to: options.range.to.valueOf().toString(),
queries: [ queries: [
...@@ -325,15 +325,15 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) { ...@@ -325,15 +325,15 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
}); });
}; };
this.awsRequest = function(data) { this.awsRequest = function(url, data) {
var options = { var options = {
method: 'POST', method: 'POST',
url: this.proxyUrl, url: url,
data: data data: data
}; };
return backendSrv.datasourceRequest(options).then(function(result) { return backendSrv.datasourceRequest(options).then(function(result) {
return result.data; return result;
}); });
}; };
......
...@@ -66,8 +66,8 @@ describe('CloudWatchDatasource', function() { ...@@ -66,8 +66,8 @@ describe('CloudWatchDatasource', function() {
}; };
beforeEach(function() { beforeEach(function() {
ctx.backendSrv.post = function(path, params) { ctx.backendSrv.datasourceRequest = function(params) {
requestParams = params; requestParams = params.data;
return ctx.$q.when(response); return ctx.$q.when(response);
}; };
}); });
...@@ -211,8 +211,8 @@ describe('CloudWatchDatasource', function() { ...@@ -211,8 +211,8 @@ describe('CloudWatchDatasource', function() {
}; };
beforeEach(function() { beforeEach(function() {
ctx.backendSrv.post = function(path, params) { ctx.backendSrv.datasourceRequest = function(params) {
requestParams = params; requestParams = params.data;
return ctx.$q.when(response); return ctx.$q.when(response);
}; };
}); });
...@@ -234,11 +234,7 @@ describe('CloudWatchDatasource', function() { ...@@ -234,11 +234,7 @@ describe('CloudWatchDatasource', function() {
beforeEach(() => { beforeEach(() => {
setupCallback(); setupCallback();
ctx.backendSrv.datasourceRequest = args => { ctx.backendSrv.datasourceRequest = args => {
scenario.request = args; scenario.request = args.data;
return ctx.$q.when({ data: scenario.requestResponse });
};
ctx.backendSrv.post = (path, args) => {
scenario.request = args;
return ctx.$q.when(scenario.requestResponse); return ctx.$q.when(scenario.requestResponse);
}; };
ctx.ds.metricFindQuery(query).then(args => { 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