Skip to content

Commit

Permalink
show all properties of the inspected object
Browse files Browse the repository at this point in the history
  • Loading branch information
Achim Settelmeier committed Nov 4, 2015
1 parent 0295054 commit 9562e5d
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 7 deletions.
22 changes: 21 additions & 1 deletion _site/assets/js/elasticsearch-gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,28 @@ function ($scope, $routeParams, $location, elastic) {
$scope.sourcedata = {};
$scope.sourcedata.indices = [];

if ($routeParams.id) {
if ($routeParams.id && $routeParams.index) {
$scope.inspect.id = $routeParams.id;

var query = {
"index": $routeParams.index,
"body": {
"query": {
"match": {
"_id": $routeParams.id
}
}
},
"size": 1
};

elastic.doSearch(query, function(result) {
$scope.result = result.hits.hits[0];
}, function(errors) {
$scope.metaResults.failedShards = 1;
$scope.metaResults.errors = [];
$scope.metaResults.errors.push(errors.error);
});
}

$scope.doInspect = function () {
Expand Down
2 changes: 1 addition & 1 deletion _site/assets/js/elasticsearch-gui.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _site/assets/js/elasticsearch-gui.min.js.map

Large diffs are not rendered by default.

41 changes: 38 additions & 3 deletions _site/partials/inspect.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="row">
<div class="col-md-12">
<div class="alert alert-info">
<p>Inspect an object.</p>
<p>Find an object by its id and show all its properties.</p>
</div>
</div>
</div>
Expand All @@ -12,15 +12,15 @@ <h3 class="panel-title">Inspect</h3>
<div class="panel-body">
<form role="form">
<div class="row">
<div class="col-md-4">
<div class="col-md-3">
<div class="form-group">
<label>Index</label>
<select class="form-control" ng-model="inspect.index" ng-options="index.name for index in sourcedata.indices">
<option value="">-- chose field --</option>
</select>
</div>
</div>
<div class="col-md-8">
<div class="col-md-9">
<div class="form-group">
<label>Object id</label>
<input type="text" class="form-control" ng-model="inspect.id"/>
Expand All @@ -33,5 +33,40 @@ <h3 class="panel-title">Inspect</h3>
</div>
</div>
</form>
<div ng-show="result">
<div class="row">
<div class="col-md-12">
<hr>
</div>
<div class="col-md-3">
<strong>Property</strong>
</div>
<div class="col-md-9">
<strong>Value</strong>
</div>
</div>
<div class="row">
<div class="col-md-3">_id</div>
<div class="col-md-9">{{result._id}}</div>
</div>
<div class="row">
<div class="col-md-3">_type</div>
<div class="col-md-9">{{result._type}}</div>
</div>
<div class="row" ng-repeat="(key, value) in result._source">
<div class="col-md-3">{{key}}</div>
<div class="col-md-9">{{value}}</div>
</div>
</div>

<div class="row" ng-show="metaResults.failedShards">
<div class="col-md-12">
<h3>Errors</h3>

<div class="alert alert-danger" ng-repeat="error in metaResults.errors">
{{error}}
</div>
</div>
</div>
</div>
</div>
22 changes: 21 additions & 1 deletion javascript/controllers/InspectCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,28 @@ function ($scope, $routeParams, $location, elastic) {
$scope.sourcedata = {};
$scope.sourcedata.indices = [];

if ($routeParams.id) {
if ($routeParams.id && $routeParams.index) {
$scope.inspect.id = $routeParams.id;

var query = {
"index": $routeParams.index,
"body": {
"query": {
"match": {
"_id": $routeParams.id
}
}
},
"size": 1
};

elastic.doSearch(query, function(result) {
$scope.result = result.hits.hits[0];
}, function(errors) {
$scope.metaResults.failedShards = 1;
$scope.metaResults.errors = [];
$scope.metaResults.errors.push(errors.error);
});
}

$scope.doInspect = function () {
Expand Down

0 comments on commit 9562e5d

Please sign in to comment.