Skip to content

Commit

Permalink
converted inspect_ctrl.js to ts (grafana#9673)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ijin08 authored and torkelo committed Oct 26, 2017
1 parent bb1097b commit 0f2989e
Showing 1 changed file with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
define([
'angular',
'lodash',
'jquery',
'../core_module',
],
function (angular, _, $, coreModule) {
'use strict';
import angular from 'angular';
import _ from 'lodash';
import $ from 'jquery';
import coreModule from '../core_module';

coreModule.default.controller('InspectCtrl', function($scope, $sanitize) {
var model = $scope.inspector;
export class InspectCtrl {

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;
}
/** @ngInject */
constructor($scope, $sanitize) {
var model = $scope.inspector;

$scope.init = function () {
$scope.editor = { index: 0 };
Expand Down Expand Up @@ -57,15 +44,26 @@ function (angular, _, $, coreModule) {
$scope.editor.index = 2;

if (_.isString(model.error.config.data)) {
$scope.request_parameters = getParametersFromQueryString(model.error.config.data);
$scope.request_parameters = this.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)};
});
}
}
};
}
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);

0 comments on commit 0f2989e

Please sign in to comment.