diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-08-23 14:37:49 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-08-23 14:37:49 +0200 |
commit | 0f6da32b148c0f4146b2ae9ad1add9a9f00cc339 (patch) | |
tree | 1272a5892e357aa0a0d370545effa6800092d568 /client/src/app/login/login.component.ts | |
parent | 39f87cb21689a912559d0498641db7d2de4a784d (diff) | |
download | PeerTube-0f6da32b148c0f4146b2ae9ad1add9a9f00cc339.tar.gz PeerTube-0f6da32b148c0f4146b2ae9ad1add9a9f00cc339.tar.zst PeerTube-0f6da32b148c0f4146b2ae9ad1add9a9f00cc339.zip |
Client: update to new form api
Diffstat (limited to 'client/src/app/login/login.component.ts')
-rw-r--r-- | client/src/app/login/login.component.ts | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index ddd62462e..fe867b7b4 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts | |||
@@ -1,23 +1,36 @@ | |||
1 | import { Component } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | import { Validators } from '@angular/common'; | ||
3 | import { FormControl, FormGroup, REACTIVE_FORM_DIRECTIVES } from '@angular/forms'; | ||
2 | import { Router } from '@angular/router'; | 4 | import { Router } from '@angular/router'; |
3 | 5 | ||
4 | import { AuthService } from '../shared'; | 6 | import { AuthService } from '../shared'; |
5 | 7 | ||
6 | @Component({ | 8 | @Component({ |
7 | selector: 'my-login', | 9 | selector: 'my-login', |
8 | template: require('./login.component.html') | 10 | template: require('./login.component.html'), |
11 | directives: [ REACTIVE_FORM_DIRECTIVES ] | ||
9 | }) | 12 | }) |
10 | 13 | ||
11 | export class LoginComponent { | 14 | export class LoginComponent implements OnInit { |
12 | error: string = null; | 15 | error: string = null; |
16 | username = ''; | ||
17 | password: ''; | ||
18 | loginForm: FormGroup; | ||
13 | 19 | ||
14 | constructor( | 20 | constructor( |
15 | private authService: AuthService, | 21 | private authService: AuthService, |
16 | private router: Router | 22 | private router: Router |
17 | ) {} | 23 | ) {} |
18 | 24 | ||
19 | login(username: string, password: string) { | 25 | ngOnInit() { |
20 | this.authService.login(username, password).subscribe( | 26 | this.loginForm = new FormGroup({ |
27 | username: new FormControl('', [ <any>Validators.required ]), | ||
28 | password: new FormControl('', [ <any>Validators.required ]), | ||
29 | }); | ||
30 | } | ||
31 | |||
32 | login() { | ||
33 | this.authService.login(this.username, this.password).subscribe( | ||
21 | result => { | 34 | result => { |
22 | this.error = null; | 35 | this.error = null; |
23 | 36 | ||