Commit 20c1284a by Rashid Khan

Merge pull request #78 from rashidkpc/master

Statistical mode for histogram and some prepping for adhoc dashboards
parents 08d3997b 906f3a3c
......@@ -9,6 +9,7 @@ angular.module('kibana.controllers', [])
title: "",
editable: true,
rows: [],
last: null
}
$scope.init = function() {
......@@ -24,7 +25,8 @@ angular.module('kibana.controllers', [])
// Load dashboard by event
eventBus.register($scope,'dashboard', function(event,dashboard){
$scope.dashboards = dashboard;
$scope.dashboards = dashboard.dashboard;
$scope.dashboards.last = dashboard.last;
_.defaults($scope.dashboards,_d)
})
......
......@@ -271,8 +271,10 @@ angular.module('kibana.dashcontrol', [])
$scope.dash_load = function(dashboard) {
if(!_.isObject(dashboard))
dashboard = JSON.parse(dashboard)
eventBus.broadcast($scope.$id,'ALL','dashboard',dashboard)
eventBus.broadcast($scope.$id,'ALL','dashboard',{
dashboard : dashboard,
last : $scope.dashboards
})
timer.cancel_all();
}
......@@ -287,7 +289,6 @@ angular.module('kibana.dashcontrol', [])
else
return false
}
})
.directive('dashUpload', function(timer, eventBus){
return {
......
......@@ -40,6 +40,7 @@ angular.module('kibana.fields', [])
eventBus.register($scope,'table_documents', function(event, docs) {
$scope.panel.query = docs.query;
$scope.docs = docs.docs;
$scope.index = docs.index;
});
eventBus.register($scope,"get_fields", function(event,id) {
eventBus.broadcast($scope.$id,$scope.panel.group,"selected_fields",$scope.active);
......
<div>
<div class="row-fluid">
<div class="span3">
<label class="small">Mode</label>
<select ng-change="set_refresh(true)" class="input-small" ng-model="panel.mode" ng-options="f for f in ['count','min','mean','max','total']"></select>
</div>
<div class="span3">
<label class="small">Field</label>
<form>
<input ng-change="set_refresh(true)" placeholder="Start typing" bs-typeahead="fields.list" type="text" class="input-small" ng-model="panel.value_field">
</form>
</div>
<div class="span5" ng-show="panel.mode != 'count'">
<label class="small">Note</label><small> In <strong>{{panel.mode}}</strong> mode the configured field <strong>must</strong> be a numeric type</small>
</div>
</div>
<div class="row-fluid">
<div class="span3">
<form style="margin-bottom: 0px">
<h6>Label</h6>
<label class="small">Label</label>
<input type="text" placeholder="New Label" style="width:70%" ng-model="newlabel">
</form>
</div>
<div class="span8">
<label class="small">Query</label>
<form class="input-append" style="margin-bottom: 0px">
<h6>Query</h6>
<input type="text" placeholder="New Query" style="width:80%" ng-model="newquery">
<button class="btn" ng-click="add_query(newlabel,newquery);newlabel='';newquery=''"><i class="icon-plus"></i></button>
</form>
......
......@@ -11,7 +11,7 @@
<div style="display:inline-block;background:{{series.color}};height:10px;width:10px;border-radius:5px;"></div>
<div class='small' style='display:inline-block'>{{series.label}} ({{series.hits}})</div>
</span>
<span ng-show="panel.legend" class="small"> per <strong>{{panel.interval}}</strong> | (<strong>{{hits}}</strong> total)</span>
<span ng-show="panel.legend" class="small"><span ng-show="panel.value_field && panel.mode != 'count'">{{panel.value_field}}</span> {{panel.mode}} per <strong>{{panel.interval}}</strong> | (<strong>{{hits}}</strong> hits)</span>
</div>
<center><img ng-show='panel.loading && _.isUndefined(data)' src="common/img/load_big.gif"></center>
<div histogram-chart params="{{panel}}" style="height:{{panel.height || row.height}};position:relative"></div>
......
......@@ -45,6 +45,8 @@ angular.module('kibana.histogram', [])
var _d = {
group : "default",
query : [ {query: "*", label:"Query"} ],
mode : 'count',
value_field: null,
auto_int : true,
interval : '5m',
fill : 3,
......@@ -124,12 +126,20 @@ angular.module('kibana.histogram', [])
// Build the facet part, injecting the query in as a facet filter
_.each(queries, function(v) {
request = request
.facet($scope.ejs.DateHistogramFacet("chart"+_.indexOf(queries,v))
.field($scope.time.field)
.interval($scope.panel.interval)
.facetFilter($scope.ejs.QueryFilter(v))
).size(0)
var facet = $scope.ejs.DateHistogramFacet("chart"+_.indexOf(queries,v))
if($scope.panel.mode === 'count') {
facet = facet.field($scope.time.field)
} else {
if(_.isNull($scope.panel.value_field)) {
$scope.panel.error = "In " + $scope.panel.mode + " mode a field must be specified";
return
}
facet = facet.keyField($scope.time.field).valueField($scope.panel.value_field)
}
facet = facet.interval($scope.panel.interval).facetFilter($scope.ejs.QueryFilter(v))
request = request.facet(facet).size(0)
})
// Populate the inspector panel
......@@ -171,14 +181,12 @@ angular.module('kibana.histogram', [])
// Assemble segments
var segment_data = [];
_.each(v.entries, function(v, k) {
segment_data.push([v['time'],v['count']])
segment_data.push([v['time'],v[$scope.panel.mode]])
hits += v['count']; // The series level hits counter
$scope.hits += v['count']; // Entire dataset level hits counter
});
data.splice.apply(data,[1,0].concat(segment_data)) // Join histogram data
// Create the flot series object
var series = {
data: {
......
<div>
<div class="row-fluid">
<div class="span2">
<label class="small">Mulit-query</label><input type="checkbox" ng-change="set_multi(panel.multi) "ng-model="panel.multi" ng-checked="panel.multi">
<label class="small">Multi-query</label><input type="checkbox" ng-change="set_multi(panel.multi) "ng-model="panel.multi" ng-checked="panel.multi">
</div>
<div class="span3" ng-show="panel.multi">
<label class="small">Arrangement</label>
......
......@@ -220,7 +220,11 @@ angular.module('kibana.table', [])
active: $scope.panel.fields
});
eventBus.broadcast($scope.$id,$scope.panel.group,"table_documents",
{query:$scope.panel.query,docs:$scope.data});
{
query: $scope.panel.query,
docs : $scope.data,
index: $scope.index
});
}
function set_time(time) {
......
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