aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/rest/rest.service.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-23 16:54:21 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-23 16:54:21 +0200
commitde59c48f5f317018e3f746bbe4a7b7efe00109f2 (patch)
treebc3d007c5aaed8dc72119763f3b1731c5777f218 /client/src/app/shared/rest/rest.service.ts
parentdef16d33d19153c6583fa8a30634760b3d64d34c (diff)
downloadPeerTube-de59c48f5f317018e3f746bbe4a7b7efe00109f2.tar.gz
PeerTube-de59c48f5f317018e3f746bbe4a7b7efe00109f2.tar.zst
PeerTube-de59c48f5f317018e3f746bbe4a7b7efe00109f2.zip
Client: centralize http res extraction in a service
Diffstat (limited to 'client/src/app/shared/rest/rest.service.ts')
-rw-r--r--client/src/app/shared/rest/rest.service.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/client/src/app/shared/rest/rest.service.ts b/client/src/app/shared/rest/rest.service.ts
new file mode 100644
index 000000000..16b47e957
--- /dev/null
+++ b/client/src/app/shared/rest/rest.service.ts
@@ -0,0 +1,27 @@
1import { Injectable } from '@angular/core';
2import { URLSearchParams } from '@angular/http';
3
4import { RestPagination } from './rest-pagination';
5
6@Injectable()
7export class RestService {
8
9 buildRestGetParams(pagination?: RestPagination, sort?: string) {
10 const params = new URLSearchParams();
11
12 if (pagination) {
13 const start: number = (pagination.currentPage - 1) * pagination.itemsPerPage;
14 const count: number = pagination.itemsPerPage;
15
16 params.set('start', start.toString());
17 params.set('count', count.toString());
18 }
19
20 if (sort) {
21 params.set('sort', sort);
22 }
23
24 return params;
25 }
26
27}