1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Begin user quota

This commit is contained in:
Chocobozzz 2017-09-04 20:07:54 +02:00
parent e7dbeae8d9
commit b0f9f39ed7
29 changed files with 274 additions and 55 deletions

View file

@ -3,14 +3,31 @@ import { Http, RequestOptionsArgs, URLSearchParams, Response } from '@angular/ht
import { ServerDataSource } from 'ng2-smart-table'
export class RestDataSource extends ServerDataSource {
constructor (http: Http, endpoint: string) {
private updateResponse: (input: any[]) => any[]
constructor (http: Http, endpoint: string, updateResponse?: (input: any[]) => any[]) {
const options = {
endPoint: endpoint,
sortFieldKey: 'sort',
dataKey: 'data'
}
super(http, options)
if (updateResponse) {
this.updateResponse = updateResponse
}
}
protected extractDataFromResponse (res: Response) {
const json = res.json()
if (!json) return []
let data = json.data
if (this.updateResponse !== undefined) {
data = this.updateResponse(data)
}
return data
}
protected extractTotalFromResponse (res: Response) {