diff options
author | crupest <crupest@outlook.com> | 2019-03-09 01:42:38 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-03-09 01:42:38 +0800 |
commit | b01ba534a0017ad8bf85ddecff7610a6de6a74e9 (patch) | |
tree | 282b8feda6ac6dfd5213f4fe67766401d72472c3 /Timeline/ClientApp/src/app/user/user-login | |
parent | 17d90077b289c6b2203a34de727dd77c1985f146 (diff) | |
download | timeline-b01ba534a0017ad8bf85ddecff7610a6de6a74e9.tar.gz timeline-b01ba534a0017ad8bf85ddecff7610a6de6a74e9.tar.bz2 timeline-b01ba534a0017ad8bf85ddecff7610a6de6a74e9.zip |
User named route in dialog.
Diffstat (limited to 'Timeline/ClientApp/src/app/user/user-login')
-rw-r--r-- | Timeline/ClientApp/src/app/user/user-login/user-login.component.ts | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Timeline/ClientApp/src/app/user/user-login/user-login.component.ts b/Timeline/ClientApp/src/app/user/user-login/user-login.component.ts index da642cb8..971d57ce 100644 --- a/Timeline/ClientApp/src/app/user/user-login/user-login.component.ts +++ b/Timeline/ClientApp/src/app/user/user-login/user-login.component.ts @@ -1,5 +1,7 @@ -import { Component, Output, OnInit, EventEmitter, Input } from '@angular/core'; +import { Component, Output, OnInit, EventEmitter } from '@angular/core'; import { FormGroup, FormControl } from '@angular/forms'; +import { UserService } from '../user-service/user.service'; +import { ActivatedRoute } from '@angular/router'; export type LoginMessage = 'nologin' | 'invalidlogin' | string; @@ -13,20 +15,24 @@ export class LoginEvent { templateUrl: './user-login.component.html', styleUrls: ['./user-login.component.css'] }) -export class UserLoginComponent { +export class UserLoginComponent implements OnInit { - @Input() - message: LoginMessage; + constructor(private route: ActivatedRoute, private userService: UserService) { } - @Output() - login = new EventEmitter<LoginEvent>(); + message: string; form = new FormGroup({ username: new FormControl(''), password: new FormControl('') }); + ngOnInit() { + this.message = this.route.snapshot.paramMap.get('reason'); + } + onLoginButtonClick() { - this.login.emit(this.form.value); + this.userService.tryLogin(this.form.value).subscribe(_ => { + this.userService.userRouteNavigate(['success', { reason: 'login' }]); + }, (error: Error) => this.message = error.message); } } |