-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doc viewer app #2121
Merged
Merged
Doc viewer app #2121
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7bc5a75
Use order<0 to set an app hidden
4f0a6e6
Add doc view app, abstract out computed fields discovery
de5d29d
Move computed fields discovery from courier to index pattern
703d817
Remove border
4cda920
Add computed fields tests
446e82c
Merge branch 'master' of github.com:elasticsearch/kibana into feature…
3b04e44
Removing unused services
652ff5c
Add test harness for doc viewer
6aab300
Disable time filter in doc app and add link form discover to doc app
faf0a5b
Add tests for the doc_viewer controller
2bddc7b
fix dov viewer tab style
w33ble 18a3d02
Merge pull request #1 from w33ble/feature/doc_viewer
rashidkpc a755b73
Remove unused less
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/kibana/components/index_patterns/_get_computed_fields.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}; | ||
|
||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
<td colspan="{{ columns.length + 2 }}"> | ||
<a class="pull-right" ng-href="#/doc/{{indexPattern.id}}/{{row._index}}/{{row._type}}/{{row._id}}"> | ||
<small>Link to /{{row._index}}/{{row._type}}/{{row._id}}</small></i> | ||
</a> | ||
<doc-viewer hit="row" filter="filter" index-pattern="indexPattern"></doc-viewer> | ||
</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
}); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<div ng-controller="doc" class="app-container"> | ||
|
||
<div class="container-fluid"> | ||
<div class="row"> | ||
|
||
<!-- no results --> | ||
<div class="col-md-12" ng-if="status === 'notFound'"> | ||
<div class="col-md-12"> | ||
<h1>Failed to locate document. <i class="fa fa-meh-o"></i></h1> | ||
|
||
<p> | ||
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 | ||
</p> | ||
|
||
</div> | ||
</div> | ||
|
||
<!-- no results --> | ||
<div class="col-md-12" ng-if="status === 'error'"> | ||
<div class="col-md-12"> | ||
<h1>This is bad. <i class="fa fa-meh-o"></i></h1> | ||
|
||
<p> | ||
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. | ||
</p> | ||
|
||
</div> | ||
</div> | ||
|
||
<!-- loading --> | ||
<div class="col-md-12" ng-if="status === undefined"> | ||
<div class="discover-overlay"> | ||
<h2>Searching</h2> | ||
<div class="spinner large"></div> | ||
<div ng-show="fetchStatus">{{fetchStatus.complete}}/{{fetchStatus.total}}</div> | ||
</div> | ||
</div> | ||
|
||
<!-- result --> | ||
<div class="col-md-12" ng-if="status === 'found'"> | ||
<h2><b>Doc:</b> {{hit._index}}/{{hit._type}}/{{hit._id}}</h2> | ||
|
||
<doc-viewer hit="hit" index-pattern="indexPattern"></doc-viewer> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Why a search here?
A: Elasticsearch GET API doesn't support stored or scripted fields, have to go through the search API
Q: Well then why didn't you use a searchSource?
A: It seemed wasteful to start up a temporary indexPattern and searchSource for one request. I would need to new up an indexPattern as the existing one could match some range of indices, and I need exactly one index. The indexPattern that does get loaded here is only used for formatters and scripted fields retrieval.