diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-09-04 20:07:54 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-09-04 20:07:54 +0200 |
commit | b0f9f39ed70299a208d1b388c72de8b7f3510cb7 (patch) | |
tree | 4b7d388125265533ac2f6d4bf457d018617e1db6 /client/src/app/shared/rest | |
parent | e7dbeae8d915cdf4470ceb51c2724b04148b30b5 (diff) | |
download | PeerTube-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.ts | 21 |
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 | |||
3 | import { ServerDataSource } from 'ng2-smart-table' | 3 | import { ServerDataSource } from 'ng2-smart-table' |
4 | 4 | ||
5 | export class RestDataSource extends ServerDataSource { | 5 | export 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) { |