Commit 77ce7b91 by Rashid Khan

Updated angularjs to 1.1.2, added microanalysis to fields panel, fixed time…

Updated angularjs to 1.1.2, added microanalysis to fields panel, fixed time picker initialization when mode is absolute or since
parent 38c92ac4
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -100,6 +100,7 @@ function recurse_field_dots(object,field) { ...@@ -100,6 +100,7 @@ function recurse_field_dots(object,field) {
return value; return value;
} }
// Probably useless now
function get_field_value(object,field,opt) { function get_field_value(object,field,opt) {
var value = recurse_field_dots(object['_source'],field); var value = recurse_field_dots(object['_source'],field);
...@@ -129,53 +130,23 @@ function get_field_value(object,field,opt) { ...@@ -129,53 +130,23 @@ function get_field_value(object,field,opt) {
return (value != null) ? value.toString() : ''; return (value != null) ? value.toString() : '';
} }
// Returns a big flat array of all values for a field // Returns a big flat array of all values for a field
function get_all_values_for_field(json,field) { function get_all_values_for_field(docs,field) {
var field_array = []; var field_array = [];
for (hit in json.hits.hits) { _.each(docs, function(doc,k) {
var value = get_field_value(json.hits.hits[hit],field,'raw') var value = doc[field]
if(typeof value === 'object' && value != null) { if(typeof value === 'object' && value != null) {
field_array.push.apply(field_array,value); field_array.push.apply(field_array,value);
} else { } else {
field_array.push(value); field_array.push(value);
} }
} })
return field_array; return field_array;
} }
// Takes a flat array of values and returns an array of arrays function top_field_values(docs,field,count) {
// reverse sorted with counts var counts = _.countBy(get_all_values_for_field(docs,field),function(field){return field;});
function count_values_in_array(array) { return _.pairs(counts).sort(function(a, b) {return a[1] - b[1]}).reverse().slice(0,count)
var count = {};
_.each(array, function(){
var num = this; // Get number
count[num] = count[num]+1 || 1; // Increment counter for each value
});
var tuples = [];
for (var key in count) tuples.push([key, count[key]]);
tuples.sort(function(a, b) {
a = a[1];
b = b[1];
return a < b ? -1 : (a > b ? 1 : 0);
});
tuples.reverse();
var count_array = [];
for (var i = 0; i < tuples.length; i++) {
var key = tuples[i][0];
var value = tuples[i][1];
count_array.push([key,value])
}
return count_array;
}
function top_field_values(json,field,count) {
var result = count_values_in_array(get_all_values_for_field(json,field));
return result.slice(0,count)
} }
/** /**
......
<kibana-panel ng-controller='dashcontrol'> <kibana-panel ng-controller='dashcontrol'>
<label class='small'>Dashboard Control</label>
<button class='btn' ng-show="panel.load.gist || panel.load.elasticsearch || panel.load.local" data-placement="bottom" data-unique="1" ng-click="elasticsearch_dblist(elasticsearch.query)" bs-popover="'panels/dashcontrol/load.html'"><i class='icon-folder-open'></i> Load <i class='icon-caret-down'></i></button> <button class='btn' ng-show="panel.load.gist || panel.load.elasticsearch || panel.load.local" data-placement="bottom" data-unique="1" ng-click="elasticsearch_dblist(elasticsearch.query)" bs-popover="'panels/dashcontrol/load.html'"><i class='icon-folder-open'></i> Load <i class='icon-caret-down'></i></button>
<button class='btn' ng-show="panel.save.gist || panel.save.elasticsearch || panel.save.local || panel.save.default" data-placement="bottom" data-unique="1" bs-popover="'panels/dashcontrol/save.html'"><i class='icon-save'></i> Save <i class='icon-caret-down'></i></button> <button class='btn' ng-show="panel.save.gist || panel.save.elasticsearch || panel.save.local || panel.save.default" data-placement="bottom" data-unique="1" bs-popover="'panels/dashcontrol/save.html'"><i class='icon-save'></i> Save <i class='icon-caret-down'></i></button>
</kibana-panel> </kibana-panel>
\ No newline at end of file
<a class="close" ng-click="dismiss()" href="">×</a>
<h4>Micro Analysis of {{micropanel.field}}</h4>
<table style="width:500px" class='table table-bordered table-striped table-condensed'>
<thead>
<th>{{micropanel.field}}</th>
<th>On Page</th>
</thead>
<tbody>
<tr ng-repeat='field in micropanel.values'>
<td>{{field[0]}}</td><td>{{field[1]}}</td>
</tr>
</tbody>
</table>
\ No newline at end of file
<kibana-panel ng-controller='fields'> <kibana-panel ng-controller='fields'>
<ul class="nav nav-list" style="height:{{row.height}};overflow-y:auto;overflow-x:hidden;"> <ul class="unstyled" style="height:{{row.height}};overflow-y:auto;overflow-x:hidden;">
<li ng-style="panel.style" ng-repeat="field in fields" ng-class="is_active(field)" ng-click="toggle_field(field)"><a>{{field}}</a></li> <li ng-style="panel.style" ng-repeat="field in fields" >
<i class="pointer" ng-class="{'icon-check': _.indexOf(active,field)>-1,'icon-check-empty': _.indexOf(active,field)<0}" ng-click="toggle_field(field)"></i>
<a data-unique="1" bs-popover="'panels/fields/micropanel.html'" ng-click="toggle_micropanel(field)" ng-class="{label: _.indexOf(active,field)>-1}">{{field}}</a>
</li>
</ul> </ul>
</kibana-panel> </kibana-panel>
\ No newline at end of file
...@@ -6,7 +6,7 @@ angular.module('kibana.fields', []) ...@@ -6,7 +6,7 @@ angular.module('kibana.fields', [])
// Set and populate defaults // Set and populate defaults
var _d = { var _d = {
group : "default", group : "default",
style : {"font-size":"85%","line-height":"15px"}, style : {},
} }
_.defaults($scope.panel,_d); _.defaults($scope.panel,_d);
...@@ -17,6 +17,16 @@ angular.module('kibana.fields', []) ...@@ -17,6 +17,16 @@ angular.module('kibana.fields', [])
$scope.fields = _.union(fields.all,$scope.fields); $scope.fields = _.union(fields.all,$scope.fields);
$scope.active = _.clone(fields.active); $scope.active = _.clone(fields.active);
}); });
eventBus.register($scope,'table_documents', function(event, docs) {
$scope.docs = docs;
});
}
$scope.toggle_micropanel = function(field) {
$scope.micropanel = {
field: field,
values : top_field_values($scope.docs,field,10)
}
} }
$scope.toggle_sort = function() { $scope.toggle_sort = function() {
...@@ -33,7 +43,7 @@ angular.module('kibana.fields', []) ...@@ -33,7 +43,7 @@ angular.module('kibana.fields', [])
} }
$scope.is_active = function(field) { $scope.is_active = function(field) {
return _.indexOf($scope.active,field) > -1 ? 'active' : ''; return _.indexOf($scope.active,field) > -1 ? ['label','label-info'] : '';
} }
$scope.init(); $scope.init();
......
...@@ -130,7 +130,6 @@ angular.module('kibana.pie', []) ...@@ -130,7 +130,6 @@ angular.module('kibana.pie', [])
$scope.$emit('render'); $scope.$emit('render');
}); });
} else { } else {
console.log('goal')
var results = request var results = request
.query(ejs.QueryStringQuery($scope.panel.query.query || '*')) .query(ejs.QueryStringQuery($scope.panel.query.query || '*'))
.filter(ejs.RangeFilter(config.timefield) .filter(ejs.RangeFilter(config.timefield)
......
...@@ -110,7 +110,7 @@ angular.module('kibana.table', []) ...@@ -110,7 +110,7 @@ angular.module('kibana.table', [])
}) })
$scope.all_fields = get_all_fields(results); $scope.all_fields = get_all_fields(results);
broadcast_fields(); broadcast_results();
}); });
} }
...@@ -123,12 +123,14 @@ angular.module('kibana.table', []) ...@@ -123,12 +123,14 @@ angular.module('kibana.table', [])
// 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.
function broadcast_fields() { function broadcast_results() {
eventBus.broadcast($scope.$id,$scope.panel.group,"fields", { eventBus.broadcast($scope.$id,$scope.panel.group,"fields", {
all : $scope.all_fields, all : $scope.all_fields,
sort : $scope.panel.sort, sort : $scope.panel.sort,
active: $scope.panel.fields active: $scope.panel.fields
}); });
eventBus.broadcast($scope.$id,$scope.panel.group,"table_documents",
$scope.data);
} }
function set_time(time) { function set_time(time) {
......
...@@ -57,14 +57,14 @@ angular.module('kibana.timepicker', []) ...@@ -57,14 +57,14 @@ angular.module('kibana.timepicker', [])
switch($scope.panel.mode) { switch($scope.panel.mode) {
case 'absolute': case 'absolute':
$scope.time = { $scope.time = {
from : Date.parse($scope.panel.time.from), from : Date.parse($scope.panel.time.from) || time_ago($scope.panel.timespan),
to : Date.parse($scope.panel.time.to) to : Date.parse($scope.panel.time.to) || new Date()
} }
break; break;
case 'since': case 'since':
$scope.time = { $scope.time = {
from : Date.parse($scope.panel.time.from), from : Date.parse($scope.panel.time.from) || time_ago($scope.panel.timespan),
to : new Date() to : new Date() || new Date()
} }
break; break;
case 'relative': case 'relative':
...@@ -138,10 +138,17 @@ angular.module('kibana.timepicker', []) ...@@ -138,10 +138,17 @@ angular.module('kibana.timepicker', [])
} }
$scope.time_check = function(){ $scope.time_check = function(){
if(!(_.isUndefined($scope.timepicker))) {
var from = $scope.panel.mode === 'relative' ? time_ago($scope.panel.timespan) : var from = $scope.panel.mode === 'relative' ? time_ago($scope.panel.timespan) :
Date.parse($scope.timepicker.from.date + " " + $scope.timepicker.from.time) Date.parse($scope.timepicker.from.date + " " + $scope.timepicker.from.time)
var to = $scope.panel.mode !== 'absolute' ? new Date() : var to = $scope.panel.mode !== 'absolute' ? new Date() :
Date.parse($scope.timepicker.to.date + " " + $scope.timepicker.to.time) Date.parse($scope.timepicker.to.date + " " + $scope.timepicker.to.time)
} else {
var from = $scope.panel.mode === 'relative' ? time_ago($scope.panel.timespan) :
$scope.time.from;
var to = $scope.panel.mode !== 'absolute' ? new Date() :
$scope.time.to;
}
if (from.getTime() >= to.getTime()) if (from.getTime() >= to.getTime())
from = new Date(to.getTime() - 1000) from = new Date(to.getTime() - 1000)
...@@ -197,6 +204,7 @@ angular.module('kibana.timepicker', []) ...@@ -197,6 +204,7 @@ angular.module('kibana.timepicker', [])
return all_indices().then(function(p) { return all_indices().then(function(p) {
var indices = _.intersection(p,possible); var indices = _.intersection(p,possible);
indices.reverse();
return indices.length == 0 ? [$scope.panel.defaultindex] : indices; return indices.length == 0 ? [$scope.panel.defaultindex] : indices;
}) })
}; };
......
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