Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Server: #152 - unify pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Apr 23, 2021
1 parent f9b03c3 commit b405287
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions frontend/src/models/pagination.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export default class Pagination {

return new Pagination(
pagination['page'],
pagination['maxPages'],
pagination['perPageLimit']
pagination['max_pages'],
pagination['per_page_limit']
)
}
}
2 changes: 1 addition & 1 deletion frontend/src/services/auth.backend.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class AuthBackend extends BackupRepositoryBackend {

return new UserListingResponse(
response.data.data.map(function (userData) { return User.fromDict(userData) }),
new Pagination(page, response.data.context.pagination.maxPages, limit)
new Pagination(page, response.data.context.pagination.max_pages, limit)
)
})
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/Domain/Backup/Entity/Authentication/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class User extends TokenFromCommon implements \JsonSerializable
{
protected Email $email;

public function jsonSerialize()
public function jsonSerialize(): array
{
return [
'id' => $this->getId(),
Expand Down
11 changes: 4 additions & 7 deletions server/src/Domain/Backup/Response/Collection/ListingResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ public static function createFromResults(array $elements, int $maxPages, int $cu

public function jsonSerialize(): array
{
$data = parent::jsonSerialize();
$data = array_merge($data, [
return array_merge(parent::jsonSerialize(), [
'elements' => $this->elements,
'pagination' => [
'page' => $this->currentPage,
'maxPages' => $this->maxPages,
'perPageLimit' => $this->perPage
'page' => $this->currentPage,
'max_pages' => $this->maxPages,
'per_page_limit' => $this->perPage
]
]);

return $data;
}
}

0 comments on commit b405287

Please sign in to comment.