Commit 6aa72fa9 by Rashid Khan

Added highlighting to table panel, remove debug statement from derivequeries

parent c25fd72c
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
margin: 0px; margin: 0px;
} }
[ng\:cloak], [ng-cloak], .ng-cloak { [ng\:cloak], [ng-cloak], .ng-cloak {
display: none !important; display: none !important;
} }
......
<div>
Nothing to see here folks
</div>
<kibana-panel ng-controller='bbuzz' ng-init="init()">
<table class="table table-condensed" style="vertical-align: middle">
<tr ng-style="cluster_color(cluster.status)">
<td>
<span style="font-size:2.5em;line-height:50px">
<strong>Cluster:</strong> {{cluster.cluster_name}}
</span>
</td>
<td></td>
<td style="text-align:right;vertical-align:middle">
<form class="input-append" style="text-align:right">
<input ng-model="settings.replicas" type="number" class="input-mini">
<button class="btn btn-info" ng-click="set_replicas(settings.replicas)"><i class="icon-copy"></i></button>
</form>
</td>
</tr>
<tr ng-style="cluster_color('nothing')" style="vertical-align:middle" ng-repeat="(name,node) in nodes.info">
<td style='font-size:1.5em;vertical-align:middle'>
<img style='font-size:1.5em;width:25px;height:25px;border-radius:20px;border:1px solid #000;margin-right: 10px' src="{{bbuzz.picture(node.transport_address)}}">
{{node.name}} / {{bbuzz.ip_address(node.transport_address)}}
</td>
<td>
P
<div ng-repeat='(index,shards) in nodes.routing[name]' bs-tooltip="index" style='display:inline-block;'>
<div ng-repeat='shard in primary(shards,true)' ng-class='shard_class(shard.state)' style='display:inline-block;font-size:7pt;line-height:10px;width:10px;height:10px;border-radius:10px;color:#fff;text-align:center;background:{{bbuzz.index_color(index)}};border:0px;margin-right: 2px'></div>
</div>
<br>
R
<div ng-repeat='(index,shards) in nodes.routing[name]' bs-tooltip="index" style='display:inline-block;'>
<div ng-repeat='shard in primary(shards,false)' ng-class='shard_class(shard.state)' style='display:inline-block;font-size:7pt;line-height:10px;width:10px;height:10px;border-radius:10px;color:#fff;text-align:center;background:{{bbuzz.index_color(index)}};border:0px;margin-right: 2px'></div>
</div><br>
</td>
<td style="text-align: right;vertical-align: middle">
<button ng-click="node_mode(bbuzz.ip_address(node.transport_address),'stop')" style="font-size:1.5em; margin-right:30px" class='icon-signout btn btn-danger'></button>
</td>
</tr>
</table>
<table style="vertical-align: middle" ng-show="nodes.dead.length > 0" class='table table-condensed'>
<tr ng-style="cluster_color('red')">
<td colspan='100'>
<span style="line-height:15px">
Missing nodes
</span>
</td>
</tr>
<tr ng-style="cluster_color('nothing')" ng-repeat="name in nodes.dead">
<td colspan="2">
<img style='width:30px;height:30px;border-radius:30px;border:2px solid #000;margin-right: 10px' src="{{bbuzz.picture(name)}}">
{{bbuzz.ip_address(name)}} {{nodes.status[name]}}
</td>
<td style="text-align: right">
<button ng-click="node_mode(bbuzz.ip_address(name),'start')" style="font-size:1.5em; margin-right:30px" class='icon-signin btn btn-info'></button>
</td>
</tr>
</table>
</kibana-panel>
\ No newline at end of file
...@@ -83,7 +83,6 @@ angular.module('kibana.derivequeries', []) ...@@ -83,7 +83,6 @@ angular.module('kibana.derivequeries', [])
_.each(results.facets.query.terms, function(v) { _.each(results.facets.query.terms, function(v) {
data.push($scope.panel.field+':"'+v.term+'"') data.push($scope.panel.field+':"'+v.term+'"')
}); });
console.log(data)
$scope.send_query(data) $scope.send_query(data)
}); });
} }
......
...@@ -16,10 +16,23 @@ ...@@ -16,10 +16,23 @@
</form> </form>
</div> </div>
<div class="span8"> <div class="span8">
<h6>Selected fields <small>Click to remove</small></h6> <h6>Columns <small>Click to remove</small></h6>
<span style="margin-left:3px" ng-click="toggle_field(field)" ng-repeat="field in $parent.panel.fields" class="label remove pointer">{{field}} </span> <span style="margin-left:3px" ng-click="toggle_field(field)" ng-repeat="field in $parent.panel.fields" class="label remove pointer">{{field}} </span>
</div> </div>
</div> </div>
<div class="row-fluid">
<div class="span4">
<form class="input-append">
<h6>Add field</h6>
<input bs-typeahead="fields.list" type="text" class="input-small" ng-model='newhighlight' ng-change="set_refresh(true)">
<button class="btn" ng-click="toggle_highlight(newhighlight);newhighlight=''"><i class="icon-plus"></i></button>
</form>
</div>
<div class="span8">
<h6>Highlighted fields <small>Click to remove</small></h6>
<span style="margin-left:3px" ng-click="toggle_highlight(field);set_refresh(true)" ng-repeat="field in $parent.panel.highlight" class="label remove pointer">{{field}} </span>
</div>
</div>
<h5>Options</h5> <h5>Options</h5>
<div class="row-fluid"> <div class="row-fluid">
<div class="span1"> <div class="span1">
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
</thead> </thead>
<tbody ng-repeat="row in data.slice(panel.offset,panel.offset+panel.size)" ng-class-odd="'odd'"> <tbody ng-repeat="row in data.slice(panel.offset,panel.offset+panel.size)" ng-class-odd="'odd'">
<tr ng-click="toggle_details(row)"> <tr ng-click="toggle_details(row)" class="pointer">
<td ng-repeat="field in panel.fields">{{row[field]}}</td> <td ng-repeat="field in panel.fields" ng-bind-html-unsafe="(row.highlight[field]||row._source[field]) | highlight"></td>
</tr> </tr>
<tr ng-show="row.kibana.details"> <tr ng-show="row.kibana.details">
<td colspan=1000> <td colspan=1000>
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<th>Action</th> <th>Action</th>
<th>Value</th> <th>Value</th>
</thead> </thead>
<tr ng-repeat="(key,value) in row.kibana.details" ng-class-odd="'odd'"> <tr ng-repeat="(key,value) in row.kibana.details._source" ng-class-odd="'odd'">
<td>{{key}}</td> <td>{{key}}</td>
<td> <td>
<i class='icon-search pointer' ng-click="build_search(key,value)"></i> <i class='icon-search pointer' ng-click="build_search(key,value)"></i>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="row-fluid" ng-show="panel.paging">> <div class="row-fluid" ng-show="panel.paging">
<div class="span1 offset3" style="text-align:right"> <div class="span1 offset3" style="text-align:right">
<i ng-click="panel.offset = 0" ng-show="panel.offset > 0" class='icon-circle-arrow-left pointer'></i> <i ng-click="panel.offset = 0" ng-show="panel.offset > 0" class='icon-circle-arrow-left pointer'></i>
<i ng-click="panel.offset = (panel.offset - panel.size)" ng-show="panel.offset > 0" class='icon-arrow-left pointer'></i> <i ng-click="panel.offset = (panel.offset - panel.size)" ng-show="panel.offset > 0" class='icon-arrow-left pointer'></i>
......
...@@ -39,6 +39,7 @@ angular.module('kibana.table', []) ...@@ -39,6 +39,7 @@ angular.module('kibana.table', [])
group : "default", group : "default",
style : {'font-size': '9pt'}, style : {'font-size': '9pt'},
fields : [], fields : [],
highlight : [],
sortable: true, sortable: true,
header : true, header : true,
paging : true, paging : true,
...@@ -92,6 +93,13 @@ angular.module('kibana.table', []) ...@@ -92,6 +93,13 @@ angular.module('kibana.table', [])
broadcast_results(); broadcast_results();
} }
$scope.toggle_highlight = function(field) {
if (_.indexOf($scope.panel.highlight,field) > -1)
$scope.panel.highlight = _.without($scope.panel.highlight,field)
else
$scope.panel.highlight.push(field)
}
$scope.toggle_details = function(row) { $scope.toggle_details = function(row) {
row.kibana = row.kibana || {}; row.kibana = row.kibana || {};
row.kibana.details = !row.kibana.details ? $scope.without_kibana(row) : false; row.kibana.details = !row.kibana.details ? $scope.without_kibana(row) : false;
...@@ -129,6 +137,12 @@ angular.module('kibana.table', []) ...@@ -129,6 +137,12 @@ angular.module('kibana.table', [])
.to($scope.time.to) .to($scope.time.to)
) )
) )
.highlight(
ejs.Highlight($scope.panel.highlight)
.fragmentSize(2147483647) // Max size of a 32bit unsigned int
.preTags('@start-highlight@')
.postTags('@end-highlight@')
)
.size($scope.panel.size*$scope.panel.pages) .size($scope.panel.size*$scope.panel.pages)
.sort($scope.panel.sort[0],$scope.panel.sort[1]); .sort($scope.panel.sort[0],$scope.panel.sort[1]);
...@@ -155,14 +169,17 @@ angular.module('kibana.table', []) ...@@ -155,14 +169,17 @@ angular.module('kibana.table', [])
// Check that we're still on the same query, if not stop // Check that we're still on the same query, if not stop
if($scope.query_id === query_id) { if($scope.query_id === query_id) {
$scope.data= $scope.data.concat(_.map(results.hits.hits, function(hit) { $scope.data= $scope.data.concat(_.map(results.hits.hits, function(hit) {
return flatten_json(hit['_source']); return {
_source : flatten_json(hit['_source']),
highlight : flatten_json(hit['highlight']||{})
}
})); }));
$scope.hits += results.hits.total; $scope.hits += results.hits.total;
// Sort the data // Sort the data
$scope.data = _.sortBy($scope.data, function(v){ $scope.data = _.sortBy($scope.data, function(v){
return v[$scope.panel.sort[0]] return v._source[$scope.panel.sort[0]]
}); });
// Reverse if needed // Reverse if needed
...@@ -177,7 +194,7 @@ angular.module('kibana.table', []) ...@@ -177,7 +194,7 @@ angular.module('kibana.table', [])
} }
// This breaks, use $scope.data for this // This breaks, use $scope.data for this
$scope.all_fields = get_all_fields($scope.data); $scope.all_fields = get_all_fields(_.pluck($scope.data,'_source'));
broadcast_results(); broadcast_results();
// If we're not sorting in reverse chrono order, query every index for // If we're not sorting in reverse chrono order, query every index for
...@@ -205,9 +222,10 @@ angular.module('kibana.table', []) ...@@ -205,9 +222,10 @@ angular.module('kibana.table', [])
} }
$scope.without_kibana = function (row) { $scope.without_kibana = function (row) {
row = _.clone(row) return {
delete row.kibana _source : row._source,
return row highlight : row.highlight
}
} }
// Broadcast a list of all fields. Note that receivers of field array // Broadcast a list of all fields. Note that receivers of field array
...@@ -222,15 +240,39 @@ angular.module('kibana.table', []) ...@@ -222,15 +240,39 @@ angular.module('kibana.table', [])
eventBus.broadcast($scope.$id,$scope.panel.group,"table_documents", eventBus.broadcast($scope.$id,$scope.panel.group,"table_documents",
{ {
query: $scope.panel.query, query: $scope.panel.query,
docs : $scope.data, docs : _.pluck($scope.data,'_source'),
index: $scope.index index: $scope.index
}); });
} }
$scope.set_refresh = function (state) {
$scope.refresh = state;
}
$scope.close_edit = function() {
if($scope.refresh)
$scope.get_data();
$scope.refresh = false;
}
function set_time(time) { function set_time(time) {
$scope.time = time; $scope.time = time;
$scope.index = _.isUndefined(time.index) ? $scope.index : time.index $scope.index = _.isUndefined(time.index) ? $scope.index : time.index
$scope.get_data(); $scope.get_data();
} }
})
.filter('highlight', function() {
return function(text) {
if (text.toString().length) {
return text.toString().
replace(/&/g, '&amp;').
replace(/</g, '&lt;').
replace(/>/g, '&gt;').
replace(/@start-highlight@/g, '<code class="highlight">').
replace(/@end-highlight@/g, '</code>')
}
return '';
}
}); });
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment