Skip to content

Commit 5fa49c6

Browse files
author
Rashid Khan
committed
Fixed bug in sorting
1 parent 39fa135 commit 5fa49c6

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

js/services.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ angular.module('kibana.services', [])
449449
return _.pluck(_.where(self.list,_require),'id');
450450
};
451451

452+
// TOFIX: Error handling when there is more than one field
453+
this.timeField = function() {
454+
return self.getByType('time')[0].field;
455+
};
456+
452457
// This special function looks for all time filters, and returns a time range according to the mode
453458
// No idea when max would actually be used
454459
this.timeRange = function(mode) {

panels/table/module.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,20 @@ <h5>Fields <i class=" icon-chevron-sign-left pointer " ng-click="panel.field_lis
5555
</th>
5656

5757
</thead>
58-
<tbody ng-repeat="row in data | slice:panel.offset:panel.offset+panel.size" ng-class-odd="'odd'">
59-
<tr ng-click="toggle_details(row)" class="pointer">
60-
<td ng-repeat="field in panel.fields" ng-bind-html-unsafe="(row.highlight[field]||row._source[field]) | tableHighlight | tableTruncate:panel.trimFactor:panel.fields.length"></td>
58+
<tbody ng-repeat="event in data | slice:panel.offset:panel.offset+panel.size" ng-class-odd="'odd'">
59+
<tr ng-click="toggle_details(event)" class="pointer">
60+
<!--<td ng-repeat="field in panel.fields" ng-bind-html-unsafe="(event.highlight[field]||event._source[field]) | tableFieldFormat:field:event:this |tableHighlight | tableTruncate:panel.trimFactor:panel.fields.length"></td>-->
61+
<td ng-repeat="field in panel.fields" ng-bind-html-unsafe="(event.highlight[field]||event._source[field]) |tableHighlight | tableTruncate:panel.trimFactor:panel.fields.length"></td>
6162
</tr>
62-
<tr ng-show="row.kibana.details">
63+
<tr ng-show="event.kibana.details">
6364
<td colspan=1000>
6465
<table class='table table-bordered table-condensed'>
6566
<thead>
6667
<th>Field</th>
6768
<th>Action</th>
6869
<th>Value</th>
6970
</thead>
70-
<tr ng-repeat="(key,value) in row.kibana.details._source" ng-class-odd="'odd'">
71+
<tr ng-repeat="(key,value) in event.kibana.details._source" ng-class-odd="'odd'">
7172
<td>{{key}}</td>
7273
<td>
7374
<i class='icon-search pointer' ng-click="build_search(key,value)"></i>

panels/table/module.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ angular.module('kibana.table', [])
5252
paging : true,
5353
field_list: true,
5454
trimFactor: 300,
55+
normTimes : true,
5556
spyable : true
5657
};
5758
_.defaults($scope.panel,_d);
@@ -219,10 +220,9 @@ angular.module('kibana.table', [])
219220
// If we're not sorting in reverse chrono order, query every index for
220221
// size*pages results
221222
// Otherwise, only get size*pages results then stop querying
222-
//($scope.data.length < $scope.panel.size*$scope.panel.pages
223-
// || !(($scope.panel.sort[0] === $scope.time.field) && $scope.panel.sort[1] === 'desc'))
224-
if($scope.data.length < $scope.panel.size*$scope.panel.pages &&
225-
_segment+1 < dashboard.indices.length ) {
223+
if (($scope.data.length < $scope.panel.size*$scope.panel.pages ||
224+
!(($scope.panel.sort[0] === filterSrv.timeField()) && $scope.panel.sort[1] === 'desc')) &&
225+
_segment+1 < dashboard.indices.length) {
226226
$scope.get_data(_segment+1,$scope.query_id);
227227
}
228228

@@ -274,4 +274,19 @@ angular.module('kibana.table', [])
274274
}
275275
return '';
276276
};
277+
// WIP
278+
}).filter('tableFieldFormat', function(fields){
279+
return function(text,field,event,scope) {
280+
var type;
281+
if(
282+
!_.isUndefined(fields.mapping[event._index]) &&
283+
!_.isUndefined(fields.mapping[event._index][event._type])
284+
) {
285+
type = fields.mapping[event._index][event._type][field]['type'];
286+
if(type === 'date' && scope.panel.normTimes) {
287+
return moment(text).format('YYYY-MM-DD HH:mm:ss');
288+
}
289+
}
290+
return text;
291+
};
277292
});

partials/dasheditor.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ <h4>Index Settings</h4>
3030
<code>[logstash-]YYYY.MM.DD</code>. The [] in "[logstash-]" are
3131
important as they instruct Kibana not to treat those letters as a
3232
pattern.
33+
Please also note that indices should rollover at midnight <strong>UTC</strong>.
3334
</p>
3435
<p class="small">
3536
See <a href="http://momentjs.com/docs/#/displaying/format/">http://momentjs.com/docs/#/displaying/format/</a>
@@ -85,6 +86,8 @@ <h6>Default Index <small ng-show="dashboard.current.index.interval != 'none'">If
8586
</div>
8687
</form>
8788
</div>
89+
<div class="row-fluid" ng-show="editor.index == 3">
90+
</div>
8891
</div>
8992
<div class="modal-footer">
9093
<button ng-click="add_row(dashboard.current,row); reset_row();" class="btn btn-success" ng-show="editor.index == 2">Create Row</button>

0 commit comments

Comments
 (0)