3
0
mirror of https://github.com/grafana/grafana.git synced 2025-02-25 18:55:37 -06:00

converted inspect_ctrl.js to ts ()

This commit is contained in:
Patrick O'Carroll 2017-10-26 13:27:17 +02:00 committed by Torkel Ödegaard
parent bb1097b7c9
commit 0f2989e19b

View File

@ -1,27 +1,14 @@
define([ import angular from 'angular';
'angular', import _ from 'lodash';
'lodash', import $ from 'jquery';
'jquery', import coreModule from '../core_module';
'../core_module',
],
function (angular, _, $, coreModule) {
'use strict';
coreModule.default.controller('InspectCtrl', function($scope, $sanitize) { export class InspectCtrl {
/** @ngInject */
constructor($scope, $sanitize) {
var model = $scope.inspector; var model = $scope.inspector;
function getParametersFromQueryString(queryString) {
var result = [];
var parameters = queryString.split("&");
for (var i = 0; i < parameters.length; i++) {
var keyValue = parameters[i].split("=");
if (keyValue[1].length > 0) {
result.push({ key: keyValue[0], value: window.unescape(keyValue[1]) });
}
}
return result;
}
$scope.init = function () { $scope.init = function () {
$scope.editor = { index: 0 }; $scope.editor = { index: 0 };
@ -57,7 +44,7 @@ function (angular, _, $, coreModule) {
$scope.editor.index = 2; $scope.editor.index = 2;
if (_.isString(model.error.config.data)) { if (_.isString(model.error.config.data)) {
$scope.request_parameters = getParametersFromQueryString(model.error.config.data); $scope.request_parameters = this.getParametersFromQueryString(model.error.config.data);
} else { } else {
$scope.request_parameters = _.map(model.error.config.data, function(value, key) { $scope.request_parameters = _.map(model.error.config.data, function(value, key) {
return {key: key, value: angular.toJson(value, true)}; return {key: key, value: angular.toJson(value, true)};
@ -65,7 +52,18 @@ function (angular, _, $, coreModule) {
} }
} }
}; };
}
getParametersFromQueryString(queryString) {
var result = [];
var parameters = queryString.split("&");
for (var i = 0; i < parameters.length; i++) {
var keyValue = parameters[i].split("=");
if (keyValue[1].length > 0) {
result.push({ key: keyValue[0], value: (<any>window).unescape(keyValue[1]) });
}
}
return result;
}
}
}); coreModule.controller('InspectCtrl', InspectCtrl);
});