Skip to content

Commit

Permalink
Fixes #1382: Added Search Before and After stable paging (#1385)
Browse files Browse the repository at this point in the history
* WIP: 1382 Search After Paging Tests

* Implemented search before and after stable paging

* Fixed search after tests

* Default to old paging in ui
  • Loading branch information
niemyjski authored Aug 1, 2023
1 parent ef3b7f8 commit c45957f
Show file tree
Hide file tree
Showing 15 changed files with 368 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@
);
},
options: {
page: 1,
limit: 10,
mode: "summary",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
});
},
options: {
page: 1,
limit: 20,
mode: "summary",
},
Expand Down
1 change: 1 addition & 0 deletions src/Exceptionless.Web/ClientApp/app/events-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
header: "Events",
get: eventService.getAll,
options: {
page: 1,
limit: 15,
mode: "summary",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@
showType: false,
},
options: {
page: 1,
limit: 10,
mode: "summary",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@
vm.previous = links.previous;
vm.next = links.next;

vm.pageSummary = paginationService.getCurrentPageSummary(
response.data,
vm.currentOptions.page,
vm.currentOptions.limit
);
if (vm.currentOptions.page) {
vm.pageSummary = paginationService.getCurrentPageSummary(
response.data,
vm.currentOptions.page,
vm.currentOptions.limit
);
}

if (vm.events.length === 0 && vm.currentOptions.page && vm.currentOptions.page > 1) {
return get();
Expand Down Expand Up @@ -227,6 +229,7 @@
vm.beforeRelativeText = beforeRelativeText;
vm.canRefresh = canRefresh;
vm.currentEventId = vm.settings.eventId;
vm.currentOptions = null;
vm.events = [];
vm.get = get;
vm.hasFilter = filterService.hasFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@
</ul>
</div>
</div>
<div
class="col-sm-4 text-center"
ng-class="vm.previous || vm.next ? 'col-xs-8': 'col-xs-12'"
ng-if="vm.pageSummary"
>
<div class="col-sm-4 text-center" ng-class="vm.previous || vm.next ? 'col-xs-8': 'col-xs-12'">
<small class="text-muted inline m-t-xs">{{vm.pageSummary}}</small>
</div>
<div class="col-sm-4 col-xs-4 text-right" ng-if="vm.previous || vm.next">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,21 @@ protected OkWithHeadersContentResult<T> OkWithLinks<T>(T content, string[] links
return new OkWithHeadersContentResult<T>(content, headers);
}

protected OkWithResourceLinks<TEntity> OkWithResourceLinks<TEntity>(IEnumerable<TEntity> content, bool hasMore, Func<TEntity, string> pagePropertyAccessor = null, IHeaderDictionary headers = null, bool isDescending = false) where TEntity : class
protected OkWithResourceLinks<TEntity> OkWithResourceLinks<TEntity>(IEnumerable<TEntity> content, bool hasMore, int? page = null, long? total = null, string before = null, string after = null) where TEntity : class
{
return new OkWithResourceLinks<TEntity>(content, hasMore, null, pagePropertyAccessor, headers, isDescending);
}

protected OkWithResourceLinks<TEntity> OkWithResourceLinks<TEntity>(IEnumerable<TEntity> content, bool hasMore, int page, long? total = null, IHeaderDictionary headers = null) where TEntity : class
{
return new OkWithResourceLinks<TEntity>(content, hasMore, page, total, headers: headers);
return new OkWithResourceLinks<TEntity>(content, hasMore, page, total, before, after);
}

protected string GetResourceLink(string url, string type)
{
return url != null ? $"<{url}>; rel=\"{type}\"" : null;
}

protected bool NextPageExceedsSkipLimit(int page, int limit)
protected bool NextPageExceedsSkipLimit(int? page, int limit)
{
if (page is null)
return false;

return (page + 1) * limit >= MAXIMUM_SKIP;
}
}
Loading

0 comments on commit c45957f

Please sign in to comment.