mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(inspector): lots of improvements and fixes for the error inspector, now shows you request details and responses in many more cases, fixes #2646
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
define([
|
define([
|
||||||
'angular',
|
'angular',
|
||||||
'lodash'
|
'lodash',
|
||||||
|
'jquery',
|
||||||
],
|
],
|
||||||
function (angular, _) {
|
function (angular, _, $) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var module = angular.module('grafana.controllers');
|
var module = angular.module('grafana.controllers');
|
||||||
@@ -30,7 +31,11 @@ function (angular, _) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_.isString(model.error.data)) {
|
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) {
|
if (model.error.config && model.error.config.params) {
|
||||||
@@ -44,43 +49,20 @@ function (angular, _) {
|
|||||||
$scope.stack_trace = model.error.stack;
|
$scope.stack_trace = model.error.stack;
|
||||||
$scope.message = model.error.message;
|
$scope.message = model.error.message;
|
||||||
}
|
}
|
||||||
else if (model.error.config && model.error.config.data) {
|
|
||||||
|
if (model.error.config && model.error.config.data) {
|
||||||
$scope.editor.index = 1;
|
$scope.editor.index = 1;
|
||||||
|
|
||||||
|
if (_.isString(model.error.config.data)) {
|
||||||
$scope.request_parameters = getParametersFromQueryString(model.error.config.data);
|
$scope.request_parameters = getParametersFromQueryString(model.error.config.data);
|
||||||
|
} else {
|
||||||
if (model.error.data.indexOf('DOCTYPE') !== -1) {
|
$scope.request_parameters = _.map(model.error.config.data, function(value, key) {
|
||||||
$scope.response_html = model.error.data;
|
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({
|
var panelModal = $modal({
|
||||||
template: partial,
|
template: partial,
|
||||||
persist: true,
|
persist: false,
|
||||||
show: false,
|
show: false,
|
||||||
scope: scope,
|
scope: scope.$new(),
|
||||||
keyboard: false
|
keyboard: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,12 +49,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="editor.index == 1">
|
<div ng-if="editor.index == 1">
|
||||||
<h5 ng-if="response" ng-bind="response"></h5>
|
<h5 ng-show="message">{{message}}</h5>
|
||||||
|
<pre class="small">
|
||||||
<div ng-if="response_html">
|
{{response}}
|
||||||
<div iframe-content="response_html"></div>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="editor.index == 2">
|
<div ng-if="editor.index == 2">
|
||||||
|
|||||||
@@ -161,13 +161,13 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
|
|||||||
|
|
||||||
return $http(options).then(function(result) {
|
return $http(options).then(function(result) {
|
||||||
return result.data;
|
return result.data;
|
||||||
}, function(reason) {
|
}, function(err) {
|
||||||
if (reason.status !== 0 || reason.status >= 300) {
|
if (err.status !== 0 || err.status >= 300) {
|
||||||
if (reason.data && reason.data.error) {
|
if (err.data && err.data.error) {
|
||||||
throw { message: 'InfluxDB Error Response: ' + reason.data.error };
|
throw { message: 'InfluxDB Error Response: ' + err.data.error, data: err.data, config: err.config };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw { messsage: 'InfluxDB Error: ' + reason.message };
|
throw { messsage: 'InfluxDB Error: ' + err.message, data: err.data, config: err.config };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user