diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-10 19:43:21 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-10 19:43:21 +0200 |
commit | 4771e0008dd26eadbb7eaff64255a6ec914fdadb (patch) | |
tree | 4fd58f8a3f3c2d674b936c99817b4f5fb958c5d8 /client/src/app/+admin | |
parent | 7a214f746bf420defbf17fa218d90d6233551bf8 (diff) | |
download | PeerTube-4771e0008dd26eadbb7eaff64255a6ec914fdadb.tar.gz PeerTube-4771e0008dd26eadbb7eaff64255a6ec914fdadb.tar.zst PeerTube-4771e0008dd26eadbb7eaff64255a6ec914fdadb.zip |
Better typescript typing for a better world
Diffstat (limited to 'client/src/app/+admin')
3 files changed, 8 insertions, 12 deletions
diff --git a/client/src/app/+admin/friends/friend-add/friend-add.component.ts b/client/src/app/+admin/friends/friend-add/friend-add.component.ts index 35cf4a1f7..0449d26a9 100644 --- a/client/src/app/+admin/friends/friend-add/friend-add.component.ts +++ b/client/src/app/+admin/friends/friend-add/friend-add.component.ts | |||
@@ -15,7 +15,7 @@ import { FriendService } from '../shared' | |||
15 | }) | 15 | }) |
16 | export class FriendAddComponent implements OnInit { | 16 | export class FriendAddComponent implements OnInit { |
17 | form: FormGroup | 17 | form: FormGroup |
18 | hosts = [ ] | 18 | hosts: string[] = [ ] |
19 | error: string = null | 19 | error: string = null |
20 | 20 | ||
21 | constructor ( | 21 | constructor ( |
diff --git a/client/src/app/+admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts index d52993a29..1c1cd575e 100644 --- a/client/src/app/+admin/users/shared/user.service.ts +++ b/client/src/app/+admin/users/shared/user.service.ts | |||
@@ -3,6 +3,7 @@ import 'rxjs/add/operator/catch' | |||
3 | import 'rxjs/add/operator/map' | 3 | import 'rxjs/add/operator/map' |
4 | 4 | ||
5 | import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared' | 5 | import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared' |
6 | import { UserCreate } from '../../../../../../shared' | ||
6 | 7 | ||
7 | @Injectable() | 8 | @Injectable() |
8 | export class UserService { | 9 | export class UserService { |
@@ -13,14 +14,8 @@ export class UserService { | |||
13 | private restExtractor: RestExtractor | 14 | private restExtractor: RestExtractor |
14 | ) {} | 15 | ) {} |
15 | 16 | ||
16 | addUser (username: string, password: string, email: string) { | 17 | addUser (userCreate: UserCreate) { |
17 | const body = { | 18 | return this.authHttp.post(UserService.BASE_USERS_URL, userCreate) |
18 | username, | ||
19 | email, | ||
20 | password | ||
21 | } | ||
22 | |||
23 | return this.authHttp.post(UserService.BASE_USERS_URL, body) | ||
24 | .map(this.restExtractor.extractDataBool) | 19 | .map(this.restExtractor.extractDataBool) |
25 | .catch(this.restExtractor.handleError) | 20 | .catch(this.restExtractor.handleError) |
26 | } | 21 | } |
diff --git a/client/src/app/+admin/users/user-add/user-add.component.ts b/client/src/app/+admin/users/user-add/user-add.component.ts index 2d25ab469..0dd99eccd 100644 --- a/client/src/app/+admin/users/user-add/user-add.component.ts +++ b/client/src/app/+admin/users/user-add/user-add.component.ts | |||
@@ -11,6 +11,7 @@ import { | |||
11 | USER_EMAIL, | 11 | USER_EMAIL, |
12 | USER_PASSWORD | 12 | USER_PASSWORD |
13 | } from '../../../shared' | 13 | } from '../../../shared' |
14 | import { UserCreate } from '../../../../../../shared' | ||
14 | 15 | ||
15 | @Component({ | 16 | @Component({ |
16 | selector: 'my-user-add', | 17 | selector: 'my-user-add', |
@@ -57,11 +58,11 @@ export class UserAddComponent extends FormReactive implements OnInit { | |||
57 | addUser () { | 58 | addUser () { |
58 | this.error = null | 59 | this.error = null |
59 | 60 | ||
60 | const { username, password, email } = this.form.value | 61 | const userCreate: UserCreate = this.form.value |
61 | 62 | ||
62 | this.userService.addUser(username, password, email).subscribe( | 63 | this.userService.addUser(userCreate).subscribe( |
63 | () => { | 64 | () => { |
64 | this.notificationsService.success('Success', `User ${username} created.`) | 65 | this.notificationsService.success('Success', `User ${userCreate.username} created.`) |
65 | this.router.navigate([ '/admin/users/list' ]) | 66 | this.router.navigate([ '/admin/users/list' ]) |
66 | }, | 67 | }, |
67 | 68 | ||