diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-01-30 22:41:14 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-01-30 22:41:14 +0100 |
commit | 28798b5d949826551740fc893d06e6424b77aa6a (patch) | |
tree | e235a7f49164a06c4b76df49ca61b89998d4ed81 /client/src/app/+admin/users/shared | |
parent | 13fc89f4a4b91b3da10493517de556240fb65463 (diff) | |
download | PeerTube-28798b5d949826551740fc893d06e6424b77aa6a.tar.gz PeerTube-28798b5d949826551740fc893d06e6424b77aa6a.tar.zst PeerTube-28798b5d949826551740fc893d06e6424b77aa6a.zip |
Client: replace simple tables by ng2 smart table component
Diffstat (limited to 'client/src/app/+admin/users/shared')
-rw-r--r-- | client/src/app/+admin/users/shared/user.service.ts | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/client/src/app/+admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts index d9005b213..f6d360e09 100644 --- a/client/src/app/+admin/users/shared/user.service.ts +++ b/client/src/app/+admin/users/shared/user.service.ts | |||
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; | |||
2 | import 'rxjs/add/operator/catch'; | 2 | import 'rxjs/add/operator/catch'; |
3 | import 'rxjs/add/operator/map'; | 3 | import 'rxjs/add/operator/map'; |
4 | 4 | ||
5 | import { AuthHttp, RestExtractor, ResultList, User } from '../../../shared'; | 5 | import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared'; |
6 | 6 | ||
7 | @Injectable() | 7 | @Injectable() |
8 | export class UserService { | 8 | export class UserService { |
@@ -25,25 +25,11 @@ export class UserService { | |||
25 | .catch(this.restExtractor.handleError); | 25 | .catch(this.restExtractor.handleError); |
26 | } | 26 | } |
27 | 27 | ||
28 | getUsers() { | 28 | getDataSource() { |
29 | return this.authHttp.get(UserService.BASE_USERS_URL) | 29 | return new RestDataSource(this.authHttp, UserService.BASE_USERS_URL); |
30 | .map(this.restExtractor.extractDataList) | ||
31 | .map(this.extractUsers) | ||
32 | .catch((res) => this.restExtractor.handleError(res)); | ||
33 | } | 30 | } |
34 | 31 | ||
35 | removeUser(user: User) { | 32 | removeUser(user: User) { |
36 | return this.authHttp.delete(UserService.BASE_USERS_URL + user.id); | 33 | return this.authHttp.delete(UserService.BASE_USERS_URL + user.id); |
37 | } | 34 | } |
38 | |||
39 | private extractUsers(result: ResultList) { | ||
40 | const usersJson = result.data; | ||
41 | const totalUsers = result.total; | ||
42 | const users = []; | ||
43 | for (const userJson of usersJson) { | ||
44 | users.push(new User(userJson)); | ||
45 | } | ||
46 | |||
47 | return { users, totalUsers }; | ||
48 | } | ||
49 | } | 35 | } |