From 6696e130738f2e63b1a0d92e607c5c7caf2430b2 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Wed, 4 Dec 2013 15:48:36 -0700 Subject: [PATCH] option to adjust table time field to browser's local timezone. Set as default on logstash dashboard --- docs/kibana/panels/table.asciidoc | 10 +++- src/app/dashboards/logstash.json | 2 + src/app/panels/table/editor.html | 77 ++++++++++++++++--------------- src/app/panels/table/module.html | 5 +- src/app/panels/table/module.js | 42 +++++++++-------- 5 files changed, 76 insertions(+), 60 deletions(-) diff --git a/docs/kibana/panels/table.asciidoc b/docs/kibana/panels/table.asciidoc index 4064dede990..85a8c1a360d 100644 --- a/docs/kibana/panels/table.asciidoc +++ b/docs/kibana/panels/table.asciidoc @@ -52,12 +52,18 @@ columns in the table, would trim each column at 20 character. The entirety of th still available in the expanded view of the event. // src/app/panels/table/module.js:105 -spyable:: Set to false to disable the inspect icon +localTime:: Set to true to adjust the timeField to the browser's local time // src/app/panels/table/module.js:112 +timeField:: If localTime is set to true, this field will be adjusted to the browsers local time +// src/app/panels/table/module.js:116 + +spyable:: Set to false to disable the inspect icon +// src/app/panels/table/module.js:120 + ==== Queries queries object:: This object describes the queries to use on this panel. queries.mode::: Of the queries available, which to use. Options: +all, pinned, unpinned, selected+ queries.ids::: In +selected+ mode, which query ids are selected. -// src/app/panels/table/module.js:116 +// src/app/panels/table/module.js:124 diff --git a/src/app/dashboards/logstash.json b/src/app/dashboards/logstash.json index 9bd1aac1550..02d24dee842 100644 --- a/src/app/dashboards/logstash.json +++ b/src/app/dashboards/logstash.json @@ -128,6 +128,8 @@ }, "overflow": "min-height", "fields": [], + "localTime": true, + "timeField": "@timestamp", "highlight": [], "sortable": true, "header": true, diff --git a/src/app/panels/table/editor.html b/src/app/panels/table/editor.html index 3a4c36bd749..9b5f26e7b3e 100644 --- a/src/app/panels/table/editor.html +++ b/src/app/panels/table/editor.html @@ -1,48 +1,49 @@
-
-
-
Add Column
+
+
Columns
+ - +
+ {{field}}
-
-
Columns Click to remove
- {{field}} -
-
-
-
-
-
Add field
+
+
Hightlighted Fields
+ - -
-
-
Highlighted fields Click to remove
- {{field}} +
+ {{field}}
-
Options
-
-
-
Header
-
-
-
Sorting
-
-
-
Sort
- - - -
-
Font Size
- -
-
-
Trim Factor Trim fields to this long divided by # of rows. Requires data refresh.
- + +
+
+
Options
+
+
Header
+
+
+
Sorting
+
+
+
Sort
+ + +
+
Font Size
+ +
+
+
Trim Factor Trim fields to this long divided by # of rows. Requires data refresh.
+ +
+
+
Local Time Adjust time field to browser's local time
+
+
+
Time Field
+ +
\ No newline at end of file diff --git a/src/app/panels/table/module.html b/src/app/panels/table/module.html index bff0bf091ec..9913c3f00c5 100644 --- a/src/app/panels/table/module.html +++ b/src/app/panels/table/module.html @@ -69,7 +69,10 @@ - + + + + diff --git a/src/app/panels/table/module.js b/src/app/panels/table/module.js index 71c8aa887f4..ed21487efb5 100644 --- a/src/app/panels/table/module.js +++ b/src/app/panels/table/module.js @@ -109,6 +109,14 @@ function (angular, app, _, kbn, moment) { * still available in the expanded view of the event. */ trimFactor: 300, + /** @scratch /panels/table/5 + * localTime:: Set to true to adjust the timeField to the browser's local time + */ + localTime: false, + /** @scratch /panels/table/5 + * timeField:: If localTime is set to true, this field will be adjusted to the browsers local time + */ + timeField: '@timestamp', /** @scratch /panels/table/5 * spyable:: Set to false to disable the inspect icon */ @@ -258,7 +266,8 @@ function (angular, app, _, kbn, moment) { _segment, request, boolQuery, - results; + queries, + sort; $scope.panel.error = false; @@ -267,6 +276,12 @@ function (angular, app, _, kbn, moment) { return; } + sort = [$scope.ejs.Sort($scope.panel.sort[0]).order($scope.panel.sort[1])]; + if($scope.panel.localTime) { + sort.push($scope.ejs.Sort($scope.panel.timeField).order($scope.panel.sort[1])); + } + + $scope.panelMeta.loading = true; _segment = _.isUndefined(segment) ? 0 : segment; @@ -275,7 +290,8 @@ function (angular, app, _, kbn, moment) { request = $scope.ejs.Request().indices(dashboard.indices[_segment]); $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries); - var queries = querySrv.getQueryObjs($scope.panel.queries.ids); + + queries = querySrv.getQueryObjs($scope.panel.queries.ids); boolQuery = $scope.ejs.BoolQuery(); _.each(queries,function(q) { @@ -294,14 +310,12 @@ function (angular, app, _, kbn, moment) { .postTags('@end-highlight@') ) .size($scope.panel.size*$scope.panel.pages) - .sort($scope.panel.sort[0],$scope.panel.sort[1]); + .sort(sort); $scope.populate_modal(request); - results = request.doSearch(); - // Populate scope when we have results - results.then(function(results) { + request.doSearch().then(function(results) { $scope.panelMeta.loading = false; if(_segment === 0) { @@ -470,19 +484,9 @@ function (angular, app, _, kbn, moment) { }); // WIP - module.filter('tableFieldFormat', function(fields){ - return function(text,field,event,scope) { - var type; - if( - !_.isUndefined(fields.mapping[event._index]) && - !_.isUndefined(fields.mapping[event._index][event._type]) - ) { - type = fields.mapping[event._index][event._type][field]['type']; - if(type === 'date' && scope.panel.normTimes) { - return moment(text).format('YYYY-MM-DD HH:mm:ss'); - } - } - return text; + module.filter('tableLocalTime', function(){ + return function(text,event) { + return moment(event.sort[1]).format("YYYY-MM-DDTHH:mm:ss.SSSZ"); }; });