Commit 6d7c8431 by Torkel Ödegaard

fix(inspector): lots of improvements and fixes for the error inspector, now…

fix(inspector): lots of improvements and fixes for the error inspector, now shows you request details and responses in many more cases, fixes #2646
parent 4b429960
define([
'angular',
'lodash'
'lodash',
'jquery',
],
function (angular, _) {
function (angular, _, $) {
'use strict';
var module = angular.module('grafana.controllers');
......@@ -30,7 +31,11 @@ function (angular, _) {
}
if (_.isString(model.error.data)) {
$scope.response = model.error.data;
$scope.response = $("<div>" + model.error.data + "</div>").text();
} else if (model.error.data) {
$scope.response = angular.toJson(model.error.data, true);
} else if (model.error.message) {
$scope.message = model.error.message;
}
if (model.error.config && model.error.config.params) {
......@@ -44,43 +49,20 @@ function (angular, _) {
$scope.stack_trace = model.error.stack;
$scope.message = model.error.message;
}
else if (model.error.config && model.error.config.data) {
$scope.editor.index = 1;
$scope.request_parameters = getParametersFromQueryString(model.error.config.data);
if (model.error.config && model.error.config.data) {
$scope.editor.index = 1;
if (model.error.data.indexOf('DOCTYPE') !== -1) {
$scope.response_html = model.error.data;
if (_.isString(model.error.config.data)) {
$scope.request_parameters = getParametersFromQueryString(model.error.config.data);
} else {
$scope.request_parameters = _.map(model.error.config.data, function(value, key) {
return {key: key, value: angular.toJson(value, true)};
});
}
}
};
});
angular
.module('grafana.directives')
.directive('iframeContent', function($parse) {
return {
restrict: 'A',
link: function($scope, elem, attrs) {
var getter = $parse(attrs.iframeContent), value = getter($scope);
$scope.$on("$destroy",function() {
elem.remove();
});
var iframe = document.createElement('iframe');
iframe.width = '100%';
iframe.height = '400px';
iframe.style.border = 'none';
iframe.src = 'about:blank';
elem.append(iframe);
iframe.contentWindow.document.open('text/html', 'replace');
iframe.contentWindow.document.write(value);
iframe.contentWindow.document.close();
}
};
});
});
......@@ -24,9 +24,9 @@ function (angular, _, $) {
var panelModal = $modal({
template: partial,
persist: true,
persist: false,
show: false,
scope: scope,
scope: scope.$new(),
keyboard: false
});
......
......@@ -49,12 +49,10 @@
</div>
<div ng-if="editor.index == 1">
<h5 ng-if="response" ng-bind="response"></h5>
<div ng-if="response_html">
<div iframe-content="response_html"></div>
</div>
<h5 ng-show="message">{{message}}</h5>
<pre class="small">
{{response}}
</pre>
</div>
<div ng-if="editor.index == 2">
......
......@@ -161,13 +161,13 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
return $http(options).then(function(result) {
return result.data;
}, function(reason) {
if (reason.status !== 0 || reason.status >= 300) {
if (reason.data && reason.data.error) {
throw { message: 'InfluxDB Error Response: ' + reason.data.error };
}, function(err) {
if (err.status !== 0 || err.status >= 300) {
if (err.data && err.data.error) {
throw { message: 'InfluxDB Error Response: ' + err.data.error, data: err.data, config: err.config };
}
else {
throw { messsage: 'InfluxDB Error: ' + reason.message };
throw { messsage: 'InfluxDB Error: ' + err.message, data: err.data, config: err.config };
}
}
});
......
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