로그인 페이지 //

remember Me 값에 따라 기본값 세팅 처리.
This commit is contained in:
leejh 2019-10-15 09:31:33 +09:00
parent 142631428a
commit a986b3a370
2 changed files with 24 additions and 12 deletions

View File

@ -35,13 +35,8 @@
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
<div <div class="remember-forgot-password" fxLayout="row" fxLayout.xs="column" fxLayoutAlign="space-between center">
class="remember-forgot-password" <mat-checkbox class="remember-me" formControlName="remember" aria-label="Remember Me">
fxLayout="row"
fxLayout.xs="column"
fxLayoutAlign="space-between center"
>
<mat-checkbox class="remember-me" aria-label="Remember Me">
Remember Me Remember Me
</mat-checkbox> </mat-checkbox>

View File

@ -9,6 +9,8 @@ import {
} from '@angular/core'; } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Company } from '@ucap-webmessenger/api-external'; import { Company } from '@ucap-webmessenger/api-external';
import { LocalStorageService } from '@ucap-webmessenger/web-storage';
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
@Component({ @Component({
selector: 'ucap-account-login', selector: 'ucap-account-login',
@ -32,13 +34,28 @@ export class LoginComponent implements OnInit {
loginForm: FormGroup; loginForm: FormGroup;
constructor(private formBuilder: FormBuilder) {} constructor(
private formBuilder: FormBuilder,
private localStorageService: LocalStorageService
) {}
ngOnInit() { ngOnInit() {
const loginInfo: LoginInfo = this.localStorageService.get<LoginInfo>(
KEY_LOGIN_INFO
);
let companyCode = '';
let loginId = '';
let remember = false;
if (loginInfo && loginInfo.companyCode && loginInfo.loginId) {
companyCode = loginInfo.companyCode;
loginId = loginInfo.loginId;
remember = true;
}
this.loginForm = this.formBuilder.group({ this.loginForm = this.formBuilder.group({
companyCode: ['', [Validators.required]], companyCode: [companyCode, [Validators.required]],
loginId: ['', [Validators.required]], loginId: [loginId, [Validators.required]],
loginPw: ['', Validators.required] loginPw: ['', Validators.required],
remember: [remember]
}); });
} }
@ -47,7 +64,7 @@ export class LoginComponent implements OnInit {
companyCode: this.loginForm.get('companyCode').value, companyCode: this.loginForm.get('companyCode').value,
loginId: this.loginForm.get('loginId').value, loginId: this.loginForm.get('loginId').value,
loginPw: this.loginForm.get('loginPw').value, loginPw: this.loginForm.get('loginPw').value,
rememberMe: true, rememberMe: this.loginForm.get('remember').value,
notValid: () => { notValid: () => {
this.loginPwElementRef.nativeElement.focus(); this.loginPwElementRef.nativeElement.focus();
} }