Added observable handling for data in login page
This commit is contained in:
parent
d5be125982
commit
11416c682f
2 changed files with 10 additions and 7 deletions
|
@ -5,7 +5,7 @@
|
||||||
<h3>Login</h3>
|
<h3>Login</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p *ngIf="isLogoutPage()" class="text-success">
|
<p *ngIf="isLogoutPage" class="text-success">
|
||||||
You have been successfully logged out.
|
You have been successfully logged out.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Router, ActivatedRoute } from '@angular/router';
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { StateService } from '../../services/state.service';
|
import { StateService } from '../../services/state.service';
|
||||||
|
@ -10,16 +10,23 @@ import { SessionOperation } from '../../operations/session.operation';
|
||||||
templateUrl: './login.component.html',
|
templateUrl: './login.component.html',
|
||||||
styleUrls: ['./login.component.scss']
|
styleUrls: ['./login.component.scss']
|
||||||
})
|
})
|
||||||
export class LoginComponent {
|
export class LoginComponent implements OnInit {
|
||||||
|
|
||||||
public loginForm: FormGroup;
|
public loginForm: FormGroup;
|
||||||
|
|
||||||
public loginError = false;
|
public loginError = false;
|
||||||
|
|
||||||
|
public isLogoutPage = false;
|
||||||
|
|
||||||
constructor(private router: Router, private fb: FormBuilder, public gs: StateService,
|
constructor(private router: Router, private fb: FormBuilder, public gs: StateService,
|
||||||
private sessions: SessionOperation, private route: ActivatedRoute) {
|
private sessions: SessionOperation, private route: ActivatedRoute) {
|
||||||
this.createForm();
|
this.createForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.route.data.subscribe((data) => this.isLogoutPage = data.logout);
|
||||||
|
}
|
||||||
|
|
||||||
private createForm() {
|
private createForm() {
|
||||||
this.loginForm = this.fb.group({
|
this.loginForm = this.fb.group({
|
||||||
username: ['', Validators.required],
|
username: ['', Validators.required],
|
||||||
|
@ -37,8 +44,4 @@ export class LoginComponent {
|
||||||
this.loginError = true;
|
this.loginError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public isLogoutPage() {
|
|
||||||
return this.route.snapshot.data.logout;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue