From 28798b5d949826551740fc893d06e6424b77aa6a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 30 Jan 2017 22:41:14 +0100 Subject: Client: replace simple tables by ng2 smart table component --- client/src/app/+admin/friends/shared/friend.service.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'client/src/app/+admin/friends/shared') diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts index e97459385..6cb84f5cd 100644 --- a/client/src/app/+admin/friends/shared/friend.service.ts +++ b/client/src/app/+admin/friends/shared/friend.service.ts @@ -3,8 +3,10 @@ import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/map'; +import { ServerDataSource } from 'ng2-smart-table'; + import { Friend } from './friend.model'; -import { AuthHttp, RestExtractor, ResultList } from '../../../shared'; +import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared'; @Injectable() export class FriendService { @@ -15,11 +17,8 @@ export class FriendService { private restExtractor: RestExtractor ) {} - getFriends() { - return this.authHttp.get(FriendService.BASE_FRIEND_URL) - .map(this.restExtractor.extractDataList) - .map(this.extractFriends) - .catch((res) => this.restExtractor.handleError(res)); + getDataSource() { + return new RestDataSource(this.authHttp, FriendService.BASE_FRIEND_URL); } makeFriends(notEmptyHosts) { @@ -37,11 +36,4 @@ export class FriendService { .map(res => res.status) .catch((res) => this.restExtractor.handleError(res)); } - - private extractFriends(result: ResultList) { - const friends: Friend[] = result.data; - const totalFriends = result.total; - - return { friends, totalFriends }; - } } -- cgit v1.2.3