diff --git a/src/kibana/components/courier/data_source/_abstract.js b/src/kibana/components/courier/data_source/_abstract.js index 148d714e7bee6..1af63f18e9cb8 100644 --- a/src/kibana/components/courier/data_source/_abstract.js +++ b/src/kibana/components/courier/data_source/_abstract.js @@ -264,16 +264,12 @@ define(function (require) { 'match_all': {} }; } - flatState.body.fields = ['*', '_source']; - _.each(flatState.index.fields.byType['date'], function (field) { - if (field.indexed) { - flatState.body.script_fields = flatState.body.script_fields || {}; - flatState.body.script_fields[field.name] = { - script: 'doc["' + field.name + '"].value' - }; - } - }); + var computedFields = flatState.index.getComputedFields(); + flatState.body.fields = computedFields.fields; + flatState.body.script_fields = flatState.body.script_fields || {}; + _.extend(flatState.body.script_fields, computedFields.scriptFields); + /** * Create a filter that can be reversed for filters with negate set diff --git a/src/kibana/components/doc_viewer/doc_viewer.html b/src/kibana/components/doc_viewer/doc_viewer.html index 7c91f0079ca66..c7b7e56a37c17 100644 --- a/src/kibana/components/doc_viewer/doc_viewer.html +++ b/src/kibana/components/doc_viewer/doc_viewer.html @@ -4,39 +4,41 @@
  • JSON
  • - - - - - +
    +
    - - - - - - - - - -
    + + + + - - - -
    + + + + + + + + + + - - - -
    + + + + + + + + -
    {{hit | json}}
    +
    {{hit | json}}
    + \ No newline at end of file diff --git a/src/kibana/components/doc_viewer/doc_viewer.less b/src/kibana/components/doc_viewer/doc_viewer.less index b3458d3d5e151..321d297bf31d5 100644 --- a/src/kibana/components/doc_viewer/doc_viewer.less +++ b/src/kibana/components/doc_viewer/doc_viewer.less @@ -14,4 +14,11 @@ doc-viewer .doc-viewer { white-space: pre-wrap; } + td, pre { + font-family: "Lucida Console", Monaco, monospace; + } + + .content { + margin-top: @padding-base-vertical; + } } \ No newline at end of file diff --git a/src/kibana/components/index_patterns/_get_computed_fields.js b/src/kibana/components/index_patterns/_get_computed_fields.js new file mode 100644 index 0000000000000..dda200fdbbb63 --- /dev/null +++ b/src/kibana/components/index_patterns/_get_computed_fields.js @@ -0,0 +1,23 @@ +// Takes a hit, merges it with any stored/scripted fields, and with the metaFields +// returns a flattened version +define(function (require) { + var _ = require('lodash'); + return function () { + var self = this; + var scriptFields = {}; + + _.each(self.fields.byType['date'], function (field) { + if (field.indexed) { + scriptFields[field.name] = { + script: 'doc["' + field.name + '"].value' + }; + } + }); + + return { + fields: ['*', '_source'], + scriptFields: scriptFields + }; + + }; +}); diff --git a/src/kibana/components/index_patterns/_index_pattern.js b/src/kibana/components/index_patterns/_index_pattern.js index 872f8e33c0758..66975b68a313b 100644 --- a/src/kibana/components/index_patterns/_index_pattern.js +++ b/src/kibana/components/index_patterns/_index_pattern.js @@ -12,6 +12,8 @@ define(function (require) { var DocSource = Private(require('components/courier/data_source/doc_source')); var flattenSearchResponse = require('components/index_patterns/_flatten_search_response'); var flattenHit = require('components/index_patterns/_flatten_hit'); + var getComputedFields = require('components/index_patterns/_get_computed_fields'); + var IndexedArray = require('utils/indexed_array/index'); @@ -224,6 +226,8 @@ define(function (require) { self.metaFields = config.get('metaFields'); self.flattenSearchResponse = flattenSearchResponse.bind(self); self.flattenHit = flattenHit.bind(self); + self.getComputedFields = getComputedFields.bind(self); + } return IndexPattern; diff --git a/src/kibana/plugins/discover/partials/table_row/details.html b/src/kibana/plugins/discover/partials/table_row/details.html index bef929434bbab..c3ab47ee219b8 100644 --- a/src/kibana/plugins/discover/partials/table_row/details.html +++ b/src/kibana/plugins/discover/partials/table_row/details.html @@ -1,3 +1,6 @@ + + Link to /{{row._index}}/{{row._type}}/{{row._id}} + \ No newline at end of file diff --git a/src/kibana/plugins/doc/controllers/doc.js b/src/kibana/plugins/doc/controllers/doc.js new file mode 100644 index 0000000000000..d9c483099b181 --- /dev/null +++ b/src/kibana/plugins/doc/controllers/doc.js @@ -0,0 +1,66 @@ +define(function (require) { + var _ = require('lodash'); + var angular = require('angular'); + + require('components/notify/notify'); + require('components/courier/courier'); + require('components/doc_viewer/doc_viewer'); + require('components/index_patterns/index_patterns'); + + var app = require('modules').get('apps/doc', [ + 'kibana/notify', + 'kibana/courier', + 'kibana/index_patterns' + ]); + + require('routes') + .when('/doc/:indexPattern/:index/:type/:id', { + template: require('text!plugins/doc/index.html'), + resolve: { + indexPattern: function (courier, savedSearches, $route) { + return courier.indexPatterns.get($route.current.params.indexPattern); + } + } + }); + + app.controller('doc', function ($scope, $route, es, timefilter) { + + timefilter.enabled = false; + + // Pretty much only need this for formatting, not actually using it for fetching anything. + $scope.indexPattern = $route.current.locals.indexPattern; + + var computedFields = $scope.indexPattern.getComputedFields(); + + es.search({ + index: $route.current.params.index, + type: $route.current.params.type, + body: { + query: { + ids: { + values: [$route.current.params.id] + } + }, + fields: computedFields.fields, + script_fields: computedFields.scriptFields + } + }).then(function (resp) { + if (resp.hits) { + if (resp.hits.total < 1) { + $scope.status = 'notFound'; + } else { + $scope.status = 'found'; + $scope.hit = resp.hits.hits[0]; + } + } + }).catch(function (err) { + if (err.status === 404) { + $scope.status = 'notFound'; + } else { + $scope.status = 'error'; + $scope.resp = err; + } + }); + + }); +}); diff --git a/src/kibana/plugins/doc/index.html b/src/kibana/plugins/doc/index.html new file mode 100644 index 0000000000000..78af147e8690a --- /dev/null +++ b/src/kibana/plugins/doc/index.html @@ -0,0 +1,47 @@ +
    + +
    +
    + + +
    +
    +

    Failed to locate document.

    + +

    + Unfortunately I could not find any documents matching that id, of that type, in that index. I tried really hard. I wanted it to be there. Sometimes I swear documents grow legs and just walk out of the index. Sneaky. I wish I could offer some advice here, something to make you feel better +

    + +
    +
    + + +
    +
    +

    This is bad.

    + +

    + Oh no. Something went very wrong. Its not just that I couldn't find your document, I couldn't even try. The index was missing, or the type. Go check out Elasticsearch, something isn't quite right here. +

    + +
    +
    + + +
    +
    +

    Searching

    +
    +
    {{fetchStatus.complete}}/{{fetchStatus.total}}
    +
    +
    + + +
    +

    Doc: {{hit._index}}/{{hit._type}}/{{hit._id}}

    + + +
    +
    +
    +
    diff --git a/src/kibana/plugins/doc/index.js b/src/kibana/plugins/doc/index.js new file mode 100644 index 0000000000000..70b8ab3c75a41 --- /dev/null +++ b/src/kibana/plugins/doc/index.js @@ -0,0 +1,12 @@ +define(function (require, module, exports) { + require('plugins/doc/controllers/doc'); + + var apps = require('registry/apps'); + apps.register(function DocAppModule() { + return { + id: 'doc', + name: 'Doc Viewer', + order: -1 + }; + }); +}); \ No newline at end of file diff --git a/src/kibana/plugins/kibana/_apps.js b/src/kibana/plugins/kibana/_apps.js index c0e948f58450a..b2ab9c425bbe3 100644 --- a/src/kibana/plugins/kibana/_apps.js +++ b/src/kibana/plugins/kibana/_apps.js @@ -11,6 +11,10 @@ define(function (require) { return app.lastPath; } + function getShow(app) { + app.show = app.order >= 0 ? true : false; + } + function setLastPath(app, path) { app.lastPath = path; return sessionStorage.set(appKey(app), path); @@ -19,6 +23,8 @@ define(function (require) { $scope.apps = Private(require('registry/apps')); // initialize each apps lastPath (fetch it from storage) $scope.apps.forEach(getLastPath); + $scope.apps.forEach(getShow); + function onRouteChange() { var route = $location.path().split(/\//); diff --git a/src/kibana/plugins/kibana/kibana.html b/src/kibana/plugins/kibana/kibana.html index 728f8f131fbfd..295b22ef8e68c 100644 --- a/src/kibana/plugins/kibana/kibana.html +++ b/src/kibana/plugins/kibana/kibana.html @@ -18,7 +18,7 @@