From 4771e0008dd26eadbb7eaff64255a6ec914fdadb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 10 Jul 2017 19:43:21 +0200 Subject: Better typescript typing for a better world --- .../src/app/+admin/friends/friend-add/friend-add.component.ts | 2 +- client/src/app/+admin/users/shared/user.service.ts | 11 +++-------- client/src/app/+admin/users/user-add/user-add.component.ts | 7 ++++--- 3 files changed, 8 insertions(+), 12 deletions(-) (limited to 'client/src/app/+admin') 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' }) export class FriendAddComponent implements OnInit { form: FormGroup - hosts = [ ] + hosts: string[] = [ ] error: string = null 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' import 'rxjs/add/operator/map' import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared' +import { UserCreate } from '../../../../../../shared' @Injectable() export class UserService { @@ -13,14 +14,8 @@ export class UserService { private restExtractor: RestExtractor ) {} - addUser (username: string, password: string, email: string) { - const body = { - username, - email, - password - } - - return this.authHttp.post(UserService.BASE_USERS_URL, body) + addUser (userCreate: UserCreate) { + return this.authHttp.post(UserService.BASE_USERS_URL, userCreate) .map(this.restExtractor.extractDataBool) .catch(this.restExtractor.handleError) } 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 { USER_EMAIL, USER_PASSWORD } from '../../../shared' +import { UserCreate } from '../../../../../../shared' @Component({ selector: 'my-user-add', @@ -57,11 +58,11 @@ export class UserAddComponent extends FormReactive implements OnInit { addUser () { this.error = null - const { username, password, email } = this.form.value + const userCreate: UserCreate = this.form.value - this.userService.addUser(username, password, email).subscribe( + this.userService.addUser(userCreate).subscribe( () => { - this.notificationsService.success('Success', `User ${username} created.`) + this.notificationsService.success('Success', `User ${userCreate.username} created.`) this.router.navigate([ '/admin/users/list' ]) }, -- cgit v1.2.3