Commit adacdf98 by Torkel Ödegaard

Removed old query inspector (that was opened by clickin error in panel title)

think the new query insector from Queries tab can replace this old one.
parent 9d5560af
import './inspect_ctrl';
import './json_editor_ctrl';
import './login_ctrl';
import './invited_ctrl';
......
import angular from 'angular';
import _ from 'lodash';
import $ from 'jquery';
import coreModule from '../core_module';
export class InspectCtrl {
/** @ngInject */
constructor($scope, $sanitize) {
const model = $scope.inspector;
$scope.init = function() {
$scope.editor = { index: 0 };
if (!model.error) {
return;
}
if (_.isString(model.error.data)) {
$scope.response = $('<div>' + model.error.data + '</div>').text();
} else if (model.error.data) {
if (model.error.data.response) {
$scope.response = $sanitize(model.error.data.response);
} else {
$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) {
$scope.request_parameters = _.map(model.error.config.params, (value, key) => {
return { key: key, value: value };
});
}
if (model.error.stack) {
$scope.editor.index = 3;
$scope.stack_trace = model.error.stack;
$scope.message = model.error.message;
}
if (model.error.config && model.error.config.data) {
$scope.editor.index = 2;
if (_.isString(model.error.config.data)) {
$scope.request_parameters = this.getParametersFromQueryString(model.error.config.data);
} else {
$scope.request_parameters = _.map(model.error.config.data, (value, key) => {
return { key: key, value: angular.toJson(value, true) };
});
}
}
};
}
getParametersFromQueryString(queryString) {
const result = [];
const parameters = queryString.split('&');
for (let i = 0; i < parameters.length; i++) {
const keyValue = parameters[i].split('=');
if (keyValue[1].length > 0) {
result.push({
key: keyValue[0],
value: (window as any).unescape(keyValue[1]),
});
}
}
return result;
}
}
coreModule.controller('InspectCtrl', InspectCtrl);
<div class="modal-body" ng-controller="InspectCtrl" ng-init="init()">
<div class="modal-header">
<h2 class="modal-header-title">
<i class="fa fa-info-circle"></i>
<span class="p-l-1">Inspector</span>
</h2>
<ul class="gf-tabs">
<li class="gf-tabs-item" ng-repeat="tab in ['Panel Description', 'Request', 'Response', 'JS Error']">
<a class="gf-tabs-link" ng-click="editor.index = $index" ng-class="{active: editor.index === $index}">
{{::tab}}
</a>
</li>
</ul>
<a class="modal-header-close" ng-click="dismiss();">
<i class="fa fa-remove"></i>
</a>
</div>
<div class="modal-content">
<div ng-if="editor.index == 0" ng-bind-html="panelInfoHtml">
</div>
<div ng-if="editor.index == 1">
<h5 class="section-heading">Request details</h5>
<table class="filter-table gf-form-group">
<tr>
<td>Url</td>
<td>{{inspector.error.config.url}}</td>
</tr>
<tr>
<td>Method</td>
<td>{{inspector.error.config.method}}</td>
</tr>
<tr ng-repeat="(key, value) in inspector.error.config.headers">
<td>
{{key}}
</td>
<td>
{{value}}
</td>
</tr>
</table>
<h5 class="section-heading">Request parameters</h5>
<table class="filter-table">
<tr ng-repeat="param in request_parameters">
<td>
{{param.key}}
</td>
<td>
{{param.value}}
</td>
</tr>
</table>
</div>
<div ng-if="editor.index == 2">
<h5 ng-show="message">{{message}}</h5>
<pre class="small">
{{response}}
</pre>
</div>
<div ng-if="editor.index == 3">
<label>Message:</label>
<pre>
{{message}}
</pre>
<label>Stack trace:</label>
<pre>
{{stack_trace}}
</pre>
</div>
</div>
</div>
......@@ -290,17 +290,4 @@ export class PanelCtrl {
html += '</div>';
return sanitize(html);
}
openInspector() {
const modalScope = this.$scope.$new();
modalScope.panel = this.panel;
modalScope.dashboard = this.dashboard;
modalScope.panelInfoHtml = this.getInfoContent({ mode: 'inspector' });
modalScope.inspector = $.extend(true, {}, this.inspector);
this.publishAppEvent('show-modal', {
src: 'public/app/features/dashboard/partials/inspector.html',
scope: modalScope,
});
}
}
......@@ -192,11 +192,6 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
scope.$watchGroup(['ctrl.error', 'ctrl.panel.description'], updatePanelCornerInfo);
scope.$watchCollection('ctrl.panel.links', updatePanelCornerInfo);
cornerInfoElem.on('click', () => {
infoDrop.close();
scope.$apply(ctrl.openInspector.bind(ctrl));
});
elem.on('mouseenter', mouseEnter);
elem.on('mouseleave', mouseLeave);
......
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