From 0aacb86688d675ba11f77fe4c945e0702edf6ea5 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Sun, 31 Mar 2013 21:29:15 -0700 Subject: [PATCH] Added support for hourly/daily/weekly/monthly/yearly index patterns, fixed field list bug --- common/lib/shared.js | 53 ++++++----------------------------- panels/table/module.html | 6 ++-- panels/table/module.js | 5 ++-- panels/timepicker/editor.html | 6 ++-- panels/timepicker/module.js | 4 +-- 5 files changed, 18 insertions(+), 56 deletions(-) diff --git a/common/lib/shared.js b/common/lib/shared.js index dadec6461b5..511449b15fb 100644 --- a/common/lib/shared.js +++ b/common/lib/shared.js @@ -7,18 +7,14 @@ function get_object_fields(obj) { return field_array.sort(); } -function get_all_fields(json) { - var field_array = []; - var obj_fields; - for (hit in json.hits.hits) { - obj_fields = get_object_fields(json.hits.hits[hit]); - for (index in obj_fields) { - if (_.indexOf(field_array,obj_fields[index]) < 0) { - field_array.push(obj_fields[index]); - } - } - } - return field_array.sort(); +function get_all_fields(data) { + var fields = []; + _.each(data,function(hit) { + fields = _.uniq(fields.concat(_.keys(hit))) + }) + // Remove stupid angular key + fields = _.without(fields,'$$hashKey') + return fields; } function has_field(obj,field) { @@ -30,39 +26,6 @@ function has_field(obj,field) { } } -function get_objids_with_field(json,field) { - var objid_array = []; - for (hit in json.hits.hits) { - if(has_field(json.hits.hits[hit],field)) { - objid_array.push(hit); - } - } - return objid_array; -} - -function get_objids_with_field_value(json,field,value) { - var objid_array = []; - for (hit in json.hits.hits) { - var hit_obj = json.hits.hits[hit]; - if(has_field(hit_obj,field)) { - var field_val = get_field_value(hit_obj,field,'raw') - if(_.isArray(field_val)) { - if(_.inArray(field_val,field) >= 0) { - objid_array.push(hit); - } - } else { - if(field_val == value) { - objid_array.push(hit); - } - } - } else { - if ( value == '') - objid_array.push(hit); - } - } - return objid_array; -} - function get_related_fields(docs,field) { var field_array = [] _.each(docs, function(doc) { diff --git a/panels/table/module.html b/panels/table/module.html index 42e45f3bc05..fda7ab41378 100644 --- a/panels/table/module.html +++ b/panels/table/module.html @@ -6,11 +6,11 @@
-
+
-
+
{{panel.offset}} to {{panel.offset + data.slice(panel.offset,panel.offset+panel.size).length}} of {{data.length}} available for paging
@@ -41,7 +41,7 @@ Action Value - + {{key}} diff --git a/panels/table/module.js b/panels/table/module.js index a4a9c812535..963363c23b6 100644 --- a/panels/table/module.js +++ b/panels/table/module.js @@ -83,6 +83,7 @@ angular.module('kibana.table', []) $scope.panel.loading = true; var _segment = _.isUndefined(segment) ? 0 : segment + $scope.segment = _segment; var request = $scope.ejs.Request().indices($scope.panel.index[_segment]) .query(ejs.FilteredQuery( @@ -139,8 +140,8 @@ angular.module('kibana.table', []) } // This breaks, use $scope.data for this - $scope.all_fields = get_all_fields(results); - + $scope.all_fields = get_all_fields($scope.data); + broadcast_results(); // If we're not sorting in reverse chrono order, query every index for diff --git a/panels/timepicker/editor.html b/panels/timepicker/editor.html index aca2a76b3b1..3d30ef8def1 100644 --- a/panels/timepicker/editor.html +++ b/panels/timepicker/editor.html @@ -10,7 +10,7 @@
Index Settings
-
+

Time stamped indices use your selected time range to create a list of @@ -30,10 +30,10 @@

-
Timestamped
+
Timestamp
-
Index pattern Absolutes in double quotes
+
Index pattern Absolutes in double quotes
diff --git a/panels/timepicker/module.js b/panels/timepicker/module.js index a4441a8ed4b..72b6d6038be 100644 --- a/panels/timepicker/module.js +++ b/panels/timepicker/module.js @@ -11,7 +11,6 @@ a pattern * timespan :: The default options selected for the relative view. Default: '15m' * timefield :: The field in which time is stored in the document. * index :: Index pattern to match. Literals should be double quoted. Default: '_all' -* timed_indices :: Should kibana generate a list of indices to try based on selected time range? * defaultindex :: Index to failover to if index not found * refresh: Object containing refresh parameters * enable :: true/false, enable auto refresh by default. Default: false @@ -37,7 +36,6 @@ angular.module('kibana.timepicker', []) index : '_all', defaultindex : "_all", index_interval: "day", - timed_indices : false, group : "default", refresh : { enable : false, @@ -205,7 +203,7 @@ angular.module('kibana.timepicker', []) // Get indices for the time period, then broadcast time range and index list // in a single object. Not sure if I like this. - if($scope.panel.timed_indices) { + if($scope.panel.index_interval !== 'none') { indices($scope.time.from,$scope.time.to).then(function (p) { $scope.time.index = p; eventBus.broadcast($scope.$id,$scope.panel.group,'time',$scope.time)