-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2121 from rashidkpc/feature/doc_viewer
Doc viewer app
- Loading branch information
Showing
15 changed files
with
382 additions
and
43 deletions.
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.