mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added details view, nested fields, clickable query building to table panel
This commit is contained in:
parent
a8570135ee
commit
38c92ac482
@ -10,10 +10,18 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.odd {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
|
||||||
[ng\:cloak], [ng-cloak], .ng-cloak {
|
[ng\:cloak], [ng-cloak], .ng-cloak {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table tbody + tbody{
|
||||||
|
border-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
.panel-error {
|
.panel-error {
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
|
@ -33,9 +33,10 @@ angular.module('kibana.services', [])
|
|||||||
if(!(_.isArray(_group)))
|
if(!(_.isArray(_group)))
|
||||||
_group = [_group];
|
_group = [_group];
|
||||||
|
|
||||||
if(_.intersection(_to,_group).length > 0 ||
|
if((_.intersection(_to,_group).length > 0 ||
|
||||||
_.indexOf(_to,_id) > -1 ||
|
_.indexOf(_to,_id) > -1 ||
|
||||||
_.indexOf(_to,'ALL') > -1
|
_.indexOf(_to,'ALL') > -1) &&
|
||||||
|
_from !== _id
|
||||||
) {
|
) {
|
||||||
//console.log('Got: '+type + ' from ' + _from + ' to ' + _to + ': ' + angular.toJson(packet.data))
|
//console.log('Got: '+type + ' from ' + _from + ' to ' + _to + ': ' + angular.toJson(packet.data))
|
||||||
fn(event,packet.data);
|
fn(event,packet.data);
|
||||||
|
@ -17,6 +17,10 @@ angular.module('kibana.stringquery', [])
|
|||||||
$scope.panel.group : [$scope.panel.group];
|
$scope.panel.group : [$scope.panel.group];
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
|
eventBus.register($scope,'query',function(event,query) {
|
||||||
|
$scope.panel.query = query;
|
||||||
|
});
|
||||||
|
|
||||||
$scope.send_query = function(query) {
|
$scope.send_query = function(query) {
|
||||||
eventBus.broadcast($scope.$id,$scope.panel.group,'query',query)
|
eventBus.broadcast($scope.$id,$scope.panel.group,'query',query)
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="small" ng-show="panel.fields.length == 0">No columns configured. You may want to add a <strong>fields panel</strong>, or click the edit button in the top right of this panel to add some columns</div>
|
<div class="small" ng-show="panel.fields.length == 0">No columns configured. You may want to add a <strong>fields panel</strong>, or click the edit button in the top right of this panel to add some columns</div>
|
||||||
<table class="table table-condensed table-striped" ng-style="panel.style">
|
<table class="table-hover table table-condensed" ng-style="panel.style">
|
||||||
<thead>
|
<thead>
|
||||||
<th style="white-space:nowrap" ng-repeat="field in panel.fields">
|
<th style="white-space:nowrap" ng-repeat="field in panel.fields">
|
||||||
<span class="pointer" ng-click="set_sort(field)">
|
<span class="pointer" ng-click="set_sort(field)">
|
||||||
@ -23,9 +23,30 @@
|
|||||||
</span>
|
</span>
|
||||||
</th>
|
</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tr ng-repeat="row in data">
|
<tbody ng-repeat="row in data" ng-class-odd="'odd'">
|
||||||
<td ng-repeat="field in panel.fields">{{row['_source'][field]}}</td>
|
<tr ng-click="toggle_details(row)">
|
||||||
</tr>
|
<td ng-repeat="field in panel.fields">{{row[field]}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr ng-show="row.kibana.details">
|
||||||
|
<td colspan=1000>
|
||||||
|
<table class='table table-bordered table-condensed'>
|
||||||
|
<thead>
|
||||||
|
<th>Field</th>
|
||||||
|
<th>Action</th>
|
||||||
|
<th>Value</th>
|
||||||
|
</thead>
|
||||||
|
<tr ng-repeat="(key,value) in row.kibana.details">
|
||||||
|
<td>{{key}}</td>
|
||||||
|
<td>
|
||||||
|
<i class='icon-search pointer' ng-click="build_search(key,value)"></i>
|
||||||
|
<i class='icon-ban-circle pointer' ng-click="build_search('NOT '+key,value)"></i>
|
||||||
|
</td>
|
||||||
|
<td>{{value}}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span1 offset3" style="text-align:right">
|
<div class="span1 offset3" style="text-align:right">
|
||||||
|
@ -24,9 +24,11 @@ angular.module('kibana.table', [])
|
|||||||
|
|
||||||
$scope.set_listeners = function(group) {
|
$scope.set_listeners = function(group) {
|
||||||
eventBus.register($scope,'time',function(event,time) {
|
eventBus.register($scope,'time',function(event,time) {
|
||||||
|
$scope.panel.offset = 0;
|
||||||
set_time(time)
|
set_time(time)
|
||||||
});
|
});
|
||||||
eventBus.register($scope,'query',function(event,query) {
|
eventBus.register($scope,'query',function(event,query) {
|
||||||
|
$scope.panel.offset = 0;
|
||||||
$scope.panel.query = query;
|
$scope.panel.query = query;
|
||||||
$scope.get_data();
|
$scope.get_data();
|
||||||
});
|
});
|
||||||
@ -55,11 +57,25 @@ angular.module('kibana.table', [])
|
|||||||
broadcast_fields();
|
broadcast_fields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.toggle_details = function(row) {
|
||||||
|
row.kibana = row.kibana || {};
|
||||||
|
row.kibana.details = !row.kibana.details ? $scope.without_kibana(row) : false;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.page = function(page) {
|
$scope.page = function(page) {
|
||||||
$scope.panel.offset = page*$scope.panel.size
|
$scope.panel.offset = page*$scope.panel.size
|
||||||
$scope.get_data();
|
$scope.get_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.build_search = function(field, value) {
|
||||||
|
var query = field + ":" + "\"" + addslashes(value.toString()) + "\"";
|
||||||
|
var glue = $scope.panel.query != "" ? " AND " : "";
|
||||||
|
$scope.panel.query = $scope.panel.query + glue + query;
|
||||||
|
$scope.panel.offset = 0;
|
||||||
|
$scope.get_data();
|
||||||
|
eventBus.broadcast($scope.$id,$scope.panel.group,'query',$scope.panel.query);
|
||||||
|
}
|
||||||
|
|
||||||
$scope.get_data = function() {
|
$scope.get_data = function() {
|
||||||
// Make sure we have everything for the request to complete
|
// Make sure we have everything for the request to complete
|
||||||
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
|
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
|
||||||
@ -88,13 +104,22 @@ angular.module('kibana.table', [])
|
|||||||
}
|
}
|
||||||
$scope.panel.error = false;
|
$scope.panel.error = false;
|
||||||
$scope.hits = results.hits.total;
|
$scope.hits = results.hits.total;
|
||||||
$scope.data = results.hits.hits;
|
$scope.data = []
|
||||||
|
_.each(results.hits.hits, function(v,k) {
|
||||||
|
$scope.data.push(flatten_json(v['_source']))
|
||||||
|
})
|
||||||
$scope.all_fields = get_all_fields(results);
|
$scope.all_fields = get_all_fields(results);
|
||||||
|
|
||||||
broadcast_fields();
|
broadcast_fields();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.without_kibana = function (row) {
|
||||||
|
row = _.clone(row)
|
||||||
|
delete row.kibana
|
||||||
|
return row
|
||||||
|
}
|
||||||
|
|
||||||
// Broadcast a list of all fields. Note that receivers of field array
|
// Broadcast a list of all fields. Note that receivers of field array
|
||||||
// events should be able to receive from multiple sources, merge, dedupe
|
// events should be able to receive from multiple sources, merge, dedupe
|
||||||
// and sort on the fly if needed.
|
// and sort on the fly if needed.
|
||||||
|
@ -13,8 +13,12 @@ curl -XPUT http://localhost:9200/_template/shakespeare -d '
|
|||||||
"play_name" : {"type": "string", "index" : "not_analyzed" },
|
"play_name" : {"type": "string", "index" : "not_analyzed" },
|
||||||
"line_id" : { "type" : "integer", "index": "not_analyzed" },
|
"line_id" : { "type" : "integer", "index": "not_analyzed" },
|
||||||
"speech_number" : { "type" : "integer", "index": "not_analyzed" },
|
"speech_number" : { "type" : "integer", "index": "not_analyzed" },
|
||||||
"state" : {"type": "string", "index" : "not_analyzed" },
|
"geo" : {
|
||||||
"country" : {"type": "string", "index" : "not_analyzed" }
|
"properties": {
|
||||||
|
"state" : {"type": "string", "index" : "not_analyzed" },
|
||||||
|
"country" : {"type": "string", "index" : "not_analyzed" }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,12 @@ fs.readFile('shakespeare.json', 'utf8', function (err,data) {
|
|||||||
var randomnumber=Math.floor(Math.random()*57600000)
|
var randomnumber=Math.floor(Math.random()*57600000)
|
||||||
var command = {index:{_index: "shakespeare", _type: "line", _id: i}};
|
var command = {index:{_index: "shakespeare", _type: "line", _id: i}};
|
||||||
o['@timestamp'] = new Date((new Date()).getTime() -9000000 + randomnumber);
|
o['@timestamp'] = new Date((new Date()).getTime() -9000000 + randomnumber);
|
||||||
o.geo = [getRandomInRange(-90, 90, 3),getRandomInRange(-180, 180, 3)]
|
o.geo = {
|
||||||
o.country = get_country();
|
geojson : [getRandomInRange(-90, 90, 3),getRandomInRange(-180, 180, 3)],
|
||||||
if(o.country == 'US')
|
country : get_country()
|
||||||
o.state = get_state()
|
}
|
||||||
|
if(o.geo.country == 'US')
|
||||||
|
o.geo.state = get_state();
|
||||||
console.log(JSON.stringify(command))
|
console.log(JSON.stringify(command))
|
||||||
console.log(JSON.stringify(o));
|
console.log(JSON.stringify(o));
|
||||||
var percent = Math.floor((i/lines)*100)
|
var percent = Math.floor((i/lines)*100)
|
||||||
|
Loading…
Reference in New Issue
Block a user