Skip to content

Commit

Permalink
Fixed bug in sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Aug 14, 2013
1 parent 39fa135 commit 5fa49c6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
5 changes: 5 additions & 0 deletions js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ angular.module('kibana.services', [])
return _.pluck(_.where(self.list,_require),'id');
};

// TOFIX: Error handling when there is more than one field
this.timeField = function() {
return self.getByType('time')[0].field;
};

// This special function looks for all time filters, and returns a time range according to the mode
// No idea when max would actually be used
this.timeRange = function(mode) {
Expand Down
11 changes: 6 additions & 5 deletions panels/table/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,20 @@ <h5>Fields <i class=" icon-chevron-sign-left pointer " ng-click="panel.field_lis
</th>

</thead>
<tbody ng-repeat="row in data | slice:panel.offset:panel.offset+panel.size" ng-class-odd="'odd'">
<tr ng-click="toggle_details(row)" class="pointer">
<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>
<tbody ng-repeat="event in data | slice:panel.offset:panel.offset+panel.size" ng-class-odd="'odd'">
<tr ng-click="toggle_details(event)" class="pointer">
<!--<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>-->
<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>
</tr>
<tr ng-show="row.kibana.details">
<tr ng-show="event.kibana.details">
<td colspan=1000>
<table class='table table-bordered table-condensed'>
<thead>
<th>Field</th>
<th>Action</th>
<th>Value</th>
</thead>
<tr ng-repeat="(key,value) in row.kibana.details._source" ng-class-odd="'odd'">
<tr ng-repeat="(key,value) in event.kibana.details._source" ng-class-odd="'odd'">
<td>{{key}}</td>
<td>
<i class='icon-search pointer' ng-click="build_search(key,value)"></i>
Expand Down
23 changes: 19 additions & 4 deletions panels/table/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ angular.module('kibana.table', [])
paging : true,
field_list: true,
trimFactor: 300,
normTimes : true,
spyable : true
};
_.defaults($scope.panel,_d);
Expand Down Expand Up @@ -219,10 +220,9 @@ angular.module('kibana.table', [])
// If we're not sorting in reverse chrono order, query every index for
// size*pages results
// Otherwise, only get size*pages results then stop querying
//($scope.data.length < $scope.panel.size*$scope.panel.pages
// || !(($scope.panel.sort[0] === $scope.time.field) && $scope.panel.sort[1] === 'desc'))
if($scope.data.length < $scope.panel.size*$scope.panel.pages &&
_segment+1 < dashboard.indices.length ) {
if (($scope.data.length < $scope.panel.size*$scope.panel.pages ||
!(($scope.panel.sort[0] === filterSrv.timeField()) && $scope.panel.sort[1] === 'desc')) &&
_segment+1 < dashboard.indices.length) {
$scope.get_data(_segment+1,$scope.query_id);
}

Expand Down Expand Up @@ -274,4 +274,19 @@ angular.module('kibana.table', [])
}
return '';
};
// WIP
}).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;
};
});
3 changes: 3 additions & 0 deletions partials/dasheditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h4>Index Settings</h4>
<code>[logstash-]YYYY.MM.DD</code>. The [] in "[logstash-]" are
important as they instruct Kibana not to treat those letters as a
pattern.
Please also note that indices should rollover at midnight <strong>UTC</strong>.
</p>
<p class="small">
See <a href="http://momentjs.com/docs/#/displaying/format/">http://momentjs.com/docs/#/displaying/format/</a>
Expand Down Expand Up @@ -85,6 +86,8 @@ <h6>Default Index <small ng-show="dashboard.current.index.interval != 'none'">If
</div>
</form>
</div>
<div class="row-fluid" ng-show="editor.index == 3">
</div>
</div>
<div class="modal-footer">
<button ng-click="add_row(dashboard.current,row); reset_row();" class="btn btn-success" ng-show="editor.index == 2">Create Row</button>
Expand Down

0 comments on commit 5fa49c6

Please sign in to comment.