aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/rest
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-09-04 20:07:54 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-09-04 20:07:54 +0200
commitb0f9f39ed70299a208d1b388c72de8b7f3510cb7 (patch)
tree4b7d388125265533ac2f6d4bf457d018617e1db6 /client/src/app/shared/rest
parente7dbeae8d915cdf4470ceb51c2724b04148b30b5 (diff)
downloadPeerTube-b0f9f39ed70299a208d1b388c72de8b7f3510cb7.tar.gz
PeerTube-b0f9f39ed70299a208d1b388c72de8b7f3510cb7.tar.zst
PeerTube-b0f9f39ed70299a208d1b388c72de8b7f3510cb7.zip
Begin user quota
Diffstat (limited to 'client/src/app/shared/rest')
-rw-r--r--client/src/app/shared/rest/rest-data-source.ts21
1 files changed, 19 insertions, 2 deletions
diff --git a/client/src/app/shared/rest/rest-data-source.ts b/client/src/app/shared/rest/rest-data-source.ts
index 7956637e0..5c205d280 100644
--- a/client/src/app/shared/rest/rest-data-source.ts
+++ b/client/src/app/shared/rest/rest-data-source.ts
@@ -3,14 +3,31 @@ import { Http, RequestOptionsArgs, URLSearchParams, Response } from '@angular/ht
3import { ServerDataSource } from 'ng2-smart-table' 3import { ServerDataSource } from 'ng2-smart-table'
4 4
5export class RestDataSource extends ServerDataSource { 5export class RestDataSource extends ServerDataSource {
6 constructor (http: Http, endpoint: string) { 6 private updateResponse: (input: any[]) => any[]
7
8 constructor (http: Http, endpoint: string, updateResponse?: (input: any[]) => any[]) {
7 const options = { 9 const options = {
8 endPoint: endpoint, 10 endPoint: endpoint,
9 sortFieldKey: 'sort', 11 sortFieldKey: 'sort',
10 dataKey: 'data' 12 dataKey: 'data'
11 } 13 }
12
13 super(http, options) 14 super(http, options)
15
16 if (updateResponse) {
17 this.updateResponse = updateResponse
18 }
19 }
20
21 protected extractDataFromResponse (res: Response) {
22 const json = res.json()
23 if (!json) return []
24 let data = json.data
25
26 if (this.updateResponse !== undefined) {
27 data = this.updateResponse(data)
28 }
29
30 return data
14 } 31 }
15 32
16 protected extractTotalFromResponse (res: Response) { 33 protected extractTotalFromResponse (res: Response) {