Skip to content

Commit

Permalink
Don't build pager when there are no results (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
berggren authored Mar 23, 2018
1 parent 8eaed37 commit f96c43e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions timesketch/ui/explore/event-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h4 class="modal-title" id="myModalLabel">Save the selected events as a new view
</div>
<br>
<br>
<div ng-show="totalPages && dataLoaded">
<div ng-show="totalPages > 0">
<ul class="pagination" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px;">
<li ng-class="{disabled: currentPage == 0}">
<a href ng-click="prevPage()">« Prev</a>
Expand All @@ -118,7 +118,7 @@ <h4 class="modal-title" id="myModalLabel">Save the selected events as a new view
<div ng-repeat="event in events">
<ts-event ng-hide="event.hidden && !meta.showHiddenEvents" enable-context-query="true" similarity-layer="similarityLayer" event="::event" meta="::meta" sketch-id="::sketchId" prev-timestamp="::events[$index-1]['_source'].timestamp" next-timestamp="::events[$index+1]['_source'].timestamp" index="::$index" order="::filter.order"></ts-event>
</div>
<div ng-show="totalPages && dataLoaded" style="margin: 0 auto; display:inline-block;">
<div ng-show="totalPages > 0 && dataLoaded" style="margin: 0 auto; display:inline-block;">
<ul class="pagination">
<li ng-class="{disabled: currentPage == 0}">
<a href ng-click="prevPage()">« Prev</a>
Expand Down
10 changes: 3 additions & 7 deletions timesketch/ui/explore/event.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export const tsEventList = ['timesketchApi', function (timesketchApi) {
event_count = $scope.meta.es_total_count
$scope.showLimitedResults = $scope.dataLoaded && false
}

total_pages = Math.ceil(event_count / $scope.filter.size) - 1
if (total_pages !== $scope.totalPages) {
$scope.currentPage = 0
Expand Down Expand Up @@ -218,18 +217,15 @@ export const tsEventList = ['timesketchApi', function (timesketchApi) {

$scope.$watch('meta', function (value) {
if (angular.isDefined(value)) {
// reciprocal dataLoaded check
if (angular.isDefined($scope.events) && $scope.events.length && value.es_total_count > 0) {
if (angular.isDefined($scope.events)) {
$scope.dataLoaded = true
$scope.getEventCount()
$scope.buildPager()
}
}
})

$scope.$watch('events', function (value) {
if (angular.isDefined(value)) {
// reciprocal dataLoaded check
if (angular.isDefined($scope.meta) && $scope.meta.es_total_count > 0 && value.length ) {
$scope.dataLoaded = true
$scope.getEventCount()
Expand Down Expand Up @@ -344,8 +340,8 @@ export const tsEvent = function () {
}

$scope.addFilterStart = function () {
$scope.$emit('datetime-clicked', {datetimeclicked: $scope.event._source.datetime})
}
$scope.$emit('datetime-clicked', {datetimeclicked: $scope.event._source.datetime})
}

$scope.getDetail = function () {
if ($scope.eventdetail) {return}
Expand Down
1 change: 0 additions & 1 deletion timesketch/ui/explore/search.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export const tsSearch = ['$location', 'timesketchApi', function ($location, time
$scope.query = query
$scope.filter = filter
$scope.queryDsl = queryDsl
$scope.dataLoaded = false

timesketchApi.search($scope.sketchId, query, filter, queryDsl)
.success(function (data) {
Expand Down

0 comments on commit f96c43e

Please sign in to comment.