Chore: Upgraded to Angular, Angular Material and Angular Flex layout 8.0

This commit is contained in:
Amritanshu
2019-06-12 17:25:10 +05:30
parent 40eaa25c76
commit fea48e1a3e
114 changed files with 749 additions and 822 deletions

View File

@ -1,69 +1,69 @@
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {AuthService} from '../auth.service';
import {ActivatedRoute, Router} from '@angular/router';
import {ToasterService} from '../../core/toaster.service';
import {FormBuilder, FormGroup} from '@angular/forms';
import {CookieService} from '../../shared/cookie.service';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement') nameElement: ElementRef;
form: FormGroup;
hide: boolean;
showOtp: boolean;
clientID: string;
private returnUrl: string;
constructor(private route: ActivatedRoute,
private auth: AuthService,
private router: Router,
private toaster: ToasterService,
private cs: CookieService,
private fb: FormBuilder
) {
this.hide = true;
this.showOtp = false;
this.createForm();
}
createForm() {
this.form = this.fb.group({
username: '',
password: '',
otp: '',
clientName: ''
});
}
ngOnInit() {
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
}
ngAfterViewInit() {
setTimeout(() => {
this.nameElement.nativeElement.focus();
}, 0);
}
login(): void {
const formModel = this.form.value;
const username = formModel.username;
const password = formModel.password;
this.auth.login(username, password).subscribe(
(result) => {
this.router.navigateByUrl(this.returnUrl);
},
(error) => {
if (error.status === 403 && ['Unknown Client', 'OTP not supplied', 'OTP is wrong'].indexOf(error.error) !== -1) {
this.showOtp = true;
this.clientID = this.cs.getCookie('ClientID');
}
this.toaster.show('Danger', error.error);
}
);
}
}
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {AuthService} from '../auth.service';
import {ActivatedRoute, Router} from '@angular/router';
import {ToasterService} from '../../core/toaster.service';
import {FormBuilder, FormGroup} from '@angular/forms';
import {CookieService} from '../../shared/cookie.service';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
form: FormGroup;
hide: boolean;
showOtp: boolean;
clientID: string;
private returnUrl: string;
constructor(private route: ActivatedRoute,
private auth: AuthService,
private router: Router,
private toaster: ToasterService,
private cs: CookieService,
private fb: FormBuilder
) {
this.hide = true;
this.showOtp = false;
this.createForm();
}
createForm() {
this.form = this.fb.group({
username: '',
password: '',
otp: '',
clientName: ''
});
}
ngOnInit() {
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
}
ngAfterViewInit() {
setTimeout(() => {
this.nameElement.nativeElement.focus();
}, 0);
}
login(): void {
const formModel = this.form.value;
const username = formModel.username;
const password = formModel.password;
this.auth.login(username, password).subscribe(
(result) => {
this.router.navigateByUrl(this.returnUrl);
},
(error) => {
if (error.status === 403 && ['Unknown Client', 'OTP not supplied', 'OTP is wrong'].indexOf(error.error) !== -1) {
this.showOtp = true;
this.clientID = this.cs.getCookie('ClientID');
}
this.toaster.show('Danger', error.error);
}
);
}
}