]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/rest/rest.service.ts
Begin user quota
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / rest / rest.service.ts
CommitLineData
df98563e
C
1import { Injectable } from '@angular/core'
2import { URLSearchParams } from '@angular/http'
de59c48f 3
df98563e 4import { RestPagination } from './rest-pagination'
de59c48f
C
5
6@Injectable()
7export class RestService {
8
df98563e
C
9 buildRestGetParams (pagination?: RestPagination, sort?: string) {
10 const params = new URLSearchParams()
de59c48f
C
11
12 if (pagination) {
df98563e
C
13 const start: number = (pagination.currentPage - 1) * pagination.itemsPerPage
14 const count: number = pagination.itemsPerPage
de59c48f 15
df98563e
C
16 params.set('start', start.toString())
17 params.set('count', count.toString())
de59c48f
C
18 }
19
20 if (sort) {
df98563e 21 params.set('sort', sort)
de59c48f
C
22 }
23
df98563e 24 return params
de59c48f
C
25 }
26
27}