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/+admin/users/shared | |
parent | e7dbeae8d915cdf4470ceb51c2724b04148b30b5 (diff) | |
download | PeerTube-b0f9f39ed70299a208d1b388c72de8b7f3510cb7.tar.gz PeerTube-b0f9f39ed70299a208d1b388c72de8b7f3510cb7.tar.zst PeerTube-b0f9f39ed70299a208d1b388c72de8b7f3510cb7.zip |
Begin user quota
Diffstat (limited to 'client/src/app/+admin/users/shared')
-rw-r--r-- | client/src/app/+admin/users/shared/user.service.ts | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/client/src/app/+admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts index 1c1cd575e..ffd7ba7da 100644 --- a/client/src/app/+admin/users/shared/user.service.ts +++ b/client/src/app/+admin/users/shared/user.service.ts | |||
@@ -2,12 +2,15 @@ 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 { BytesPipe } from 'angular-pipes/src/math/bytes.pipe' | ||
6 | |||
5 | import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared' | 7 | import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared' |
6 | import { UserCreate } from '../../../../../../shared' | 8 | import { UserCreate } from '../../../../../../shared' |
7 | 9 | ||
8 | @Injectable() | 10 | @Injectable() |
9 | export class UserService { | 11 | export class UserService { |
10 | private static BASE_USERS_URL = API_URL + '/api/v1/users/' | 12 | private static BASE_USERS_URL = API_URL + '/api/v1/users/' |
13 | private bytesPipe = new BytesPipe() | ||
11 | 14 | ||
12 | constructor ( | 15 | constructor ( |
13 | private authHttp: AuthHttp, | 16 | private authHttp: AuthHttp, |
@@ -21,10 +24,30 @@ export class UserService { | |||
21 | } | 24 | } |
22 | 25 | ||
23 | getDataSource () { | 26 | getDataSource () { |
24 | return new RestDataSource(this.authHttp, UserService.BASE_USERS_URL) | 27 | return new RestDataSource(this.authHttp, UserService.BASE_USERS_URL, this.formatDataSource.bind(this)) |
25 | } | 28 | } |
26 | 29 | ||
27 | removeUser (user: User) { | 30 | removeUser (user: User) { |
28 | return this.authHttp.delete(UserService.BASE_USERS_URL + user.id) | 31 | return this.authHttp.delete(UserService.BASE_USERS_URL + user.id) |
29 | } | 32 | } |
33 | |||
34 | private formatDataSource (users: User[]) { | ||
35 | const newUsers = [] | ||
36 | |||
37 | users.forEach(user => { | ||
38 | let videoQuota | ||
39 | if (user.videoQuota === -1) { | ||
40 | videoQuota = 'Unlimited' | ||
41 | } else { | ||
42 | videoQuota = this.bytesPipe.transform(user.videoQuota) | ||
43 | } | ||
44 | |||
45 | const newUser = Object.assign(user, { | ||
46 | videoQuota | ||
47 | }) | ||
48 | newUsers.push(newUser) | ||
49 | }) | ||
50 | |||
51 | return newUsers | ||
52 | } | ||
30 | } | 53 | } |