From b0f9f39ed70299a208d1b388c72de8b7f3510cb7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 4 Sep 2017 20:07:54 +0200 Subject: Begin user quota --- client/src/app/shared/rest/rest-data-source.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'client/src/app/shared/rest/rest-data-source.ts') 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 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) { -- cgit v1.2.3