| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- define([
- 'angular'
- ],
- function (angular) {
- 'use strict';
- var module = angular.module('kibana.controllers');
- module.controller('InspectCtrl', function($scope) {
- 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.editor = { index: 0 };
- if (!model.error) {
- return;
- }
- if (model.error.stack) {
- $scope.editor.index = 2;
- $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.data.indexOf('DOCTYPE') !== -1) {
- $scope.response_html = model.error.data;
- }
- }
- };
- });
- angular
- .module('kibana.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();
- }
- };
- });
- });
|