@ -24,9 +24,11 @@ angular.module('kibana.table', [])
$scope . set _listeners = function ( group ) {
eventBus . register ( $scope , 'time' , function ( event , time ) {
$scope . panel . offset = 0 ;
set _time ( time )
} ) ;
eventBus . register ( $scope , 'query' , function ( event , query ) {
$scope . panel . offset = 0 ;
$scope . panel . query = query ;
$scope . get _data ( ) ;
} ) ;
@ -55,11 +57,25 @@ angular.module('kibana.table', [])
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 . panel . offset = page * $scope . panel . size
$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 ( ) {
// Make sure we have everything for the request to complete
if ( _ . isUndefined ( $scope . panel . index ) || _ . isUndefined ( $scope . time ) )
@ -88,13 +104,22 @@ angular.module('kibana.table', [])
}
$scope . panel . error = false ;
$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 ) ;
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
// events should be able to receive from multiple sources, merge, dedupe
// and sort on the fly if needed.